From patchwork Tue Apr 11 16:33:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9675707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C5FC600CB for ; Tue, 11 Apr 2017 16:34:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BD072858A for ; Tue, 11 Apr 2017 16:34:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C2D1285A0; Tue, 11 Apr 2017 16:34:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84C132858A for ; Tue, 11 Apr 2017 16:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=sedNXL7tmNessVb/ED7Fn01stH1B1Blk2qB988xFhYs=; b=q8tMMc7tpQHaZrWYGR0fY0REg/ elbmYKf8hPgk4lMHJ7yjRISjzroq+6cZV5UfGAEI/2aW2U865uEo6ieDchoGA5H7N4KcCC26yKI34 Z9F00n7vmO+YyhJgpxiiUzUd0Iyq0lFxuTdG2uqB5movlAmY24P+MDm86NxslQRT9N7kxV3MMJsTf CjuSwewVSxpbkV+8KDx/wFH4Rmkk3tPrQ6akmYn72rQQl2pXHkiOCnKLwlRmqLfZbg4MVaRmdHGWI bS5iWMgRSgSS0xrciQ4lSNJjOXJscrs+qKt5GQ/+WiPv7VK0MtBK3TZHK7O5gIGcFu5comPf5W7po G7riFYJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cxyk1-0005Xb-94; Tue, 11 Apr 2017 16:34:05 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cxyjj-00053T-Ku for linux-arm-kernel@lists.infradead.org; Tue, 11 Apr 2017 16:33:49 +0000 Received: by mail-wm0-x234.google.com with SMTP id u2so5174669wmu.0 for ; Tue, 11 Apr 2017 09:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xzIdjA+HY/IFbyr8wEAxu7hStIluQlpDGYSdBaw5GUg=; b=iWoSqEUzmwXZepSmh2dYjnf476PFUrpTl6kcFe6XtmEEd/e6VCmwXTjkGue/wUWU0a fbKUKTRNqNzUSjYc8U47ajnnFaPiHyGQE6zX62HDX7UfoMJPmIcfi8HVN91BRj8OGOyK 9TlVIzMhJZZvqXGrh7LEVqNtZeqODdfBeVFlU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xzIdjA+HY/IFbyr8wEAxu7hStIluQlpDGYSdBaw5GUg=; b=oYeQIU5GGIGgha+CD/GE1LGpEU9HKdxlmo9LeDVYjqXYuA3CZA6eltayoejoD+6mp1 U58XObtbl3wGQIwYtgXV4FMqT0cHcfWrfcip/7+vtaIlDlsms/N6NVim36ESQO1LHY23 xdy3UNoGdlj4NQPmn3G0SnP6nD1I+eQwdY44cxqOE6FnZpNqAUi/8CGG1w6g7azVt5A4 WrgvghaTnOsIuQQrI3LDGV2vCqelQByN6ypm6gSvxPCd2woPBtZAgp2bozObfW5Y4PJL t5sO9SWr7CuRJYICEKyl/yV0AeF+hVxELYqkhsg7X41IZUvivMZaEISerR2snnCGKg/p PgJg== X-Gm-Message-State: AN3rC/4LImw20Kj1cBmr2bCDpHjMN40M+iiLBvwwBGjVjUl2k2kBD1n/IjJmffXUqNM72Oiq X-Received: by 10.28.35.207 with SMTP id j198mr13567333wmj.17.1491928405873; Tue, 11 Apr 2017 09:33:25 -0700 (PDT) Received: from localhost.localdomain ([196.85.182.219]) by smtp.gmail.com with ESMTPSA id u145sm3125556wmu.1.2017.04.11.09.33.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 09:33:25 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH 2/2] arm64: acpi/pci: invoke _DSM whether to preserve firmware PCI setup Date: Tue, 11 Apr 2017 17:33:13 +0100 Message-Id: <20170411163313.18577-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170411163313.18577-1-ard.biesheuvel@linaro.org> References: <20170411163313.18577-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170411_093347_884447_7F38A0ED X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, graeme.gregory@linaro.org, Ard Biesheuvel , catalin.marinas@arm.com, will.deacon@arm.com, leif.lindholm@linaro.org, okaya@codeaurora.org, tn@semihalf.com, bhelgaas@google.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On arm64 ACPI systems, we unconditionally reconfigure the entire PCI hierarchy at boot. This is a departure from what is customary on ACPI systems, and may break assumptions in some places (e.g., EFIFB), that the kernel will leave BARs of enabled PCI devices where they are. Given that PCI already specifies a device specific ACPI method (_DSM) for PCI root bridge nodes that tells us whether the firmware thinks the configuration should be left alone, let's sidestep the entire policy debate about whether the PCI configuration should be preserved or not, and put it under the control of the firmware instead. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/pci.c | 20 ++++++++++++++++++-- include/linux/pci-acpi.h | 7 ++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 4f0e3ebfea4b..c88e07e2eb84 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -185,6 +185,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) struct acpi_pci_generic_root_info *ri; struct pci_bus *bus, *child; struct acpi_pci_root_ops *root_ops; + union acpi_object *obj; ri = kzalloc_node(sizeof(*ri), GFP_KERNEL, node); if (!ri) @@ -208,8 +209,23 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) if (!bus) return NULL; - pci_bus_size_bridges(bus); - pci_bus_assign_resources(bus); + /* + * Invoke the PCI device specific method (_DSM) #5 'Ignore PCI Boot + * Configuration', which tells us whether the firmware wants us to + * preserve the configuration of the PCI resource tree for this root + * bridge. + */ + obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), pci_acpi_dsm_uuid, 1, + IGNORE_PCI_BOOT_CONFIG_DSM, NULL); + if (obj && obj->type == ACPI_TYPE_INTEGER && obj->integer.value == 0) { + /* preserve existing resource assignment */ + pci_bus_claim_resources(bus); + } else { + /* reconfigure the resource tree from scratch */ + pci_bus_size_bridges(bus); + pci_bus_assign_resources(bus); + } + ACPI_FREE(obj); list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 7a4e83a8c89c..308111489b83 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -106,9 +106,10 @@ static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { } #endif extern const u8 pci_acpi_dsm_uuid[]; -#define DEVICE_LABEL_DSM 0x07 -#define RESET_DELAY_DSM 0x08 -#define FUNCTION_DELAY_DSM 0x09 +#define IGNORE_PCI_BOOT_CONFIG_DSM 0x05 +#define DEVICE_LABEL_DSM 0x07 +#define RESET_DELAY_DSM 0x08 +#define FUNCTION_DELAY_DSM 0x09 #else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus(struct pci_bus *bus) { }