From nobody Thu Dec 18 08:07:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665427797; cv=none; d=zohomail.com; s=zohoarc; b=ghfvLF4UAxAriPwANWQUu082WH2vu0wGcDYSe1mceb7x57ZqF/P7/+HikjNmFBTf4qb6MquhrHoaN3mSvPf7zk09/5jpF0PNp9bFnry8ZbNJsP7NW9CN7cGJyBLQtBk7CfUMhYAL3b6ElAHQ9Qud327KIQ0y2HrR0BMFfsn3McQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665427797; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5bysEFpqvfb0vnOAHiSAOOyWiN95lODHFTH7Hy6GPk0=; b=BBQa5ygWA8COjm9CdJpTij5YFyVMGfF9jUiAWPpVmi+32ZWwd2XvUhe8CN+drbF05sOSoZlW3j+iVodfxyo5I7vW8tk/h+D5wzlGaJxaEGhSRTl+Jl10XaqM5udRX+MiJO00waXYyUvZbcLobPcz9nSDh8s179+rc0Q+FK+9z1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665427797525500.32462465724655; Mon, 10 Oct 2022 11:49:57 -0700 (PDT) Received: from localhost ([::1]:59024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohxqe-0001dE-Bs for importer@patchew.org; Mon, 10 Oct 2022 14:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwe8-0005MW-Bs for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:32:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwe2-0007hc-Gs for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:32:56 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-487-Y47RBxDUObmp226iVFCZCw-1; Mon, 10 Oct 2022 13:32:48 -0400 Received: by mail-wr1-f70.google.com with SMTP id u20-20020adfc654000000b0022cc05e9119so2953661wrg.16 for ; Mon, 10 Oct 2022 10:32:48 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id u9-20020a5d4349000000b0022cdb687bf9sm12070076wrr.0.2022.10.10.10.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665423170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5bysEFpqvfb0vnOAHiSAOOyWiN95lODHFTH7Hy6GPk0=; b=ZJdiR2OQFpACFhtlPcQVBOhBVZj8sTR2gkILO6DU7QvxtFsc6Y1pDzMpZZgbvGBQ0dznQP mrydPsTZ01FlRskj85MpMg+RaaJ5D+jJFW22vq03RdNDtaffZcZKbTO/QWKWEf+lF+WvH/ Eb1BvvRcRAfd8/rrcM/JFQ7T1ZfoFXk= X-MC-Unique: Y47RBxDUObmp226iVFCZCw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5bysEFpqvfb0vnOAHiSAOOyWiN95lODHFTH7Hy6GPk0=; b=v43blivVUdpqlwQn7M1J25ygvF6/HZMaJdWXG+2h1bJFRYHlmVnibC480jrjtG7IEY kzoaPyzt2MpvkQ1nqu6HaeRK00VkTvypFA2Ih8ukS94Ihb5LLNjpBfn/uI04FJcAoeKJ rm0bSMmi7AMfjNtO2tm2eVWqZ0GqxnN7ATMFW7bIEwQPP7VuZKShImb/hoNYz7OLFv4g fRX/S1wrY8u8YbawG5m1wxBoj0srfD00Aqws02HXD/xlkrpBxTVveVT67p5XaFb+U1ne mPAe/lcR1LPCpq+0RIpzIQJZAOcsP8TH91oLv116E3dEoNhUjtFSeXgetHwYRPZynfEQ H6Fw== X-Gm-Message-State: ACrzQf3sWjGrqHK4WGUbD8w157LWh02nAdn7imfEoGbMMvEj7I/NAA5E PGz7sPe6GihYPCKWO3S93PQHZTpEBbq1RLX3aPm8BNawwKHdDxudQrf8yDaGZNV3qOHL2qIxa7m 5ch3P9iAB8tvZzdx42Y2FYtBj4hqNxUZFw65hqsnVJfDw4VrKchgHF3bMFNqI X-Received: by 2002:a05:6000:1882:b0:230:9595:4131 with SMTP id a2-20020a056000188200b0023095954131mr3780874wri.17.1665423167546; Mon, 10 Oct 2022 10:32:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7D7cWCeXh7IB2Ej7acYNXoc972Z/js1NDAB4zMpAGmZBzQT6ytSfyf3hyMmZFMlfrOIr8kNg== X-Received: by 2002:a05:6000:1882:b0:230:9595:4131 with SMTP id a2-20020a056000188200b0023095954131mr3780851wri.17.1665423167245; Mon, 10 Oct 2022 10:32:47 -0700 (PDT) Date: Mon, 10 Oct 2022 13:32:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 55/55] x86: pci: acpi: consolidate PCI slots creation Message-ID: <20221010172813.204597-56-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665427799190100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov No functional changes nor AML bytecode changes. Consolidate code that generates empty and populated slot descriptors. Besides eliminating duplication, it helps consolidate conditions for generating parts of Device{} desriptor in one place, which makes code more compact and easier to read. Signed-off-by: Igor Mammedov Message-Id: <20220701133515.137890-18-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 111 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 57 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index fc23cb08c3..4f54b61904 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -427,13 +427,41 @@ static void build_append_pci_bus_devices(Aml *parent_= scope, PCIBus *bus, int func =3D PCI_FUNC(devfn); /* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ int adr =3D slot << 16 | func; - bool hotplug_enabled_dev; - bool bridge_in_acpi; - bool cold_plugged_bridge; + bool hotpluggbale_slot =3D false; + bool bridge_in_acpi =3D false; + bool cold_plugged_bridge =3D false; + bool is_vga =3D false; + + if (pdev) { + pc =3D PCI_DEVICE_GET_CLASS(pdev); + dc =3D DEVICE_GET_CLASS(pdev); + + if (pc->class_id =3D=3D PCI_CLASS_BRIDGE_ISA) { + continue; + } + + is_vga =3D pc->class_id =3D=3D PCI_CLASS_DISPLAY_VGA; =20 - if (!pdev) { /* - * add hotplug slots for non present devices. + * Cold plugged bridges aren't themselves hot-pluggable. + * Hotplugged bridges *are* hot-pluggable. + */ + cold_plugged_bridge =3D pc->is_bridge && !DEVICE(pdev)->hotplu= gged; + bridge_in_acpi =3D cold_plugged_bridge && pcihp_bridge_en; + + hotpluggbale_slot =3D bsel && dc->hotpluggable && + !cold_plugged_bridge; + + /* + * allow describing coldplugged bridges in ACPI even if they a= re not + * on function 0, as they are not unpluggable, for all other d= evices + * generate description only for function 0 per slot + */ + if (func && !bridge_in_acpi) { + continue; + } + } else { + /* * hotplug is supported only for non-multifunction device * so generate device description only for function 0 */ @@ -441,46 +469,11 @@ static void build_append_pci_bus_devices(Aml *parent_= scope, PCIBus *bus, if (pci_bus_is_express(bus) && slot > 0) { break; } - dev =3D aml_device("S%.02X", devfn); - aml_append(dev, aml_name_decl("_ADR", aml_int(adr))); - aml_append(dev, aml_name_decl("ASUN", aml_int(slot))); - aml_append(dev, aml_pci_device_dsm()); - aml_append(dev, aml_name_decl("_SUN", aml_int(slot))); - method =3D aml_method("_EJ0", 1, AML_NOTSERIALIZED); - aml_append(method, - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN")) - ); - aml_append(dev, method); - aml_append(parent_scope, dev); - - build_append_pcihp_notify_entry(notify_method, slot); + /* mark it as empty hotpluggable slot */ + hotpluggbale_slot =3D true; + } else { + continue; } - continue; - } - - pc =3D PCI_DEVICE_GET_CLASS(pdev); - dc =3D DEVICE_GET_CLASS(pdev); - - /* - * Cold plugged bridges aren't themselves hot-pluggable. - * Hotplugged bridges *are* hot-pluggable. - */ - cold_plugged_bridge =3D pc->is_bridge && !DEVICE(pdev)->hotplugged; - bridge_in_acpi =3D cold_plugged_bridge && pcihp_bridge_en; - - hotplug_enabled_dev =3D bsel && dc->hotpluggable && !cold_plugged_= bridge; - - if (pc->class_id =3D=3D PCI_CLASS_BRIDGE_ISA) { - continue; - } - - /* - * allow describing coldplugged bridges in ACPI even if they are n= ot - * on function 0, as they are not unpluggable, for all other devic= es - * generate description only for function 0 per slot - */ - if (func && !bridge_in_acpi) { - continue; } =20 /* start to compose PCI device descriptor */ @@ -496,7 +489,7 @@ static void build_append_pci_bus_devices(Aml *parent_sc= ope, PCIBus *bus, aml_append(dev, aml_pci_device_dsm()); } =20 - if (pc->class_id =3D=3D PCI_CLASS_DISPLAY_VGA) { + if (is_vga) { /* add VGA specific AML methods */ int s3d; =20 @@ -517,19 +510,10 @@ static void build_append_pci_bus_devices(Aml *parent_= scope, PCIBus *bus, method =3D aml_method("_S3D", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_int(s3d))); aml_append(dev, method); - } else if (hotplug_enabled_dev) { - aml_append(dev, aml_name_decl("_SUN", aml_int(slot))); - /* add _EJ0 to make slot hotpluggable */ - method =3D aml_method("_EJ0", 1, AML_NOTSERIALIZED); - aml_append(method, - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN")) - ); - aml_append(dev, method); + } =20 - if (bsel) { - build_append_pcihp_notify_entry(notify_method, slot); - } - } else if (bridge_in_acpi) { + bridge_in_acpi =3D cold_plugged_bridge && pcihp_bridge_en; + if (bridge_in_acpi) { /* * device is coldplugged bridge, * add child device descriptions into its scope @@ -538,6 +522,19 @@ static void build_append_pci_bus_devices(Aml *parent_s= cope, PCIBus *bus, =20 build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en); } + + if (hotpluggbale_slot) { + aml_append(dev, aml_name_decl("_SUN", aml_int(slot))); + /* add _EJ0 to make slot hotpluggable */ + method =3D aml_method("_EJ0", 1, AML_NOTSERIALIZED); + aml_append(method, + aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN")) + ); + aml_append(dev, method); + + build_append_pcihp_notify_entry(notify_method, slot); + } + /* device descriptor has been composed, add it into parent context= */ aml_append(parent_scope, dev); } --=20 MST