From nobody Mon Feb 9 06:00:16 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498255895602183.63071328259036; Fri, 23 Jun 2017 15:11:35 -0700 (PDT) Received: from localhost ([::1]:37436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOWnc-0007fO-SQ for importer@patchew.org; Fri, 23 Jun 2017 18:11:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOWlo-0006Sr-Ps for qemu-devel@nongnu.org; Fri, 23 Jun 2017 18:09:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOWln-0007GO-Pw for qemu-devel@nongnu.org; Fri, 23 Jun 2017 18:09:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44402) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOWlj-0007Ck-Ig; Fri, 23 Jun 2017 18:09:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35607C07DEB3; Fri, 23 Jun 2017 22:09:30 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-231.bos.redhat.com [10.18.17.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D39C5D968; Fri, 23 Jun 2017 22:09:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 35607C07DEB3 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnow@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 35607C07DEB3 From: John Snow To: qemu-block@nongnu.org Date: Fri, 23 Jun 2017 18:09:24 -0400 Message-Id: <20170623220926.11479-2-jsnow@redhat.com> In-Reply-To: <20170623220926.11479-1-jsnow@redhat.com> References: <20170623220926.11479-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 23 Jun 2017 22:09:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] ahci: add ahci_get_num_ports 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 , f4bug@amsat.org, qemu-devel@nongnu.org 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" Instead of reaching into the PCI state, allow the AHCIDevice to respond with how many ports it has. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.c | 8 ++++++++ hw/mips/boston.c | 4 ++-- include/hw/ide/ahci.h | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 1523ef3..8715514 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -241,8 +241,8 @@ static void pc_q35_init(MachineState *machine) true, "ich9-ahci"); idebus[0] =3D qdev_get_child_bus(&ahci->qdev, "ide.0"); idebus[1] =3D qdev_get_child_bus(&ahci->qdev, "ide.1"); - g_assert(MAX_SATA_PORTS =3D=3D ICH_AHCI(ahci)->ahci.ports); - ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports); + g_assert(MAX_SATA_PORTS =3D=3D ahci_get_num_ports(ahci)); + ide_drive_get(hd, ahci_get_num_ports(ahci)); ahci_ide_create_devs(ahci, hd); } else { idebus[0] =3D idebus[1] =3D NULL; diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index f60826d..1ab3245 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1833,6 +1833,14 @@ static void sysbus_ahci_register_types(void) =20 type_init(sysbus_ahci_register_types) =20 +int32_t ahci_get_num_ports(PCIDevice *dev) +{ + AHCIPCIState *d =3D ICH_AHCI(dev); + AHCIState *ahci =3D &d->ahci; + + return ahci->ports; +} + void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd) { AHCIPCIState *d =3D ICH_AHCI(dev); diff --git a/hw/mips/boston.c b/hw/mips/boston.c index a4677f7..ad59404 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -538,8 +538,8 @@ static void boston_mach_init(MachineState *machine) ahci =3D pci_create_simple_multifunction(&PCI_BRIDGE(&pcie2->root)->se= c_bus, PCI_DEVFN(0, 0), true, TYPE_ICH9_AHCI); - g_assert(ARRAY_SIZE(hd) =3D=3D ICH_AHCI(ahci)->ahci.ports); - ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports); + g_assert(ARRAY_SIZE(hd) =3D=3D ahci_get_num_ports(ahci)); + ide_drive_get(hd, ahci_get_num_ports(ahci)); ahci_ide_create_devs(ahci, hd); =20 if (machine->firmware) { diff --git a/include/hw/ide/ahci.h b/include/hw/ide/ahci.h index 0ca7c65..f866bbf 100644 --- a/include/hw/ide/ahci.h +++ b/include/hw/ide/ahci.h @@ -372,6 +372,7 @@ void ahci_uninit(AHCIState *s); =20 void ahci_reset(AHCIState *s); =20 +int32_t ahci_get_num_ports(PCIDevice *dev); void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd); =20 #define TYPE_SYSBUS_AHCI "sysbus-ahci" --=20 2.9.4