From nobody Fri Mar 29 01:43:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1638186536635676.8353711801868; Mon, 29 Nov 2021 03:48:56 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id F40BB16E3DD4; Mon, 29 Nov 2021 11:48:52 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 68EDD16E36D5 for ; Mon, 29 Nov 2021 11:48:38 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-426-E19t2-YEMkq8CtwmVSepkg-1; Mon, 29 Nov 2021 06:48:35 -0500 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED44D81CCB5; Mon, 29 Nov 2021 11:48:34 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A9F960BF1; Mon, 29 Nov 2021 11:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638186517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Af+HaoE2vDG4ada+VZ/5Ku5lt8TOFGmcAB95hAs2OW8=; b=QWpBgfa/K0GRj3z1K7dyu8mA47Oj3SMPUDNdg/Zns1knD6RYqJXnvxZi0F9V/kgRAd1oa1 o6Km+Lg6aB3CNcUdLGFfPfXdIpS+A0qcR96NptTf3xcmEX3eIVFfbjuVIHsIcJE8n0AM0Q clRCmzW1xrnwXETMBC/lK29AKlHHOyY= X-MC-Unique: E19t2-YEMkq8CtwmVSepkg-1 From: Igor Mammedov To: seabios@seabios.org Date: Mon, 29 Nov 2021 06:48:11 -0500 Message-Id: <20211129114812.231849-2-imammedo@redhat.com> In-Reply-To: <20211129114812.231849-1-imammedo@redhat.com> References: <20211129114812.231849-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: KKKLT6IFD5ZVLG3LAFVJLXRLKHNW2NCL X-Message-ID-Hash: KKKLT6IFD5ZVLG3LAFVJLXRLKHNW2NCL X-MailFrom: imammedo@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pmenzel@molgen.mpg.de, mapfelba@redhat.com, kraxel@redhat.com, mst@redhat.com, lvivier@redhat.com, jusual@redhat.com X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCH v3 1/2] pci: reserve resources for pcie-pci-bridge to fix regressed hotplug on q35 List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ----- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638186538577100001 Content-Type: text/plain; charset="utf-8" If QEMU is started with unpopulated pcie-pci-bridge with ACPI PCI hotplug enabled (default since QEMU-6.1), hotplugging a PCI device into one of the bridge slots fails due to lack of resources. once linux guest is booted (test used Fedora 34), hotplug NIC from QEMU monitor: (qemu) device_add rtl8139,bus=3Dpcie-pci-bridge-0,addr=3D0x2 guest fails hotplug with: pci 0000:01:02.0: [10ec:8139] type 00 class 0x020000 pci 0000:01:02.0: reg 0x10: [io 0x0000-0x00ff] pci 0000:01:02.0: reg 0x14: [mem 0x00000000-0x000000ff] pci 0000:01:02.0: reg 0x30: [mem 0x00000000-0x0003ffff pref] pci 0000:01:02.0: BAR 6: no space for [mem size 0x00040000 pref] pci 0000:01:02.0: BAR 6: failed to assign [mem size 0x00040000 pref] pci 0000:01:02.0: BAR 0: no space for [io size 0x0100] pci 0000:01:02.0: BAR 0: failed to assign [io size 0x0100] pci 0000:01:02.0: BAR 1: no space for [mem size 0x00000100] pci 0000:01:02.0: BAR 1: failed to assign [mem size 0x00000100] 8139cp: 8139cp: 10/100 PCI Ethernet driver v1.3 (Mar 22, 2004) PCI Interrupt Link [GSIG] enabled at IRQ 22 8139cp 0000:01:02.0: no MMIO resource 8139cp: probe of 0000:01:02.0 failed with error -5 Reason for this is that commit [1] didn't take into account pcie-pci-bridge, marking bridge as non hotpluggable instead of handling it as possibly SHPC capable bridge. Fix issue by checking if pcie-pci-bridge is SHPC capable and if it is mark it as hotpluggable. Fixes regression in QEMU-6.1 and later, since it was switched to ACPI based PCI hotplug on Q35 by default at that time. RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=3D2001732 [1] Fixes: 3aa31d7d637 ("hw/pci: reserve IO and mem for pci express downstream = ports with no devices attached") Signed-off-by: Igor Mammedov imammedo@redhat.com CC: mapfelba@redhat.com CC: kraxel@redhat.com CC: mst@redhat.com CC: lvivier@redhat.com CC: jusual@redhat.com Acked-by: Michael S. Tsirkin Tested-by: Laurent Vivier --- src/fw/pciinit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index d25931bb..7342d8d8 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -802,6 +802,10 @@ static int pci_bus_hotplug_support(struct pci_bus *bus= , u8 pcie_cap) pcie_cap + PCI_EXP_FLAGS); u8 port_type =3D ((pcie_flags & PCI_EXP_FLAGS_TYPE) >> (__builtin_ffs(PCI_EXP_FLAGS_TYPE) - 1)); + + if (port_type =3D=3D PCI_EXP_TYPE_PCI_BRIDGE) + goto check_shpc; + u8 downstream_port =3D (port_type =3D=3D PCI_EXP_TYPE_DOWNSTREAM) = || (port_type =3D=3D PCI_EXP_TYPE_ROOT_PORT); /* @@ -818,6 +822,7 @@ static int pci_bus_hotplug_support(struct pci_bus *bus,= u8 pcie_cap) return downstream_port && slot_implemented; } =20 +check_shpc: shpc_cap =3D pci_find_capability(bus->bus_dev->bdf, PCI_CAP_ID_SHPC, 0= ); return !!shpc_cap; } --=20 2.27.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Mar 29 01:43:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1638186564445116.73167078143922; Mon, 29 Nov 2021 03:49:24 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id F223C16E3DDC; Mon, 29 Nov 2021 11:49:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 8EC0B16E3DD7 for ; Mon, 29 Nov 2021 11:49:08 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-560-PuvviMuaOQmboFFVde_WUQ-1; Mon, 29 Nov 2021 06:49:06 -0500 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A92C19253C2; Mon, 29 Nov 2021 11:49:05 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CF0B60BF1; Mon, 29 Nov 2021 11:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638186547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cq+H20B0B6bPQ3DZ60IN0HJPVgEDX6wFHRspPBNX/ow=; b=W4mEk0iKKiMq8bEcubl5mLeZ5LMK+QgjRN2myTVPJiDEuR3cyL27uKa/i6zTxrflFLTNUo JngWWYPBEt0MEVouQqcMvbED0GCJAR3Bd/RqexGTP7RgePZAInE60hvfh8XSIBPGfRZsyU f3aeMmAmGTBaf0AjCNiW5NU4XAmCIx8= X-MC-Unique: PuvviMuaOQmboFFVde_WUQ-1 From: Igor Mammedov To: seabios@seabios.org Date: Mon, 29 Nov 2021 06:48:12 -0500 Message-Id: <20211129114812.231849-3-imammedo@redhat.com> In-Reply-To: <20211129114812.231849-1-imammedo@redhat.com> References: <20211129114812.231849-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: RQVWXS6UIESMJGB4CQD22E3FMG5TGNRB X-Message-ID-Hash: RQVWXS6UIESMJGB4CQD22E3FMG5TGNRB X-MailFrom: imammedo@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pmenzel@molgen.mpg.de, mapfelba@redhat.com, kraxel@redhat.com, mst@redhat.com, lvivier@redhat.com, jusual@redhat.com X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCH v3 2/2] pci: let firmware reserve IO for pcie-pci-bridge List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: ----- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638186566170100001 Content-Type: text/plain; charset="utf-8" With [1] patch hotplug of rtl8139 succeeds, with caveat that it fails to initialize IO bar, which is caused by [2] that makes firmware skip IO reservation for any PCIe device, which isn't correct in case of pcie-pci-bridge. Fix it by exposing hotplug type and making IO resource optional only if PCIe hotplug is in use. [1] "pci: reserve resources for pcie-pci-bridge to fix regressed hotplug on q3= 5" [2] Fixes: 76327b9f32a ("fw/pci: do not automatically allocate IO region for PC= Ie bridges") Signed-off-by: Igor Mammedov imammedo@redhat.com CC: mapfelba@redhat.com CC: kraxel@redhat.com CC: mst@redhat.com CC: lvivier@redhat.com CC: jusual@redhat.com Acked-by: Michael S. Tsirkin Tested-by: Laurent Vivier --- src/fw/pciinit.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 7342d8d8..badf13d3 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -793,7 +793,13 @@ pci_region_create_entry(struct pci_bus *bus, struct pc= i_device *dev, return entry; } =20 -static int pci_bus_hotplug_support(struct pci_bus *bus, u8 pcie_cap) +typedef enum hotplug_type_t { + HOTPLUG_NO_SUPPORTED =3D 0, + HOTPLUG_PCIE, + HOTPLUG_SHPC +} hotplug_type_t; + +static hotplug_type_t pci_bus_hotplug_support(struct pci_bus *bus, u8 pcie= _cap) { u8 shpc_cap; =20 @@ -819,12 +825,13 @@ static int pci_bus_hotplug_support(struct pci_bus *bu= s, u8 pcie_cap) */ u16 slot_implemented =3D pcie_flags & PCI_EXP_FLAGS_SLOT; =20 - return downstream_port && slot_implemented; + return downstream_port && slot_implemented ? + HOTPLUG_PCIE : HOTPLUG_NO_SUPPORTED; } =20 check_shpc: shpc_cap =3D pci_find_capability(bus->bus_dev->bdf, PCI_CAP_ID_SHPC, 0= ); - return !!shpc_cap; + return !!shpc_cap ? HOTPLUG_SHPC : HOTPLUG_NO_SUPPORTED; } =20 /* Test whether bridge support forwarding of transactions @@ -909,7 +916,7 @@ static int pci_bios_check_devices(struct pci_bus *busse= s) u8 pcie_cap =3D pci_find_capability(bdf, PCI_CAP_ID_EXP, 0); u8 qemu_cap =3D pci_find_resource_reserve_capability(bdf); =20 - int hotplug_support =3D pci_bus_hotplug_support(s, pcie_cap); + hotplug_type_t hotplug_support =3D pci_bus_hotplug_support(s, pcie= _cap); for (type =3D 0; type < PCI_REGION_TYPE_COUNT; type++) { u64 align =3D (type =3D=3D PCI_REGION_TYPE_IO) ? PCI_BRIDGE_IO_MIN : PCI_BRIDGE_MEM_MIN; @@ -953,7 +960,9 @@ static int pci_bios_check_devices(struct pci_bus *busse= s) if (pci_region_align(&s->r[type]) > align) align =3D pci_region_align(&s->r[type]); u64 sum =3D pci_region_sum(&s->r[type]); - int resource_optional =3D pcie_cap && (type =3D=3D PCI_REGION_= TYPE_IO); + int resource_optional =3D 0; + if (hotplug_support =3D=3D HOTPLUG_PCIE) + resource_optional =3D pcie_cap && (type =3D=3D PCI_REGION_= TYPE_IO); if (!sum && hotplug_support && !resource_optional) sum =3D align; /* reserve min size for hot-plug */ if (size > sum) { --=20 2.27.0 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org