From nobody Tue Feb 10 03:57:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528312333688951.2007966564291; Wed, 6 Jun 2018 12:12:13 -0700 (PDT) Received: from localhost ([::1]:54141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQdql-000259-O4 for importer@patchew.org; Wed, 06 Jun 2018 15:12:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQdot-0000ob-Qx for qemu-devel@nongnu.org; Wed, 06 Jun 2018 15:10:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQdon-0000km-Rz for qemu-devel@nongnu.org; Wed, 06 Jun 2018 15:10:07 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37426 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQdoi-0000e0-Sc; Wed, 06 Jun 2018 15:09:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0B991133E7; Wed, 6 Jun 2018 19:09:55 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-177.bos.redhat.com [10.18.17.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1F1F2026E0E; Wed, 6 Jun 2018 19:09:55 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Wed, 6 Jun 2018 15:09:49 -0400 Message-Id: <20180606190955.20845-2-jsnow@redhat.com> In-Reply-To: <20180606190955.20845-1-jsnow@redhat.com> References: <20180606190955.20845-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 06 Jun 2018 19:09:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 06 Jun 2018 19:09:56 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jsnow@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/7] libqos/ahci: track sector size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D &(cmd->fis); - uint16_t sect_count =3D (cmd->xbytes / AHCI_SECTOR_SIZE); + uint16_t sect_count =3D (cmd->xbytes / cmd->sector_size); =20 fis->fis_type =3D REG_H2D_FIS; fis->flags =3D 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 =3D ATA_DEVICE_LBA; } - fis->count =3D (cmd->xbytes / AHCI_SECTOR_SIZE); + fis->count =3D (cmd->xbytes / cmd->sector_size); } fis->icc =3D 0x00; fis->control =3D 0x00; @@ -857,6 +858,7 @@ AHCICommand *ahci_command_create(uint8_t command_name) cmd->xbytes =3D props->size; cmd->prd_size =3D 4096; cmd->buffer =3D 0xabad1dea; + cmd->sector_size =3D props->atapi ? ATAPI_SECTOR_SIZE : AHCI_SECTOR_SI= ZE; =20 if (!cmd->props->ncq) { cmd->interrupts =3D 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 =3D cmd->atapi_cmd; - uint64_t nsectors =3D xbytes / 2048; + uint64_t nsectors =3D xbytes / ATAPI_SECTOR_SIZE; uint32_t tmp; g_assert(cbd); =20 @@ -1080,7 +1082,7 @@ void ahci_command_set_sizes(AHCICommand *cmd, uint64_= t xbytes, cmd->prd_size =3D prd_size; } cmd->xbytes =3D xbytes; - sect_count =3D (cmd->xbytes / AHCI_SECTOR_SIZE); + sect_count =3D (cmd->xbytes / cmd->sector_size); =20 if (cmd->props->ncq) { NCQFIS *nfis =3D (NCQFIS *)&(cmd->fis); --=20 2.14.3