From patchwork Mon Feb 27 02:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 13152601 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 49CA0C6FA8E for ; Mon, 27 Feb 2023 02:14:00 +0000 (UTC) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NJPtpUO8ydlu6ZgTF+LOkfQySYYRkDOQrjBtIWtIa/c=; b=aoBz6HdEgj7PiG 6t+efXS2T10w4cbw66LdGTOZddtGaCd8nF0hSWd6V2qeenGye426Dzh9zL4rYR6yMpUgiV5FhuB8X knmso4vBIz7jWxfMgnQZK96410DAZjDzbZt0/YXEeRrIfolgFl6elSOOCY4YtQCorOPtB3FaaEIgU SI8v0Doi3+24LmQXKTecNdVCQ3WiphLDtLPdeHppFGSMqEYPr8gYQqaDQTr9JZOKcrnMxjsucJ/EF 8nVGVjbc7L8OyilGXOK264a+3hiva8pl3bzqJO4WoAo4vkJdeb0A/Ucmj9nZfI6i1ZAzmzu0l4uBu 5NW3w+PIadMoE7C0BVgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWT0h-008FEG-0Z; Mon, 27 Feb 2023 02:13:03 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWT0c-008F7k-0N for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2023 02:12:59 +0000 Received: by mail-pj1-x102b.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso3675786pjs.3 for ; Sun, 26 Feb 2023 18:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W9Elx/OktSxbW/ZTsMXsiJKt2uP4I2yrugiLovEI2eU=; b=tF1eklQmlLz5nvLkUV7z7sNrSoRJ5Z3ElhvAX1ZQ46oBIl56yxrldAoNyZyN49kR75 KRW4AnMlCGgt56FtQKXPH0oGjc0T8r9j350X6iO6r3b06ipjlWhfDhoJU+DtXe+NsOYN uYgq6878KXvXZVfk56ZjfhBEkmbYdjlLHQQw26dOHmO1PdU/qgQV+TQjh1dKs5lcBzO7 9X3F2qgc8kf/3dv11Og0C7iWqUMKD0+55Wypw7gHBEEx6MrZiUeKHy1fXwqV4gpZ6iX+ gG80HjwtEeckb7qpZFrVA51OO2tMhsVPZrcReZBjMMniRmmOxKQI3xuF4R6JMU27goJz 6tgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W9Elx/OktSxbW/ZTsMXsiJKt2uP4I2yrugiLovEI2eU=; b=EmxQTAM350BS3ngXDavYuKwLTXZc/s2S65ty+BRDNIPovhCqPfEdatD8HG2J2vcFRu j2sukhEcA7FVklGh2NVzL92Td8PZ0pDflhlRAFnp0/8iVZT5eOqiX3LEqeGnnOW4mPW9 D64Xf10BTIstEFoQ7HLXNKQp1nS4joq7N52mIGQTnLK8+8Xi6VoVQFOtNzYxHN1NK5MJ Uxia/HtvW+WLHpi+O02YmpFyE1RgtpMGe8IUbTyiq3s1cmyKZXaM2mk1o90bHCe3Jk+t 8P+cx/kLuwynJpiwQtCwBlTR/WygFOfae+HATGgMt5u6CVWRyiM0uDY/CmQ0C3jK1OIK YnBQ== X-Gm-Message-State: AO0yUKU7yEYMyAqsCH9FSe0XLPmcLzrMMta7KeuY+STrcZvaCcvTm3Y/ qD5NFQ1hE8MHAtS2rbq1T7twkYqsT/AVfm0A X-Google-Smtp-Source: AK7set/WT431W3AXator1w5cHD9yTUKHJM7s2Y35U5EitKL/JiMXaRXP5rZCuKam91/vBJCfjydGwg== X-Received: by 2002:a17:90b:4c50:b0:234:1f57:ecb1 with SMTP id np16-20020a17090b4c5000b002341f57ecb1mr23918858pjb.40.1677463966735; Sun, 26 Feb 2023 18:12:46 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id q2-20020a17090a68c200b00234b785af1dsm3124513pjj.26.2023.02.26.18.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 18:12:45 -0800 (PST) From: Shawn Guo To: Catalin Marinas , Will Deacon Cc: Bjorn Helgaas , Maximilian Luz , Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH] arm64: PCI: Add quirk for platforms running Windows Date: Mon, 27 Feb 2023 10:12:21 +0800 Message-Id: <20230227021221.17980-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230226_181258_273805_78FC6C9F X-CRM114-Status: GOOD ( 14.56 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. The assumption stands true until Qualcomm Snapdragon Windows laptops emerge. These laptops describe host bridge windows in PNP0A03 _CRS resources instead. For example, the Microsoft Surface Pro X has host bridges defined as Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID 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 ) WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, 0x0000, // Granularity 0x0000, // Range Minimum 0x0001, // Range Maximum 0x0000, // Translation Offset 0x0002, // Length ,, ) }) Return (RBUF) /* \_SB_.PCI0._CRS.RBUF */ } The Memory32Fixed holds a host bridge window, but it's not properly defined as a "producer" resource. 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 platforms to avoid the resource being removed. Signed-off-by: Shawn Guo --- We are running into the issue on more devices than just Surface Pro X now, so trying to sort it out with a quirk as suggested by Lorenzo [1]. [1] https://lore.kernel.org/all/20210527093200.GA16444@lpieralisi/ arch/arm64/kernel/pci.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 2276689b5411..896dbd028b67 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -109,16 +109,42 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; } +#define QCOM_DSDT_QUIRK "Host bridge windows in PNP0A03 _CRS" + +static struct acpi_platform_list qcom_platlist[] = { + /* Thinkpad X13s */ + { "LENOVO", "SDM8280 ", 0, ACPI_SIG_DSDT, all_versions, QCOM_DSDT_QUIRK }, + /* Microsoft Surface Pro 9 (5G) and Windows Dev Kit 2023 */ + { "QCOMM ", "SDM8280 ", 0, ACPI_SIG_DSDT, all_versions, QCOM_DSDT_QUIRK }, + /* Microsoft Surface Pro X */ + { "QCOMM ", "SDM8180 ", 0, ACPI_SIG_DSDT, all_versions, QCOM_DSDT_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); + + /* + * Most arm64 platforms that do not run Windows describe host bridge + * registers in PNP0A03 _CRS resources, but some like Qualcomm + * Snapdragon Windows laptops describe host bridge windows in there. + * We do not want to destroy the resources for 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; }