All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: jsnow@redhat.com, peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 24/30] libqos/ahci: track sector size
Date: Fri,  8 Jun 2018 13:47:27 -0400	[thread overview]
Message-ID: <20180608174733.4936-25-jsnow@redhat.com> (raw)
In-Reply-To: <20180608174733.4936-1-jsnow@redhat.com>

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>
---
 tests/libqos/ahci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index bc201d762b..63e1f9b92d 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);
-- 
2.14.3

  parent reply	other threads:[~2018-06-08 17:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 17:47 [Qemu-devel] [PULL 00/30] Ide patches John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 01/30] ahci: trim signatures on raise/lower John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 02/30] ahci: fix PxCI register race John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 03/30] ahci: don't schedule unnecessary BH John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 04/30] ahci: add port register enumeration John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 05/30] ahci: modify ahci_port_read to use register numbers John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 06/30] ahci: make port read traces more descriptive John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 07/30] ahci: fix spacing damage on ahci_port_write John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 08/30] ahci: combine identical clauses in port write John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 09/30] ahci: modify ahci_port_write to use register numbers John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 10/30] ahci: make port write traces more descriptive John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 11/30] ahci: delete old port register address definitions John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 12/30] ahci: add host register enumeration John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 13/30] ahci: fix host register max address John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 14/30] ahci: modify ahci_mem_read_32 to work on register numbers John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 15/30] ahci: make mem_read_32 traces more descriptive John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 16/30] ahci: fix spacing damage on ahci_mem_write John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 17/30] ahci: adjust ahci_mem_write to work on registers John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 18/30] ahci: delete old host register address definitions John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 19/30] ahci: make ahci_mem_write traces more descriptive John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 20/30] tests/boot-sector: Add magic bytes to s390x boot code header John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 21/30] tests/cdrom-test: Test booting from CD-ROM ISO image file John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 22/30] tests/cdrom-test: Test that -cdrom parameter is working John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 23/30] MAINTAINERS: Add the cdrom-test to John's section John Snow
2018-06-08 17:47 ` John Snow [this message]
2018-06-08 17:47 ` [Qemu-devel] [PULL 25/30] ahci: move PIO Setup FIS before transfer, fix it for ATAPI commands John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 26/30] ide: push end_transfer_func out of start_transfer callback, rename callback John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 27/30] ide: call ide_cmd_done from ide_transfer_stop John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 28/30] ide: make ide_transfer_stop idempotent John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 29/30] atapi: call ide_set_irq before ide_transfer_start John Snow
2018-06-08 17:47 ` [Qemu-devel] [PULL 30/30] ide: introduce ide_transfer_start_norecurse John Snow
2018-06-11 11:46 ` [Qemu-devel] [PULL 00/30] Ide patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180608174733.4936-25-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.