From nobody Thu Nov 21 13:36:23 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=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass(p=reject dis=none) header.from=seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1726665067; cv=none; d=zohomail.com; s=zohoarc; b=d+JRbArIWKD4s33fgLox0va7J/EePKADgd4IFnc5108MBa7KFvwGJOpDqB6EqXA8ageha+nch11kbAjsF/P+zCazC2aon03SAW/jHd/1Cid7NF5xh2n4/XqGttXcVj4TeG/wWWSxMYwv+SZdd2emAInszN2ywuBFZGTt1LciaNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726665067; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=2S9aNP3IISDhBCWHxOswFGqS32aW4QHocnbcogQnKLw=; b=XbDEQxbi8+HUel1sYMdsHGDRTXXqzd02Xrdlfyl/aKOBObfCjSH/CacyTT4HvplPvLGqlamfdboVZ32CoqMQCMG/SiOEvrT1Jtz3XBI6sTD3+yok0kmoT+V9Hvo7IPnFxDctMWip1r1DQfoFnwn4bXtyIkyrnc9Sgt5zkLgR3jA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1726665067696501.3635750664457; Wed, 18 Sep 2024 06:11:07 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id E55CFE370E; Wed, 18 Sep 2024 13:11:02 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 56125E1329 for ; Wed, 18 Sep 2024 13:10:27 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2024 13:10:19 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.8.19:2525] with esmtp (Farcaster) id 5e5d6b68-fa55-4e56-9521-cfa9e4a4be70; Wed, 18 Sep 2024 13:10:18 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX19MTAEUC001.ant.amazon.com (10.252.51.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Wed, 18 Sep 2024 13:10:17 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX19D033EUB003.ant.amazon.com (10.252.61.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Wed, 18 Sep 2024 13:10:17 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (10.43.8.2) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34 via Frontend Transport; Wed, 18 Sep 2024 13:10:17 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by email-imr-corp-prod-pdx-all-2c-8a67eb17.us-west-2.amazon.com (Postfix) with ESMTPS id B224A40487; Wed, 18 Sep 2024 13:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seabios.org; s=dkim; t=1726665064; h=from:from:sender:reply-to: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:list-id:list-owner: list-unsubscribe:list-subscribe:list-post; bh=2S9aNP3IISDhBCWHxOswFGqS32aW4QHocnbcogQnKLw=; b=wBPgITA05qfXY0eidZmeP9ahRnE64s6cJojf7E0iI2MH9PCACMIzvb4g9XnnMpRXSVnupj dCjhY+vKgHR9lmnY2fj47VNbH86BC379W8+A3WM+nXS+OJ3Pq87C7G2oBhLJu/B6uEwodD 2pO5v/+MwipfJvN6A9sqvmhuBX41hcY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1726665028; x=1758201028; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J/eucn749vH+hqPKONb1sYQ0ecrMmDPYEtHc0qQZNO0=; b=oxAK5mO+hqkOHLWjV7KPV3YhhjBem2kYhY7tsNI/6a+C7OI9oyQqs8EV HH9r0JAAF+r2yxK790Hdck1Gh53HV4Th2IY4nYZP8AGRKdTLnQF8PSyCD xc7en5vUk8V2kPs7tb+onmsM1S6KbqQJqlurJAMbyFjljyen4Lwi18/ft o=; X-IronPort-AV: E=Sophos;i="6.10,238,1719878400"; d="scan'208";a="368859497" X-Farcaster-Flow-ID: 5e5d6b68-fa55-4e56-9521-cfa9e4a4be70 To: Date: Wed, 18 Sep 2024 13:09:59 +0000 Message-ID: <20240918131000.55955-2-sainiabr@amazon.de> In-Reply-To: <20240918131000.55955-1-sainiabr@amazon.de> References: <20240918131000.55955-1-sainiabr@amazon.de> MIME-Version: 1.0 Message-ID-Hash: X232VCZI7ILNSRWKTZW4QKX43SFECL3Y X-Message-ID-Hash: X232VCZI7ILNSRWKTZW4QKX43SFECL3Y X-MailFrom: prvs=984d2d70c=sainiabr@amazon.de 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: nh-open-source@amazon.com, rkagan@amazon.de, kraxel@redhat.com, Abhimanyu Saini X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH 1/2] fw/pciinit: factor out pci resource allocation List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Abhimanyu Saini via SeaBIOS Reply-To: Abhimanyu Saini 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: pass (identity @seabios.org) X-ZM-MESSAGEID: 1726665068213116600 Content-Type: text/plain; charset="utf-8" Factor out PCI resource allocation code to a separate function. This makes it easier to follow, and paves the way to support skipping this step when instructed by the platform (in a followup patch). While at it, fix the leak of *busses in case pci_bios_check_devices fails. Signed-off-by: Abhimanyu Saini --- src/fw/pciinit.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index b3e359d7..334fd30c 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -1174,6 +1174,26 @@ static void pci_bios_map_devices(struct pci_bus *bus= ses) } } =20 +static void pci_allocate_resources(void) +{ + struct pci_bus *busses; + + dprintf(1, "=3D=3D=3D PCI new allocation pass #1 =3D=3D=3D\n"); + busses =3D malloc_tmp(sizeof(*busses) * (MaxPCIBus + 1)); + if (!busses) { + warn_noalloc(); + return; + } + memset(busses, 0, sizeof(*busses) * (MaxPCIBus + 1)); + if (pci_bios_check_devices(busses)) + goto cleanup; + + dprintf(1, "=3D=3D=3D PCI new allocation pass #2 =3D=3D=3D\n"); + pci_bios_map_devices(busses); + +cleanup: + free(busses); +} =20 /**************************************************************** * Main setup code @@ -1217,22 +1237,9 @@ pci_setup(void) pcimem_start =3D RamSize; pci_bios_init_platform(); =20 - dprintf(1, "=3D=3D=3D PCI new allocation pass #1 =3D=3D=3D\n"); - struct pci_bus *busses =3D malloc_tmp(sizeof(*busses) * (MaxPCIBus + 1= )); - if (!busses) { - warn_noalloc(); - return; - } - memset(busses, 0, sizeof(*busses) * (MaxPCIBus + 1)); - if (pci_bios_check_devices(busses)) - return; - - dprintf(1, "=3D=3D=3D PCI new allocation pass #2 =3D=3D=3D\n"); - pci_bios_map_devices(busses); + pci_allocate_resources(); =20 pci_bios_init_devices(); =20 - free(busses); - pci_enable_default_vga(); } --=20 2.40.1 Amazon Web Services Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Thu Nov 21 13:36:23 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=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass(p=reject dis=none) header.from=seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1726665054; cv=none; d=zohomail.com; s=zohoarc; b=jqub93YRPMQnGs7wKLpe4kLN7OqObzLe7/jjxDde3Csq92SHkcWoqk5vxaVVsXSeeiPIR2dEY2Cwuvj32I0CZXurG73DfGd7gVoYifJ96jYrpkwaSYfyBy/DcuojBIzbS0/FXnZ69kygLWSGqVSVaBriozzR+lUOjVPWrapxg64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726665054; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=rRD7vxeKecIBvU8XSZqg1oVlebnVLP5iX7cGxrNLoSg=; b=ZrGPV8jUqcVSfpvoeNBpEltmu6eIrzR46HD/vA/4THLGBeW0uudMxbkyTh3ydxp/Bb+Y6NMbPxfqDa44k7okycWVxgAc+/LngikqZimVF+iszz/UkL+TZkrWfguUpjxDzt+NaaHivZ0GPgY7Lh2/4nQRDgcUydVWFdsFHTDB/Mw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1726665054040820.22650271822; Wed, 18 Sep 2024 06:10:54 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 3B658E29B9; Wed, 18 Sep 2024 13:10:49 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 982A8E0E86 for ; Wed, 18 Sep 2024 13:10:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2024 13:10:20 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.16.194:2525] with esmtp (Farcaster) id 6206f1d9-5fe6-4d1d-ab39-5a2e72877780; Wed, 18 Sep 2024 13:10:19 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX19MTAEUC001.ant.amazon.com (10.252.51.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Wed, 18 Sep 2024 13:10:19 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) EX19D019EUA003.ant.amazon.com (10.252.50.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Wed, 18 Sep 2024 13:10:19 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (10.43.8.2) by mail-relay.amazon.com (10.252.134.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34 via Frontend Transport; Wed, 18 Sep 2024 13:10:18 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by email-imr-corp-prod-pdx-all-2c-8a67eb17.us-west-2.amazon.com (Postfix) with ESMTPS id 75E0440498; Wed, 18 Sep 2024 13:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seabios.org; s=dkim; t=1726665050; h=from:from:sender:reply-to: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:list-id:list-owner: list-unsubscribe:list-subscribe:list-post; bh=rRD7vxeKecIBvU8XSZqg1oVlebnVLP5iX7cGxrNLoSg=; b=kgpEKVRFqMI0alb7OGNp/8xkkYFt6enHH9neOQdbBnCDkly+r0ggAuYe+UFs5VcaYFyd1b 8ZEhcy/HikukiVQooAJ8V3wSh1UOgkGNGlKfKPzDow0mBLe1pzliDorC+PCUQ9FilDVVBJ z6DZdgY3o0L1ratDYlNxk4dESqb7bwo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1726665021; x=1758201021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wI+Ai/Gb9czXffBmE0ml2s6sQAbu+rzgQO1eB2MXZS0=; b=tqhk/XdKfrXdLjDtJ1xgIEskE53u3+mogDh9be1K5t85TfDZSheBEHt8 n74FsHXxZNtzUH8JpZGAjspimt26onTlgfS9unwqJGTcDeS8ZMVH0IRbX TujqDtcjjvXcAS7g79muHdQXhpArf6nzuEtDEUFKOStj/xXKyqcj64Sun 4=; X-IronPort-AV: E=Sophos;i="6.10,238,1719878400"; d="scan'208";a="434269222" X-Farcaster-Flow-ID: 6206f1d9-5fe6-4d1d-ab39-5a2e72877780 To: Date: Wed, 18 Sep 2024 13:10:00 +0000 Message-ID: <20240918131000.55955-3-sainiabr@amazon.de> In-Reply-To: <20240918131000.55955-1-sainiabr@amazon.de> References: <20240918131000.55955-1-sainiabr@amazon.de> MIME-Version: 1.0 Message-ID-Hash: CMJAXEFJ2ZKETO533OYJJU2CIKMEL2AI X-Message-ID-Hash: CMJAXEFJ2ZKETO533OYJJU2CIKMEL2AI X-MailFrom: prvs=984d2d70c=sainiabr@amazon.de 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: nh-open-source@amazon.com, rkagan@amazon.de, kraxel@redhat.com, Abhimanyu Saini X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] [PATCH 2/2] pci: skip pci resource allocation if instructed by platform List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Abhimanyu Saini via SeaBIOS Reply-To: Abhimanyu Saini 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: pass (identity @seabios.org) X-ZM-MESSAGEID: 1726665056131116600 Content-Type: text/plain; charset="utf-8" A hypervisor may want to perform PCI resource allocation (bus numbers, io and mmio ranges) and program the resulting values into the devices itself rather than delegate this to the firmware. One possible reason for doing so is more control for the hypervisor over assigned ranges. This will also be faster than entering the guest and then trapping on config space accesses. Introduce a new flag in fw_cfg, "etc/pci-noalloc", to instruct the firmware to skip the resource allocation phase and use whatever is already programmed in the devices. Signed-off-by: Abhimanyu Saini --- src/fw/pciinit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index 334fd30c..e1c05410 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -1176,8 +1176,13 @@ static void pci_bios_map_devices(struct pci_bus *bus= ses) =20 static void pci_allocate_resources(void) { + u64 noalloc; struct pci_bus *busses; =20 + noalloc =3D romfile_loadint("etc/pci-noalloc", 0); + if (noalloc) + return; + dprintf(1, "=3D=3D=3D PCI new allocation pass #1 =3D=3D=3D\n"); busses =3D malloc_tmp(sizeof(*busses) * (MaxPCIBus + 1)); if (!busses) { --=20 2.40.1 Amazon Web Services Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org