From patchwork Mon Jun 7 11:28:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 12303367 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 B76C9C47094 for ; Mon, 7 Jun 2021 11:33:21 +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 858E060FDC for ; Mon, 7 Jun 2021 11:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 858E060FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=0n3frBz20ro6aBXYHfh3Mn/VR1njNe9mRhgxrX1N38I=; b=jUHW1TJELfSoSG duau51Gnz8+oMoGuS4XE2g15oooj1U9aR+m7DP4HcmV24sGczbIkbkMB+4ypP6rQKCYbvK2WRQwGC 3ahm9pzdiRmJv13XCfyuvEK1wgmWCrofloeH9uWnyCHO/qMJM7T6LUWW9OBGwPfhfwhYBS7MP8mqF MKRTfDd80EHeLmIn2zLEgq3k+A0nwxuSeDTLoETnYBkbIDdIcOJt58TyPjOmrsFAAfNHkhaCnK8Jt xWc7SJzLKz8DGPaPWaYYlczyEdg5CTXDkeFIh0MMj8EgFkc2XtDJqA5paw7nwQ5bfvZ5T4beOny6I X8lkX+7AHYIusKaQyz7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDTK-003MhD-Ed; Mon, 07 Jun 2021 11:31:10 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDRP-003Lze-U4; Mon, 07 Jun 2021 11:29:13 +0000 Received: by mail-pf1-x42e.google.com with SMTP id g6so12852135pfq.1; Mon, 07 Jun 2021 04:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YCToNP4lwbo49RVCOfoWUbLA0lZuEyfjkp0b5XCIINA=; b=nI5Q01rIet4WeJW9GCi/1goLl90w/OB7zL9RMrdqmXVkYdnYtyK8GQBLIExcFjRexR /TNYbgs7tuinG3wCB2uo6ILPXzgoLaKrsRkRjbi2c9jP0VBHblYzx3CLt0sfXMZblxtb KQCA7eflorikpmtnDLhTsQr1HCJ/hueB8uiDQGPtiT0w6YcGMiWFWBWuUT/owIL9ioBA sIjX8YcWX6tG0nMwu+NGC7/wiSAa2HJe7dMbhCOC/gtgLQWNjFbgt98vYvd8gNIidMLc HmCcnN0MfXsBlj0ya9YnFDYuuK3jCak/H/A2V0FTN98wJsWRA3nZbgBz1WDhfBEuEL9G 3uHw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=YCToNP4lwbo49RVCOfoWUbLA0lZuEyfjkp0b5XCIINA=; b=TENsGmelV+Hau2R18ARqPyBd6bsVrgmF0tC0GbVuJ/8jEjMmjzk54PUvEfplnTVg7L liTjVOKfBQ1W/A2wf8TYANK1SaYbdhSi0E6OIqt9aX4SrqehYOd5QWS1Ie2C5A+W09IL +S0GgW5LPVdhYvKoG0X7s9bp/JZE9Ss4smSKUXy2+f+rw2C2tjfMZbG5esNvX/gostcm tlZxomBQDI3pbQBItuJH6S9vz76Hyh0piaYrTk7VHbDk7T0fp66eHSPFJ2zZ69RiF0+a HIcr3WTympJebN/moZCuusc+jF3KbCNGIdkEWHVfdEpZYjQsDYopvlVYzLcHSKcjObd7 mhaw== X-Gm-Message-State: AOAM530FjSSnN6+2FvI7EPt+5y3hEidi6B2REPgUU7rBJ4qOeZKRY5rc XhRTFKKTOWKqvN9wG3FVNrQ= X-Google-Smtp-Source: ABdhPJx0kIhVcKMkYM8J/nN6t7I96Ryv12N586HazWMrF66vgSMvWCBoKF26ggQsOxOptM4bhMf5cg== X-Received: by 2002:a62:860a:0:b029:2ec:81e1:23e4 with SMTP id x10-20020a62860a0000b02902ec81e123e4mr15672830pfd.11.1623065348506; Mon, 07 Jun 2021 04:29:08 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id c130sm7919370pfc.51.2021.06.07.04.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:29:08 -0700 (PDT) From: Punit Agrawal To: helgaas@kernel.org, robh+dt@kernel.org Cc: Punit Agrawal , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alexandru.elisei@arm.com, wqu@suse.com, robin.murphy@arm.com, pgwipeout@gmail.com, ardb@kernel.org, briannorris@chromium.org, shawn.lin@rock-chips.com, Bjorn Helgaas Subject: [PATCH v3 1/4] PCI: of: Clear 64-bit flag for non-prefetchable memory below 4GB Date: Mon, 7 Jun 2021 20:28:53 +0900 Message-Id: <20210607112856.3499682-2-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607112856.3499682-1-punitagrawal@gmail.com> References: <20210607112856.3499682-1-punitagrawal@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210607_042912_032174_5FF732FB X-CRM114-Status: GOOD ( 11.49 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some host bridges advertise non-prefetchable memory windows that are entirely located below 4GB but are marked as 64-bit address memory. Since commit 9d57e61bf723 ("of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses"), the OF PCI range parser takes a stricter view and treats 64-bit address ranges as advertised while before such ranges were treated as 32-bit. A PCI root port modelled as a PCI-to-PCI bridge cannot forward 64-bit non-prefetchable memory ranges. As a result, the change in behaviour due to the commit causes failure to allocate 32-bit BAR from a 64-bit non-prefetchable window. In order to not break platforms where non-prefetchable memory ranges lie entirely below 4GB, clear the 64-bit flag. Suggested-by: Ard Biesheuvel Link: https://lore.kernel.org/r/7a1e2ebc-f7d8-8431-d844-41a9c36a8911@arm.com Signed-off-by: Punit Agrawal Tested-by: Alexandru Elisei Cc: Bjorn Helgaas Cc: Rob Herring --- drivers/pci/of.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 85dcb7097da4..1e45186a5715 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -353,6 +353,14 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev, dev_warn(dev, "More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", dev_node); *io_base = range.cpu_addr; + } else if (resource_type(res) == IORESOURCE_MEM) { + if (!(res->flags & IORESOURCE_PREFETCH)) { + if (res->flags & IORESOURCE_MEM_64) + if (!upper_32_bits(range.pci_addr + range.size - 1)) { + dev_warn(dev, "Clearing 64-bit flag for non-prefetchable memory below 4GB\n"); + res->flags &= ~IORESOURCE_MEM_64; + } + } } pci_add_resource_offset(resources, res, res->start - range.pci_addr); From patchwork Mon Jun 7 11:28:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 12303371 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 E72FFC47095 for ; Mon, 7 Jun 2021 11:35:03 +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 BB23461249 for ; Mon, 7 Jun 2021 11:35:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB23461249 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=rgNjzKcXaa65A+BLjrju8MYtPyYnDBIxPSoaBlSvU+4=; b=CVC2StK3q2LpXs Ma6eIpd6IvEDXbCkAapRGDDrqQx6iv0V6VUYPxOtVoRCL76Di14u2+yHa1Lzqj0Iesyj4O0+1sucZ RjI7yhuTibYOV3GzUxw2MgHkmsp18BfkKdzAK36gf7x9ghwWaLF8bdYhsuwBq5zWj5LAkrjUo6XvJ WkGn+CXntEkuf/UKvjY67gUHUFxYYi5WlwaY/5R6E9Q/6OJbqZcaaojK3tq4MSIC3GIxgSBr5ev5x H7aWLAnx/1s6nAfnvwI4oLYpk/svyXh2dDeK6rA0PQ/5Uv9H0RL+UMBUmzxKws/OIYtyFSQsuTMs1 LHqIWM0hp3UfASv5VTqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDUy-003NIs-P6; Mon, 07 Jun 2021 11:32:54 +0000 Received: from mail-pj1-f48.google.com ([209.85.216.48]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDSR-003MOD-JQ; Mon, 07 Jun 2021 11:30:17 +0000 Received: by mail-pj1-f48.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso8119972pjx.1; Mon, 07 Jun 2021 04:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gYiHNfH1kBmlkfBbotBqPsqiGVKKUt560+1kJ7V9BBI=; b=HSjMpYqbSO55esGzCWNfGkoYFj4gMqtwfUfHXE29SoUjYg37Hb+SuucnnMj9G8fzbL mYA1d0dno5FmYgmBIwveBEpO4fVaS/RCuo/vWRQ1knSJvNVTEPA0Yf6k3jYgHJXcRSOE 25RXPij1VsOc6kkoWt5UV3Lw9uo7IprR5sS69pv6xAawn2N8U48H6guaaFI50W1uK2z8 PqSPeN91DfEhs5yuomAa+W8bPkj1s7gpU0EA9euZPaydazhVJt5fE5a3bOzvAAyHfKnX H86UYjnw9lPB+vgq4+CJrIsc8/p8AM18wlQY50UZ9os7FZk60dV2h9sgOEUkxi4a8Tsl ePjg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gYiHNfH1kBmlkfBbotBqPsqiGVKKUt560+1kJ7V9BBI=; b=DvpTQsI422hrl5O1LPh0EYMIn3rDZqI6B4OS1PAVQgL3+rXnuo18yNpKpPsdCaTZY9 mJpp/HsKcEmmcVFICifF18/cTQrABt2fWfgQTxWodpvcZBX3qwgswr7eKUdcnESu9CIm NPjlnHj3Kqy2vWVffFgMV3Q94/nzWPIXVaxHnj/C7QwwguXSAmGxM/bK7fuTKaJcKYQ5 FNTib5MJsqhpNZV20k4MT/8piuvPTBmaDLkyJXvJ4SwpMFrZrh1wbIg7FkKJn6dgbsvt LegOTim64UkljYz/yb7XlF2VNco7da4ZeHKQTE7g7c3m+1qTqzPC8+hcsTPb+MxgVbJM 2GLw== X-Gm-Message-State: AOAM530mU8PQB7pcZU1gtKNsUA3IDl3Ia20ajBxx0ixr+c+TLi/jKJGd /PbviTNMm5Vkxh5NQKZ75DvsMQL+aRKKzQ== X-Google-Smtp-Source: ABdhPJyJGEghd9xFqSDRVaCu/4EepRG3WEkYdxRhmQn4Msi5hfJY0FokTjDtG1ac+2yeZYi+sEBMQQ== X-Received: by 2002:a17:90a:f304:: with SMTP id ca4mr20846856pjb.177.1623065354552; Mon, 07 Jun 2021 04:29:14 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id i21sm8029078pfd.219.2021.06.07.04.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:29:14 -0700 (PDT) From: Punit Agrawal To: helgaas@kernel.org, robh+dt@kernel.org Cc: Punit Agrawal , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alexandru.elisei@arm.com, wqu@suse.com, robin.murphy@arm.com, pgwipeout@gmail.com, ardb@kernel.org, briannorris@chromium.org, shawn.lin@rock-chips.com, Vidya Sagar Subject: [PATCH v3 2/4] PCI: of: Relax the condition for warning about non-prefetchable memory aperture size Date: Mon, 7 Jun 2021 20:28:54 +0900 Message-Id: <20210607112856.3499682-3-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607112856.3499682-1-punitagrawal@gmail.com> References: <20210607112856.3499682-1-punitagrawal@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210607_043015_693464_E014BCF9 X-CRM114-Status: GOOD ( 12.88 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit fede8526cc48 ("PCI: of: Warn if non-prefetchable memory aperture size is > 32-bit") introduced a warning for non-prefetchable resources that need more than 32bits to resolve. It turns out that the check is too restrictive and should be applicable to only resources that are limited to host bridge windows that don't have the ability to map 64-bit address space. Relax the condition to only warn when the resource size requires > 32-bits and doesn't allow mapping to 64-bit addresses. Link: https://lore.kernel.org/r/7a1e2ebc-f7d8-8431-d844-41a9c36a8911@arm.com Signed-off-by: Punit Agrawal Tested-by: Alexandru Elisei Cc: Vidya Sagar --- drivers/pci/of.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 1e45186a5715..38fe2589beb0 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -581,7 +581,8 @@ static int pci_parse_request_of_pci_ranges(struct device *dev, res_valid |= !(res->flags & IORESOURCE_PREFETCH); if (!(res->flags & IORESOURCE_PREFETCH)) - if (upper_32_bits(resource_size(res))) + if (!(res->flags & IORESOURCE_MEM_64) && + upper_32_bits(resource_size(res))) dev_warn(dev, "Memory resource size exceeds max for 32 bits\n"); break; From patchwork Mon Jun 7 11:28:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 12303373 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 EB697C47082 for ; Mon, 7 Jun 2021 11:36:04 +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 B1C0E61107 for ; Mon, 7 Jun 2021 11:36:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1C0E61107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=pPikXNPLw9dfDR2BfmiaSPc9PTnmy7JwLiSy53XZcLY=; b=aHCwODkHcR2eKJ YhBbCnNqkbwo6VZMRoeNl49HJPKohw1hPSJn5n54WHnLR4evTaJIF8bfPma87xHwOG1WGLTAHpJP+ eWyELnl/+tvr34ONYz6UeCEo2hfU4iKUVZeYS63dRFIxKiJQp7cirJUVZMv9OEoG3JR5lXCiS9grU vDttfvYTAX0GbwEPHtjC+8ZorT+79eDeZvIPJTOiBXEGUTVA21EIZF5V/TNU3u7khSATz27KucP88 Iu4MsV4PRCgEBMK7FCH3kIR7FbYJicW9Ru7lL/bLvEL5qA1Mw1zNRVZp/6lqCMwN4V7LTqwy7WrXe 3IwKztbqMrpJo23RTLzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDVo-003Naf-Gf; Mon, 07 Jun 2021 11:33:45 +0000 Received: from mail-pj1-f49.google.com ([209.85.216.49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDSW-003MQA-DL; Mon, 07 Jun 2021 11:30:24 +0000 Received: by mail-pj1-f49.google.com with SMTP id mp5-20020a17090b1905b029016dd057935fso3538538pjb.5; Mon, 07 Jun 2021 04:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rvzb4qtGRQUWi/ckS9nOcXRKxlM0Wnl5P5x853tHbFI=; b=WVWBYvsx5qebQs4uhxeWPTzu+987IycgSJNvyTphaVZrETj044Iw58W6NbDZyHgxse r5AwKefCsExOVbY3OQaHaijWhGJm8Bnd3b5eNIibKARMPxmBXDeW4f5d5cyyg9z5I8ZF FDXjSJKyFIJRfk/JsSNyibt2LYfBdRNPDxyH9PqyZF7pIrTwge0x9S0P/r9cgwHkA6oQ 3d6DKAIwRz1+GjxMzI7diW4cIGU7BEajxdieRXURAaE+C5ROu6UCtr3WjkCKLMMEG6FP OTOdGOndNHpnmHg8xUpabWofMjMoq1m+VrGTY4DAqSx7dRBD6hqm6PB58wsTlNMIlUVx exKg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rvzb4qtGRQUWi/ckS9nOcXRKxlM0Wnl5P5x853tHbFI=; b=Py7VEVmksaU65hsHAPS8BVLoQvTaBN9+E6VN+7/aRCzPtw85RmPzGE1T+spBk7K2Uy ogqQHRps7YKZ8YElZRV0796RrdHwTLNDLpLGT/VeLC2YKAPgGOh8cyPjH6nJ4d9GPs1q utWOhOgKjoLvbbKkIDEDiz4qoSlmxkDtCzted3TzGAWURe5MQ4HWObiQPnb+Haj9LzGY Xf/hv5nG+CS9DOKtLX4EgYOe3c8AKMwwAJcMfUKCJgQhdrPCUoyVyO0gAn7Mouh5YMbY +04pvqSAS4S7tlmDLx47J9+o4sdkqAEEwQEAZJunRxtRNgCeRL41wq1FcLrj3uHJnMvw Q2uQ== X-Gm-Message-State: AOAM531G7wbywbjjEQr3MPKVSR3dF8th1Wd8HLbXcVaFjiB18/GiEWt/ cNxYweJB9WOVY8JaNEP3m2I= X-Google-Smtp-Source: ABdhPJzfodVWiIz5t1qZzTiFumpaNqWNvckd2dBZi4kAiT/7o4BeWZ8rJjTxJXM+qOQg/O+SeaBJHA== X-Received: by 2002:a17:90a:7e84:: with SMTP id j4mr32325306pjl.101.1623065359403; Mon, 07 Jun 2021 04:29:19 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id d23sm1725619pjz.15.2021.06.07.04.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:29:18 -0700 (PDT) From: Punit Agrawal To: helgaas@kernel.org, robh+dt@kernel.org Cc: Punit Agrawal , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alexandru.elisei@arm.com, wqu@suse.com, robin.murphy@arm.com, pgwipeout@gmail.com, ardb@kernel.org, briannorris@chromium.org, shawn.lin@rock-chips.com, Vidya Sagar Subject: [PATCH v3 3/4] PCI: of: Refactor the check for non-prefetchable 32-bit window Date: Mon, 7 Jun 2021 20:28:55 +0900 Message-Id: <20210607112856.3499682-4-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607112856.3499682-1-punitagrawal@gmail.com> References: <20210607112856.3499682-1-punitagrawal@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210607_043020_504327_5D8E4518 X-CRM114-Status: GOOD ( 13.61 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Recently, an override was added for non-prefetchable host bridge windows below 4GB that have the 64-bit address attribute set. As many of the conditions for the check overlap with the check for non-prefetchable window size, refactor the code to unify the ranges validation into devm_of_pci_get_host_bridge_resources(). As an added benefit, the warning message is now printed right after the range mapping giving the user a better indication of where the issue is. Signed-off-by: Punit Agrawal Tested-by: Alexandru Elisei Cc: Vidya Sagar --- drivers/pci/of.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 38fe2589beb0..0580c654127e 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -355,11 +355,15 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev, *io_base = range.cpu_addr; } else if (resource_type(res) == IORESOURCE_MEM) { if (!(res->flags & IORESOURCE_PREFETCH)) { - if (res->flags & IORESOURCE_MEM_64) + if (res->flags & IORESOURCE_MEM_64) { if (!upper_32_bits(range.pci_addr + range.size - 1)) { dev_warn(dev, "Clearing 64-bit flag for non-prefetchable memory below 4GB\n"); res->flags &= ~IORESOURCE_MEM_64; } + } else { + if (upper_32_bits(resource_size(res))) + dev_warn(dev, "Memory resource size exceeds max for 32 bits\n"); + } } } @@ -579,12 +583,6 @@ static int pci_parse_request_of_pci_ranges(struct device *dev, break; case IORESOURCE_MEM: res_valid |= !(res->flags & IORESOURCE_PREFETCH); - - if (!(res->flags & IORESOURCE_PREFETCH)) - if (!(res->flags & IORESOURCE_MEM_64) && - upper_32_bits(resource_size(res))) - dev_warn(dev, "Memory resource size exceeds max for 32 bits\n"); - break; } } From patchwork Mon Jun 7 11:28:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 12303375 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 3C4C5C47094 for ; Mon, 7 Jun 2021 11:36:53 +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 06FF361130 for ; Mon, 7 Jun 2021 11:36:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06FF361130 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=1VzGZ4nEUanJqgKsvVxR89b74v7wy7zmP5LfmUKP3Tk=; b=Nf3F0z6bB0SBLn 6X6a6KncCqz7vEvUFFCtPUqAwlFrA8+0i6spONFSd07GWpDjc2hb8dsUO5k7W+6/c9Qff+vwPesVy Aks8gtcnz/zAISvHEEojRL/qYVpnRuamoaa+fc9CSKymZVW2pCVJqNy++/gqW1FP0xsT/biY3HBlC 0Hvm3kbHZbWi2rX6k/Wqe8g4ewX7x5vv6GEzFNCByXDuahWwZpVl0M0ltwTjZY2eZI4/pMRbyrqjB 2wcgozFb8iPI5kcCx3n1aeT0NUjiVuXFo8QVJtmwRrucihsq3TY31LhA/6+6BpZyGCHGB4gFtIaU9 WMjY0GQ3qyCUmp1HlUOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDWj-003NtF-Op; Mon, 07 Jun 2021 11:34:42 +0000 Received: from mail-pf1-f171.google.com ([209.85.210.171]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqDSa-003MRu-Ph; Mon, 07 Jun 2021 11:30:29 +0000 Received: by mail-pf1-f171.google.com with SMTP id s14so11951227pfd.9; Mon, 07 Jun 2021 04:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H/Yt3X2SxGHabq+c62sPHm2CdmHzwbxXy3zXvTGn4O4=; b=ldrUEjrnpMhEVVxmlliYmACwqqm8IvzyyrQfhmAk1A6f9Su/OdpzkQSBVsgxvFPCM5 gmXNlbuzGrSi47sfuyW/Sr/LapMRlUXY2WO91uQL3trreQOzg6abRzKeE0U96cVl+QYL s9c5/UlRESxzHcXUOwydNQ1aVaIb6/ftBY5tOORuq8nvbK71LgzR76wREqMhqb6BbaIw 1jKMRPA31xU2/FsOVSnKC+O2W6+ixL1spxhtXwuB9KucDT/Gj2bTezmRK9a+vvpEf0p4 XEEfnvTR8CrWN7hxigRzRDpM+3vX3+TRfDVZxjPe57eErtAUAlfaondGrvJ81N63D8Yt 2J1g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=H/Yt3X2SxGHabq+c62sPHm2CdmHzwbxXy3zXvTGn4O4=; b=Zb0s9DWrxvQSV8H6v84Rw4ogyWP/WsyRT6FAV8EiGvLRspzonYJBo+byhdqunXXAWl dTCM2BnJ228tNhO4KVaiNiCvKGjeqLn/hz/PaFk6z5wCZDih7TNkPZSPYPehf77UsCp/ lekg1Y9ExtlYvXivi/XA0Nfn0eC3hUrbgsBhuMp0vNC9/AORIEfHrBzgjC6+Rqugn4AE Nw5YDuuKCTW9V/ePQDDLikYsItUPxSrNyvh6hCAYqizm7YR3LO8qNKW1h4TNpG40P3fA zIcD8Mxpp0N0GUc9Xjl8Pd1JbSu2IEr8be87OwY2IhZ+ITp0wrQmaCD2rFPkqGN+vO9Z J9OQ== X-Gm-Message-State: AOAM532j44PKAcdOYF/5uoY8FUqiqLauN+9r9Ft9hkkIIH/Zi/E/5w1H DONCImQ0D7kqKFWoogUu3eWUuRhUOtwHvQ== X-Google-Smtp-Source: ABdhPJzZluhwYML3k2RzI64KyTnPU63QAHQCUn82ffdDDiH0PpVuJ0F+5G0pCsKr0rDDuVbI+qA6Yg== X-Received: by 2002:aa7:9515:0:b029:2e9:c6f4:2c44 with SMTP id b21-20020aa795150000b02902e9c6f42c44mr17038239pfp.28.1623065363761; Mon, 07 Jun 2021 04:29:23 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id e17sm7950720pfi.131.2021.06.07.04.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:29:23 -0700 (PDT) From: Punit Agrawal To: helgaas@kernel.org, robh+dt@kernel.org Cc: Punit Agrawal , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alexandru.elisei@arm.com, wqu@suse.com, robin.murphy@arm.com, pgwipeout@gmail.com, ardb@kernel.org, briannorris@chromium.org, shawn.lin@rock-chips.com, Heiko Stuebner Subject: [PATCH v3 4/4] arm64: dts: rockchip: Update PCI host bridge window to 32-bit address memory Date: Mon, 7 Jun 2021 20:28:56 +0900 Message-Id: <20210607112856.3499682-5-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607112856.3499682-1-punitagrawal@gmail.com> References: <20210607112856.3499682-1-punitagrawal@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210607_043024_875487_38ED68B4 X-CRM114-Status: GOOD ( 14.34 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PCIe host bridge on RK3399 advertises a single 64-bit memory address range even though it lies entirely below 4GB. Previously the OF PCI range parser treated 64-bit ranges more leniently (i.e., as 32-bit), but since commit 9d57e61bf723 ("of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses") the code takes a stricter view and treats the ranges as advertised in the device tree (i.e, as 64-bit). The change in behaviour causes failure when allocating bus addresses to devices connected behind a PCI-to-PCI bridge that require non-prefetchable memory ranges. The allocation failure was observed for certain Samsung NVMe drives connected to RockPro64 boards. Update the host bridge window attributes to treat it as 32-bit address memory. This fixes the allocation failure observed since commit 9d57e61bf723. Reported-by: Alexandru Elisei Link: https://lore.kernel.org/r/7a1e2ebc-f7d8-8431-d844-41a9c36a8911@arm.com Suggested-by: Robin Murphy Signed-off-by: Punit Agrawal Tested-by: Alexandru Elisei Cc: Heiko Stuebner Cc: Rob Herring Acked-by: Heiko Stuebner Acked-by: Rob Herring --- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index 634a91af8e83..4b854eb21f72 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi @@ -227,7 +227,7 @@ pcie0: pcie@f8000000 { <&pcie_phy 2>, <&pcie_phy 3>; phy-names = "pcie-phy-0", "pcie-phy-1", "pcie-phy-2", "pcie-phy-3"; - ranges = <0x83000000 0x0 0xfa000000 0x0 0xfa000000 0x0 0x1e00000>, + ranges = <0x82000000 0x0 0xfa000000 0x0 0xfa000000 0x0 0x1e00000>, <0x81000000 0x0 0xfbe00000 0x0 0xfbe00000 0x0 0x100000>; resets = <&cru SRST_PCIE_CORE>, <&cru SRST_PCIE_MGMT>, <&cru SRST_PCIE_MGMT_STICKY>, <&cru SRST_PCIE_PIPE>,