From patchwork Sun Oct 22 15:51:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 13431915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7040C25B41 for ; Sun, 22 Oct 2023 15:54:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.620668.966292 (Exim 4.92) (envelope-from ) id 1qualz-0008Gn-F8; Sun, 22 Oct 2023 15:53:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 620668.966292; Sun, 22 Oct 2023 15:53:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qualz-0008EC-21; Sun, 22 Oct 2023 15:53:51 +0000 Received: by outflank-mailman (input) for mailman id 620668; Sun, 22 Oct 2023 15:53:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qualx-0006wY-JW for xen-devel@lists.xenproject.org; Sun, 22 Oct 2023 15:53:49 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2fc9f612-70f3-11ee-98d5-6d05b1d4d9a1; Sun, 22 Oct 2023 17:53:47 +0200 (CEST) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1quakJ-008TGY-LP; Sun, 22 Oct 2023 15:52:07 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1quakJ-001qZv-0q; Sun, 22 Oct 2023 16:52:07 +0100 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 2fc9f612-70f3-11ee-98d5-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=6L5rZLJkasqL2URPgSPiTRsDPGw7U0heegSHbSvzw3g=; b=f75rAvV8nOwsqPiNmVeTfSee1t XW4m6d9NDBlJfEGVCCJGehx1BzvS8lrgmm0vlO8qcJOc3iTpzr3wJmqyNgM8Dxb5Lu5MLUDpUYg6Y eg9nPGVDBlq5DSegiKbacR1M1wJHnIOj/T8lqqd6ytqVdunSDd7roaH5gPptSCXTh0BSn7SvJ+3is 69N+xf/y/evGIgkEtjUno+fCmB1wmelTe1EBdKeaqGFAErncf2L39a0wEUZu7JgyvlZZ4Msq//Wmj CUuJM0vGVuyiWSUOdioM+ssCVinEgrzOduSYfsDoVZdjMcnElchlSMIFuDbCcF8gKAfZW/BXZkc6i NdcqKqIA==; From: David Woodhouse To: qemu-devel@nongnu.org Cc: Richard Henderson , Beniamino Galvani , Peter Maydell , Strahinja Jankovic , Niek Linnenbank , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Andrew Jeffery , Joel Stanley , Igor Mitsyanko , Jean-Christophe Dubois , Andrey Smirnov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Rob Herring , Subbaraya Sundeep , Jan Kiszka , Tyrone Ting , Hao Wu , Radoslaw Biernacki , Leif Lindholm , Marcin Juszkiewicz , "Edgar E. Iglesias" , Alistair Francis , Helge Deller , Paolo Bonzini , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Song Gao , Thomas Huth , Laurent Vivier , Huacai Chen , Jiaxun Yang , =?utf-8?q?Herv=C3=A9_Poussineau?= , Aleksandar Rikalo , Aurelien Jarno , Jason Wang , Jia Liu , Stafford Horne , Mark Cave-Ayland , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Bin Meng , Palmer Dabbelt , Weiwei Li , Liu Zhiwei , David Hildenbrand , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , Eric Farman , Yoshinori Sato , Magnus Damm , Artyom Tarasenko , Stefano Stabellini , Anthony Perard , Paul Durrant , Max Filippov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org Subject: [PATCH 25/45] hw/net/smc91c111: use qemu_configure_nic_device() Date: Sun, 22 Oct 2023 16:51:40 +0100 Message-Id: <20231022155200.436340-26-dwmw2@infradead.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231022155200.436340-1-dwmw2@infradead.org> References: <20231022155200.436340-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html From: David Woodhouse Some callers instantiate the device unconditionally, others will do so only if there is a NICInfo to go with it. This appears to be fairly random, but preserve the existing behaviour for now. Signed-off-by: David Woodhouse --- hw/arm/gumstix.c | 6 ++---- hw/arm/integratorcp.c | 5 +++-- hw/arm/mainstone.c | 3 +-- hw/arm/realview.c | 25 ++++++++++--------------- hw/arm/versatilepb.c | 15 ++++----------- hw/net/smc91c111.c | 5 ++--- include/hw/net/smc91c111.h | 2 +- 7 files changed, 23 insertions(+), 38 deletions(-) diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c index 2ca4140c9f..f58c4da7f9 100644 --- a/hw/arm/gumstix.c +++ b/hw/arm/gumstix.c @@ -74,8 +74,7 @@ static void connex_init(MachineState *machine) FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0); /* Interrupt line of NIC is connected to GPIO line 36 */ - smc91c111_init(&nd_table[0], 0x04000300, - qdev_get_gpio_in(cpu->gpio, 36)); + smc91c111_init(0x04000300, qdev_get_gpio_in(cpu->gpio, 36)); } static void verdex_init(MachineState *machine) @@ -98,8 +97,7 @@ static void verdex_init(MachineState *machine) FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0); /* Interrupt line of NIC is connected to GPIO line 99 */ - smc91c111_init(&nd_table[0], 0x04000300, - qdev_get_gpio_in(cpu->gpio, 99)); + smc91c111_init(0x04000300, qdev_get_gpio_in(cpu->gpio, 99)); } static void connex_class_init(ObjectClass *oc, void *data) diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index d176e9af7e..29bc128992 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -669,8 +669,9 @@ static void integratorcp_init(MachineState *machine) sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x1d000000); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[25]); - if (nd_table[0].used) - smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); + if (qemu_find_nic_info("smc91c111", true, NULL)) { + smc91c111_init(0xc8000000, pic[27]); + } sysbus_create_simple("pl110", 0xc0000000, pic[22]); diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c index 68329c4617..84dbb6e525 100644 --- a/hw/arm/mainstone.c +++ b/hw/arm/mainstone.c @@ -153,8 +153,7 @@ static void mainstone_common_init(MachineState *machine, qdev_get_gpio_in(mst_irq, S1_IRQ), qdev_get_gpio_in(mst_irq, S1_CD_IRQ)); - smc91c111_init(&nd_table[0], MST_ETH_PHYS, - qdev_get_gpio_in(mst_irq, ETHERNET_IRQ)); + smc91c111_init(MST_ETH_PHYS, qdev_get_gpio_in(mst_irq, ETHERNET_IRQ)); mainstone_binfo.board_id = arm_id; arm_load_kernel(mpu->cpu, machine, &mainstone_binfo); diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 8f89526596..591f50581e 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -89,7 +89,6 @@ static void realview_init(MachineState *machine, I2CBus *i2c; int n; unsigned int smp_cpus = machine->smp.cpus; - int done_nic = 0; qemu_irq cpu_irq[4]; int is_mpcore = 0; int is_pb = 0; @@ -295,24 +294,20 @@ static void realview_init(MachineState *machine, n--; } } - for(n = 0; n < nb_nics; n++) { - nd = &nd_table[n]; - - if (!done_nic && (!nd->model || - strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) { - if (is_pb) { - lan9118_init(nd, 0x4e000000, pic[28]); - } else { - smc91c111_init(nd, 0x4e000000, pic[28]); - } - done_nic = 1; + + nd = qemu_find_nic_info(is_pb ? "lan9118" : "smc91c111", true, NULL); + if (nd) { + if (is_pb) { + lan9118_init(nd, 0x4e000000, pic[28]); } else { - if (pci_bus) { - pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL); - } + smc91c111_init(0x4e000000, pic[28]); } } + if (pci_bus) { + pci_init_nic_devices(pci_bus, "rtl8139"); + } + dev = sysbus_create_simple(TYPE_ARM_SBCON_I2C, 0x10002000, NULL); i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); i2c_slave_create_simple(i2c, "ds1338", 0x68); diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index 2f22dc890f..7bf2ba7c21 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -192,10 +192,8 @@ static void versatile_init(MachineState *machine, int board_id) SysBusDevice *busdev; DeviceState *pl041; PCIBus *pci_bus; - NICInfo *nd; I2CBus *i2c; int n; - int done_smc = 0; DriveInfo *dinfo; if (machine->ram_size > 0x10000000) { @@ -263,16 +261,11 @@ static void versatile_init(MachineState *machine, int board_id) sysbus_connect_irq(busdev, 3, sic[30]); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); - for(n = 0; n < nb_nics; n++) { - nd = &nd_table[n]; - - if (!done_smc && (!nd->model || strcmp(nd->model, "smc91c111") == 0)) { - smc91c111_init(nd, 0x10010000, sic[25]); - done_smc = 1; - } else { - pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL); - } + if (qemu_find_nic_info("smc91c111", true, NULL)) { + smc91c111_init(0x10010000, sic[25]); } + pci_init_nic_devices(pci_bus, "rtl8139"); + if (machine_usb(machine)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c index ddbceda967..dec4982cfe 100644 --- a/hw/net/smc91c111.c +++ b/hw/net/smc91c111.c @@ -817,14 +817,13 @@ static void smc91c111_register_types(void) /* Legacy helper function. Should go away when machine config files are implemented. */ -void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) +void smc91c111_init(uint32_t base, qemu_irq irq) { DeviceState *dev; SysBusDevice *s; - qemu_check_nic_model(nd, "smc91c111"); dev = qdev_new(TYPE_SMC91C111); - qdev_set_nic_properties(dev, nd); + qemu_configure_nic_device(dev, true, NULL); s = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(s, &error_fatal); sysbus_mmio_map(s, 0, base); diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h index df5b11dcef..dba32a233f 100644 --- a/include/hw/net/smc91c111.h +++ b/include/hw/net/smc91c111.h @@ -13,6 +13,6 @@ #include "net/net.h" -void smc91c111_init(NICInfo *, uint32_t, qemu_irq); +void smc91c111_init(uint32_t, qemu_irq); #endif