From nobody Mon Sep 16 19:19:15 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