aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2018-06-06 15:09:49 -0400
committerJohn Snow <jsnow@redhat.com>2018-06-08 13:17:59 -0400
commit27e4648ce98f8172c2c2449896430e87652818d1 (patch)
treeead0d39618c863ce029795f4f17290c795d13051 /tests
parentedc35b3dc25a71f226ce9a0e6517a9ee26a023ff (diff)
downloadqemu-27e4648ce98f8172c2c2449896430e87652818d1.zip
qemu-27e4648ce98f8172c2c2449896430e87652818d1.tar.gz
qemu-27e4648ce98f8172c2c2449896430e87652818d1.tar.bz2
libqos/ahci: track sector size
It's not always 512, and it does wind up mattering for PIO tranfers, because this means DRQ blocks are four times as big for ATAPI. Replace an instance of 2048 with the correct define, too. This patch by itself winds changing no behavior. fis->count is ignored for CMD_PACKET, and sect_count only gets used in non-ATAPI cases. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20180606190955.20845-2-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/libqos/ahci.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index bc201d7..63e1f9b 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -90,6 +90,7 @@ struct AHCICommand {
uint32_t interrupts;
uint64_t xbytes;
uint32_t prd_size;
+ uint32_t sector_size;
uint64_t buffer;
AHCICommandProp *props;
/* Data to be transferred to the guest */
@@ -796,7 +797,7 @@ static void command_header_init(AHCICommand *cmd)
static void command_table_init(AHCICommand *cmd)
{
RegH2DFIS *fis = &(cmd->fis);
- uint16_t sect_count = (cmd->xbytes / AHCI_SECTOR_SIZE);
+ uint16_t sect_count = (cmd->xbytes / cmd->sector_size);
fis->fis_type = REG_H2D_FIS;
fis->flags = REG_H2D_FIS_CMD; /* "Command" bit */
@@ -819,7 +820,7 @@ static void command_table_init(AHCICommand *cmd)
if (cmd->props->lba28 || cmd->props->lba48) {
fis->device = ATA_DEVICE_LBA;
}
- fis->count = (cmd->xbytes / AHCI_SECTOR_SIZE);
+ fis->count = (cmd->xbytes / cmd->sector_size);
}
fis->icc = 0x00;
fis->control = 0x00;
@@ -857,6 +858,7 @@ AHCICommand *ahci_command_create(uint8_t command_name)
cmd->xbytes = props->size;
cmd->prd_size = 4096;
cmd->buffer = 0xabad1dea;
+ cmd->sector_size = props->atapi ? ATAPI_SECTOR_SIZE : AHCI_SECTOR_SIZE;
if (!cmd->props->ncq) {
cmd->interrupts = AHCI_PX_IS_DHRS;
@@ -1033,7 +1035,7 @@ void ahci_command_set_buffer(AHCICommand *cmd, uint64_t buffer)
static void ahci_atapi_set_size(AHCICommand *cmd, uint64_t xbytes)
{
unsigned char *cbd = cmd->atapi_cmd;
- uint64_t nsectors = xbytes / 2048;
+ uint64_t nsectors = xbytes / ATAPI_SECTOR_SIZE;
uint32_t tmp;
g_assert(cbd);
@@ -1080,7 +1082,7 @@ void ahci_command_set_sizes(AHCICommand *cmd, uint64_t xbytes,
cmd->prd_size = prd_size;
}
cmd->xbytes = xbytes;
- sect_count = (cmd->xbytes / AHCI_SECTOR_SIZE);
+ sect_count = (cmd->xbytes / cmd->sector_size);
if (cmd->props->ncq) {
NCQFIS *nfis = (NCQFIS *)&(cmd->fis);