From patchwork Wed Sep 8 07:02:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuesong Chen X-Patchwork-Id: 12480321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 309F1C433EF for ; Wed, 8 Sep 2021 07:05:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED4CA61100 for ; Wed, 8 Sep 2021 07:05:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ED4CA61100 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=wA/uRvkBNOFqh3nweyefffKi9sMaKHJ2+zbsUV7Z4qU=; b=zjX W0yBEOrKwBuEcHfpXYzpF6i0kQCbObOB7zZfGzQgt6b3HhKAGS1bfkS8KdPMXQ8BPQW+sawDMhVi+ Tx2w0L1HKmgSj8VPnyFz03EtQRzUaUjnm9UBUvl3+BIaTvlmbQMDrll8VQOxNst5Q9uJkBlkBk//v bX0DXL+vyPrGrzfP7VLKHgJ6TW1EOeUj+DkXGi5J2fzXfjvhJ2Qt4obrgtgmQaE8g+GZIhI5Cq9dR IPmR8pz9fuwU7JGPmME9OLNCLCRs+ICZhChwWHJedWIneBYK+EyOxJxpreYTwU8ZEbYRfJBqLZuXt LeldOaOUsUG4H1IICHhE5OsZ5HIrOhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNrbx-005iM1-VI; Wed, 08 Sep 2021 07:03:10 +0000 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNrbn-005iJP-OJ for linux-arm-kernel@lists.infradead.org; Wed, 08 Sep 2021 07:03:01 +0000 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R541e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04394; MF=xuesong.chen@linux.alibaba.com; NM=1; PH=DS; RN=7; SR=0; TI=SMTPD_---0UnfsSzn_1631084573; Received: from localhost(mailfrom:xuesong.chen@linux.alibaba.com fp:SMTPD_---0UnfsSzn_1631084573) by smtp.aliyun-inc.com(127.0.0.1); Wed, 08 Sep 2021 15:02:54 +0800 Date: Wed, 8 Sep 2021 15:02:53 +0800 From: Xuesong Chen To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, steve.capper@arm.com, lorenzo.pieralisi@arm.com, mark.rutland@arm.com, xuesong.chen@linux.alibaba.com Subject: [PATCH] arm64/apei: Filter the apei GAS address from the ECAM space Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_000300_041215_057A51BD X-CRM114-Status: GOOD ( 14.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Xuesong Chen Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ECAM configuration memory space is reserved during the initializaion of the kernel, but sometimes the apei needs to access the GAS address within the ECAM space, thus the request_mem_region(...) will be failed in this case, the error message looks like: ... APEI: Can not request [mem 0x50100000-0x50100003] for APEI EINJ Trigger registers ... This patch provides an arm64 specific filter function to remove the GAS address range from the reserved ECAM resource regions, which will make the apei's GAS address can pass the check while not affecting the original reserved ECAM area. Signed-off-by: Xuesong Chen Cc: Catalin Marinas Cc: Will Deacon Cc: Steve Capper Cc: Lorenzo Pieralisi Cc: Mark Rutland --- arch/arm64/kernel/pci.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 1006ed2..6096165 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -19,6 +19,13 @@ #include #ifdef CONFIG_ACPI +struct pci_mcfg_res_region { + struct list_head list; + struct resource res; +}; + +static LIST_HEAD(pci_mcfg_res_list); +static DEFINE_MUTEX(pci_mcfg_lock); /* * Try to assign the IRQ number when probing a new device */ @@ -107,6 +114,58 @@ static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) return status; } +#ifdef CONFIG_ACPI_APEI +extern int (*arch_apei_filter_addr)(int (*func)(__u64 start, __u64 size, + void *data), void *data); + +static int pci_mcfg_for_each_region(int (*func)(__u64 start, __u64 size, + void *data), void *data) +{ + struct pci_mcfg_res_region *e; + int rc = 0; + + if (list_empty(&pci_mcfg_res_list)) + return 0; + + list_for_each_entry(e, &pci_mcfg_res_list, list) { + rc = func(e->res.start, resource_size(&e->res), data); + if (rc) + return rc; + } + + return 0; +} + +#define set_apei_filter() \ + do { \ + if (!arch_apei_filter_addr) \ + arch_apei_filter_addr = pci_mcfg_for_each_region; \ + } while (0) +#else +#define set_apei_filter() +#endif + +static int pci_mcfg_res_add(struct resource *res) +{ + struct pci_mcfg_res_region *new; + + if (!res) + return -EINVAL; + + new = kzalloc(sizeof(*new), GFP_KERNEL); + if (!new) + return -ENOMEM; + + new->res.start = res->start; + new->res.end = res->end; + + mutex_lock(&pci_mcfg_lock); + list_add(&new->list, &pci_mcfg_res_list); + mutex_unlock(&pci_mcfg_lock); + + return 0; +} + /* * Lookup the bus range for the domain in MCFG, and set up config space * mapping. @@ -144,6 +203,11 @@ static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) return NULL; } + /* insert the mcfg resource region of current segment into the list */ + ret = pci_mcfg_res_add(&cfgres); + if (ret) + dev_warn(dev, "add %pR into the mcfg res list failed\n", &cfgres); + return cfg; } @@ -204,6 +268,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); + set_apei_filter(); + return bus; }