Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2706853rwr; Fri, 28 Apr 2023 14:40:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Difaj8sFmeD9LrbRHxQA7gCUfsEfRZwPri1N6dQqfAd/EJujWk3pU8uGcV2wHIFijH0DB X-Received: by 2002:a17:903:244b:b0:1a6:5f92:3ba with SMTP id l11-20020a170903244b00b001a65f9203bamr7972600pls.0.1682718051900; Fri, 28 Apr 2023 14:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682718051; cv=none; d=google.com; s=arc-20160816; b=Mdzt45gRLtJyO+lWHq+/XAZ8+Xr0JackP9jvSHwZr7fNOJwCwziGlYInc3KFRV14xS AM7JeabMBTmousxBlePo6Nvt6YyMHOJ0dbiADfq/Jwry8A1DtFmCx6gavcf0Rs9pRLzI VWDrG/flJKLbzGVm9kuPtHyHiPX8xd97yUEPwAaWIs1gZIwlKsxCwjb+FfGNxNoHJUzf aXEWS0v5A/hq68CKawfDkNyxy2cbpHkeN4h5mnTnQv0IlGbX8IaQu895Go+nY8KQvuPG +zliz/0fVO0zQml2Idp9an6HHpa3jZ2Xu7NYspQH3JB1g17+gIvsuh76Nst3M5tBVq+w XcsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=SujHfRTE32G2kzczb1AjOorQUgpL8wVW3PI92C6o1eU=; b=bOhYTv5bf7CWn0njCj7r3Nkv2fUog++rG1JO26spcLkYf88JGzouYRXPT//0CH0Ze4 ZlTeR7T8yXwx3UqVkFVSyPiiIqnkqIlz0eJUZh33UByypv9vKxodvz12iNUf61AZAfCn 67IIVUr7wgEAE3ojVFTE98nYoI1RuWs3fv/qPIOfezah5BSpWBwdnbSGLJoibfGon6L/ fB9yS9qDWdrdtvWs2U9zDmymUVrSsVeJebtsZR658jptw3rfylv2D7QbyppuRarxpaPp 3kKFh6hBmdB9GahAyH1vf+xCXifWYRBS8kPdXYagQAoy66scY6qp4tgXhRjikp6WQVVZ rqaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=scNMVTiK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a170902e88600b001a6c524c18asi21989347plg.40.2023.04.28.14.40.38; Fri, 28 Apr 2023 14:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=scNMVTiK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345685AbjD1Vad (ORCPT + 99 others); Fri, 28 Apr 2023 17:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjD1Vab (ORCPT ); Fri, 28 Apr 2023 17:30:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 617661725; Fri, 28 Apr 2023 14:30:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ECB52645A7; Fri, 28 Apr 2023 21:30:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0223FC433D2; Fri, 28 Apr 2023 21:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682717429; bh=LZyvQOlA+YPLE+u/H4MSi/7JEM8BoKst314zkORamyM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=scNMVTiK+VrCxkEm4YpMEKmW87PGkYkYyYdp6RXnUtRMt/VRZJWrcXtkoBBk++qy0 Za3H+LFtJwN0E1O6M0oSK8R6wrh92prC7RryMEiDkAA+XgzdrQSZmD8WPDesPo3fIy faBVHY3G0oo6DwDmnou9KfWJcSPuUBufRU+wprVFZDE/UrGBbVhJoAYPUXEEf/9MYH DB1ozSHYZrTEWkd14yHVwn7XnulTLIofDkuKPx9Tei4URqOamoYxqI6c7Cnyc6uBUc Bafhm2RD9A2I7aUcdPtyHhc+BWMAk296O8FJBOYne2NqeZEs8JXAXaOlNuj/J//T4Q HAMPm3JzuprfQ== Date: Fri, 28 Apr 2023 16:30:27 -0500 From: Bjorn Helgaas To: Shawn Guo Cc: Lorenzo Pieralisi , Bjorn Helgaas , Catalin Marinas , Will Deacon , Maximilian Luz , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson Subject: Re: [PATCH v2] arm64: PCI: Add quirk for Qualcomm WoA devices Message-ID: <20230428213027.GA363093@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230423030520.9570-1-shawn.guo@linaro.org> X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEXHASH_WORD, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Andy, Bjorn A, plea for help from Qualcomm firmware folks] On Sun, Apr 23, 2023 at 11:05:20AM +0800, Shawn Guo wrote: > Commit 8fd4391ee717 ("arm64: PCI: Exclude ACPI "consumer" resources from > host bridge windows") introduced a check to remove host bridge register > resources for all arm64 platforms, with the assumption that the PNP0A03 > _CRS resources would always be host bridge registers and never as windows > on arm64 platforms. That's not quite what the commit log says. The 8fd4391ee717 assumption is that on arm64, - _CRS *consumer* resources are host bridge registers - _CRS *producer* resources are windows which I think matches the intent of the ACPI spec. > The assumption stands true until Qualcomm WoA (Windows on ARM) devices > emerge. These devices describe host bridge windows in PNP0A03 _CRS > resources instead. For example, the Microsoft Surface Pro X has host > bridges defined as > > Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID > > Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings > { > Name (RBUF, ResourceTemplate () > { > Memory32Fixed (ReadWrite, > 0x60200000, // Address Base > 0x01DF0000, // Address Length > ) > ... > The Memory32Fixed holds a host bridge window, but it's not properly > defined as a "producer" resource. I assume you're saying the use of Memory32Fixed for a window is a firmware defect, right? (Per ACPI r6.5, sec 19.6.83, the Memory32Fixed descriptor cannot specify a Producer/Consumer ResourceUsage. I think that means the space is assumed to be ResourceConsumer.) > Consequently the resource gets removed by kernel, and the BAR > allocation fails later on: > > [ 0.150731] pci 0002:00:00.0: BAR 14: no space for [mem size 0x00100000] > [ 0.150744] pci 0002:00:00.0: BAR 14: failed to assign [mem size 0x00100000] > [ 0.150758] pci 0002:01:00.0: BAR 0: no space for [mem size 0x00004000 64bit] > [ 0.150769] pci 0002:01:00.0: BAR 0: failed to assign [mem size 0x00004000 64bit] > > This eventually prevents the PCIe NVME drive from being accessible. > > Add a quirk for these devices to avoid the resource being removed. Since this is a Windows laptop, I assume this works with Windows and that Windows will in fact assign BARs in that Memory32Fixed area. If we knew what the firmware author's intent was, we could probably make Linux understand it. Maybe (probably) Windows treats these descriptors the same on arm64 as on x86, i.e., *everything* in PNP0A03 _CRS is assumed to be "producer" (at least, that's my experimental observation; I have no actual knowledge of Windows). So I guess 8fd4391ee717 must have been motivated by some early arm64 platform that put "consumer" descriptors in PNP0A03 _CRS as Lorenzo said [1]. In that case I guess our choices are: - Add quirks like this and keep adding them for every new arm64 platform that uses the same "everything in PNP0A03 _CRS is a producer" strategy. - Remove 8fd4391ee717, break whatever early arm64 platforms needed it, and add piecemeal quirks for them. I hate both, but I think I hate the first more because it has no end, while the second is painful but limited. Obviously we would need to do whatever we can to identify and fix things that depend on 8fd4391ee717 before reverting it. Bjorn [1] https://lore.kernel.org/lkml/ZBA2Gl5xCjk7mMoW@lpieralisi/ > Signed-off-by: Shawn Guo > --- > Changes for v2: > - Match devices using PPTT instead of DSDT to avoid maintenance burden. > Hope this is an acceptable compromise. > - Add const delaration to qcom_platlist[]. > > v1 link: > https://lore.kernel.org/lkml/20230227021221.17980-1-shawn.guo@linaro.org/ > > arch/arm64/kernel/pci.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c > index 2276689b5411..2ff2f3befa76 100644 > --- a/arch/arm64/kernel/pci.c > +++ b/arch/arm64/kernel/pci.c > @@ -109,16 +109,44 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) > return 0; > } > > +#define QCOM_PCI_QUIRK "Host bridge windows in PNP0A03 _CRS" > + > +/* > + * Ideally DSDT (Differentiated System Description Table) should be used to > + * match the platforms, as the quirk is in there. But devices from different > + * manufacturers usually have different oem_id and oem_table_id in DSDT, > + * so matching DSDT makes the list a maintenance burden. As a compromise, > + * PPTT (Processor Properties Topology Table) is used instead to work > + * around this quirk for the most Qualcomm WoA (Windows on ARM) devices. > + */ > +static const struct acpi_platform_list qcom_platlist[] = { > + { "QCOM ", "QCOMEDK2", 0, ACPI_SIG_PPTT, all_versions, QCOM_PCI_QUIRK }, > + { } > +}; > + > static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) > { > struct resource_entry *entry, *tmp; > int status; > + int idx; > > status = acpi_pci_probe_root_resources(ci); > + > + /* > + * Instead of describing host bridge registers in PNP0A03 _CRS > + * resources, Qualcomm WoA devices describe host bridge windows in > + * there. We do not want to destroy the resources on these platforms. > + */ > + idx = acpi_match_platform_list(qcom_platlist); > + if (idx >= 0) > + goto done; > + > resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { > if (!(entry->res->flags & IORESOURCE_WINDOW)) > resource_list_destroy_entry(entry); > } > + > +done: > return status; > } > > -- > 2.17.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel