From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637166990588820.8220884463402; Wed, 17 Nov 2021 08:36:30 -0800 (PST) Received: from localhost ([::1]:32850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNvB-0006Xn-6U for importer@patchew.org; Wed, 17 Nov 2021 11:36:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtE-0003MK-0m for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt7-00087x-D1 for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-gpDRdBhPNaKBye0I5OYPcw-1; Wed, 17 Nov 2021 11:34:18 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74C0019251A0; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0731E60657; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 76B3711380AA; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n71huKi+yk6NL30jm1M2LsU8+cBgcad2WusbapSISfE=; b=EQmMHnoEyQG4xYxe86V4wSFRREeDCCgycPPnqfMSKFgc9X7Zcw4xPdJLO+AeE/fA0BydM+ P43Pz5khHWbBDJvQMH0/AqsFExCmcG2TB2EMtLkiNRqTd5cMP6xiYiSB9uqf+ff/Q6xmai XPw8ZaOm6KHzaqTnUpKNYXBmzhbErdk= X-MC-Unique: gpDRdBhPNaKBye0I5OYPcw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 01/13] hw/sd/ssi-sd: Do not create SD card within controller's realize Date: Wed, 17 Nov 2021 17:33:57 +0100 Message-Id: <20211117163409.3587705-2-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-riscv@nongnu.org, qemu-block@nongnu.org, Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Alistair Francis , Palmer Dabbelt Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637166991379100001 ssi_sd_realize() creates an "sd-card" device. This is inappropriate, and marked FIXME. Move it to the boards that create these devices. Prior art: commit eb4f566bbb for device "generic-sdhci", and commit 26c607b86b for device "pl181". The device remains not user-creatable, because its users should (and do) wire up its GPIO chip-select line. Cc: Peter Maydell Cc: Alistair Francis Cc: Bin Meng Cc: Palmer Dabbelt Cc: "Philippe Mathieu-Daud=C3=A9" Cc: qemu-arm@nongnu.org Cc: qemu-riscv@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/stellaris.c | 15 ++++++++++++++- hw/riscv/sifive_u.c | 13 ++++++++++++- hw/sd/ssi-sd.c | 29 +---------------------------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 78827ace6b..b6c8a5d609 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/sysbus.h" +#include "hw/sd/sd.h" #include "hw/ssi/ssi.h" #include "hw/arm/boot.h" #include "qemu/timer.h" @@ -1157,6 +1158,9 @@ static void stellaris_init(MachineState *ms, stellari= s_board_info *board) void *bus; DeviceState *sddev; DeviceState *ssddev; + DriveInfo *dinfo; + DeviceState *carddev; + BlockBackend *blk; =20 /* * Some boards have both an OLED controller and SD card connec= ted to @@ -1221,8 +1225,17 @@ static void stellaris_init(MachineState *ms, stellar= is_board_info *board) * - Make the ssd0323 OLED controller chipselect active-low */ bus =3D qdev_get_child_bus(dev, "ssi"); - sddev =3D ssi_create_peripheral(bus, "ssi-sd"); + + dinfo =3D drive_get(IF_SD, 0, 0); + blk =3D dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; + carddev =3D qdev_new(TYPE_SD_CARD); + qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal); + qdev_prop_set_bit(carddev, "spi", true); + qdev_realize_and_unref(carddev, + qdev_get_child_bus(sddev, "sd-bus"), + &error_fatal); + ssddev =3D ssi_create_peripheral(bus, "ssd0323"); gpio_out[GPIO_D][0] =3D qemu_irq_split( qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0), diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 589ae72a59..a4ecadaf12 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -46,6 +46,7 @@ #include "hw/char/serial.h" #include "hw/cpu/cluster.h" #include "hw/misc/unimp.h" +#include "hw/sd/sd.h" #include "hw/ssi/ssi.h" #include "target/riscv/cpu.h" #include "hw/riscv/riscv_hart.h" @@ -536,7 +537,8 @@ static void sifive_u_machine_init(MachineState *machine) uint32_t fdt_load_addr; uint64_t kernel_entry; DriveInfo *dinfo; - DeviceState *flash_dev, *sd_dev; + BlockBackend *blk; + DeviceState *flash_dev, *sd_dev, *card_dev; qemu_irq flash_cs, sd_cs; =20 /* Initialize SoC */ @@ -686,6 +688,15 @@ static void sifive_u_machine_init(MachineState *machin= e) =20 sd_cs =3D qdev_get_gpio_in_named(sd_dev, SSI_GPIO_CS, 0); sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi2), 1, sd_cs); + + dinfo =3D drive_get(IF_SD, 0, 0); + blk =3D dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; + card_dev =3D qdev_new(TYPE_SD_CARD); + qdev_prop_set_drive_err(card_dev, "drive", blk, &error_fatal); + qdev_prop_set_bit(card_dev, "spi", true); + qdev_realize_and_unref(card_dev, + qdev_get_child_bus(sd_dev, "sd-bus"), + &error_fatal); } =20 static bool sifive_u_machine_get_start_in_flash(Object *obj, Error **errp) diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index e60854eeef..167c03b780 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -368,36 +368,9 @@ static const VMStateDescription vmstate_ssi_sd =3D { =20 static void ssi_sd_realize(SSIPeripheral *d, Error **errp) { - ERRP_GUARD(); ssi_sd_state *s =3D SSI_SD(d); - DeviceState *carddev; - DriveInfo *dinfo; =20 qbus_init(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, DEVICE(d), "sd-bus= "); - - /* Create and plug in the sd card */ - /* FIXME use a qdev drive property instead of drive_get_next() */ - dinfo =3D drive_get_next(IF_SD); - carddev =3D qdev_new(TYPE_SD_CARD); - if (dinfo) { - if (!qdev_prop_set_drive_err(carddev, "drive", - blk_by_legacy_dinfo(dinfo), errp)) { - goto fail; - } - } - - if (!object_property_set_bool(OBJECT(carddev), "spi", true, errp)) { - goto fail; - } - - if (!qdev_realize_and_unref(carddev, BUS(&s->sdbus), errp)) { - goto fail; - } - - return; - -fail: - error_prepend(errp, "failed to init SD card: "); } =20 static void ssi_sd_reset(DeviceState *dev) @@ -426,7 +399,7 @@ static void ssi_sd_class_init(ObjectClass *klass, void = *data) k->cs_polarity =3D SSI_CS_LOW; dc->vmsd =3D &vmstate_ssi_sd; dc->reset =3D ssi_sd_reset; - /* Reason: init() method uses drive_get_next() */ + /* Reason: GPIO chip-select line should be wired up */ dc->user_creatable =3D false; } =20 --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167440953659.5259762595216; Wed, 17 Nov 2021 08:44:00 -0800 (PST) Received: from localhost ([::1]:59890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO2R-0007r2-Tb for importer@patchew.org; Wed, 17 Nov 2021 11:43:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtH-0003Qf-MD for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt9-00088p-Tp for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-250-yzX-l9IxOD2U8Tr0TBfI3w-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A324810168C0; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0811A179B3; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7A80211380B8; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nv7xEc0r9K+UFSB/+bjTC9hP1s8f7mZ1TvPS4t1YCmc=; b=eRtR3v/Gk50+JJTgpAtGZYiEaMqnO1IHFGAzZI88UfOTgfX+7ATUba+ZxM6uiENNWFpJ8o wKiZi94lbpUJhfAm4QaCrJVBGk00i8QHAK/MqlDPPFPvofLyBTEcfWJgbvGxgZxYS/fWhv JC1b/443ETOMLg12hkzeFHM1Y0m1Tc0= X-MC-Unique: yzX-l9IxOD2U8Tr0TBfI3w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 02/13] hw: Replace trivial drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:33:58 +0100 Message-Id: <20211117163409.3587705-3-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-riscv@nongnu.org, qemu-block@nongnu.org, Michael Tokarev , Bin Meng , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , Subbaraya Sundeep , Beniamino Galvani , Niek Linnenbank , qemu-arm@nongnu.org, Alistair Francis , Palmer Dabbelt , Jean-Christophe Dubois , Artyom Tarasenko , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167443440100001 drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. A number of machines connect just one backend with drive_get_next(). Change them to use drive_get() directly. This makes the (zero) unit number explicit in the code. Cc: Beniamino Galvani Cc: Peter Maydell Cc: Subbaraya Sundeep Cc: Niek Linnenbank Cc: Andrew Baumann Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Jean-Christophe Dubois Cc: Alistair Francis Cc: Bin Meng Cc: Palmer Dabbelt Cc: Artyom Tarasenko Cc: Mark Cave-Ayland Cc: Michael Tokarev Cc: Laurent Vivier Cc: qemu-arm@nongnu.org Cc: qemu-riscv@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Alistair Francis --- hw/arm/cubieboard.c | 2 +- hw/arm/integratorcp.c | 2 +- hw/arm/msf2-som.c | 2 +- hw/arm/orangepi.c | 2 +- hw/arm/raspi.c | 2 +- hw/arm/realview.c | 2 +- hw/arm/sabrelite.c | 2 +- hw/misc/sifive_u_otp.c | 2 +- hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/sparc64/niagara.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index 294ba5de6e..5e3372a3c7 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -81,7 +81,7 @@ static void cubieboard_init(MachineState *machine) } =20 /* Retrieve SD bus */ - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, 0); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; bus =3D qdev_get_child_bus(DEVICE(a10), "sd-bus"); =20 diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index 16e8985953..b109ece3ae 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -649,7 +649,7 @@ static void integratorcp_init(MachineState *machine) qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_WPROT, = 0)); qdev_connect_gpio_out_named(dev, "card-inserted", 0, qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_CARDIN,= 0)); - dinfo =3D drive_get_next(IF_SD); + dinfo =3D drive_get(IF_SD, 0, 0); if (dinfo) { DeviceState *card; =20 diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c index 396e8b9913..d9f881690e 100644 --- a/hw/arm/msf2-som.c +++ b/hw/arm/msf2-som.c @@ -45,7 +45,7 @@ static void emcraft_sf2_s2s010_init(MachineState *machine) DeviceState *spi_flash; MSF2State *soc; MachineClass *mc =3D MACHINE_GET_CLASS(machine); - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, 0); qemu_irq cs_line; BusState *spi_bus; MemoryRegion *sysmem =3D get_system_memory(); diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c index 0cf9895ce7..e796382236 100644 --- a/hw/arm/orangepi.c +++ b/hw/arm/orangepi.c @@ -85,7 +85,7 @@ static void orangepi_init(MachineState *machine) qdev_realize(DEVICE(h3), NULL, &error_abort); =20 /* Retrieve SD bus */ - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, 0); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; bus =3D qdev_get_child_bus(DEVICE(h3), "sd-bus"); =20 diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 146d35382b..b4dd6c1e99 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -284,7 +284,7 @@ static void raspi_machine_init(MachineState *machine) qdev_realize(DEVICE(&s->soc), NULL, &error_fatal); =20 /* Create and plug in the SD cards */ - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, 0); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; bus =3D qdev_get_child_bus(DEVICE(&s->soc), "sd-bus"); if (bus =3D=3D NULL) { diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 1c54316ba3..ddc70b54a5 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -237,7 +237,7 @@ static void realview_init(MachineState *machine, qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); qdev_connect_gpio_out_named(dev, "card-read-only", 0, mmc_irq[0]); qdev_connect_gpio_out_named(dev, "card-inserted", 0, mmc_irq[1]); - dinfo =3D drive_get_next(IF_SD); + dinfo =3D drive_get(IF_SD, 0, 0); if (dinfo) { DeviceState *card; =20 diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c index 553608e583..cce49aa25c 100644 --- a/hw/arm/sabrelite.c +++ b/hw/arm/sabrelite.c @@ -76,7 +76,7 @@ static void sabrelite_init(MachineState *machine) if (spi_bus) { DeviceState *flash_dev; qemu_irq cs_line; - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, 0); =20 flash_dev =3D qdev_new("sst25vf016b"); if (dinfo) { diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c index 18aa0bd55d..5d5a8c8a90 100644 --- a/hw/misc/sifive_u_otp.c +++ b/hw/misc/sifive_u_otp.c @@ -209,7 +209,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Erro= r **errp) TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); =20 - dinfo =3D drive_get_next(IF_NONE); + dinfo =3D drive_get(IF_NONE, 0, 0); if (dinfo) { int ret; uint64_t perm; diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 57d779fb55..d1d065efbc 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -458,7 +458,7 @@ static void microchip_icicle_kit_machine_init(MachineSt= ate *machine) target_ulong firmware_end_addr, kernel_start_addr; uint64_t kernel_entry; uint32_t fdt_load_addr; - DriveInfo *dinfo =3D drive_get_next(IF_SD); + DriveInfo *dinfo =3D drive_get(IF_SD, 0, 0); =20 /* Sanity check on RAM size */ if (machine->ram_size < mc->default_ram_size) { diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index a4ecadaf12..aa74e67889 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -672,7 +672,7 @@ static void sifive_u_machine_init(MachineState *machine) =20 /* Connect an SPI flash to SPI0 */ flash_dev =3D qdev_new("is25wp256"); - dinfo =3D drive_get_next(IF_MTD); + dinfo =3D drive_get(IF_MTD, 0, 0); if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo), diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c index f3e42d0326..ccad2c43a3 100644 --- a/hw/sparc64/niagara.c +++ b/hw/sparc64/niagara.c @@ -98,7 +98,7 @@ static void add_rom_or_fail(const char *file, const hwadd= r addr) static void niagara_init(MachineState *machine) { NiagaraBoardState *s =3D g_new(NiagaraBoardState, 1); - DriveInfo *dinfo =3D drive_get_next(IF_PFLASH); + DriveInfo *dinfo =3D drive_get(IF_PFLASH, 0, 0); MemoryRegion *sysmem =3D get_system_memory(); =20 /* init CPUs */ --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167611704938.2165042699776; Wed, 17 Nov 2021 08:46:51 -0800 (PST) Received: from localhost ([::1]:38028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO5C-0003kh-Cw for importer@patchew.org; Wed, 17 Nov 2021 11:46:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtO-0003dt-6F for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtD-00089v-NV for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-5IarRvImMOW4jSuEP9ggDg-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8362B804140; Wed, 17 Nov 2021 16:34:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 146B25C232; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7EE1F11380BA; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZJwQU4w8VmhCqL45WDYwISlZ94BAmtX/oVcRCe35xsM=; b=W0ngoEh6o1wjvykQoGJhLiP8J307UIgQiEJzdPK0Gdie29Yc8nJGi3lVavHNkLCrl48aNX smAn0wtcc5jGl48Qq5RAdUAhe2OBzbfOYDqAvlrFDssNaLFks6l10WOpLyhnGDy2SETudc xOvhVPBIQt64NKX783CYGH37QBrljRk= X-MC-Unique: 5IarRvImMOW4jSuEP9ggDg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 03/13] hw/arm/npcm7xx_boards: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:33:59 +0100 Message-Id: <20211117163409.3587705-4-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tyrone Ting , qemu-arm@nongnu.org, Havard Skinnemoen , qemu-block@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167612343100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "quanta-gbs-bmc" connects just one backend with drive_get_next(), but with a helper function. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Havard Skinnemoen Cc: Tyrone Ting Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Havard Skinnemoen --- hw/arm/npcm7xx_boards.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index dec7d16ae5..d8a49e4e85 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -84,9 +84,9 @@ static void npcm7xx_connect_dram(NPCM7xxState *soc, Memor= yRegion *dram) &error_abort); } =20 -static void sdhci_attach_drive(SDHCIState *sdhci) +static void sdhci_attach_drive(SDHCIState *sdhci, int unit) { - DriveInfo *di =3D drive_get_next(IF_SD); + DriveInfo *di =3D drive_get(IF_SD, 0, unit); BlockBackend *blk =3D di ? blk_by_legacy_dinfo(di) : NULL; =20 BusState *bus =3D qdev_get_child_bus(DEVICE(sdhci), "sd-bus"); @@ -374,7 +374,7 @@ static void quanta_gbs_init(MachineState *machine) drive_get(IF_MTD, 0, 0)); =20 quanta_gbs_i2c_init(soc); - sdhci_attach_drive(&soc->mmc.sdhci); + sdhci_attach_drive(&soc->mmc.sdhci, 0); npcm7xx_load_kernel(machine, soc); } =20 --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167064110176.07201832862256; Wed, 17 Nov 2021 08:37:44 -0800 (PST) Received: from localhost ([::1]:38042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNwN-0001am-6G for importer@patchew.org; Wed, 17 Nov 2021 11:37:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtH-0003Qd-M2 for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt9-000890-Tk for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568--CTeMP9SNG2rqBjQpFBpRw-1; Wed, 17 Nov 2021 11:34:17 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CC698799E0; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B3A560C13; Wed, 17 Nov 2021 16:34:16 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 82C1911380C3; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dg8Y/pSUQZzurv6Scuss9r3ZPr1dYJI5QxZwyNKqZKY=; b=Gt1qykmVJmwDkw7lkE7yoeKCXfqVMgblcgn5DmyTn3PyIe/SeVC7clZmHBZkT5Qrk3GL9/ 3SUnA0A+P8EXaDLJ1b4Td8Cq4gpk212zyOI6Bxj9KD7/eLspFrFIjh6D/qcQOZaUrW8Rlq Dc3RGVKJ/QjY7drwHGDXWyH0tme6U6U= X-MC-Unique: -CTeMP9SNG2rqBjQpFBpRw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 04/13] hw/arm/versatilepb hw/arm/vexpress: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:00 +0100 Message-Id: <20211117163409.3587705-5-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167065677100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. The versatile and vexpress machines ("versatileab", "versatilepb", "vexpress-a9", "vexpress-a15") connect just one or two backends of a type with drive_get_next(). Change them to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Peter Maydell --- hw/arm/versatilepb.c | 4 ++-- hw/arm/vexpress.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index 575399c4fc..ecc1f6cf74 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -310,7 +310,7 @@ static void versatile_init(MachineState *machine, int b= oard_id) qdev_connect_gpio_out(sysctl, 0, qdev_get_gpio_in(dev, 0)); =20 dev =3D sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NU= LL); - dinfo =3D drive_get_next(IF_SD); + dinfo =3D drive_get(IF_SD, 0, 0); if (dinfo) { DeviceState *card; =20 @@ -322,7 +322,7 @@ static void versatile_init(MachineState *machine, int b= oard_id) } =20 dev =3D sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NU= LL); - dinfo =3D drive_get_next(IF_SD); + dinfo =3D drive_get(IF_SD, 0, 1); if (dinfo) { DeviceState *card; =20 diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 58481c0762..966758cf82 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -625,7 +625,7 @@ static void vexpress_common_init(MachineState *machine) qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPR= OT)); qdev_connect_gpio_out_named(dev, "card-inserted", 0, qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CAR= DIN)); - dinfo =3D drive_get_next(IF_SD); + dinfo =3D drive_get(IF_SD, 0, 0); if (dinfo) { DeviceState *card; =20 @@ -657,7 +657,7 @@ static void vexpress_common_init(MachineState *machine) =20 sysbus_create_simple("pl111", map[VE_CLCD], pic[14]); =20 - dinfo =3D drive_get_next(IF_PFLASH); + dinfo =3D drive_get(IF_PFLASH, 0, 0); pflash0 =3D ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flas= h0", dinfo); if (!pflash0) { @@ -673,7 +673,7 @@ static void vexpress_common_init(MachineState *machine) memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], flashal= ias); } =20 - dinfo =3D drive_get_next(IF_PFLASH); + dinfo =3D drive_get(IF_PFLASH, 0, 1); if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo)) { error_report("vexpress: error registering flash 1"); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167614120513.5283516865805; Wed, 17 Nov 2021 08:46:54 -0800 (PST) Received: from localhost ([::1]:38274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO5F-0003uP-6p for importer@patchew.org; Wed, 17 Nov 2021 11:46:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtN-0003Zv-8t for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtD-0008AD-MO for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-123-aKRgiaUNOcWcNH8zphsTvg-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A84919251A2; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD99357CAB; Wed, 17 Nov 2021 16:34:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 862BF11380CA; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XGpMwJw1PHYIcQxJSbkz4subx26/DcZw4fXuCyXFOr8=; b=Pw0+K2TWsnwc8c/+q+BgwA/Kw3ZSv3GDgC12RkILTNB48eqUhEk6TqEQnMgUk+FKtrr64n V+Q0qFXAz3FM5mm1Eir4Dh8+HYgMwSJF+N2ziAvRElVEG6+ElFV+thU2IQV/SS2cboANIQ XQkrotkPjxar7caT+OgsmevWWuEbPs8= X-MC-Unique: aKRgiaUNOcWcNH8zphsTvg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 05/13] hw/arm/imx25_pdk: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:01 +0100 Message-Id: <20211117163409.3587705-6-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, qemu-block@nongnu.org, Jean-Christophe Dubois Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167616663100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "imx25-pdk" connects backends with drive_get_next() in a counting loop. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Peter Maydell Cc: Jean-Christophe Dubois Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Peter Maydell --- hw/arm/imx25_pdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c index bd16acd4d9..6dff000163 100644 --- a/hw/arm/imx25_pdk.c +++ b/hw/arm/imx25_pdk.c @@ -123,7 +123,7 @@ static void imx25_pdk_init(MachineState *machine) DriveInfo *di; BlockBackend *blk; =20 - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, i); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; bus =3D qdev_get_child_bus(DEVICE(&s->soc.esdhc[i]), "sd-bus"); carddev =3D qdev_new(TYPE_SD_CARD); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167410052366.14180511224447; Wed, 17 Nov 2021 08:43:30 -0800 (PST) Received: from localhost ([::1]:57674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO1w-0006Ld-QD for importer@patchew.org; Wed, 17 Nov 2021 11:43:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtL-0003Wy-As for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtD-0008A5-Lw for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:34 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-ArWkdGdkNiCFrHW72Ts7Lg-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BD5B1006AA1; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD77B5C1BB; Wed, 17 Nov 2021 16:34:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8972711380CD; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lpC7s2V46IdA7XTvAi97Rc2I1PaB7uDNF371b2rv/so=; b=WOw7R+l5Z3FuoKoIGjy9XJKIZDx3rLV5ZRzi0xBWj9+nqrWs3SDreoih4kqucKXb4j8fjm YeU9gh39u7FdXjxS+tPrN1GFe3JS3R5GpaNmTV1jLQ/qJDg54hJRB9dDA/mJqhQK3Ec/Fl w3fifwlyDbpUNVmyXhbkodjKkp32cKk= X-MC-Unique: ArWkdGdkNiCFrHW72Ts7Lg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 06/13] hw/arm/mcimx6ul-evk: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:02 +0100 Message-Id: <20211117163409.3587705-7-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, qemu-block@nongnu.org, Jean-Christophe Dubois Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167411096100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "mcimx6ul-evk" connects backends with drive_get_next() in a counting loop. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Peter Maydell Cc: Jean-Christophe Dubois Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Peter Maydell --- hw/arm/mcimx6ul-evk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c index 77fae874b1..28b4886f48 100644 --- a/hw/arm/mcimx6ul-evk.c +++ b/hw/arm/mcimx6ul-evk.c @@ -52,7 +52,7 @@ static void mcimx6ul_evk_init(MachineState *machine) DriveInfo *di; BlockBackend *blk; =20 - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, i); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; bus =3D qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus"); carddev =3D qdev_new(TYPE_SD_CARD); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167128243353.3563305734307; Wed, 17 Nov 2021 08:38:48 -0800 (PST) Received: from localhost ([::1]:42642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNxP-0004fk-9f for importer@patchew.org; Wed, 17 Nov 2021 11:38:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtE-0003MW-1g for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt9-00088U-Rv for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-177-1SLvi43POV6U-hB9QFRVsg-1; Wed, 17 Nov 2021 11:34:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B63419251A4; Wed, 17 Nov 2021 16:34:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE74C5F4E0; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8CC9D11380CF; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EgarIjhvXGK6SoTdao173npcs6FsLF5ihY/bFRR9IPE=; b=Q5mAcLOnNL1tYtnyu6KM2pM/srsyiPYAtOler4WCPcLE0SBWSBY4TQHKLLwvy75fqCHwd+ zq/725YBCTbLTJWbPY8w5l8NprC8vVxONYRATjaxXc4tHt7HeIs08/J35/p5eIxujw5o+p vblNLI87mDOMjoo1wielPBbx3nYytTA= X-MC-Unique: 1SLvi43POV6U-hB9QFRVsg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 07/13] hw/arm/mcimx7d-sabre: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:03 +0100 Message-Id: <20211117163409.3587705-8-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Smirnov , Peter Maydell , qemu-arm@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167129388100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "mcimx7d-sabre" connects backends with drive_get_next() in a counting loop. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Peter Maydell Cc: Andrey Smirnov Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Peter Maydell --- hw/arm/mcimx7d-sabre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c index 935d4b0f1c..50a5ecde31 100644 --- a/hw/arm/mcimx7d-sabre.c +++ b/hw/arm/mcimx7d-sabre.c @@ -52,7 +52,7 @@ static void mcimx7d_sabre_init(MachineState *machine) DriveInfo *di; BlockBackend *blk; =20 - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, i); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; bus =3D qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus"); carddev =3D qdev_new(TYPE_SD_CARD); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167373243518.1634883069644; Wed, 17 Nov 2021 08:42:53 -0800 (PST) Received: from localhost ([::1]:56440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO1L-0005XF-UN for importer@patchew.org; Wed, 17 Nov 2021 11:42:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtN-0003dC-Uv for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtD-0008Ay-Qx for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-182-FTlBO-prP3uP3vAS5izApA-1; Wed, 17 Nov 2021 11:34:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FA221006AA1; Wed, 17 Nov 2021 16:34:20 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF2685F4E0; Wed, 17 Nov 2021 16:34:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9011D11380D7; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/hCNF90n88ZaOSveBM5R6+mc+3MVPday5x+7l3fC5ok=; b=h10RmQzGhRahLayII7yauvii3K99eordfkchWXEQL3ArITGH0YoIIYiYd7oGDcL5ymfPlg f1sGSUq3As1oEb28rhGdRAFFFasOsml4e+OfB7AOWRO2kPIHF1biyCZlYQLSqFgKKgdPOR vlGjmc0qzIh/06HTTplo60763GWdVUM= X-MC-Unique: FTlBO-prP3uP3vAS5izApA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 08/13] hw/arm/xlnx-versal-virt: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:04 +0100 Message-Id: <20211117163409.3587705-9-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E. Iglesias" , Alistair Francis , qemu-arm@nongnu.org, qemu-block@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167374029100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "xlnx-versal-virt" connects backends with drive_get_next() in a counting loop. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Alistair Francis Cc: "Edgar E. Iglesias" Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Acked-by: Edgar E. Iglesias --- hw/arm/xlnx-versal-virt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c index d2f55e29b6..0c5edc898e 100644 --- a/hw/arm/xlnx-versal-virt.c +++ b/hw/arm/xlnx-versal-virt.c @@ -669,7 +669,8 @@ static void versal_virt_init(MachineState *machine) =20 /* Plugin SD cards. */ for (i =3D 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) { - sd_plugin_card(&s->soc.pmc.iou.sd[i], drive_get_next(IF_SD)); + sd_plugin_card(&s->soc.pmc.iou.sd[i], + drive_get(IF_SD, 0, i)); } =20 s->binfo.ram_size =3D machine->ram_size; --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163716729879023.56368314023746; Wed, 17 Nov 2021 08:41:38 -0800 (PST) Received: from localhost ([::1]:51144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO09-00020h-N7 for importer@patchew.org; Wed, 17 Nov 2021 11:41:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtE-0003M5-GI for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt7-00088C-D1 for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:24 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-XrCm3ZIeNj-ZPcBIx2lLVQ-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FAD72FD01; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F281E60BF1; Wed, 17 Nov 2021 16:34:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9349F11380DF; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4qus80bJCqcZ460QKBRhG99/6Gn4a/GmFECWfV9sdvE=; b=LOFEWe28dbdPm7nJrjAnxVFrHG3qgZ3q2WAOA/GjMq6bkvS89lwlyXbyjclI8F0fgdQKKP rCFfHce4y8ByB+wVMhTLEwH5eYqRz2BtP1rPQNBsECBg5qzB7mw/iTgOUX80oeh37Sid6+ ITHStZjQ8clOplPumT3axupEJMvB0gA= X-MC-Unique: XrCm3ZIeNj-ZPcBIx2lLVQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 09/13] hw/microblaze: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:05 +0100 Message-Id: <20211117163409.3587705-10-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E. Iglesias" , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167299797100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "petalogix-ml605" connects backends with drive_get_next() in a counting loop. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: "Edgar E. Iglesias" Signed-off-by: Markus Armbruster Acked-by: Edgar E. Iglesias --- hw/microblaze/petalogix_ml605_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_= ml605_mmu.c index 159db6cbe2..a24fadddca 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -183,7 +183,7 @@ petalogix_ml605_init(MachineState *machine) spi =3D (SSIBus *)qdev_get_child_bus(dev, "spi"); =20 for (i =3D 0; i < NUM_SPI_FLASHES; i++) { - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, i); qemu_irq cs_line; =20 dev =3D qdev_new("n25q128"); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163716713461184.09241444215616; Wed, 17 Nov 2021 08:38:54 -0800 (PST) Received: from localhost ([::1]:43258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNxV-00054J-JC for importer@patchew.org; Wed, 17 Nov 2021 11:38:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtH-0003Qo-Mj for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt9-000893-Ty for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-i3Y4S7cVMYiULzdpXz7Suw-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59FA110168C4; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 282B1100EBBE; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 975301132D27; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rYswMrWmEmAz/Uk6rnfHjwvLtZ0axzsg1ucyN0GZvJw=; b=SVdPfS5oFpsHbpxqVbJckKEVsdhYm/fBHmCbwFwnIZq+Axm1xyb9NK7yFiKFA/a/ofQUzz tVDDK+vpjZZGoHrVd6DfhpV/UXuk2nEf6Cu5VkNIJcOM8L2f6QIunwKyNvYmYnXYfcVQ1+ S+ahcurQ1+CW6KARe2SofgjF9LRJKLI= X-MC-Unique: i3Y4S7cVMYiULzdpXz7Suw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 10/13] hw/arm/xlnx-zcu102: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:06 +0100 Message-Id: <20211117163409.3587705-11-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E. Iglesias" , Alistair Francis , qemu-arm@nongnu.org, qemu-block@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167136274100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "xlnx-zcu102" connects backends with drive_get_next() in several counting loops. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: Alistair Francis Cc: "Edgar E. Iglesias" Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Acked-by: Edgar E. Iglesias --- hw/arm/xlnx-zcu102.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c index 3dc2b5e8ca..45eb19ab3b 100644 --- a/hw/arm/xlnx-zcu102.c +++ b/hw/arm/xlnx-zcu102.c @@ -169,7 +169,7 @@ static void xlnx_zcu102_init(MachineState *machine) /* Create and plug in the SD cards */ for (i =3D 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) { BusState *bus; - DriveInfo *di =3D drive_get_next(IF_SD); + DriveInfo *di =3D drive_get(IF_SD, 0, i); BlockBackend *blk =3D di ? blk_by_legacy_dinfo(di) : NULL; DeviceState *carddev; char *bus_name; @@ -190,7 +190,7 @@ static void xlnx_zcu102_init(MachineState *machine) BusState *spi_bus; DeviceState *flash_dev; qemu_irq cs_line; - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, i); gchar *bus_name =3D g_strdup_printf("spi%d", i); =20 spi_bus =3D qdev_get_child_bus(DEVICE(&s->soc), bus_name); @@ -212,7 +212,7 @@ static void xlnx_zcu102_init(MachineState *machine) BusState *spi_bus; DeviceState *flash_dev; qemu_irq cs_line; - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, XLNX_ZYNQMP_NUM_SPIS + i= ); int bus =3D i / XLNX_ZYNQMP_NUM_QSPI_BUS_CS; gchar *bus_name =3D g_strdup_printf("qspi%d", bus); =20 --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167425627917.5051429950187; Wed, 17 Nov 2021 08:43:45 -0800 (PST) Received: from localhost ([::1]:58730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnO2C-00073l-Jh for importer@patchew.org; Wed, 17 Nov 2021 11:43:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtL-0003Ww-Ah for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtD-0008AS-Jw for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:34 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-gwWkTUUUPMSA-jwxnir80Q-1; Wed, 17 Nov 2021 11:34:20 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B584A8799EB; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 828945C1BB; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9A8F91132996; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qy/be1AOUE7Ms2lbtbLyXpcwHOrPuiAjrY96KknfdPQ=; b=PyXRqMNvpo5Wwbf2pwdchXj40OeTp2JSbdBRMKR4YHlETnvYaUNwmZZnA02ApBdiQCDj8h HP+iSdVcmY+0ag+xnpdizlkP9mQfaJcGeJW5m6ao6W1ks3STtjMGMe2UqijT8mRMeQ22im l6AFaviV/okF1XSicPh4GKv39eenscg= X-MC-Unique: gwWkTUUUPMSA-jwxnir80Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 11/13] hw/arm/xilinx_zynq: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:07 +0100 Message-Id: <20211117163409.3587705-12-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E. Iglesias" , Alistair Francis , qemu-arm@nongnu.org, qemu-block@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167426987100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. Machine "xlnx-zcu102" connects backends with drive_get_next() in two counting loops, one of them in a helper function. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: "Edgar E. Iglesias" Cc: Alistair Francis Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Acked-by: Edgar E. Iglesias --- hw/arm/xilinx_zynq.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 69c333e91b..50e7268396 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -125,9 +125,10 @@ static void gem_init(NICInfo *nd, uint32_t base, qemu_= irq irq) sysbus_connect_irq(s, 0, irq); } =20 -static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, - bool is_qspi) +static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, + bool is_qspi, int unit0) { + int unit =3D unit0; DeviceState *dev; SysBusDevice *busdev; SSIBus *spi; @@ -156,7 +157,7 @@ static inline void zynq_init_spi_flashes(uint32_t base_= addr, qemu_irq irq, spi =3D (SSIBus *)qdev_get_child_bus(dev, bus_name); =20 for (j =3D 0; j < num_ss; ++j) { - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, unit++); flash_dev =3D qdev_new("n25q128"); if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", @@ -170,6 +171,7 @@ static inline void zynq_init_spi_flashes(uint32_t base_= addr, qemu_irq irq, } } =20 + return unit; } =20 static void zynq_init(MachineState *machine) @@ -247,9 +249,9 @@ static void zynq_init(MachineState *machine) pic[n] =3D qdev_get_gpio_in(dev, n); } =20 - zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET], false); - zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET], false); - zynq_init_spi_flashes(0xE000D000, pic[51-IRQ_OFFSET], true); + n =3D zynq_init_spi_flashes(0xE0006000, pic[58 - IRQ_OFFSET], false, 0= ); + n =3D zynq_init_spi_flashes(0xE0007000, pic[81 - IRQ_OFFSET], false, n= ); + n =3D zynq_init_spi_flashes(0xE000D000, pic[51 - IRQ_OFFSET], true, n); =20 sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]); sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]); @@ -298,7 +300,7 @@ static void zynq_init(MachineState *machine) sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, hci_addr); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[hci_irq - IRQ_OFFSE= T]); =20 - di =3D drive_get_next(IF_SD); + di =3D drive_get(IF_SD, 0, n); blk =3D di ? blk_by_legacy_dinfo(di) : NULL; carddev =3D qdev_new(TYPE_SD_CARD); qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167267267703.5488650640893; Wed, 17 Nov 2021 08:41:07 -0800 (PST) Received: from localhost ([::1]:48846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNzd-0000Lc-NJ for importer@patchew.org; Wed, 17 Nov 2021 11:41:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtM-0003X3-4o for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtD-00089q-MF for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-suNczjPHOiGvpwrbgMFXHg-1; Wed, 17 Nov 2021 11:34:20 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 000A110168C6; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A08057CAA; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9E9861132999; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aXR06R6xzJI3KAPToNPIsvnoPM1tdfEZjAqK89BERnc=; b=UtnOpquA8+HfyAZc0j7rbObO/M4uFnVcjYcjKahkMHiJAzjNFV7kvzX/g/ztnz/cWY73xl k0yxIpKaaBrlQB5HBRhog1z/yvkM2knWIEughd0rTvPH/4PBa+u9EyL3QwRKOknB+pbV1Z KRIgxVh8FV732LeEkuldNqPYSNmj2fo= X-MC-Unique: suNczjPHOiGvpwrbgMFXHg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 12/13] hw/arm/aspeed: Replace drive_get_next() by drive_get() Date: Wed, 17 Nov 2021 17:34:08 +0100 Message-Id: <20211117163409.3587705-13-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-block@nongnu.org, Andrew Jeffery , qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167269477100001 drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. The aspeed machines connects backends with drive_get_next() in several counting loops, one of them in a helper function, and a conditional. Change it to use drive_get() directly. This makes the unit numbers explicit in the code. Cc: "C=C3=A9dric Le Goater" Cc: Peter Maydell Cc: Andrew Jeffery Cc: Joel Stanley Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: C=C3=A9dric Le Goater --- hw/arm/aspeed.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index a77f46b3ad..cf20ae0db5 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -284,12 +284,13 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr a= ddr, size_t rom_size, } =20 static void aspeed_board_init_flashes(AspeedSMCState *s, - const char *flashtype) + const char *flashtype, + int unit0) { int i ; =20 for (i =3D 0; i < s->num_cs; ++i) { - DriveInfo *dinfo =3D drive_get_next(IF_MTD); + DriveInfo *dinfo =3D drive_get(IF_MTD, 0, unit0 + i); qemu_irq cs_line; DeviceState *dev; =20 @@ -382,10 +383,12 @@ static void aspeed_machine_init(MachineState *machine) "max_ram", max_ram_size - machine->ram_size); memory_region_add_subregion(&bmc->ram_container, machine->ram_size, &b= mc->max_ram); =20 - aspeed_board_init_flashes(&bmc->soc.fmc, bmc->fmc_model ? - bmc->fmc_model : amc->fmc_model); - aspeed_board_init_flashes(&bmc->soc.spi[0], bmc->spi_model ? - bmc->spi_model : amc->spi_model); + aspeed_board_init_flashes(&bmc->soc.fmc, + bmc->fmc_model ? bmc->fmc_model : amc->fmc_m= odel, + 0); + aspeed_board_init_flashes(&bmc->soc.spi[0], + bmc->spi_model ? bmc->spi_model : amc->spi_m= odel, + bmc->soc.fmc.num_cs); =20 /* Install first FMC flash content as a boot rom. */ if (drive0) { @@ -435,11 +438,13 @@ static void aspeed_machine_init(MachineState *machine) } =20 for (i =3D 0; i < bmc->soc.sdhci.num_slots; i++) { - sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD)= ); + sdhci_attach_drive(&bmc->soc.sdhci.slots[i], + drive_get(IF_SD, 0, i)); } =20 if (bmc->soc.emmc.num_slots) { - sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD)); + sdhci_attach_drive(&bmc->soc.emmc.slots[0], + drive_get(IF_SD, 0, bmc->soc.sdhci.num_slots)); } =20 arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo); --=20 2.31.1 From nobody Fri May 17 22:55:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637167141588392.3192279926533; Wed, 17 Nov 2021 08:39:01 -0800 (PST) Received: from localhost ([::1]:43872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnNxc-0005U1-FS for importer@patchew.org; Wed, 17 Nov 2021 11:39:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNtE-0003MP-I8 for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnNt8-00088Q-36 for qemu-devel@nongnu.org; Wed, 17 Nov 2021 11:34:26 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-hAy4kiBhM86c6P6KrywAFA-1; Wed, 17 Nov 2021 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C99D10168C7; Wed, 17 Nov 2021 16:34:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0EA260BF1; Wed, 17 Nov 2021 16:34:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A1F0811329AF; Wed, 17 Nov 2021 17:34:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637166861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ap4sEt8ZfSx0lqgzCPOkQ2QMH0aRdFl0dLpn6iICdz8=; b=CAdZWEpBY6DMjSgLT9jOWxvfa8b1OK5iSg3t/xjyu7BTiuQWx0Eup1dYin3+CLQyCetjts QwbwF3NQjTb5054SArkkU2/2fraI2WfxSGghZfhG/KdqmMSRN+iL9yOjAlkG0oKpJQ13bM lUDwwoUizX9CelkutNUuwXw82NdPVvc= X-MC-Unique: hAy4kiBhM86c6P6KrywAFA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 13/13] blockdev: Drop unused drive_get_next() Date: Wed, 17 Nov 2021 17:34:09 +0100 Message-Id: <20211117163409.3587705-14-armbru@redhat.com> In-Reply-To: <20211117163409.3587705-1-armbru@redhat.com> References: <20211117163409.3587705-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.701, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637167143273100001 Content-Type: text/plain; charset="utf-8" drive_get_next() is basically a bad idea. It returns the "next" block backend of a certain interface type. "Next" means bus=3D0,unit=3DN, where subsequent calls count N up from zero, per interface type. This lets you define unit numbers implicitly by execution order. If the order changes, or new calls appear "in the middle", unit numbers change. ABI break. Hard to spot in review. The previous commits eliminated all uses. Drop the function. Cc: Kevin Wolf Cc: Hanna Reitz Signed-off-by: Markus Armbruster Reviewed-by: Hanna Reitz --- include/sysemu/blockdev.h | 1 - blockdev.c | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 32c2d6023c..a750f99b79 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -50,7 +50,6 @@ void drive_check_orphaned(void); DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); int drive_get_max_bus(BlockInterfaceType type); int drive_get_max_devs(BlockInterfaceType type); -DriveInfo *drive_get_next(BlockInterfaceType type); =20 QemuOpts *drive_def(const char *optstr); QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, diff --git a/blockdev.c b/blockdev.c index b35072644e..0eb2823b1b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -303,16 +303,6 @@ int drive_get_max_bus(BlockInterfaceType type) return max_bus; } =20 -/* Get a block device. This should only be used for single-drive devices - (e.g. SD/Floppy/MTD). Multi-disk devices (scsi/ide) should use the - appropriate bus. */ -DriveInfo *drive_get_next(BlockInterfaceType type) -{ - static int next_block_unit[IF_COUNT]; - - return drive_get(type, 0, next_block_unit[type]++); -} - static void bdrv_format_print(void *opaque, const char *name) { qemu_printf(" %s", name); --=20 2.31.1