From patchwork Mon Nov 12 11:15:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 996348 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="IqPtKD+a"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42tp886wfKz9s3q for ; Mon, 12 Nov 2018 22:15:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbeKLVIG (ORCPT ); Mon, 12 Nov 2018 16:08:06 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53729 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728302AbeKLVIG (ORCPT ); Mon, 12 Nov 2018 16:08:06 -0500 Received: by mail-wm1-f68.google.com with SMTP id f10-v6so8053730wme.3 for ; Mon, 12 Nov 2018 03:15:18 -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=EQB9tZHTykcdTERBnFRL0vdG71N1IvLfnOeuvuLo1LM=; b=IqPtKD+aR0Nmkxq4pmR74da6t/BUgMiGI0HLNNiYmCN5x36noDt/1B+QT89mkv+PeX U9X/GBAcqfdWL5BJY79dhwwO23D8JaVDsvgxAhDFTTXzfASAEA9g55HkWr/UlgxtZR4O mCVmw6W3g6svCZHktVlftVYJplstF92luf5xs= 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; bh=EQB9tZHTykcdTERBnFRL0vdG71N1IvLfnOeuvuLo1LM=; b=ebmRllhWBz8pHocX5hHdGIaP26kblrcyq8cU09KE2dpvoDR9D+RlnFKnmvCvROCH2+ Nzsqp/OrOPOy4Jr+p/fzYZgHj4JEbr2AxU/jUGb6glxN7qNWxijY0lIlNXs1w7tI6Y5g xM9Uo4EzZtbgsq+H6L/8scf8LSfoKGZ1n8dWlIJxmAXDz6q2vq3P0Y/Nby3Zd5nr95e7 x6OzZd+QcaPjLH/ZnD3yaHroiWwVMX4QRxI9fQBmoZPdC2LoJZZeOqWgt26ozRNZ1f6U 3sLiqaEhSa+hRwol06coytbOm+XXgS5XAq4tdWkWDxUXu1YGLS3uDFrkw1HgDXzOHjRM IYbA== X-Gm-Message-State: AGRZ1gLFzR99+MRPZPM6CRppIYkGQMLJawPOCfqG+TkGorJLJIzD+YJX jOc6tyMNgn/FfvMd2zCkLBFxkw== X-Google-Smtp-Source: AJdET5cdfWJKW7JVSh/oRw3ZAqI3rcFP/M5/gZO6a37/oalXw9t3iePYNhYr6GLVsOOmbQHq0HDn0w== X-Received: by 2002:a1c:9b4e:: with SMTP id d75-v6mr7851600wme.62.1542021317545; Mon, 12 Nov 2018 03:15:17 -0800 (PST) Received: from localhost.localdomain (237.204.154.77.rev.sfr.net. [77.154.204.237]) by smtp.gmail.com with ESMTPSA id q11-v6sm2923009wrn.45.2018.11.12.03.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 03:15:16 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com, graeme.gregory@linaro.org, nariman.poushin@linaro.org, Ard Biesheuvel Subject: [PATCH] arm64: acpi/pci: WARN() when ignoring _DSM request to preserve PCI resources Date: Mon, 12 Nov 2018 12:15:11 +0100 Message-Id: <20181112111511.12091-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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., CCIX), that the OS will honour the PCI resource allocation as configured by the firmware. ACPI already specifies a device specific ACPI method (_DSM) for PCI root bridge nodes that tells us whether the firmware thinks the configuration should be ignored or preserved, but unfortunately, we cannot simply change the behavior of the OS and start honouring these requests unconditionally, given that firmware implementations in the field may issue the _DSM request inadvertently and still rely on the OS to create the resource allocation from scratch. So as a preliminary step, let's issue a warning about this case, increasing the likelihood that we can fix this behavior at some point in the future. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/pci.c | 15 +++++++++++++++ include/linux/pci-acpi.h | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index bb85e2f4603f..318ca865c41f 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -168,6 +168,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(sizeof(*ri), GFP_KERNEL); if (!ri) @@ -193,6 +194,20 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) if (!bus) return NULL; + /* + * Invoke the PCI device specific method (_DSM) #5 'Ignore PCI Boot + * Configuration', which tells us whether the firmware wants us to + * preserve or ignore the firmware's configuration of the PCI resource + * tree for this root bridge. + */ + obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 1, + IGNORE_PCI_BOOT_CONFIG_DSM, NULL); + if (obj && obj->type == ACPI_TYPE_INTEGER) + WARN_ONCE(obj->integer.value == 0, + "Firmware did not request its PCI resource allocation to be ignored, but ignoring it anyway\n"); + + ACPI_FREE(obj); + pci_bus_size_bridges(bus); pci_bus_assign_resources(bus); diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 8082b612f561..62b7fdcc661c 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -107,9 +107,10 @@ static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { } #endif extern const guid_t pci_acpi_dsm_guid; -#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) { }