From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C4E5C433F5 for ; Wed, 29 Sep 2021 01:35:10 +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 4302C613C8 for ; Wed, 29 Sep 2021 01:35:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4302C613C8 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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GkV0y/n3E3SchkoA5659d0SasBKaI6OhijrRQVyJ6vY=; b=PoMImfyWo+NDYP NUrIX1jbAgKqa+L/44dchc1Qe1eI51wSPgrdbuc/D+15gyphv5bmDmjH5tz8X3DL1NHKPXbYtYdT1 vvTBwFgV6BEgSoCglB5AnC0gyYQTPWLnPnsp/z47gigE+6EKyOW5X98ph5cH+jafo36BaapW/Gf3N EIQRm/mV+NV5gYj1vLqS545VOe6xftRlrC7DYxTtdbnkBTLqr1erzoTBhuEfstCotjdx99UgwVu9E PCTAHGnq96jvDiG6e0wrgzHfx/7EnbsTiO0nJ+9SUrcriJnlibxLd6QaFgLN6ntxPbHsBnx6tFwxP kKPz5pm6dVtlH3YxyH0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVOTC-009YRN-3F; Wed, 29 Sep 2021 01:33:14 +0000 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVOT8-009YQK-03 for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 01:33:12 +0000 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R131e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=alimailimapcm10staff010182156082; MF=xuesong.chen@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0UpzWrzZ_1632879181; Received: from 30.225.212.55(mailfrom:xuesong.chen@linux.alibaba.com fp:SMTPD_---0UpzWrzZ_1632879181) by smtp.aliyun-inc.com(127.0.0.1); Wed, 29 Sep 2021 09:33:02 +0800 Message-ID: Date: Wed, 29 Sep 2021 09:32:56 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH] arm64/apei: Filter the apei GAS address from the ECAM space To: lorenzo.pieralisi@arm.com, catalin.marinas@arm.com Cc: will@kernel.org, steve.capper@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org References: From: Xuesong Chen In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210928_183310_270458_D2063CC5 X-CRM114-Status: GOOD ( 24.44 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello Lorenzo & Catalin, Any comments about this? Xuesong On 08/09/2021 15:02, Xuesong Chen wrote: > 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; > } > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel