From patchwork Thu Jan 26 21:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cCyMMM4H; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2tqL3DkCz23hg for ; Fri, 27 Jan 2023 08:18:37 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dI-00080k-7c; Thu, 26 Jan 2023 16:18:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9d4-0007u7-Um; Thu, 26 Jan 2023 16:17:55 -0500 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d3-0007ip-Eg; Thu, 26 Jan 2023 16:17:54 -0500 Received: by mail-ej1-x634.google.com with SMTP id tz11so8804561ejc.0; Thu, 26 Jan 2023 13:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NRj6OGg23wCeRTbA04p9tOvOWVwWcmNFfwTftypZSv0=; b=cCyMMM4HVPhkTKyQp0sLfNjV/+3DmI4P2MzgsuMPSInLkPqXtLt802b6CXAxtJciwI EA9OfUUrlKO0sTxmZITIq0WKkHxW8z07IN9dIFDhVOoo12vODDmFwWaTu3BKXSDvQpUO A4iUWWyUVkqVBj4Ye1N7bNamqoaaOWusYKcJ0/PgO1SVz+KMZZnaNeNns7gxBT6baxJJ p0vXBdOjaCIkmgKyDcvGc9wmG04Meg0PvmFGSGi6txdB0IjHgkOkQPbqNdHnI9wyvk+2 lBt4U5eYIcp7o5wQwyInHRasv7VR58k6ChySeB3HojIJRl6uvPFY0ZOxrATJMlyCBES2 OaPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NRj6OGg23wCeRTbA04p9tOvOWVwWcmNFfwTftypZSv0=; b=C043tkNp1/djgCw6xjh0pOMw3e7ZZQ4LcNVvSBBVXLSSfFExAprAoU+uOA0mqMn5xP eeiFCkScsCcG35Qb4zgi3WVw8mMNgdV+gOD86cYuX9eFyxnr2QiIWLB3/M4O+F5TjwLf Ea8ARZQ9rR7eaoELL2fuLUJd59CxZRI6/FcuKoZe7cfsAN9UIwm9bSW6y6Kiqdq1/vtc pBtRN3kGAe+E6X+F2Xy5BGqTRm1ep1KpVG3ZyNona4i72WzoLkqDmByDJLbcnTW7YfRp SmhMWN/+JrVizeUCtCxy5EZXMX/0Z/SmR+1xOm6XPCOM0IK0NVlhGNm81xW3ETGoQ/ni 8rjw== X-Gm-Message-State: AFqh2kpzMn3C9xs5e4fzL9qBgk2XT56dLFx26PUaqgClJsIyf0YoMTvz umKD3gvo1M+702pqgtc4EXKofa9ZMevTrw== X-Google-Smtp-Source: AMrXdXv6lHbh4VZXtVdZ7iyKCstBM79UNytcU6EmuIcATRHOA3LsS7527fLU7yWKOi5EFyIebnYjvw== X-Received: by 2002:a17:907:ca07:b0:7c0:a1f9:c778 with SMTP id uk7-20020a170907ca0700b007c0a1f9c778mr34416818ejc.13.1674767871090; Thu, 26 Jan 2023 13:17:51 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:50 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 01/10] softmmu/ioport: Move portio_list_init() in front of portio_list_add() Date: Thu, 26 Jan 2023 22:17:31 +0100 Message-Id: <20230126211740.66874-2-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=shentey@gmail.com; helo=mail-ej1-x634.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is a preparation for the next patch to keep its diff smaller. Signed-off-by: Bernhard Beschow --- softmmu/ioport.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/softmmu/ioport.c b/softmmu/ioport.c index cb8adb0b93..215344467b 100644 --- a/softmmu/ioport.c +++ b/softmmu/ioport.c @@ -113,27 +113,6 @@ uint32_t cpu_inl(uint32_t addr) return val; } -void portio_list_init(PortioList *piolist, - Object *owner, - const MemoryRegionPortio *callbacks, - void *opaque, const char *name) -{ - unsigned n = 0; - - while (callbacks[n].size) { - ++n; - } - - piolist->ports = callbacks; - piolist->nr = 0; - piolist->regions = g_new0(MemoryRegion *, n); - piolist->address_space = NULL; - piolist->opaque = opaque; - piolist->owner = owner; - piolist->name = name; - piolist->flush_coalesced_mmio = false; -} - void portio_list_set_flush_coalesced(PortioList *piolist) { piolist->flush_coalesced_mmio = true; @@ -250,6 +229,26 @@ static void portio_list_add_1(PortioList *piolist, ++piolist->nr; } +void portio_list_init(PortioList *piolist, Object *owner, + const MemoryRegionPortio *callbacks, + void *opaque, const char *name) +{ + unsigned n = 0; + + while (callbacks[n].size) { + ++n; + } + + piolist->ports = callbacks; + piolist->nr = 0; + piolist->regions = g_new0(MemoryRegion *, n); + piolist->address_space = NULL; + piolist->opaque = opaque; + piolist->owner = owner; + piolist->name = name; + piolist->flush_coalesced_mmio = false; +} + void portio_list_add(PortioList *piolist, MemoryRegion *address_space, uint32_t start) From patchwork Thu Jan 26 21:17:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WeY1LrST; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trp5rMYz23hg for ; Fri, 27 Jan 2023 08:19:54 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dO-00084s-IV; Thu, 26 Jan 2023 16:18:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9d6-0007wM-FD; Thu, 26 Jan 2023 16:17:56 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d4-0007ix-7N; Thu, 26 Jan 2023 16:17:56 -0500 Received: by mail-ej1-x629.google.com with SMTP id vw16so8543647ejc.12; Thu, 26 Jan 2023 13:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PzZ3R1BYdECVzNFKQABQW6t7uLiAQAn5aLsoxndi4do=; b=WeY1LrSTvMKPUVlHl8jMF1vUHvuRMRMgLUGQDbfWyLpsTmzhZC0jpHdnKlfMl9pt5j m0nyJ55gr3HM8iZ2FaA9NaEPCAVP/mJB59VI3PeDylv2RO3u6UqS9NWSR/A5BrcvpqqB lwm2975b6LPye2HKwSqz3UUb7mojj4+oFGV2M38L7u1mOiHMhX1QQxCcbsKKO3SmMNhN lK4zP1RQZQISR2LRuGLQKP3x+XoG5pYlpO+B3da6DEyEZ9EI+wExiRUewdq3iXBlRVsV MoGQqK8dfDBH4ahMdIuUH11P0/L9Xa2c6WKF8LqKsOTjEoAGC5LhcdNq55JjvFsWcV7m OZNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PzZ3R1BYdECVzNFKQABQW6t7uLiAQAn5aLsoxndi4do=; b=l3KFZwj3T9GajFcQvKxTw9XAKJJHbRtOpxSSekQ87hDf2HLvckRvjiVFTgYODC8V0L Em01U/yTxqbsRkrxCll4cxkuQMUXE3W+gBeM01CSTnaTG0XWMDHmf/BG8pyLeVRog76p UWnNH9GHQRoW7y4QLp6LuwY5e3rIMVB4hm6QTsStNJBmESGsepZKA+1jeO5qkk/QFqJU 59f12buHH7Rg3tjdICLI4fx6FoxO13MylPNcLFCyB7/sd8u/hxGL9MwwR+6FzDbCh//g XquAt5PkWaO1Ua7lT2WjJJabUHez9EZXozEBeh2Zqja2r7EClcGYvvbIQdwWvGOfj9Z/ 7REw== X-Gm-Message-State: AFqh2kqWjxZr7iZpwJk2qcJMzAuI/gH3OKtj5HbNIiY9c2cMYYK6Vghb 8akOEaX0WinKjG0uzEq4L/1nFErQWDjICg== X-Google-Smtp-Source: AMrXdXvdhtjZ6jV1vaLfkO3UdWukBzWfeqeP27TZtWC4OOZyLE8Wt21QKjDKOV+4ZnZ8FqAMCSPbbA== X-Received: by 2002:a17:907:8b08:b0:860:c12c:14fd with SMTP id sz8-20020a1709078b0800b00860c12c14fdmr41829712ejc.76.1674767872089; Thu, 26 Jan 2023 13:17:52 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:51 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow , 20210518215545.1793947-9-philmd@redhat.com Subject: [PATCH v2 02/10] softmmu/ioport: Merge portio_list_add() into portio_list_init() Date: Thu, 26 Jan 2023 22:17:32 +0100 Message-Id: <20230126211740.66874-3-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Both functions are always used together and in the same order. Let's reflect this in the API. Inspired-by: <20210518215545.1793947-9-philmd@redhat.com> 'hw/isa: Extract bus part from isa_register_portio_list()' Signed-off-by: Bernhard Beschow --- include/exec/ioport.h | 6 ++---- hw/audio/adlib.c | 4 ++-- hw/display/qxl.c | 5 ++--- hw/display/vga.c | 8 ++++---- hw/dma/i82374.c | 6 ++---- hw/isa/isa-bus.c | 6 ++---- hw/watchdog/wdt_ib700.c | 4 ++-- softmmu/ioport.c | 19 +++++++------------ 8 files changed, 23 insertions(+), 35 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index e34f668998..ec3e8e5942 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -64,12 +64,10 @@ typedef struct PortioList { void portio_list_init(PortioList *piolist, Object *owner, const struct MemoryRegionPortio *callbacks, - void *opaque, const char *name); + void *opaque, const char *name, + MemoryRegion *address_space_io, uint16_t start); void portio_list_set_flush_coalesced(PortioList *piolist); void portio_list_destroy(PortioList *piolist); -void portio_list_add(PortioList *piolist, - struct MemoryRegion *address_space, - uint32_t addr); void portio_list_del(PortioList *piolist); #endif /* IOPORT_H */ diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 5f979b1487..957abe3da7 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -291,8 +291,8 @@ static void adlib_realizefn (DeviceState *dev, Error **errp) adlib_portio_list[0].offset = s->port; adlib_portio_list[1].offset = s->port + 8; - portio_list_init (&s->port_list, OBJECT(s), adlib_portio_list, s, "adlib"); - portio_list_add (&s->port_list, isa_address_space_io(&s->parent_obj), 0); + portio_list_init(&s->port_list, OBJECT(s), adlib_portio_list, s, "adlib", + isa_address_space_io(&s->parent_obj), 0); } static Property adlib_properties[] = { diff --git a/hw/display/qxl.c b/hw/display/qxl.c index ec712d3ca2..6d5a931425 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2224,10 +2224,9 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp) } vga_init(vga, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev), false); - portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list, - vga, "vga"); + portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list, vga, + "vga", pci_address_space_io(dev), 0x3b0); portio_list_set_flush_coalesced(&qxl->vga_port_list); - portio_list_add(&qxl->vga_port_list, pci_address_space_io(dev), 0x3b0); qxl->have_vga = true; vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); diff --git a/hw/display/vga.c b/hw/display/vga.c index 7a5fdff649..2b606a526c 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2309,12 +2309,12 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space, 1); memory_region_set_coalescing(vga_io_memory); if (init_vga_ports) { - portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga"); + portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga", + address_space_io, 0x3b0); portio_list_set_flush_coalesced(&s->vga_port_list); - portio_list_add(&s->vga_port_list, address_space_io, 0x3b0); } if (vbe_ports) { - portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe"); - portio_list_add(&s->vbe_port_list, address_space_io, 0x1ce); + portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe", + address_space_io, 0x1ce); } } diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c index 34c3aaf7d3..5914b34079 100644 --- a/hw/dma/i82374.c +++ b/hw/dma/i82374.c @@ -131,10 +131,8 @@ static void i82374_realize(DeviceState *dev, Error **errp) } i8257_dma_init(isa_bus, true); - portio_list_init(&s->port_list, OBJECT(s), i82374_portio_list, s, - "i82374"); - portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), - s->iobase); + portio_list_init(&s->port_list, OBJECT(s), i82374_portio_list, s, "i82374", + isa_address_space_io(&s->parent_obj), s->iobase); memset(s->commands, 0, sizeof(s->commands)); } diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 1bee1a47f1..b3497dad61 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -124,8 +124,6 @@ int isa_register_portio_list(ISADevice *dev, const MemoryRegionPortio *pio_start, void *opaque, const char *name) { - assert(piolist && !piolist->owner); - if (!isabus) { return -ENODEV; } @@ -135,8 +133,8 @@ int isa_register_portio_list(ISADevice *dev, actually handled e.g. the FDC device. */ isa_init_ioport(dev, start); - portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name); - portio_list_add(piolist, isabus->address_space_io, start); + portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name, + isabus->address_space_io, start); return 0; } diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c index b116c3a3aa..e53e474b83 100644 --- a/hw/watchdog/wdt_ib700.c +++ b/hw/watchdog/wdt_ib700.c @@ -115,8 +115,8 @@ static void wdt_ib700_realize(DeviceState *dev, Error **errp) s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ib700_timer_expired, s); - portio_list_init(&s->port_list, OBJECT(s), wdt_portio_list, s, "ib700"); - portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), 0); + portio_list_init(&s->port_list, OBJECT(s), wdt_portio_list, s, "ib700", + isa_address_space_io(&s->parent_obj), 0); } static void wdt_ib700_reset(DeviceState *dev) diff --git a/softmmu/ioport.c b/softmmu/ioport.c index 215344467b..c92e3cb27d 100644 --- a/softmmu/ioport.c +++ b/softmmu/ioport.c @@ -231,8 +231,13 @@ static void portio_list_add_1(PortioList *piolist, void portio_list_init(PortioList *piolist, Object *owner, const MemoryRegionPortio *callbacks, - void *opaque, const char *name) + void *opaque, const char *name, + MemoryRegion *address_space_io, uint16_t start) { + assert(piolist && !piolist->owner); + + const MemoryRegionPortio *pio, *pio_start = callbacks; + unsigned int off_low, off_high, off_last, count; unsigned n = 0; while (callbacks[n].size) { @@ -242,21 +247,11 @@ void portio_list_init(PortioList *piolist, Object *owner, piolist->ports = callbacks; piolist->nr = 0; piolist->regions = g_new0(MemoryRegion *, n); - piolist->address_space = NULL; + piolist->address_space = address_space_io; piolist->opaque = opaque; piolist->owner = owner; piolist->name = name; piolist->flush_coalesced_mmio = false; -} - -void portio_list_add(PortioList *piolist, - MemoryRegion *address_space, - uint32_t start) -{ - const MemoryRegionPortio *pio, *pio_start = piolist->ports; - unsigned int off_low, off_high, off_last, count; - - piolist->address_space = address_space; /* Handle the first entry specially. */ off_last = off_low = pio_start->offset; From patchwork Thu Jan 26 21:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=OsA2JAo0; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trr6yHxz23hg for ; Fri, 27 Jan 2023 08:19:56 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dO-000868-RL; Thu, 26 Jan 2023 16:18:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9d7-0007wW-4c; Thu, 26 Jan 2023 16:17:57 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d5-0007jF-Lo; Thu, 26 Jan 2023 16:17:56 -0500 Received: by mail-ed1-x531.google.com with SMTP id w11so3143875edv.0; Thu, 26 Jan 2023 13:17:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fGhWaMW25bDreQ5GS2SvNFJnZIg8Fsu2CnnXot6JUbI=; b=OsA2JAo06+Z6ba8ZsjiIInnSNpgVpyEIv2tzf5Z47/YXb+iOsU7WsUHWreTB0h+iXK NHLnF8478edYfjCylnwDk7mGkk0ZW0/QPat2Bav7aw8zQncEup8MZ/L0ZUduuaou0d40 MZBCLDY1pVtyJptAliEC+xucUQEUd4Nbqz1YkkDKoMZiqgvIF22l2oViHYrt3b9Dycb0 jv+GnpuTLBPEoq/hQUhR2PwGcuGqoSo8Z445gjeSebccDjAMdUkUMJqeh7ZhQiV3o2cn ujGd3VtlhYY6AldGWiV3XQ+PTW+wxMeXb/H2a5/DMnzy+rtZkRsHfYv0Xu8I17zFpCKs bIPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fGhWaMW25bDreQ5GS2SvNFJnZIg8Fsu2CnnXot6JUbI=; b=Wopj4HmCipQIDMkMJ84q0f6wOnEMy8RnJtudoc6u79npH7ksOZszeJAiuzzCbD2cp5 +ORUs8dmKWGNA1606WYnCS2CezSRRdHEWeEwjN/qzOYJuKQPSBFpaTiouakdGG9JMhaD J34fKnFa5KWuUkK2FbOdSDwfkr2BZxyq7vBEcgnZ3IoAd1d3aO6zU3JhWGpdy8Rq5S4r yCYpGYayvhhFN6f1vrni8S6xKzXYVuUyVG/mb+T+ooz/zHdtmY7/Czn6icJq+aYmg9Xn fnT2+o2Cj+T1ZTPGqvHhNzljl9mwdAPG1d+WsTqbaWgiahqqMeu3V8HnQEH71RDfgYLj Yv2Q== X-Gm-Message-State: AFqh2kqZBv4dm5qvIwML9fAC74MWLK6TaGlWeguXNXRdTU+sofLVa7b8 zvMRVIs11bKVYg5xtIVx//zPU4bmHn0hxQ== X-Google-Smtp-Source: AMrXdXsg9IoXVr6eCqMDSDoR/ZCRvofinSweOU+ws9sIh241Mp1s17q0MfIBXveKNXRCWaTmwH11dA== X-Received: by 2002:a05:6402:194c:b0:498:b9ea:1896 with SMTP id f12-20020a056402194c00b00498b9ea1896mr45122812edz.9.1674767873221; Thu, 26 Jan 2023 13:17:53 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:52 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 03/10] softmmu/ioport: Remove unused functions Date: Thu, 26 Jan 2023 22:17:33 +0100 Message-Id: <20230126211740.66874-4-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=shentey@gmail.com; helo=mail-ed1-x531.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Bernhard Beschow --- include/exec/ioport.h | 2 -- softmmu/ioport.c | 24 ------------------------ 2 files changed, 26 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index ec3e8e5942..1ef5aebba3 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -67,7 +67,5 @@ void portio_list_init(PortioList *piolist, Object *owner, void *opaque, const char *name, MemoryRegion *address_space_io, uint16_t start); void portio_list_set_flush_coalesced(PortioList *piolist); -void portio_list_destroy(PortioList *piolist); -void portio_list_del(PortioList *piolist); #endif /* IOPORT_H */ diff --git a/softmmu/ioport.c b/softmmu/ioport.c index c92e3cb27d..0a55d39196 100644 --- a/softmmu/ioport.c +++ b/softmmu/ioport.c @@ -118,19 +118,6 @@ void portio_list_set_flush_coalesced(PortioList *piolist) piolist->flush_coalesced_mmio = true; } -void portio_list_destroy(PortioList *piolist) -{ - MemoryRegionPortioList *mrpio; - unsigned i; - - for (i = 0; i < piolist->nr; ++i) { - mrpio = container_of(piolist->regions[i], MemoryRegionPortioList, mr); - object_unparent(OBJECT(&mrpio->mr)); - g_free(mrpio); - } - g_free(piolist->regions); -} - static const MemoryRegionPortio *find_portio(MemoryRegionPortioList *mrpio, uint64_t offset, unsigned size, bool write) @@ -280,14 +267,3 @@ void portio_list_init(PortioList *piolist, Object *owner, /* There will always be an open sub-list. */ portio_list_add_1(piolist, pio_start, count, start, off_low, off_high); } - -void portio_list_del(PortioList *piolist) -{ - MemoryRegionPortioList *mrpio; - unsigned i; - - for (i = 0; i < piolist->nr; ++i) { - mrpio = container_of(piolist->regions[i], MemoryRegionPortioList, mr); - memory_region_del_subregion(piolist->address_space, &mrpio->mr); - } -} From patchwork Thu Jan 26 21:17:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=F2DImfWJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2tqh0wT4z23hg for ; Fri, 27 Jan 2023 08:18:56 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dI-000815-8r; Thu, 26 Jan 2023 16:18:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9d8-0007x5-1U; Thu, 26 Jan 2023 16:17:58 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d6-0007jX-FH; Thu, 26 Jan 2023 16:17:57 -0500 Received: by mail-ej1-x633.google.com with SMTP id v6so8638139ejg.6; Thu, 26 Jan 2023 13:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o8JuCJ+MK8BSdi47hiI3ktQK7/lqejbuLuPqwQLbMvQ=; b=F2DImfWJINLLnKTzuAuSDKbCpo4DRQicKtocvpoq2HxJL354sDM0Mzxky13GqWwvzi xwRhNZR/MIdyMUwYYPIublC+IiD5eyP/Kk5HLMQ/l4fQW/Pr2hycGuJx1r7a4AmZWrHF chHaKcdEjR/f3kaUTKVaWx+fp3EV8f+RJp162wH+ixhKqVP1IHP6/2lLAKYnNsw6bzD/ rssy4aZqQR4FIxMJOfofYpjFuDjBDmvJwS1SoZTAYtBaccu4x8nF3cPwinQpNe0fASlM 8uYgC1bDOZ/eHF3qmlJjwiPBYYDhpD8SMm4ymmzjsw3WOEJLAehHHnkWEunA1wtMNVSv 5dng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o8JuCJ+MK8BSdi47hiI3ktQK7/lqejbuLuPqwQLbMvQ=; b=nrqeDvqG6glrbF6jKznf402k+dSwjCSynS9ceRxyKSd+QL5229Rll9V+Z0/EOzHGhl On9NYnskCZstJzMK17BIyS/rpwF0cJ5razYLD4B5+8ST9dU8i/metIFRuJYbUcysoujS g08Y/NTQAzMMy1Xv5PrGf4M/EItpfsdl+v7xiPTzjJHp7BnAgK7FVpWCHDuCCfQwkBxB aYI/uZEZqtGXTKqp5ahIJw5ee9QYTsBeuUVsFiowjo5SNx19Wjohe0dTjQIdEovc7MEK n8Yqcn5sbSzYB1SGBXHkhXt3sNKRo2h8cgnsvoPNQTtqr9uvqSq4RpCRmyVomfJGyB3X zsCg== X-Gm-Message-State: AFqh2koQjiRAibNs7UAxWd5PGhys63sGFVnP44+Ve4X+tCaqG/9l0BmS pRKuxZyMM+6GM9w+CUPRbsy+a5tnlhQxYg== X-Google-Smtp-Source: AMrXdXst8Higc9bV5z7c3cicO70+hC743R96fQwVzO/4xNwNfYX2A/6stZHPoWLuVkGinqmrrie90Q== X-Received: by 2002:a17:907:2a07:b0:86f:4a4e:4853 with SMTP id fd7-20020a1709072a0700b0086f4a4e4853mr33236951ejc.49.1674767874176; Thu, 26 Jan 2023 13:17:54 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:53 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 04/10] hw/ide/piix: Disuse isa_get_irq() Date: Thu, 26 Jan 2023 22:17:34 +0100 Message-Id: <20230126211740.66874-5-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org isa_get_irq() asks for an ISADevice which piix-ide doesn't provide. Passing a NULL pointer works but causes the isabus global to be used then. By fishing out TYPE_ISA_BUS from the QOM tree it is possible to achieve the same as isa_get_irq(). This is an alternative solution to commit 9405d87be25d '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. Signed-off-by: Bernhard Beschow --- hw/ide/piix.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 267dbf37db..a6646d9657 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -126,7 +126,7 @@ static void piix_ide_reset(DeviceState *dev) pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */ } -static int pci_piix_init_ports(PCIIDEState *d) +static int pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) { static const struct { int iobase; @@ -145,7 +145,7 @@ static int pci_piix_init_ports(PCIIDEState *d) if (ret) { return ret; } - ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); + ide_init2(&d->bus[i], isa_bus->irqs[port_info[i].isairq]); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; @@ -159,6 +159,8 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d = PCI_IDE(dev); uint8_t *pci_conf = dev->config; + ISABus *isa_bus; + bool ambiguous; int rc; pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode @@ -168,7 +170,20 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); - rc = pci_piix_init_ports(d); + isa_bus = ISA_BUS(object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous)); + if (ambiguous) { + error_setg(errp, + "More than one ISA bus found while %s supports only one", + object_get_typename(OBJECT(dev))); + return; + } + if (!isa_bus) { + error_setg(errp, "No ISA bus found while %s requires one", + object_get_typename(OBJECT(dev))); + return; + } + + rc = pci_piix_init_ports(d, isa_bus); if (rc) { error_setg_errno(errp, -rc, "Failed to realize %s", object_get_typename(OBJECT(dev))); From patchwork Thu Jan 26 21:17:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=l/OJx7ng; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trk4bdTz23hg for ; Fri, 27 Jan 2023 08:19:50 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dQ-000886-O9; Thu, 26 Jan 2023 16:18:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9d9-0007xH-It; Thu, 26 Jan 2023 16:18:00 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d7-0007jn-Dm; Thu, 26 Jan 2023 16:17:59 -0500 Received: by mail-ej1-x62a.google.com with SMTP id kt14so8685472ejc.3; Thu, 26 Jan 2023 13:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FWcvHkgyfXqKn+dsG6qj6iJyl76389CHLqD2jjmiaFM=; b=l/OJx7ng+XN5KzkiCo6I2lHZCKTVaDFkbaS0qLTR8Urhrc4D/x8EPEvWojaougHfUJ uRDkw1mTyQFsn/f3kBC5HzBz+2Zpl9a8oQ7HNThG6TqGmbQJICQrqhW+AhWgnDZbNJ47 BLNKZ9n9Ysmg0HaASkAlQs3pdU3kpeJAjMm02sdIKuZq3P8jVj+9sp9FK2tN+uclzYcL 7nLU10HvQtMj/y9Wcv4Z+BLXP3MuDMTGNvThoj7AQIh7yLqLbxg2lVMNYCfn/Mdgsjd0 XO/zelBPdXy4eRxM6KpkfhJixKCu9eGZ1DwFwutCfGaBLtL0SNXxONXIzOXwJyk6KIDV moOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWcvHkgyfXqKn+dsG6qj6iJyl76389CHLqD2jjmiaFM=; b=WHWqYn3ewHsgV3fydUBYMcxMFf4P+CmLzqZo0YUoIKmucZdD0OLuNE1URE8b8kgUXv KkJP5F+SeeMAQ8/ulE8E5AodMRVoi6UDOIS8dZeSuaPKGcYR/PwlNjQjZpLsNRllSOIN BBG4bfpB8TMK/mC2QuGmwpMpDiKg+HZdJbJs9CrT6fWy8cHwYNTWIqk7r5pQmfHWyzrg e2oEuY02q00wJrOseyY2NNhSEe5KnFve5rEo6V5Qc/g+sluScTdaR+P7HsM42iE+HJ91 nqBnifuc4qS1dbMUxD8ChD9w2l6Fo24MUJkoV+0bHBbop/hzbHFm/8HfmJker4ou/sVC fM+w== X-Gm-Message-State: AO0yUKX9ELeSblTZTQOkcmTeoWZ7stMrPzLQfth/B/vg4GEvuwYHx6vI knQ1fwTwo0Q9EdkA9R0fPkt9HvzF+ZyKxQ== X-Google-Smtp-Source: AK7set+y4WY59FtXzaAY/llDy62MY0b1iGbZNC6At6nFwhQO6Vr0TcnA9eqkzdf69Hz6C7lB2sFTKg== X-Received: by 2002:a17:907:9625:b0:879:6abc:3bfc with SMTP id gb37-20020a170907962500b008796abc3bfcmr1004805ejc.19.1674767875199; Thu, 26 Jan 2023 13:17:55 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:54 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 05/10] Revert "hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine" Date: Thu, 26 Jan 2023 22:17:35 +0100 Message-Id: <20230126211740.66874-6-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=shentey@gmail.com; helo=mail-ej1-x62a.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- include/hw/ide/internal.h | 2 +- include/hw/isa/isa.h | 13 +++++-------- hw/ide/ioport.c | 16 ++++++---------- hw/ide/piix.c | 20 +++++--------------- hw/isa/isa-bus.c | 14 ++++---------- 5 files changed, 21 insertions(+), 44 deletions(-) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index fc0aa81a88..42c49414f4 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -628,7 +628,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) { 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 a6646d9657..5980045db0 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -126,7 +126,7 @@ static void piix_ide_reset(DeviceState *dev) pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */ } -static int pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) +static void pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) { static const struct { int iobase; @@ -136,23 +136,18 @@ static int pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) {0x1f0, 0x3f6, 14}, {0x170, 0x376, 15}, }; - int i, ret; + int i; 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_bus->irqs[port_info[i].isairq]); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; ide_register_restart_cb(&d->bus[i]); } - - return 0; } static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) @@ -161,7 +156,6 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) uint8_t *pci_conf = dev->config; ISABus *isa_bus; bool ambiguous; - int rc; pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode @@ -183,11 +177,7 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) return; } - rc = pci_piix_init_ports(d, isa_bus); - if (rc) { - error_setg_errno(errp, -rc, "Failed to realize %s", - object_get_typename(OBJECT(dev))); - } + pci_piix_init_ports(d, isa_bus); } static void pci_piix_ide_exitfn(PCIDevice *dev) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index b3497dad61..d3e2d9de35 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -119,15 +119,11 @@ 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) { - 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. */ @@ -135,8 +131,6 @@ int isa_register_portio_list(ISADevice *dev, portio_list_init(piolist, OBJECT(dev), pio_start, opaque, name, isabus->address_space_io, start); - - return 0; } ISADevice *isa_new(const char *name) From patchwork Thu Jan 26 21:17:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=iBO4Eoad; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trL5HFFz23hg for ; Fri, 27 Jan 2023 08:19:30 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dS-00088p-2h; Thu, 26 Jan 2023 16:18:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9dA-0007yp-Ae; Thu, 26 Jan 2023 16:18:01 -0500 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d8-0007k4-LK; Thu, 26 Jan 2023 16:18:00 -0500 Received: by mail-ej1-x635.google.com with SMTP id hw16so8565904ejc.10; Thu, 26 Jan 2023 13:17:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tubdnU+XgZjPA7MkbgO7dHANtWvi4WyU/xxOFVAkR7E=; b=iBO4EoadoBXls5uNA2tElNL2S1FttQ/UdB8d+D2r2QYpI8xo9aNgE2Tvz9T2qjcxxI MqcYaVAV0GtIftBNUoSUsUG72aCWLwHwPqblulo0scs94tRURwHI8gjkV5+/RkAX/tCg G+N6oc8LYZg0i5s3LJiEuz8uLAMoKAFGhO+KiXkRTb60NTWcVKpR8Dyh1VrSwfH9XbLo 77PIihgCtLKRUtQDYW5FH/+hLupMUemX6YLZH1pU+qU/MStApj2DcwKwjlvhi4KKxF9H CCjsBE4nSIPQonpdIseBNbsKjBidC4u74aOc5gDNCYujUV8IN120ci/CyVg7id4KOGu+ bJHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tubdnU+XgZjPA7MkbgO7dHANtWvi4WyU/xxOFVAkR7E=; b=yAdI7lsMwyf3q+otugYUg5aNtWBxJHpT7h/k7jF9MQq0IrfgpdVmDaE4EDlqjEuLxY 5OERqLonUp/dcjODt87OZU/TI/FKdn6BDfFwO/N/qTQ/ILyw45CEoNk7dHnt9pQ20uyu bmr8Kk03UHhapdh2ssmI/EONKKXI0BKkesamj7JRh2dgo9jCZu5n0Hj2fRDjowW3BWpf +T9Q6doPIQiahh2Xg7NEmA7LpL1C7TaUGUvPMGSgLrFtRWYya2n0B/TwGfjG5nC/i99W kwSeBsa/Yjr83+XMrYrDSg9r2dDqlZbtnpqm2pUa2z/TgPtNX+J3HLznZLlC548tuMte psKA== X-Gm-Message-State: AFqh2krowHXn1WxR86E6lBpPfspgOG2jYEZ7Os/7Adsg3XJigJ/sSnbf wvhv3KWtgoy+tOZlU2lquN6An+bhJ5rjog== X-Google-Smtp-Source: AMrXdXvpp7SLzC8OpEOeUkNRWxFqwM0eV+TfjaAZtWz7wcupSlV7KwhMLtLZkMt75UzYZbzbD66OWQ== X-Received: by 2002:a17:906:5414:b0:861:b4c5:63ba with SMTP id q20-20020a170906541400b00861b4c563bamr35055792ejo.41.1674767876310; Thu, 26 Jan 2023 13:17:56 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:55 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 06/10] hw/ide/pci: Add PCIIDEState::isa_irqs[] Date: Thu, 26 Jan 2023 22:17:36 +0100 Message-Id: <20230126211740.66874-7-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=shentey@gmail.com; helo=mail-ej1-x635.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org These legacy ISA IRQs allow the PIIX IDE functions to be wired up in their south bridges and the VIA IDE functions to disuse PCI_INTERRUPT_LINE as outlined in https://lists.nongnu.org/archive/html/ qemu-devel/2020-03/msg01707.html . Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- include/hw/ide/pci.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h index 2a6284acac..24c0b7a2dd 100644 --- a/include/hw/ide/pci.h +++ b/include/hw/ide/pci.h @@ -49,6 +49,7 @@ 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]; From patchwork Thu Jan 26 21:17:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=fbhT2Wf1; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trV28wxz23hg for ; Fri, 27 Jan 2023 08:19:38 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dQ-000888-Pl; Thu, 26 Jan 2023 16:18:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9dB-0007yu-Bj; Thu, 26 Jan 2023 16:18:02 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9d9-0007kR-GO; Thu, 26 Jan 2023 16:18:01 -0500 Received: by mail-ej1-x631.google.com with SMTP id ss4so8572874ejb.11; Thu, 26 Jan 2023 13:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B+0raqkDXWQWPBkic8BAc4ozUWXA5qkVo1EM1DG1MHQ=; b=fbhT2Wf12e3Y8dvlbs0Ac1eGV1bm6TWMeYWfp40bfTgeaDhppILO1G04rFob1naJM8 K+giGKPygPNbT2J8VZLWgWoxODK4BKaSJS0dGETI0d15V3O3MFeAkutjyi1Qq25duhyB 1ouGiQ5cZ6f5nZoPeFR87p35mh8FMfsbw8aIHXYYcih34MafK8A7K0oegZQzORqepGFP w+5ZS+MBINy13dJiIl7IpdaUBdJ/p4BBKpGPwyEvRBmFl1CgHmRpw/E+K40+v/sw3xO8 zSN3d/5fkwEzUYFXYIEZThw7owvnIhchg7u9HpVxDnGzgBf3HSa/C4b3m+0yag4d74+S 9f+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B+0raqkDXWQWPBkic8BAc4ozUWXA5qkVo1EM1DG1MHQ=; b=j3JGlE+fy+T/8/Kq4j+Mo8R+ysRfU45e1rzwBT0wtutq+IkHXfUh31AgEsn+t6na+/ hHcDq9fD7LihtB56kY60hu21VHX5CxXTNR6TKWjMvNt9XZhX5ZJvG0F5h9Ug7mzO/kjr 6qAK4RGcx6ORjC2f3nFq6kPeE1RQXJkiOjD+l2aJx0e8ACIyD47DPFOnsVK3KufX4SHF gYjE4egbyK+/Wu774/2vf3lwWMSBIjf48vYLJdKfTanFRb9JsfvNo8SCgRKVihOVfLwe 61YDerG1vDGuxb8pDDRZDR7lKnTh7auxsTTR8udpGbEkEnvzQ6uR/IQBjSDUIzLhZ8Bv ZmwQ== X-Gm-Message-State: AFqh2kq+mACOqvribL/J8N4vkeXs3CyFI+153ykc41gYlE1xiofyFgX4 z2MbgsNezm1QgDMVE0sFohaAMFdRyeIqeg== X-Google-Smtp-Source: AMrXdXsI/peXlhxMg0oZ8ahP++jiimXbNmvIm9IaErhetcapmj4EkrS7wzVjWLFfHkLydmNxG9vO+Q== X-Received: by 2002:a17:906:368f:b0:877:593a:58d0 with SMTP id a15-20020a170906368f00b00877593a58d0mr33509499ejc.29.1674767877348; Thu, 26 Jan 2023 13:17:57 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:57 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 07/10] hw/ide/piix: Require an ISABus only for user-created instances Date: Thu, 26 Jan 2023 22:17:37 +0100 Message-Id: <20230126211740.66874-8-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=shentey@gmail.com; helo=mail-ej1-x631.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Internal instances now defer interrupt wiring to the caller which decouples them from the ISABus. User-created devices still fish out the ISABus from the QOM tree and the interrupt wiring remains in PIIX IDE. The latter mechanism is considered a workaround and intended to be removed once a deprecation period for user-created PIIX IDE devices is over. Signed-off-by: Bernhard Beschow --- include/hw/ide/pci.h | 1 + hw/ide/piix.c | 64 ++++++++++++++++++++++++++++++++++---------- hw/isa/piix.c | 5 ++++ 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h index 24c0b7a2dd..ee2c8781b7 100644 --- a/include/hw/ide/pci.h +++ b/include/hw/ide/pci.h @@ -54,6 +54,7 @@ struct PCIIDEState { MemoryRegion bmdma_bar; MemoryRegion cmd_bar[2]; MemoryRegion data_bar[2]; + bool user_created; }; static inline IDEState *bmdma_active_if(BMDMAState *bmdma) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 5980045db0..f0d95761ac 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -108,6 +108,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); @@ -138,11 +145,18 @@ static void pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) }; int i; + if (isa_bus) { + d->isa_irqs[0] = isa_bus->irqs[port_info[0].isairq]; + d->isa_irqs[1] = isa_bus->irqs[port_info[1].isairq]; + } else { + qdev_init_gpio_out(DEVICE(d), 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_init_ioport(&d->bus[i], NULL, port_info[i].iobase, port_info[i].iobase2); - ide_init2(&d->bus[i], isa_bus->irqs[port_info[i].isairq]); + ide_init2(&d->bus[i], qdev_get_gpio_in(DEVICE(d), i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; @@ -154,8 +168,7 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d = PCI_IDE(dev); uint8_t *pci_conf = dev->config; - ISABus *isa_bus; - bool ambiguous; + ISABus *isa_bus = NULL; pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode @@ -164,22 +177,36 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); - isa_bus = ISA_BUS(object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous)); - if (ambiguous) { - error_setg(errp, - "More than one ISA bus found while %s supports only one", - object_get_typename(OBJECT(dev))); - return; - } - if (!isa_bus) { - error_setg(errp, "No ISA bus found while %s requires one", - object_get_typename(OBJECT(dev))); - return; + if (d->user_created) { + bool ambiguous; + + isa_bus = ISA_BUS(object_resolve_path_type("", TYPE_ISA_BUS, + &ambiguous)); + + if (ambiguous) { + error_setg(errp, + "More than one ISA bus found while %s supports only one", + object_get_typename(OBJECT(dev))); + return; + } + + if (!isa_bus) { + error_setg(errp, "No ISA bus found while %s requires one", + object_get_typename(OBJECT(dev))); + return; + } } pci_piix_init_ports(d, isa_bus); } +static void pci_piix_ide_init(Object *obj) +{ + DeviceState *dev = DEVICE(obj); + + qdev_init_gpio_in(dev, piix_ide_set_irq, 2); +} + static void pci_piix_ide_exitfn(PCIDevice *dev) { PCIIDEState *d = PCI_IDE(dev); @@ -191,6 +218,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) { @@ -205,11 +237,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 = TYPE_PIIX3_IDE, .parent = TYPE_PCI_IDE, + .instance_init = pci_piix_ide_init, .class_init = piix3_ide_class_init, }; @@ -227,11 +261,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 = TYPE_PIIX4_IDE, .parent = TYPE_PCI_IDE, + .instance_init = pci_piix_ide_init, .class_init = piix4_ide_class_init, }; diff --git a/hw/isa/piix.c b/hw/isa/piix.c index 54a1246a9d..f9974c2a77 100644 --- a/hw/isa/piix.c +++ b/hw/isa/piix.c @@ -345,9 +345,14 @@ static void pci_piix_realize(PCIDevice *dev, const char *uhci_type, /* IDE */ qdev_prop_set_int32(DEVICE(&d->ide), "addr", dev->devfn + 1); + qdev_prop_set_bit(DEVICE(&d->ide), "user-created", false); if (!qdev_realize(DEVICE(&d->ide), BUS(pci_bus), errp)) { return; } + qdev_connect_gpio_out(DEVICE(&d->ide), 0, + qdev_get_gpio_in(DEVICE(&d->pic), 14)); + qdev_connect_gpio_out(DEVICE(&d->ide), 1, + qdev_get_gpio_in(DEVICE(&d->pic), 15)); /* USB */ if (d->has_usb) { From patchwork Thu Jan 26 21:17:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=kJpga6Fa; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trJ5Kqnz23hg for ; Fri, 27 Jan 2023 08:19:28 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dS-00089f-LY; Thu, 26 Jan 2023 16:18:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9dC-0007zN-JM; Thu, 26 Jan 2023 16:18:04 -0500 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9dA-0007ki-T7; Thu, 26 Jan 2023 16:18:02 -0500 Received: by mail-ej1-x634.google.com with SMTP id me3so8622228ejb.7; Thu, 26 Jan 2023 13:17:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZsBlYIVLivHH9TZQ9hPd1AFL1bCBF6f+F/1DMZlLLw0=; b=kJpga6Fa3WYMl4Sa4cUx+96O0Ajw0d5HVVHvVleSEmGl7J85jQKFBZiBfdHssV91wt KzOph/4YPN+HQtO4S9TtsvoCHPf5R2aZMk4ympofFCM+OLEg8n1lSJ6fGX3cx01r+13i JGqadbYV4MSKNZjzQaMsn8oaNrzMahMN9j1jwWwjQDFqOxcF+nOF6Cgp1IOeFQFC8VxX 5FjwIofv0BLz2aHDIT1kgvnlYR5skIQI4lC52d1KJT5zt1oGRdbS4RZ8uVdrB82cx3+4 vn3f0jEOgMHuftji8Ff5ofnbU5R4VQbnlaf4495gHacG0V6uOtmyCwR3qQxBBWw0z4g+ opzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZsBlYIVLivHH9TZQ9hPd1AFL1bCBF6f+F/1DMZlLLw0=; b=4UjK/m1O8/TveIm2QJgMD2AbtbTi22Ksd4M36Q3I+D6Y54wfqV9TbBTnTeNz+qX8oe 8Oa5dD+CWBRoVnNh2mn4uAmCl7+EZGWi9JyTJvSNj1j0vOY3gihWob2w7h/M6yfyGcSG Vos72DTDsttxfNh+Ne9nieK1UIJgj5PgdvUcO/AvLFyZ4MYlj/npYSMtEcRp2yWvXXoe evcKVBehEYQkwyDcjnmy/zn/z30+JuHpi0kARmksPrPbP/7fYrmF48QbySNY8yjmUNLr KWuh1x46TweT3HTk7Rbg9TI/stOSIio2HXGX9HWwgiT87kVgEvuX5t/cv3OBJQwVtf6p zrSQ== X-Gm-Message-State: AFqh2kqQP1+aO7pgvdEKQM1Ac2z+YxBDbJQDxD/+mU11XrT6dUg1/moR /9fINI115KEt/fI4S1xP4ioZpwjpU1w/9w== X-Google-Smtp-Source: AMrXdXs03IvcnUkRF2y8A/OBDZBxG0TAAAvjaEWu2oipECPwLqB1Uc42JyrgHZXIAJe/h5x5NDAJuw== X-Received: by 2002:a17:907:9d09:b0:7c0:efb4:71fb with SMTP id kt9-20020a1709079d0900b007c0efb471fbmr40543003ejc.28.1674767878579; Thu, 26 Jan 2023 13:17:58 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:58 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow , 20210518215545.1793947-10-philmd@redhat.com Subject: [PATCH v2 08/10] hw/ide: Let ide_init_ioport() take a MemoryRegion argument instead of ISADevice Date: Thu, 26 Jan 2023 22:17:38 +0100 Message-Id: <20230126211740.66874-9-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=shentey@gmail.com; helo=mail-ej1-x634.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Both callers to ide_init_ioport() have access to the I/O memory region of the ISA bus, so can pass it directly. This allows ide_init_ioport() to directly call portio_list_init(). Note, now the callers become the owner of the PortioList. Inspired-by: <20210518215545.1793947-10-philmd@redhat.com> 'hw/ide: Let ide_init_ioport() take an ISA bus argument instead of device' Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- include/hw/ide/internal.h | 3 ++- hw/ide/ioport.c | 15 ++++++++------- hw/ide/isa.c | 4 +++- hw/ide/piix.c | 8 ++++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 42c49414f4..c3e4d192fa 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -628,7 +628,8 @@ 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 ide_init_ioport(IDEBus *bus, MemoryRegion *address_space_io, Object *owner, + int iobase, int iobase2); void ide_register_restart_cb(IDEBus *bus); void ide_exec_cmd(IDEBus *bus, uint32_t val); diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c index b613ff3bba..00e9baf0d1 100644 --- a/hw/ide/ioport.c +++ b/hw/ide/ioport.c @@ -50,15 +50,16 @@ static const MemoryRegionPortio ide_portio2_list[] = { PORTIO_END_OF_LIST(), }; -void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2) +void ide_init_ioport(IDEBus *bus, MemoryRegion *address_space_io, Object *owner, + 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. */ - isa_register_portio_list(dev, &bus->portio_list, - iobase, ide_portio_list, bus, "ide"); + assert(address_space_io); + + portio_list_init(&bus->portio_list, owner, ide_portio_list, bus, "ide", + address_space_io, iobase); if (iobase2) { - isa_register_portio_list(dev, &bus->portio2_list, - iobase2, ide_portio2_list, bus, "ide"); + portio_list_init(&bus->portio2_list, owner, ide_portio2_list, bus, + "ide", address_space_io, iobase2); } } diff --git a/hw/ide/isa.c b/hw/ide/isa.c index 8bedbd13f1..cab5d0a07a 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -72,9 +72,11 @@ static void isa_ide_realizefn(DeviceState *dev, Error **errp) { ISADevice *isadev = ISA_DEVICE(dev); ISAIDEState *s = ISA_IDE(dev); + ISABus *isabus = isa_bus_from_device(isadev); ide_bus_init(&s->bus, sizeof(s->bus), dev, 0, 2); - ide_init_ioport(&s->bus, isadev, s->iobase, s->iobase2); + ide_init_ioport(&s->bus, isabus->address_space_io, OBJECT(dev), + 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 f0d95761ac..236b5b7416 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -29,6 +29,7 @@ #include "qemu/osdep.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/module.h" @@ -143,8 +144,11 @@ static void pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) {0x1f0, 0x3f6, 14}, {0x170, 0x376, 15}, }; + PCIBus *pci_bus = pci_get_bus(&d->parent_obj); int i; + assert(pci_bus); + if (isa_bus) { d->isa_irqs[0] = isa_bus->irqs[port_info[0].isairq]; d->isa_irqs[1] = isa_bus->irqs[port_info[1].isairq]; @@ -154,8 +158,8 @@ static void pci_piix_init_ports(PCIIDEState *d, ISABus *isa_bus) for (i = 0; i < 2; i++) { ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); - ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, - port_info[i].iobase2); + ide_init_ioport(&d->bus[i], pci_bus->address_space_io, OBJECT(d), + port_info[i].iobase, port_info[i].iobase2); ide_init2(&d->bus[i], qdev_get_gpio_in(DEVICE(d), i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); From patchwork Thu Jan 26 21:17:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TvcMYYZL; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2tr01ZDMz23hm for ; Fri, 27 Jan 2023 08:19:12 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dS-00089s-PQ; Thu, 26 Jan 2023 16:18:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9dE-0007zc-8t; Thu, 26 Jan 2023 16:18:04 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9dB-0007ix-31; Thu, 26 Jan 2023 16:18:03 -0500 Received: by mail-ej1-x629.google.com with SMTP id vw16so8544489ejc.12; Thu, 26 Jan 2023 13:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0/UI99wcQaKxLqnv3FygvPHxyrVoR4RWF0FVKnuVN2k=; b=TvcMYYZLCD+RVmzMnALsgJ7ihRAQEoFSEkWgw8RmM5wSN+Xr+Fe1iUyLrBdkKuVrEu 2YNlivrN17ydh2WSANAo1MJ10eCU9Hf3ZoSZCBDGKaBJxppG+rukef6sJMFuVkP/szwT G5+MNJdsv5f3qeT2hooJhlrGkp8OWJxdzWHy+2CsT1K2c7QVGL7YtJhcRCaJrIEjhOuM VVa2toRLjXfEU3xRHuUlAAwR5IsdqamYScDDMFBuslvy1KsbteAnm/my3F+dccQ4STnW /VnBJ7nIWKCmJRcRAofImZBOAWehQu4nO9S70EmiHxmpEuBl2oWRGDq1no7JsHV/NKJ3 B1+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0/UI99wcQaKxLqnv3FygvPHxyrVoR4RWF0FVKnuVN2k=; b=FONNq+ndukJsNhOln9PCaQG47DbdM08vw6SnZvHNsM85yD5pUhOnfT6GRWD0rdkNA3 Trtgnz+3mx+PEtVpb3yiOVQBCYC7Pv5qA2qhWje5aes1rn+PrKpRxmSFmHidUkIlDDPf B6ZNUlZP+6GjR/zIUkFNKLlUVhvKtIsl9SCb6tGS0+QfGUoK9J/YdDLWhDvNlzag7giL x3vRWY65tV7HuyJWe076Qv93u+7ZMTttr2OX7JVbCzcEZj7e/XJYjIXeeznWqMDxxJSu qCmTUW1OV5s5GJuElJpoVUo8GGjHqHfs8nGW6hwGIpTekm5E+tLzy0hVgdl8U4uVrrgL JJHQ== X-Gm-Message-State: AFqh2kpA2n1+2WQa1nmUhXKK6cYmVAR2pAzhGbwV1F4V7BIiEYoyASxU pzmDTcMtZEN0iRvESGJb4O9gEt6SlqtqUA== X-Google-Smtp-Source: AMrXdXviEZb3DYfFPs5FmA7wminCPZdCFeTG94lGHgzZK9V4Od3/OA1XdrD6RTO9B+jFlcTkpu9H6Q== X-Received: by 2002:a17:907:8b8a:b0:82e:a57b:cc9b with SMTP id tb10-20020a1709078b8a00b0082ea57bcc9bmr59117127ejc.24.1674767879596; Thu, 26 Jan 2023 13:17:59 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:17:59 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v2 09/10] hw/isa: Remove use of global isa bus Date: Thu, 26 Jan 2023 22:17:39 +0100 Message-Id: <20230126211740.66874-10-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Philippe Mathieu-Daudé In the previous commits we removed all calls to these functions passing a NULL ISADevice argument. We can simplify and remove the use of the global isabus object. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20210518215545.1793947-11-philmd@redhat.com> Signed-off-by: Bernhard Beschow --- include/hw/isa/isa.h | 2 +- hw/isa/isa-bus.c | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) 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. diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index d3e2d9de35..8bae5cc473 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -81,8 +81,12 @@ 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); + ISABus *isabus; + + assert(dev); assert(isairq < ISA_NUM_IRQS); + isabus = isa_bus_from_device(dev); + return isabus->irqs[isairq]; } @@ -115,6 +119,11 @@ 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); } @@ -124,6 +133,11 @@ void isa_register_portio_list(ISADevice *dev, const MemoryRegionPortio *pio_start, void *opaque, const char *name) { + ISABus *isabus; + + assert(dev); + 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. */ @@ -243,18 +257,20 @@ 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; - } + ISABus *isabus; + + assert(dev); + isabus = isa_bus_from_device(dev); return isabus->address_space; } MemoryRegion *isa_address_space_io(ISADevice *dev) { - if (dev) { - return isa_bus_from_device(dev)->address_space_io; - } + ISABus *isabus; + + assert(dev); + isabus = isa_bus_from_device(dev); return isabus->address_space_io; } From patchwork Thu Jan 26 21:17:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1732583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=GJ2EdVuT; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2trz3D7Lz23hg for ; Fri, 27 Jan 2023 08:20:03 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pL9dP-00086u-AS; Thu, 26 Jan 2023 16:18:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pL9dE-0007zd-8j; Thu, 26 Jan 2023 16:18:04 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL9dC-0007jn-K8; Thu, 26 Jan 2023 16:18:03 -0500 Received: by mail-ej1-x62a.google.com with SMTP id kt14so8686024ejc.3; Thu, 26 Jan 2023 13:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Y9cub/HmI35SV/LefG5zdwf9+3G3TlrTC86o8kKOss=; b=GJ2EdVuTDRtYLNG6XRwVVUaG6VASv7C4oRcMf76/MPKICHqHoJLvhYS62CUYlNA/CC +tpnaH5FSBzH090vg2MVcsowb7t1qFrWV6iTQBzvvZGC/DBWOYOy9+SpIsAq+ocCeu32 zYQBloPj8t0WMu+kPvsOep9oxmamb4g3KSGh/LBEDbOYfYg7GXbwPugf18gEypsFYtBl 1hBmYrS2fDlmJxfFubVtzK7aHq149w0HpoFuua//mCsRuVREZze9mjQGXG7vCDXIWKTZ uV0KwHCuQsBJN+kVGcTMJnvzKlPWPvWEFS5tbniTuLM2mFinl5d0LFfAda9JVknVux2h HZ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Y9cub/HmI35SV/LefG5zdwf9+3G3TlrTC86o8kKOss=; b=bd+Yg7MJLbZiKVuEeCCcdTgvovL6OLOavczF5s2j6cWEjaxdnhnEqKJFN9V9NiC1tO okglvDd/sroqJXesM4z1jFfEdiLZW8LlNtjrieaZhrxIqs2h+HM8PuTbXsfrfNS9PKYL 3hmWsB6IDeQNkjt1c5DSNt59yav5OYbhwZW1ytTfZcCFfqUAaB9gbJOezD308TN8oF0u GWsYQZx1Q12ZeEAm080CEdsyc243a+mbn7doVQjAAvwrY7upjDJHXu0A17JEu1/uKtlM S+IxJfdwNf0p2DzrkkRgNImni0byjlqZ7RzB71hWxBoQFpm6eiXUeQPNPhNybD+SpD/f mOzQ== X-Gm-Message-State: AO0yUKUsjUNeIS4bHHw9h//OHOJ1uUg0fdI8jG4z1MqcZGEUwOgCgwNU 8oSEA2ZnbyxCeIsRip8OpmUyObyJxRlrvg== X-Google-Smtp-Source: AK7set/4bzhGGo0RUN4HxwYDBn88GzMuH8YOU17+fbSPRFWO55XLWKzYrKrzU1eqni6NsnBuxaylDA== X-Received: by 2002:a17:906:2b98:b0:878:81d6:1e2d with SMTP id m24-20020a1709062b9800b0087881d61e2dmr1399874ejg.7.1674767880849; Thu, 26 Jan 2023 13:18:00 -0800 (PST) Received: from osoxes.fritz.box (p200300faaf0bb2009c4947838afc41b6.dip0.t-ipconnect.de. [2003:fa:af0b:b200:9c49:4783:8afc:41b6]) by smtp.gmail.com with ESMTPSA id w5-20020a170906384500b00878003adeeesm1117568ejc.23.2023.01.26.13.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:18:00 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Herv=C3=A9_Pous?= =?utf-8?q?sineau?= , Gerd Hoffmann , "Michael S. Tsirkin" , Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Hildenbrand , Peter Xu , qemu-ppc@nongnu.org, qemu-block@nongnu.org, John Snow , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v2 10/10] hw/isa/isa-bus: Resolve isabus global Date: Thu, 26 Jan 2023 22:17:40 +0100 Message-Id: <20230126211740.66874-11-shentey@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126211740.66874-1-shentey@gmail.com> References: <20230126211740.66874-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=shentey@gmail.com; helo=mail-ej1-x62a.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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 8bae5cc473..b8c89a1e65 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);