From patchwork Mon Jun 27 07:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896303 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 C554DC43334 for ; Mon, 27 Jun 2022 07:19:27 +0000 (UTC) Received: from localhost ([::1]:56914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j1p-0006bz-OK for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izM-0003eV-9n; Mon, 27 Jun 2022 03:16:52 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:35779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izG-0003sn-5Y; Mon, 27 Jun 2022 03:16:48 -0400 Received: by mail-ej1-x62f.google.com with SMTP id pk21so17190696ejb.2; Mon, 27 Jun 2022 00:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TR7o8npeCsSKFGJvppVbOeFp+PwNckjxSIksu1sdxqw=; b=WrmRulFkL2RwWM/7zfLELAmBqEM0H5rnPq2lnZZ8irfZQmpV8s3jjg5dvw5+BGBQqZ jBVrbEf2yuR2QoB0ATmdFm+hHtJPttmo8+Rt+zWmIVxvounZuaiAAR1XPLuM648CLo+m nnrntiEAe49zRvF3VLeXzGMKWa2Fx+enRSECicHcu7iKdf9H7C9ANhGvIPco/P77mN0D SPZp8y8keoc7CYNmiqteg06DOyg6bGLj/DHkiLmacspKOTxAAZ7/82I2EhUANbXUmc6V x98KSQ7bEim/kRMNzPdMiVj5JrGevy90yx+/y9/PdhN/PHtwbNCEpcAD5FrT6t00b3Y3 2oeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TR7o8npeCsSKFGJvppVbOeFp+PwNckjxSIksu1sdxqw=; b=UysTiY6PltXg+MGRmH7KJimFSgPwQoCB6I/SEV7Yobn7TAq0z4HlA5EKOYMzyzgO7R XTY6OrdSEH2kbsFKXqOkeM4gXE4XM+IKZcCO/o3dHRO2Z86JRuN5njlnXIGguA6GU+7k e5wjgghDXA9gLdOUzXipdOiTlcWCXrilzjYYAYEVj1pWzFxLIPMqohZnOrdoalgoND0a Fnw6I7n43M3mudazBrIXG9TaAXTKrFGJWb58js/8VAFy2/dRgvEwQ8Rc/qGmgvTSzGKr Oz+g1Kqu3HF3zyTVOakJjP80QvZ84oV34dbMj0FFowPkoyvB8RnhjKZAK1LGSlAXpB2D UQ+g== X-Gm-Message-State: AJIora/EQv/PYzpv/0WgZy1M5N1GMlEvF2yad2/P3QqzLae5St9B4z+j ++ExRY7jEnYG/jvcDp3WipDjcdi/fW4eVg== X-Google-Smtp-Source: AGRyM1uxYoDvK44MM8BNT49qTILHCpv7CQW6rNOlnMmM8lrns6INoxIdV50l9mvlaftIEOuHvGO+vA== X-Received: by 2002:a17:906:2a86:b0:711:d8a5:cb0c with SMTP id l6-20020a1709062a8600b00711d8a5cb0cmr11566299eje.426.1656314204116; Mon, 27 Jun 2022 00:16:44 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:43 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 01/10] hw/ide/piix: Check for presence of ISABus before using it Date: Mon, 27 Jun 2022 09:16:02 +0200 Message-Id: <20220627071611.8793-2-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=shentey@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This is an alternative solution to commit 9405d87be25db6dff4d7b5ab48a81bbf6d083e47 'hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine' which allows for cleaning up the ISA API while keeping PIIX IDE functions user-createable for an arbitrarily long deprecation period. Signed-off-by: Bernhard Beschow --- hw/ide/piix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 9a9b28078e..e8f3abc4b5 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -136,6 +136,17 @@ static int pci_piix_init_ports(PCIIDEState *d) }; int i, ret; + { + ISABus *isa_bus; + bool ambiguous; + + isa_bus = ISA_BUS(object_resolve_path_type("", TYPE_ISA_BUS, + &ambiguous)); + if (!isa_bus || ambiguous) { + return -ENODEV; + } + } + for (i = 0; i < 2; i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); ret = ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, From patchwork Mon Jun 27 07:16:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896309 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 546C9CCA473 for ; Mon, 27 Jun 2022 07:23:59 +0000 (UTC) Received: from localhost ([::1]:36750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j6E-0003h2-7Q for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:23:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izN-0003ev-48; Mon, 27 Jun 2022 03:16:53 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:34667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izH-0003sv-D8; Mon, 27 Jun 2022 03:16:49 -0400 Received: by mail-ed1-x52f.google.com with SMTP id o10so11653449edi.1; Mon, 27 Jun 2022 00:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Owsck5Aw6Urq8fF1sfCFdLXNiN0ri19YPUA3MBR7xfA=; b=nVjfnpAXbD/IT7+jmfqopuIO6OmTo7ARqGTNXmo/Z5xpMAt8kyhGD6T6skRHBrDEp5 lHHTRYYHy+77RGxVbZhNVL+M3VV4anBiQaoTwjqG6fnDjMqEHKpnpEcLfeJhwxY9+prc faHAfFI0byPPkVaaDBHSUPQOvwo5+rJfWtTTCVOXuQV2XbAepGSv6P94wu5JmPNRlK6m O0p4dRqib2Smar680WMbh/CvyL6fVe13TuI4FC2YRVHrgEOGw9NapS1tm41Pz/3F/SPw /0wfxodGcnS87kJ1fos5aFcYsdxta2wiAt3vJ7it49wcS0awfADzJyX/W696pJR7TKMm WEhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Owsck5Aw6Urq8fF1sfCFdLXNiN0ri19YPUA3MBR7xfA=; b=6pLxDVM+z3kXYrhoTMbaEF9ucbbCr58Ejuw1eFw3N6ZGmJD5L8EYnXaAb9h0kcjRtH q4eTUsELnbAnBKqnXeEmqNY/kVvYXU2AncNBNtXrhOfTIHrIQunBLcbDGHiLfgCvEmWg 6b008WsvSTBOgoa6L9uI7oNC1andmkENI+lhHGaJ41eF0M5n0mW24NtPtfGcSobXZ2RG FlWEOPZeiYltzHQa332FwIDsyuAkWamJK1mSVcUGtuDsN/v80hiYTWxE2WGNPfffVq5Z 37S8ZptxBQAX6u4GslugFQeBWIK+2PvSWL6pGcgfKHmzSR/KTn75F4vBlDFUFFC8JKI1 G28A== X-Gm-Message-State: AJIora8jdkpGI7lh9BWcjbMOWShRQmJF6tQLnIxRPfAEL+/44hMRH9zw vFm/i2HijXUy/D37ZExjZEVgnQSKNKUN3w== X-Google-Smtp-Source: AGRyM1uPJEZ6Bmo98wpFZHjeRQapFXL+ghqR4Lq7pgnxZm2JFcKUt0st3q9YKwVtsSyPKhit//hjaA== X-Received: by 2002:a05:6402:d6b:b0:435:7170:cf15 with SMTP id ec43-20020a0564020d6b00b004357170cf15mr14595161edb.314.1656314205256; Mon, 27 Jun 2022 00:16:45 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:45 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 02/10] Revert "hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine" Date: Mon, 27 Jun 2022 09:16:03 +0200 Message-Id: <20220627071611.8793-3-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=shentey@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that the PIIX IDE device models check for presence of an ISABus before using it, this fix isn't needed any longer. This reverts commit 9405d87be25db6dff4d7b5ab48a81bbf6d083e47. Signed-off-by: Bernhard Beschow --- hw/ide/ioport.c | 16 ++++++---------- hw/ide/piix.c | 9 +++------ hw/isa/isa-bus.c | 14 ++++---------- include/hw/ide/internal.h | 2 +- include/hw/isa/isa.h | 13 +++++-------- 5 files changed, 19 insertions(+), 35 deletions(-) diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c index e6caa537fa..b613ff3bba 100644 --- a/hw/ide/ioport.c +++ b/hw/ide/ioport.c @@ -50,19 +50,15 @@ static const MemoryRegionPortio ide_portio2_list[] = { PORTIO_END_OF_LIST(), }; -int ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) +void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) { - int ret; - /* ??? Assume only ISA and PCI configurations, and that the PCI-ISA bridge has been setup properly to always register with ISA. */ - ret = isa_register_portio_list(dev, &bus->portio_list, - iobase, ide_portio_list, bus, "ide"); + isa_register_portio_list(dev, &bus->portio_list, + iobase, ide_portio_list, bus, "ide"); - if (ret == 0 && iobase2) { - ret = isa_register_portio_list(dev, &bus->portio2_list, - iobase2, ide_portio2_list, bus, "ide"); + if (iobase2) { + isa_register_portio_list(dev, &bus->portio2_list, + iobase2, ide_portio2_list, bus, "ide"); } - - return ret; } diff --git a/hw/ide/piix.c b/hw/ide/piix.c index e8f3abc4b5..21777ecc8b 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -134,7 +134,7 @@ static int pci_piix_init_ports(PCIIDEState *d) {0x1f0, 0x3f6, 14}, {0x170, 0x376, 15}, }; - int i, ret; + int i; { ISABus *isa_bus; @@ -149,11 +149,8 @@ static int pci_piix_init_ports(PCIIDEState *d) for (i = 0; i < 2; i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); - ret = ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, - port_info[i].iobase2); - if (ret) { - return ret; - } + ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, + port_info[i].iobase2); ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); bmdma_init(&d->bus[i], &d->bmdma[i], d); diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 1bee1a47f1..0537a9f2c1 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -119,17 +119,13 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start) isa_init_ioport(dev, start); } -int isa_register_portio_list(ISADevice *dev, - PortioList *piolist, uint16_t start, - const MemoryRegionPortio *pio_start, - void *opaque, const char *name) +void isa_register_portio_list(ISADevice *dev, + PortioList *piolist, uint16_t start, + const MemoryRegionPortio *pio_start, + void *opaque, const char *name) { assert(piolist && !piolist->owner); - if (!isabus) { - return -ENODEV; - } - /* START is how we should treat DEV, regardless of the actual contents of the portio array. This is how the old code actually handled e.g. the FDC device. */ @@ -137,8 +133,6 @@ int isa_register_portio_list(ISADevice *dev, portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name); portio_list_add(piolist, isabus->address_space_io, start); - - return 0; } ISADevice *isa_new(const char *name) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 97e7e59dc5..348e7f2510 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -624,7 +624,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, int chs_trans, Error **errp); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_exit(IDEState *s); -int ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); +void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); void ide_register_restart_cb(IDEBus *bus); void ide_exec_cmd(IDEBus *bus, uint32_t val); diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 6c8a8a92cb..8dd2953211 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -114,15 +114,12 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); * @portio: the ports, sorted by offset. * @opaque: passed into the portio callbacks. * @name: passed into memory_region_init_io. - * - * Returns: 0 on success, negative error code otherwise (e.g. if the - * ISA bus is not available) */ -int isa_register_portio_list(ISADevice *dev, - PortioList *piolist, - uint16_t start, - const MemoryRegionPortio *portio, - void *opaque, const char *name); +void isa_register_portio_list(ISADevice *dev, + PortioList *piolist, + uint16_t start, + const MemoryRegionPortio *portio, + void *opaque, const char *name); static inline ISABus *isa_bus_from_device(ISADevice *d) { From patchwork Mon Jun 27 07:16:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896310 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 3AF55C43334 for ; Mon, 27 Jun 2022 07:24:15 +0000 (UTC) Received: from localhost ([::1]:37436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j6U-0004C0-Ez for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izQ-0003fr-9K; Mon, 27 Jun 2022 03:16:56 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:46065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izM-0003t3-Iw; Mon, 27 Jun 2022 03:16:55 -0400 Received: by mail-ej1-x629.google.com with SMTP id h23so17091011ejj.12; Mon, 27 Jun 2022 00:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ejXc4e4k71xe4RFsx8c1sx/U647khWejGVztu+EJOtw=; b=OXs/JI8Sweu7Ndy+YLWj5SIbGaX2kQTVq+tNFEdAYfHTcVJ6x3tt7zM5UNywgMPM8Y dL2rRrfeJpDOiNcouoA2pPpCAl3OARQ1q8gxD9MtpYyvqTxOlWykQFINUSz7zVDM7U2B Fd4/ioeuy/mLDvBE7lsfFhlptRaOeh+24U+ZGhbwn8tiU+xCPD4J4V3w8ARoMYl5QzaJ h+mZdYVd5u1bzHeq2ijZu5v9aIQkBoLGvM1bhUd8F5AlTMpk369YcDSBFaudh9rfgqqG ojQtbPx7uBzo1CXKkdqDsMgAYmgtLba6WCB3KWRAEM6/7hxBdciO/oA17xoCUpLfS/mc cVHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ejXc4e4k71xe4RFsx8c1sx/U647khWejGVztu+EJOtw=; b=dvQ0PMMaucK9KnsfHuRUeF4WhRKjPwJcNu08GEqM7eOaBBsrwXNf7BISihbUVcJO1D U1ard+7JW8ybvNA/eR7ISwyBre1dqvneJFDqTeCINKIUAtVXKbohEioj+n1OvwDNy628 UNKzFhvcXlhWbXtoP3dfl1lEsLgDC76siRrnHWL4PONfAnDefD5qb/IwfX7uN2BZrsP1 +n0XeMaUprZlCF0K1ZHetvQUeX6JeXr9FmHAH4P3X+166R/vRF5+1TB/Zc3EjCHgeoWz 5tBkSx6kz4yDKVHbxVvyhDD2Qj9wGLv0B3jsoUw6ldx5Izmhh7ifEdoE92djtTlA2Yq7 Mu9g== X-Gm-Message-State: AJIora+p/adjhc0r7/AlYNQdTbW5SiIkhXXYq03+XvSJxiFbpy1IlsgZ BVlA77DzrpNZaxClKdxyNkxc52vtalqtsw== X-Google-Smtp-Source: AGRyM1tNmkwasFTkn9ZFZ8xlzQJRLJH0vKPy8Vcus584CQOIs8DdM0+YcX6uAVds5OvvLotOdLjuNg== X-Received: by 2002:a17:907:7f03:b0:726:2d20:ea76 with SMTP id qf3-20020a1709077f0300b007262d20ea76mr11385738ejc.586.1656314206361; Mon, 27 Jun 2022 00:16:46 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:46 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 03/10] hw/i386/pc_piix: Allow for setting properties on "piix3-ide" before realizing it Date: Mon, 27 Jun 2022 09:16:04 +0200 Message-Id: <20220627071611.8793-4-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=shentey@gmail.com; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The next patch will introduce a quirk for user-created PIIX IDE devices for backwards compatibility. In order to opt-in to new behavior for builtin devices a property will need to be set until a deprecation period is over. Signed-off-by: Bernhard Beschow --- hw/i386/pc_piix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 0fc2361ffe..2d146b19c0 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -252,7 +252,8 @@ static void pc_init1(MachineState *machine, if (pcmc->pci_enabled) { PCIDevice *dev; - dev = pci_create_simple(pci_bus, piix3_devfn + 1, "piix3-ide"); + dev = pci_new_multifunction(piix3_devfn + 1, false, "piix3-ide"); + pci_realize_and_unref(dev, pci_bus, &error_fatal); pci_ide_create_devs(dev); idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); From patchwork Mon Jun 27 07:16:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896304 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 DADB2C433EF for ; Mon, 27 Jun 2022 07:19:36 +0000 (UTC) Received: from localhost ([::1]:57532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j1z-000716-JZ for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izS-0003gd-84; Mon, 27 Jun 2022 03:16:59 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:43826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izM-0003tO-CN; Mon, 27 Jun 2022 03:16:57 -0400 Received: by mail-ej1-x62b.google.com with SMTP id u15so17112148ejc.10; Mon, 27 Jun 2022 00:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tyv5gCJ3AbNyEZF4KCYh7JHG+L/xYML+lJ9AXX6nAzc=; b=BBmvYIx/uvdVwqV8ILucW0fTFzPy+zOjAAAU6tX/5xP+Y1X0rEucuRScMU6ggI1QRQ iOyj6nsTiWrIGNaJfDBfRWoLrSJf6OLO1qcWR8HJTwS8T0VyrqrOKP/RwKoIr6isUMPP ROHo+zHS9kLAzUFWvjUovdZrqGUkMvTfGT2EJEwQsPFFAEQYAi6+IDtxGognggQPorfc rTJE8bTw+xirnS4UGv063U0PirfUmioiyDhWByK/XoNYtB50+STsblwL5hOFeXc3dGyQ RnHnAZ+a/VIuol4IHNgl8YKCrgZcj1AFT2ntC1dXO9H7ieV6ieHAOVx3rMT1O+ZU3omF YGXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tyv5gCJ3AbNyEZF4KCYh7JHG+L/xYML+lJ9AXX6nAzc=; b=Yut7U993zmGNgybGmMZv4k1YLv9aI3PpQ2sRPXHLM49SPth907AfLAzXT91FLF3/LU 6hW1mN4zyA3rEl/CkcIP5DjWryGRgVPNQqLn9gSYizaAjd3gKok87+94DiOURu4hslh6 ngVoJGeLtrlVk0kovdzL+lyih+GkSVu1qg8qkny2fnlUxD3nJYl9TI/kl/sOS+yO7bF+ 37v0QtyAjd6oLSE4892Hrce3B34+4BGxd/FQcuoZYMeEdCt602xqHnNnd7bITzL2DCLp bR6CxEqYsiVBYy/w64yg9UsWvzFf7qxJvBnWRH2NGAfffYgtPOQFKmBMZK4BIc1FzOL+ O1Qg== X-Gm-Message-State: AJIora+ixjj8j8nlnx/H/lWMThQvPUNSw/aXXH/mpRAw91yIoc3mfgBt 8NE29PYrI+wIb/TMAu5UisjBEOMiU8ri6w== X-Google-Smtp-Source: AGRyM1vGtrs1s3UEkKlQO2agBjmA0wVPfystfaehHuEjvONEoubYSv5gcAC2xDIlQQj2bOS+VvXTnA== X-Received: by 2002:a17:907:2d86:b0:711:da8b:b579 with SMTP id gt6-20020a1709072d8600b00711da8bb579mr11935006ejc.67.1656314207476; Mon, 27 Jun 2022 00:16:47 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:47 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 04/10] hw/ide/piix: Avoid the isabus global when wiring ISA interrupts for internal devices Date: Mon, 27 Jun 2022 09:16:05 +0200 Message-Id: <20220627071611.8793-5-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=shentey@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" isa_get_irq() currently always uses the "isabus" global to get the desired qemu_irq. In order to resolve this global, we want isa_get_irq() to determine the ISABus from its *dev parameter using isa_bus_from_device(). As a preparation, all callers who pass NULL as *dev need to be resolved which seems to happen in hw/ide/piix only. This patch roughly implements the solution outlined in https:// lists.nongnu.org/archive/html/qemu-devel/2020-03/msg01707.html. In oder to address the PIIX IDE functions being user-creatable, (see https://lists.nongnu.org/archive/html/qemu-devel/2021-04/msg05655.html) a backwards compatibility quirk is introduced which can be removed after some deprecation period. The quirk consists of internal devices to opt into new behavior where the ISA interrupt wiring is performed by the caller rather than by the device itself. The opt-in can be performed by: qdev_prop_set_bit(DEVICE(dev), "user-created", false); RFC: qdev_init_gpio_in() seems to expose interrupts internal to the device. Can this be fixed? Signed-off-by: Bernhard Beschow --- hw/i386/pc_piix.c | 3 +++ hw/ide/piix.c | 41 +++++++++++++++++++++++++++++++++++------ hw/isa/piix4.c | 3 +++ include/hw/ide/pci.h | 2 ++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2d146b19c0..e24fbab334 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -253,8 +253,11 @@ static void pc_init1(MachineState *machine, PCIDevice *dev; dev = pci_new_multifunction(piix3_devfn + 1, false, "piix3-ide"); + qdev_prop_set_bit(DEVICE(dev), "user-created", false); pci_realize_and_unref(dev, pci_bus, &error_fatal); pci_ide_create_devs(dev); + qdev_connect_gpio_out(DEVICE(dev), 0, x86ms->gsi[14]); + qdev_connect_gpio_out(DEVICE(dev), 1, x86ms->gsi[15]); idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 21777ecc8b..fbf2756b47 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -103,6 +103,13 @@ static void bmdma_setup_bar(PCIIDEState *d) } } +static void piix_ide_set_irq(void *opaque, int n, int level) +{ + PCIIDEState *d = opaque; + + qemu_set_irq(d->isa_irqs[n], level); +} + static void piix_ide_reset(DeviceState *dev) { PCIIDEState *d = PCI_IDE(dev); @@ -129,14 +136,14 @@ static int pci_piix_init_ports(PCIIDEState *d) static const struct { int iobase; int iobase2; - int isairq; } port_info[] = { - {0x1f0, 0x3f6, 14}, - {0x170, 0x376, 15}, + {0x1f0, 0x3f6}, + {0x170, 0x376}, }; + DeviceState *dev = DEVICE(d); int i; - { + if (d->user_created) { ISABus *isa_bus; bool ambiguous; @@ -145,13 +152,18 @@ static int pci_piix_init_ports(PCIIDEState *d) if (!isa_bus || ambiguous) { return -ENODEV; } + + d->isa_irqs[0] = isa_bus->irqs[14]; + d->isa_irqs[1] = isa_bus->irqs[15]; + } else { + qdev_init_gpio_out(dev, d->isa_irqs, 2); } for (i = 0; i < 2; i++) { - ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); + ide_bus_init(&d->bus[i], sizeof(d->bus[i]), dev, i, 2); ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, port_info[i].iobase2); - ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); + ide_init2(&d->bus[i], qdev_get_gpio_in(dev, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; @@ -181,6 +193,14 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) } } +static void pci_piix_ide_init(Object *obj) +{ + PCIIDEState *d = PCI_IDE(obj); + DeviceState *dev = DEVICE(d); + + qdev_init_gpio_in(dev, piix_ide_set_irq, 2); +} + static void pci_piix_ide_exitfn(PCIDevice *dev) { PCIIDEState *d = PCI_IDE(dev); @@ -192,6 +212,11 @@ static void pci_piix_ide_exitfn(PCIDevice *dev) } } +static Property piix_ide_properties[] = { + DEFINE_PROP_BOOL("user-created", PCIIDEState, user_created, true), + DEFINE_PROP_END_OF_LIST(), +}; + /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */ static void piix3_ide_class_init(ObjectClass *klass, void *data) { @@ -206,11 +231,13 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->hotpluggable = false; + device_class_set_props(dc, piix_ide_properties); } static const TypeInfo piix3_ide_info = { .name = "piix3-ide", .parent = TYPE_PCI_IDE, + .instance_init = pci_piix_ide_init, .class_init = piix3_ide_class_init, }; @@ -228,11 +255,13 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data) k->class_id = PCI_CLASS_STORAGE_IDE; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->hotpluggable = false; + device_class_set_props(dc, piix_ide_properties); } static const TypeInfo piix4_ide_info = { .name = "piix4-ide", .parent = TYPE_PCI_IDE, + .instance_init = pci_piix_ide_init, .class_init = piix4_ide_class_init, }; diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 15f344dbb7..900c77cf68 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -251,10 +251,13 @@ static void piix4_realize(PCIDevice *dev, Error **errp) /* IDE */ qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1); + qdev_prop_set_bit(DEVICE(&s->ide), "user-created", false); if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) { return; } pci_ide_create_devs(PCI_DEVICE(&s->ide)); + qdev_connect_gpio_out(DEVICE(&s->ide), 0, s->isa[14]); + qdev_connect_gpio_out(DEVICE(&s->ide), 1, s->isa[15]); /* USB */ qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2); diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h index d8384e1c42..7ccbfa0a71 100644 --- a/include/hw/ide/pci.h +++ b/include/hw/ide/pci.h @@ -49,10 +49,12 @@ struct PCIIDEState { IDEBus bus[2]; BMDMAState bmdma[2]; + qemu_irq isa_irqs[2]; uint32_t secondary; /* used only for cmd646 */ MemoryRegion bmdma_bar; MemoryRegion cmd_bar[2]; MemoryRegion data_bar[2]; + bool user_created; }; static inline IDEState *bmdma_active_if(BMDMAState *bmdma) From patchwork Mon Jun 27 07:16:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896311 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 C0828C43334 for ; Mon, 27 Jun 2022 07:26:46 +0000 (UTC) Received: from localhost ([::1]:42478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j8v-0007k6-SA for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:26:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izS-0003gb-7H; Mon, 27 Jun 2022 03:16:59 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:35401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izO-0003tc-EU; Mon, 27 Jun 2022 03:16:57 -0400 Received: by mail-ed1-x536.google.com with SMTP id e40so11647166eda.2; Mon, 27 Jun 2022 00:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PCwZzAUgvUr9rmEVpXX+ZUgA//EEMyR5LEAQr/9gy9c=; b=j+eED5IKZ878Wev1wc0fHoW8ddR2x7B9LjXHFRrgxKLj8Exv3g4Hm+kLG3KQfnBm+S uz6t5cgB9eiFI4p6SKJnF9b3S3icyWyoyjwmzwBxmnretta/J9rX+B9BQnzILOUu3TxT X/P3IZvLFi/EHroYQcBI3DFDiJtmFGLi838DA27Sne7kS7CYJc/rrdyCy8SzhoH/2WEo 5wX8LbVLqM70kof4fKO4o7g9nDEEnHAzTwbZn+ZV5eKLyFo5/8vq89XsPk4UnO0a1N2x DM7Qv0DNFsg+NGkB7jAaBhcwCWcw0TYfD8pjzulCMHbAmnb/lG9aN3ER69zInpxXHhI8 YaYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PCwZzAUgvUr9rmEVpXX+ZUgA//EEMyR5LEAQr/9gy9c=; b=rN8xoM4hscNaEB56SglP5M8lpRzXVj7H+ic4yKsl3LNSMMtUzzMRPruHGlZfjtavUK h3xnS2W/S3PABtzh/CFYZy9yTMREmQ3HOVBi9VrHJ5v2n6pRZF2Xk7gWustx1GDIBY4Z vpB+GXr5l4cMctKPaSs0Dx6MCVjRDVXH93arve2ElDtqh470957tVXVDUyyu7tQT6SqB h99eZgzRr1+kmf+BgErtrqizCzZY5t5s2kT2JUpX9GNB/dfqCL8vni0GaC6z4zMzaOBO HZK1lLMBBTH8gWcBCmak400sKRigIEe9AHJTtV21XE+iVzMDDmDgXPosv2PIGu4tYVlq zO2Q== X-Gm-Message-State: AJIora/RYPny4L8uGtyIuAKz3uauuIjVGyv3DeptNm4u7cqElt0pxcMB Im6/zyAHR4SNW2RcHNp1DbF40B/IeZkj0g== X-Google-Smtp-Source: AGRyM1uZET3tawJEoBFjqw8Ol+MO3Ofe2kWtKCZPkpH0qMm18ME6qbV4XqSatVA/HGgLZzo7RLT++w== X-Received: by 2002:a05:6402:403:b0:434:eb49:218f with SMTP id q3-20020a056402040300b00434eb49218fmr14926944edv.426.1656314208547; Mon, 27 Jun 2022 00:16:48 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:48 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 05/10] hw/isa/isa-bus: assert() if isa_get_irq() gets passed a NULL ISADevice Date: Mon, 27 Jun 2022 09:16:06 +0200 Message-Id: <20220627071611.8793-6-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=shentey@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that all call-sites have been fixed to pass non-NULL ISADevices, we can assert() on NULL ISADevices to catch regressions. Signed-off-by: Bernhard Beschow --- hw/isa/isa-bus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 0537a9f2c1..9e8b5da027 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -81,9 +81,10 @@ void isa_bus_irqs(ISABus *bus, qemu_irq *irqs) */ qemu_irq isa_get_irq(ISADevice *dev, unsigned isairq) { - assert(!dev || ISA_BUS(qdev_get_parent_bus(DEVICE(dev))) == isabus); + assert(dev); assert(isairq < ISA_NUM_IRQS); - return isabus->irqs[isairq]; + + return isa_bus_from_device(dev)->irqs[isairq]; } void isa_connect_gpio_out(ISADevice *isadev, int gpioirq, unsigned isairq) From patchwork Mon Jun 27 07:16:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896305 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 98535C43334 for ; Mon, 27 Jun 2022 07:19:43 +0000 (UTC) Received: from localhost ([::1]:58202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j26-0007Tv-Li for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:19:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izQ-0003fu-A7; Mon, 27 Jun 2022 03:16:56 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:44674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izN-0003tm-7n; Mon, 27 Jun 2022 03:16:55 -0400 Received: by mail-ed1-x536.google.com with SMTP id z19so11571026edb.11; Mon, 27 Jun 2022 00:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o52L6RrnUDqK3SXfYbgJj8ZZPWiN199qyUgLPkMswD4=; b=dH6kcn37vLGmjZ9WONTRNbv/u5UGzZB95B6TKToUsieK8So7rw/kGsjzqINksUZd+m Vf43U4UnI+JJM4s82ARZT8ArjkmtgFir5sYnWg7B9ec+YsmrIMqoI8Sjtc0Sg9V5EfX0 0qHagT8cG0zXRHwDOJb+5FzSCex37O0BN6jtH3Mu56pt7FLCcpEqO7t/rkTC1fQCKsuZ TWahoCT9Zo9gSQ0cEg1tCALGWncrdWFMFatsnTS9CneEuLRTRPxiUjVaZ96Ao+7HkVvz 8Ho/7+zFkBbj2Sx4MNkGNA4vejFtWaDLLC9GvGdj+LqpFR5Px7Pc7CDMIiljS/v0XDP7 pvvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o52L6RrnUDqK3SXfYbgJj8ZZPWiN199qyUgLPkMswD4=; b=7wxougw61S2gnAIZD3uwWGUVWc3i5OvwClcqs5lJd94OGpvn/1HkHmvWzDXLUU5UP9 NDqKPGAgurH9AYKERM5eYTDdIPf5C0Fw/gI3bw8VJlTFzGRFxv2ipxxHAFtzqikaR4In MBIyP18vFHUFu+rPYR32S2s5fjWTMIb42JRQXj4EMzWUhdC+7nDEQcc7Fwy5C2ujM3h1 hHs3Y+VYljROuyEnwge8Kgz4QomJGd2je/mpJE8I2mqLf43byc+zn7Tm4SAkGa1hO7lK z4srhyhntjAEj7RxpNPnWVgRspQOgMtlhIVYwFf9ZtYPOJ4h6bmruHmi3bSkt6HWwiGV Rl5w== X-Gm-Message-State: AJIora8HVZ5QdgkeB0sFmvIpLcFEzhlZiiea8pmpnhw9UD1zrzGLCzOw gKhCURwTSLTXB5WahLY6w6cL1pWb7Kq2kA== X-Google-Smtp-Source: AGRyM1s8pZBrMtrYtjKYDyu8ysrrb5P6yz1bIXQGs3VkEF5n5zZfr+UGEdtOs/YXIMnFS+3B5NBKxw== X-Received: by 2002:a05:6402:34c2:b0:436:7edf:ba with SMTP id w2-20020a05640234c200b004367edf00bamr15196652edc.67.1656314209658; Mon, 27 Jun 2022 00:16:49 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:49 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 06/10] hw/ide/ioport: Rename ide_init_ioport() to isa_ide_init_ioport() Date: Mon, 27 Jun 2022 09:16:07 +0200 Message-Id: <20220627071611.8793-7-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=shentey@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" ide_init_ioport() takes an ISADevice* parameter which eventually gets passed to isa_address_space_io(). Unfortunately, there is no ISADevice in hw/ide/ piix, so NULL gets passed instead. This causes isa_address_space_io() to resort to using the isabus global - which we want to get rid of. To resolve this, observe that hw/isa/piix* models pass PCI's IO address space to ISA which can be used instead. The next patch therefore introduces pci_ide_init_ioport() which takes a PCIDevice* parameter instead and is available in hw/ide/piix. Signed-off-by: Bernhard Beschow --- hw/ide/ioport.c | 2 +- hw/ide/isa.c | 2 +- hw/ide/piix.c | 4 ++-- include/hw/ide/internal.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c index b613ff3bba..ed1f34f573 100644 --- a/hw/ide/ioport.c +++ b/hw/ide/ioport.c @@ -50,7 +50,7 @@ static const MemoryRegionPortio ide_portio2_list[] = { PORTIO_END_OF_LIST(), }; -void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) +void isa_ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) { /* ??? Assume only ISA and PCI configurations, and that the PCI-ISA bridge has been setup properly to always register with ISA. */ diff --git a/hw/ide/isa.c b/hw/ide/isa.c index 8bedbd13f1..79ed33aefa 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -74,7 +74,7 @@ static void isa_ide_realizefn(DeviceState *dev, Error **errp) ISAIDEState *s = ISA_IDE(dev); ide_bus_init(&s->bus, sizeof(s->bus), dev, 0, 2); - ide_init_ioport(&s->bus, isadev, s->iobase, s->iobase2); + isa_ide_init_ioport(&s->bus, isadev, s->iobase, s->iobase2); s->irq = isa_get_irq(isadev, s->isairq); ide_init2(&s->bus, s->irq); vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_isa, s); diff --git a/hw/ide/piix.c b/hw/ide/piix.c index fbf2756b47..312611c61f 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -161,8 +161,8 @@ static int pci_piix_init_ports(PCIIDEState *d) for (i = 0; i < 2; i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), dev, i, 2); - ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, - port_info[i].iobase2); + isa_ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, + port_info[i].iobase2); ide_init2(&d->bus[i], qdev_get_gpio_in(dev, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 348e7f2510..86ecc04ce4 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -624,7 +624,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, int chs_trans, Error **errp); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_exit(IDEState *s); -void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); +void isa_ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); void ide_register_restart_cb(IDEBus *bus); void ide_exec_cmd(IDEBus *bus, uint32_t val); From patchwork Mon Jun 27 07:16:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896319 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 9A26AC43334 for ; Mon, 27 Jun 2022 07:34:35 +0000 (UTC) Received: from localhost ([::1]:58318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5jGU-0001rD-Gh for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:34:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izW-0003iS-2s; Mon, 27 Jun 2022 03:17:02 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:35398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izS-0003ts-BB; Mon, 27 Jun 2022 03:17:01 -0400 Received: by mail-ed1-x532.google.com with SMTP id e40so11647284eda.2; Mon, 27 Jun 2022 00:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8v+otkILnaLVE4jysgeV47PF0Np5ww+CCUJXKRHwxJw=; b=kcQduIUWtTGR2Shh0+LXn7VqoXG3ebbunVgxeAvzvOz9j09SyIh0W+UkIkLJjsPXbq tjrX9wN+rXJCnqn5nwltWyfcv9wtEOO+gECCwWh+eWYHw+CBAATEEitrEl0ZJGlgjuKm xy9SKJVfis86UivA2TFf2cXXdExkyz3BHaEn9drV0YTEsbVPK2RgYyYJYivvITLTpC7j C2HJQjcO5xUre14EtO4EC9X8VcfwZMfYjd83cJzfr5nxFZzaUMy1Vd6lYlYDyMPLnTbR Csr0DzpbQYKjTJI2Z4VGlHhgK3tYxoTqxgID4VHUd1DOXGWG2P8mnjYTLcKA8yKxmuz1 FimQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8v+otkILnaLVE4jysgeV47PF0Np5ww+CCUJXKRHwxJw=; b=2ZRm6+DMdUqVWgOlCAnBB2iKL06+eQC6/hjUtYt2hdrVjXiD1blMo5F8s2V6rTxW01 w6ZTafj1sRU8pMHRuCJqVhnLXni1q9Zaj5FEkIJQ9Lr2hrZGM9OWLPMDL8dj3miOsxe2 JNUqa5su1mCMQuJGO5isnSLau6mNPITt6Sja3CI+/wdY/mY58pOYXJDVUHn97tzXSqv+ LjKWDncUi/i/CH4Ki98Uc9/Bg1S2IfXtcOqqMwaGfYDkpATs/Xx5iqLET2eeA76khaqb hQDzLNFaVy59b+wrYWZMyrxvrmx+fqUjoNKwUSx8ww+C/aTjVnQpCAZ05+KKdzCeflmk BsuQ== X-Gm-Message-State: AJIora/IVNN88OhF+6tMG7dsqL5ot63FcXP4o4nG5NXgc6gxe0uNgQgg NKtudeu2wN+ixwz195IhzueBckPX6XwEhA== X-Google-Smtp-Source: AGRyM1sH48BmoYvqhS4IQ9UVTQ/M86BD7O3rC1lUoinJsaSgZy6NNtdq1cOjhsPeQdDI0ZT4BkZHUw== X-Received: by 2002:a05:6402:5288:b0:435:ccbb:2a3a with SMTP id en8-20020a056402528800b00435ccbb2a3amr15091632edb.382.1656314210713; Mon, 27 Jun 2022 00:16:50 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:50 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 07/10] hw/pci/pci: Introduce pci_register_portio_list() Date: Mon, 27 Jun 2022 09:16:08 +0200 Message-Id: <20220627071611.8793-8-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=shentey@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" pci_ide_init_ioport() and pci_register_portio_list() are introduced which mirror their ISA counterparts. But rather than asking for an ISADevice, the functions ask for PCIDevice which can be used in hw/ide/piix which fixes having to pass a NULL ISADevice which is not avialable there. Passing NULL as ISADevice to pci_ide_init_ioport() also causes a NULL ISADevice to be passed to isa_register_ioport(). Currently this function always uses the isabus global. To fix this, we'll want to determine the ISABus using isa_bus_from_device(), so no call-site must pass a NULL ISADevice. Signed-off-by: Bernhard Beschow --- hw/ide/ioport.c | 14 ++++++++++++++ hw/pci/pci.c | 18 ++++++++++++++++++ include/hw/ide/internal.h | 1 + include/hw/pci/pci.h | 21 +++++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c index ed1f34f573..69e4fa15d4 100644 --- a/hw/ide/ioport.c +++ b/hw/ide/ioport.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "hw/isa/isa.h" +#include "hw/pci/pci_bus.h" #include "qemu/error-report.h" #include "qemu/timer.h" #include "sysemu/blockdev.h" @@ -62,3 +63,16 @@ void isa_ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) iobase2, ide_portio2_list, bus, "ide"); } } + +void pci_ide_init_ioport(IDEBus *bus, PCIDevice *dev, int iobase, int iobase2) +{ + assert(dev); + + pci_register_portio_list(dev, &bus->portio_list, + iobase, ide_portio_list, bus, "ide"); + + if (iobase2) { + pci_register_portio_list(dev, &bus->portio2_list, + iobase2, ide_portio2_list, bus, "ide"); + } +} diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2f450f6a72..3046dd5477 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1440,6 +1440,24 @@ pcibus_t pci_bar_address(PCIDevice *d, return new_addr; } +void pci_register_portio_list(PCIDevice *dev, + PortioList *piolist, uint16_t start, + const MemoryRegionPortio *pio_start, + void *opaque, const char *name) +{ + PCIBus *bus; + + assert(dev); + assert(piolist && !piolist->owner); + + bus = pci_get_bus(dev); + + assert(bus); + + portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name); + portio_list_add(piolist, bus->address_space_io, start); +} + static void pci_update_mappings(PCIDevice *d) { PCIIORegion *r; diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 86ecc04ce4..4a375d3c09 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -625,6 +625,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, void ide_init2(IDEBus *bus, qemu_irq irq); void ide_exit(IDEState *s); void isa_ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); +void pci_ide_init_ioport(IDEBus *bus, PCIDevice *isa, int iobase, int iobase2); void ide_register_restart_cb(IDEBus *bus); void ide_exec_cmd(IDEBus *bus, uint32_t val); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index b54b6ef88f..91b479d542 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -522,6 +522,27 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque); pcibus_t pci_bar_address(PCIDevice *d, int reg, uint8_t type, pcibus_t size); +/** + * pci_register_portio_list: Initialize a set of io ports + * + * Several ISA devices have many dis-joint I/O ports. Worse, these I/O + * ports can be interleaved with I/O ports from other devices. This + * function makes it easy to create multiple MemoryRegions for a single + * device and use the legacy portio routines. + * + * @dev: the PCIDevice against which these are registered + * @piolist: the PortioList associated with the io ports + * @start: the base I/O port against which the portio->offset is applied. + * @portio: the ports, sorted by offset. + * @opaque: passed into the portio callbacks. + * @name: passed into memory_region_init_io. + */ +void pci_register_portio_list(PCIDevice *dev, + PortioList *piolist, + uint16_t start, + const MemoryRegionPortio *portio, + void *opaque, const char *name); + static inline void pci_set_byte(uint8_t *config, uint8_t val) { From patchwork Mon Jun 27 07:16:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896312 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 30BA5C433EF for ; Mon, 27 Jun 2022 07:26:57 +0000 (UTC) Received: from localhost ([::1]:43090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5j96-00088u-AW for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:26:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izS-0003gc-7O; Mon, 27 Jun 2022 03:16:59 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:39778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izP-0003u6-Pj; Mon, 27 Jun 2022 03:16:57 -0400 Received: by mail-ej1-x62d.google.com with SMTP id ay16so17160780ejb.6; Mon, 27 Jun 2022 00:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oo7ypyvUebOkqcGL5BdIfd3NhdOwiRUM4reqQb4VVlY=; b=EbtxfAwAWU1lVQ9PL53Cyb8OMyhEzN3H3c/l+9/mpYym/pNV5bUqj8tlxMO4ut5C+B o7ZVnjfJq7MDdUdXQRKv6Db+BmbtulaBpUcYuq5/DdTOvJOy+iMN/DLJCX7QwwMBqL9b KtN2BBwjW1XO8qbtUCKo/BDW86Q+OfshbuA9d/OUElwoufNgUUfYY527sBQGXZcebPeI /kfyH9nLMp4O9bXO4uQ6r6iagMkOQIY/Ny/Gllyjxx+vxPuOZ9u7Y3J9XLeGKFbfvH3b uCWXPsb+nZLgzLg7u9FmeGAYKFtIALMZYT9KhgmhXHoI0der6VWVLy+VES/+iAGEKXLF y8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oo7ypyvUebOkqcGL5BdIfd3NhdOwiRUM4reqQb4VVlY=; b=IQE0xyWOR7kyv5L/PkS5av6PZmF/vz0LlcjYPM8yPLxz7UgBVjOLfeiigz4da6/cZe MY8qWJ6b4pOx7OUmvLL1RlwxLQY5IFZko0FezvH2HP7jfik595VSflKpH8yqt4Qzalei PzzeJRq0zDwhTwGsF8RqaVlxSOSObrRFMcBV2JjtYtESpY1KsZgxh2M7H7rTNKpfvuu3 8om7WxGdUedZSawdAyaA4PmgbQDTGwlRceg/0KDYyxnQ01CniQoyOyxsAc81ELIPyx7w 0Jyb/L8YDJxbluzhnAFFwseersIip3CS0H665RQOlesYqEOoaZZb2FuHIjzi538x7AKS l2iQ== X-Gm-Message-State: AJIora+yCRkcL5+ZMROedqCh6hZQhSY9ZRVe5sVEiFxgy/hh2mFXQIFU lPy3Ft6JmuOE8fp+53lw8n4iRMB4WDZl3g== X-Google-Smtp-Source: AGRyM1uMUKn6ZnmgPB1qUC4Qr31MCoBeyCp5nanYCIBQv0sJxcuZBXFEKrMbuyRz8UxZV52cHuD1DA== X-Received: by 2002:a17:906:d54f:b0:726:4424:9d31 with SMTP id cr15-20020a170906d54f00b0072644249d31mr10450568ejc.227.1656314211776; Mon, 27 Jun 2022 00:16:51 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:51 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 08/10] hw/ide/piix: Use pci_ide_init_ioport() rather than isa_ide_init_ioport() Date: Mon, 27 Jun 2022 09:16:09 +0200 Message-Id: <20220627071611.8793-9-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=shentey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This should fix the last caller causing a NULL ISADev to be passed to isa_register_portio_list() which now allows for disusing the isabus global there. Signed-off-by: Bernhard Beschow --- hw/ide/piix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 312611c61f..087568ecf1 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -161,7 +161,7 @@ static int pci_piix_init_ports(PCIIDEState *d) for (i = 0; i < 2; i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), dev, i, 2); - isa_ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, + pci_ide_init_ioport(&d->bus[i], PCI_DEVICE(d), port_info[i].iobase, port_info[i].iobase2); ide_init2(&d->bus[i], qdev_get_gpio_in(dev, i)); From patchwork Mon Jun 27 07:16:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896316 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 6C34DC433EF for ; Mon, 27 Jun 2022 07:31:12 +0000 (UTC) Received: from localhost ([::1]:50562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5jDD-0004sx-IX for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:31:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izU-0003hm-5t; Mon, 27 Jun 2022 03:17:01 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:44702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izQ-0003uL-DC; Mon, 27 Jun 2022 03:16:59 -0400 Received: by mail-ej1-x62f.google.com with SMTP id sb34so17085991ejc.11; Mon, 27 Jun 2022 00:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OgLTEN559d5MRc9woY4BVfF0YnifdBVutDH48Qz2Aqs=; b=VYPjjR4DQvS/fQ4RTJ31KtZ2g58lsop8f04Zl/K/4OUbMbLaVlgrtsfOiXnjE/okTP 7g/DAWdRTyThdv0Mt+4APc5yssi5FaBxSVZwGyLK4dBOR4A05bfgC/gR8zw3X6Fd0vqE Vmo0oEX19wv/R6OCp6Mvb54Gs9BdKPqFCC5BbL5hXtxA/CXdF2kon0tA02qXYP9gKBf0 cvfdE/rs/D0J57CkTk/rBfI3q91NAHNh/qSqv9iO4lkzOUHselQe4ifGHS/1vB2r5gig jIcqJYtdJeEoJaR0wbSI1XKZ5HsuJnVMGbkt4Mw32/q8tx6E5fFhG98xtFFrpUrX7YO4 jfSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OgLTEN559d5MRc9woY4BVfF0YnifdBVutDH48Qz2Aqs=; b=5UMzPkGBNceJWVwuPr+psKajTZESsEo9L/ltBiSNxlSm323gcXkEA/5BiqUcbqCxQY TanRgTIlTABQcP9yFFt8YkxKAcg8S5RKNRfhMgFENNg65g/D+Gde9k2vsG34WD8/niuK xCkIVhUwDy68I/52iWEUAcrhCDV8GzQ4P/oWQAOIOVZbBAT7181Rjq4eml7VoEkIWqty GHhZmZ5qyCYRMY1dcPkKzD9YzxvwgmjTrMDPQMO6zDD/p4WeFD6pwvZwXH0Wp3KXSN1L WVMoZkU9TgC6lAwP9kka72DtVim6mFBn0Y6Eq8ZJTtDELYQP/CcjxjKAYJLZm3r5urYB njIg== X-Gm-Message-State: AJIora/LHVGdLhn+b8Rjpk0JeXWJfTGl438mUUkjfRMp4K8Ne4yAVtCz 9jzilhB9vMaSkomsKrRBhM/sk67coeIR8Q== X-Google-Smtp-Source: AGRyM1u8MRMKRKJkw4FonumDfEcoqukTO9AKDwT7xB5FZcbupwH3b3MzxzDB8ymmVl/k+A90w/YBLA== X-Received: by 2002:a17:906:1998:b0:726:a78c:2a2f with SMTP id g24-20020a170906199800b00726a78c2a2fmr2943097ejd.463.1656314212868; Mon, 27 Jun 2022 00:16:52 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:52 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 09/10] hw/isa: Resolve unneeded usage of isabus global Date: Mon, 27 Jun 2022 09:16:10 +0200 Message-Id: <20220627071611.8793-10-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=shentey@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that all call sites of these functions are fixed to pass non-NULL ISADevices, the ISABus can be determined from the ISADevice argument. Patch based on https://lists.nongnu.org/archive/html/qemu-devel/2021-05/ msg05785.html. Signed-off-by: Bernhard Beschow --- hw/ide/ioport.c | 4 ++-- hw/isa/isa-bus.c | 21 +++++++++++++-------- include/hw/isa/isa.h | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c index 69e4fa15d4..112726e415 100644 --- a/hw/ide/ioport.c +++ b/hw/ide/ioport.c @@ -53,8 +53,8 @@ static const MemoryRegionPortio ide_portio2_list[] = { void isa_ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) { - /* ??? Assume only ISA and PCI configurations, and that the PCI-ISA - bridge has been setup properly to always register with ISA. */ + assert(dev); + isa_register_portio_list(dev, &bus->portio_list, iobase, ide_portio_list, bus, "ide"); diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 9e8b5da027..5518db93cd 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -116,6 +116,10 @@ static inline void isa_init_ioport(ISADevice *dev, uint16_t ioport) void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start) { + ISABus *isabus; + + assert(dev); + isabus = isa_bus_from_device(dev); memory_region_add_subregion(isabus->address_space_io, start, io); isa_init_ioport(dev, start); } @@ -125,8 +129,13 @@ void isa_register_portio_list(ISADevice *dev, const MemoryRegionPortio *pio_start, void *opaque, const char *name) { + ISABus *isabus; + + assert(dev); assert(piolist && !piolist->owner); + isabus = isa_bus_from_device(dev); + /* START is how we should treat DEV, regardless of the actual contents of the portio array. This is how the old code actually handled e.g. the FDC device. */ @@ -246,20 +255,16 @@ static char *isabus_get_fw_dev_path(DeviceState *dev) MemoryRegion *isa_address_space(ISADevice *dev) { - if (dev) { - return isa_bus_from_device(dev)->address_space; - } + assert(dev); - return isabus->address_space; + return isa_bus_from_device(dev)->address_space; } MemoryRegion *isa_address_space_io(ISADevice *dev) { - if (dev) { - return isa_bus_from_device(dev)->address_space_io; - } + assert(dev); - return isabus->address_space_io; + return isa_bus_from_device(dev)->address_space_io; } type_init(isabus_register_types) diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 8dd2953211..486851e7cb 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -108,7 +108,7 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); * function makes it easy to create multiple MemoryRegions for a single * device and use the legacy portio routines. * - * @dev: the ISADevice against which these are registered; may be NULL. + * @dev: the ISADevice against which these are registered * @piolist: the PortioList associated with the io ports * @start: the base I/O port against which the portio->offset is applied. * @portio: the ports, sorted by offset. From patchwork Mon Jun 27 07:16:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12896315 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 644ECC43334 for ; Mon, 27 Jun 2022 07:30:49 +0000 (UTC) Received: from localhost ([::1]:49628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5jCn-0004CU-Fq for qemu-devel@archiver.kernel.org; Mon, 27 Jun 2022 03:30:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5izU-0003hx-68; Mon, 27 Jun 2022 03:17:01 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:46076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5izQ-0003uW-DY; Mon, 27 Jun 2022 03:16:59 -0400 Received: by mail-ej1-x633.google.com with SMTP id h23so17091560ejj.12; Mon, 27 Jun 2022 00:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gF4N2f/+uctQMoQqFK3rzPl6NGxOr0FFEKFIXo82HYE=; b=Qx9xsRNy6kp75wskT6zJ3EdKy9XlGUWJvaoC/YizSVrxIXFXq4R9wdS3lGcpX9rzRK 6WE5Kb6T+Poa2Pk1pOM+60PkzTnESMHbKpqO5Y2DSCEtzeQjPSQQvdKzGsV9cp0XQOul rfanBjX9N5MqjzE3DzgBUGe3FF32U6gHWOQfCKCIA9cHNKL4/rWNCpfc/pCWQD+lb1xS Bkj+ZojPGHlW7TcYh7uIMbv4J6C78pMDa87Rv2/SUTCE483+IeCBGBIokEMWir/I3Lba kl8rSdiEFgghNng1XDfEtgKwWeT/Ni0wscahy/Mk8d9w0zB8L9mbCTlnLMdYJfFopK9K tByA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gF4N2f/+uctQMoQqFK3rzPl6NGxOr0FFEKFIXo82HYE=; b=hWE+TgwOLVWAWCEnBqYV5RPRgRumWVbloalt1khuWM4DDlx4I42PnW3oa4Vba2C2/n a7meOXu9W37UL7DwASot10DO70JMjYghVfqQrdWakMocnHuG8oNcSEDa1uURMRB1bM+q NRvjdexRo7iVYCOowyWcSn5m3vokJ1zOYFx1Qnwcgv6kaXc2w+z6WrmICUgawZFLaU05 FEjPX5wVar2VjlaTAsxfIQMLl7Wo8N0RyaHNUKtOTBK/2MwHP6AEqdj86XB+wuky86Wm 0lDzoUjY1aeTgsCvpsHIFVuXeZ74Qj4t7fYFSi5o1EmRKl0PqK+ERVjiulZBBMls6lOj bctA== X-Gm-Message-State: AJIora+SQTrVv+Y56D188nNzDBsjfg0bF7wG6w4V2Ia9ZVXy05jzD2mo b1uayTTF/kXZ32dxRkyTaAtaBQfOg3krLg== X-Google-Smtp-Source: AGRyM1tq4Kr5bWUqapTvYEVGyxGtVoGqWlcr3Aogn/iUZifjFk3+Y5uM1QXuRbEApbLVRPftVcLh0g== X-Received: by 2002:a17:906:830c:b0:726:a68b:d1bc with SMTP id j12-20020a170906830c00b00726a68bd1bcmr3670137ejx.305.1656314213921; Mon, 27 Jun 2022 00:16:53 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-183-075-191.77.183.pool.telefonica.de. [77.183.75.191]) by smtp.gmail.com with ESMTPSA id g16-20020a1709064e5000b007072dc80e06sm4593294ejw.190.2022.06.27.00.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 00:16:53 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Richard Henderson , mark.cave-ayland@ilande.co.uk, balaton@eik.bme.hu, "Michael S. Tsirkin" , qemu-block@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost , Paolo Bonzini , John Snow , Marcel Apfelbaum , Bernhard Beschow Subject: [RFC PATCH 10/10] hw/isa/isa-bus: Resolve isabus global Date: Mon, 27 Jun 2022 09:16:11 +0200 Message-Id: <20220627071611.8793-11-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627071611.8793-1-shentey@gmail.com> References: <20220627071611.8793-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=shentey@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that only isa_bus_new() accesses the isabus global it can be removed assuming that all call sites take care of not passing the same address spaces twice to different isa_bus_new() invocations. Signed-off-by: Bernhard Beschow --- hw/isa/isa-bus.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 5518db93cd..783506685d 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -26,8 +26,6 @@ #include "hw/isa/isa.h" #include "hw/acpi/acpi_aml_interface.h" -static ISABus *isabus; - static char *isabus_get_fw_dev_path(DeviceState *dev); static void isa_bus_class_init(ObjectClass *klass, void *data) @@ -53,10 +51,8 @@ static const TypeInfo isa_bus_info = { ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space, MemoryRegion *address_space_io, Error **errp) { - if (isabus) { - error_setg(errp, "Can't create a second ISA bus"); - return NULL; - } + ISABus *isabus; + if (!dev) { dev = qdev_new("isabus-bridge"); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);