From patchwork Fri Mar 11 12:19:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63754 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp999152lbc; Fri, 11 Mar 2016 04:19:46 -0800 (PST) X-Received: by 10.66.124.130 with SMTP id mi2mr14610852pab.106.1457698784586; Fri, 11 Mar 2016 04:19:44 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 132si13483954pfa.13.2016.03.11.04.19.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Mar 2016 04:19:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 520A81A1F75; Fri, 11 Mar 2016 04:19:59 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-pa0-x236.google.com (mail-pa0-x236.google.com [IPv6:2607:f8b0:400e:c03::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 623E51A1F74 for ; Fri, 11 Mar 2016 04:19:58 -0800 (PST) Received: by mail-pa0-x236.google.com with SMTP id fe3so80412978pab.1 for ; Fri, 11 Mar 2016 04:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=wV+A5lxD5fyLkpZY1T4mttjdqDAkqhFVdclzyqg2bNI=; b=aWgUY0kflyEfmRwtFJTuU1+8WsCcD/heLR3xehi8csJdcUAvWM+tI1Wmp+ZB03Gz3P wAlGjXijafB6MEG90mOaOx/kZh+GzyXL1LPobW7/vlYvRd5Ep8I2x8Xx/72IIelnWA93 uvWEZo2YjBXQpDNPajrCz4buhnKUZ8NhQFN1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wV+A5lxD5fyLkpZY1T4mttjdqDAkqhFVdclzyqg2bNI=; b=Sqlsucdj2eotgPm9KWdJaCDC6gx0Uaozt9FE+/93sGjLKiS+ULWlY56vwu6HaZFhtE z5xXQj2sEk8DPGsp/Ypd/wl6BLQwswPtIDVpXEvfZuNw6lsKmirdyDMmN2lKfkiLA8Bk /i9QXV9LIxa4dn6xDLyyb+7IeU3JVcjN8AU+SUGMACF9/kXqPMSsWXkipDD2aP5xCqMg FZ3CC+RzMKZYtAoOfPFRyI+ALWFmXYAHMSUzNfZaBNJHUbkr6w0hJ7ySuJ+sIZVZKPhP 0BtkQk1WZkSYdy1XywTvk/yJFfM2XBR9maLaHv2a5HhR1nhV7Z9939q72MTi73SmvK3i M/kg== X-Gm-Message-State: AD7BkJIqzHYKXBoKF7+TxyZNmKxDhg3nQ9oAUq6X+dw3dJGVCNS4A97+gXBb5a8cZVpl8kKB X-Received: by 10.66.142.132 with SMTP id rw4mr14368297pab.26.1457698782527; Fri, 11 Mar 2016 04:19:42 -0800 (PST) Received: from localhost.localdomain ([1.46.97.136]) by smtp.gmail.com with ESMTPSA id p75sm12673783pfi.29.2016.03.11.04.19.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Mar 2016 04:19:41 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Fri, 11 Mar 2016 19:19:33 +0700 Message-Id: <1457698773-26840-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 Cc: Ard Biesheuvel Subject: [edk2] [PATCH v2] ArmVirtPkg/VirtFdtDxe: set /chosen/linux, pci-probe-only to 1 in DTB X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Unlike Linux on x86, which typically honors the PCI configuration performed by the firmware, Linux on ARM assumes that the PCI subsystem needs to be configured from scratch. This is not entirely unreasonable given the historical background of embedded systems using very basic bootloaders, but is no longer tenable with Linux on arm64 moving to UEFI and ACPI in the server space. For this reason, PCI support in the arm64 kernel running under ACPI is likely to move to the x86 model of honoring the PCI configuration done by the firmware. So let's align with that in our DT based configuration as well, and set the /chosen/linux,pci-probe-only property to 1 in the Device Tree before we hand it to the OS. In case we are exposing an emulated VGA PCI device to the guest, which may subsequently get exposed via the Graphics Output protocol and driven as an efifb by the OS, this ensures the PCI resource allocations for the framebuffer are not overridden, since that would cause the framebuffer to stop working. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c index 74f80d1d2b78..4e4989751455 100644 --- a/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c @@ -304,6 +304,7 @@ InitializeVirtFdtDxe ( UINT64 FwCfgDataSize; UINT64 FwCfgDmaAddress; UINT64 FwCfgDmaSize; + BOOLEAN HavePci; Hob = GetFirstGuidHob(&gFdtHobGuid); if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64)) { @@ -322,6 +323,7 @@ InitializeVirtFdtDxe ( DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, DeviceTreeBase)); RtcNode = -1; + HavePci = FALSE; // // Now enumerate the nodes and install peripherals that we are interested in, // i.e., GIC, RTC and virtio MMIO nodes @@ -356,8 +358,8 @@ InitializeVirtFdtDxe ( ASSERT (Len == 2 * sizeof (UINT64)); Status = ProcessPciHost (DeviceTreeBase, Node, RegProp); ASSERT_EFI_ERROR (Status); + HavePci = TRUE; break; - case PropertyTypeFwCfg: ASSERT (Len == 2 * sizeof (UINT64)); @@ -579,5 +581,28 @@ InitializeVirtFdtDxe ( "disabled") != 0) { DEBUG ((EFI_D_WARN, "Failed to set PL031 status to 'disabled'\n")); } + + if (HavePci) { + // + // Set the /chosen/linux,pci-probe-only property to 1, so that the PCI + // setup we will perform in the firmware is honored by the Linux OS, + // rather than torn down and done from scratch. This is generally a more + // sensible approach, and aligns with what ACPI based OSes do in general. + // + // In case we are exposing an emulated VGA PCI device to the guest, which + // may subsequently get exposed via the Graphics Output protocol and + // driven as an efifb by Linux, we need this setting to prevent the + // framebuffer from becoming unresponsive. + // + Node = fdt_path_offset (DeviceTreeBase, "/chosen"); + if (Node < 0) { + Node = fdt_add_subnode (DeviceTreeBase, 0, "/chosen"); + } + if (Node < 0 || + fdt_setprop_u32 (DeviceTreeBase, Node, "linux,pci-probe-only", 1) < 0) { + DEBUG ((EFI_D_WARN, "Failed to set /chosen/linux,pci-probe-only property")); + } + } + return EFI_SUCCESS; }