From patchwork Mon May 31 22:10: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: 12290081 X-Patchwork-Delegate: bhelgaas@google.com 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 64BD9C47082 for ; Mon, 31 May 2021 22:11:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D67B60FF1 for ; Mon, 31 May 2021 22:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbhEaWNX (ORCPT ); Mon, 31 May 2021 18:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbhEaWNW (ORCPT ); Mon, 31 May 2021 18:13:22 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9770FC061574; Mon, 31 May 2021 15:11:41 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 133so4183477pgf.2; Mon, 31 May 2021 15:11:41 -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=ObJnk/4SRS5pFYp9Ryi74xRKcVKBz9rodsuAFbTAcF0=; b=NuJwoNvOCmk/TUqCGSOTXCu34DL22xBUfOL8NrOsw1RgI/+bcANwngaNNpF4xJlPXF D+PxMKt4B9NxIOiarz7Ot+QbC2klai1lJSIATiUarbkqxsBh520zgml0OBdVrQkoAWO+ 5vorZt7+wtyWfLVNvxGig+Hv/w/FdEiwBbhSFK7IN7TJPbjYBojzS6Bfrzcqr0iAb18s OqH0OJjweH9z00GiMKHC6mi6TMgz68VkYUivsIoHzgFypCRHt88aCFSi+0zMjR07BUmQ oO0Eqr7/b5ZdBOKmcxmWt7G0agsGvhKZtrhLdetVWcwPa1m8vOqGV0NinCq/r9no4pRt uZnw== 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=ObJnk/4SRS5pFYp9Ryi74xRKcVKBz9rodsuAFbTAcF0=; b=hq8re+HlgDOfyCmDMAZz65ZB0o9ArTC/uWqXHzz/CbCWdldiVa7yPoJAEgszFoCvNT is06qkO/U9o9IL21rjQ+hovuHmoHdbBb6/oVC3F8sBLTdC4o+iOmOOtde/xm7eN+16T2 av2cVzvVSG11zdJZ2Bq7uF+efE1P/0hUB39Nz2HRMaNQonWF1JuCmLCGNinzxrdYhMeg 2mQnPAujpX08+cmMsZTFNa1XcXo6CnOm4LRuXUVmbVAPbjPUoaw6K+Ui9uKFgwhh8FSn lsRjY8bSGlFqdnJEisdmspglgtcbTbkqSrUnv/09j3eY/pkNCjTBxj9u2tl99mAz2oEO nKWw== X-Gm-Message-State: AOAM5334lyD+2yd0ja34a6BeP8ml7iwFiigT+ss/4imFt+KpmTxqXv99 8hb8B2/ivi+atSbLWLvd8gA= X-Google-Smtp-Source: ABdhPJyM6MZ78Cel4rzoNBtZsG5ANMUhigCb2ZFgVsujzRfnVOIzCkaz6aJHGBVbCnCg/2LjYhHZhw== X-Received: by 2002:a65:64c8:: with SMTP id t8mr5505003pgv.96.1622499100960; Mon, 31 May 2021 15:11:40 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id z6sm12604823pgp.89.2021.05.31.15.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 15:11:40 -0700 (PDT) From: Punit Agrawal To: linux-rockchip@lists.infradead.org, linux-pci@vger.kernel.org Cc: Punit Agrawal , linux-arm-kernel@lists.infradead.org, linux-kernel@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, helgaas@kernel.org, robh+dt@kernel.org, Bjorn Helgaas Subject: [PATCH v2 1/4] PCI: of: Override 64-bit flag for non-prefetchable memory below 4GB Date: Tue, 1 Jun 2021 07:10:54 +0900 Message-Id: <20210531221057.3406958-2-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531221057.3406958-1-punitagrawal@gmail.com> References: <20210531221057.3406958-1-punitagrawal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some host bridges advertise non-prefetable 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 host bridge that is modelled as PCI-to-PCI bridge cannot forward 64-bit non-prefetchable memory ranges. As a result, the change in behaviour due to the commit causes allocation failure for devices that require non-prefetchable bus addresses. In order to not break platforms, override the 64-bit flag for non-prefetchable memory ranges that lie entirely below 4GB. Suggested-by: Ard Biesheuvel Link: https://lore.kernel.org/r/7a1e2ebc-f7d8-8431-d844-41a9c36a8911@arm.com Signed-off-by: Punit Agrawal Cc: Bjorn Helgaas Cc: Rob Herring Signed-off-by: Punit Agrawal --- drivers/pci/of.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index da5b414d585a..e2e64c5c55cb 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -346,6 +346,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 May 31 22:10: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: 12290083 X-Patchwork-Delegate: bhelgaas@google.com 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 252BEC47082 for ; Mon, 31 May 2021 22:12:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04BD260232 for ; Mon, 31 May 2021 22:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232230AbhEaWNk (ORCPT ); Mon, 31 May 2021 18:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232228AbhEaWNj (ORCPT ); Mon, 31 May 2021 18:13:39 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D09C06174A; Mon, 31 May 2021 15:11:59 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id e1so1556233pld.13; Mon, 31 May 2021 15:11:59 -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=gw59jQnc+Uma0baDOULLtxudFXMhd44Brz/fTI3+KK4=; b=h/Gg08nBXnR+NAlEizOR5wFpKHRzB4VnrTv2o7OpQ5UH78vidsV6CfXyQbIhpAx42y wunLHz9/4YRny3R+sFpJ1LWKEg5/YW293+g+r3NICv30Z5h6+CckWjIuI8FKtsPtwlKI 5V7DmdQ2LJd3f78yRAqllGgnCtnhqYxq79ljbICuQgWfsTj4YdOWYDP5q37lTZQrDmgl xZSFRnPs9+Lgz3/7XxCG9ZN96sl18Hv9Gd/UW06yQLBkiourrJg90O3mq/sWEdhoNuHZ /YILnPISLKlvjAuKfpeRs2I2abB4ceWwGe787jvAnSLtb3Af6w/hTlId51dGcjSz72yk GD7g== 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=gw59jQnc+Uma0baDOULLtxudFXMhd44Brz/fTI3+KK4=; b=BQ73+tvBdaqPlvgcXHoZcjBrqU8tNgq5tqQW+dS6OZRfjUItqvEfbIzieKSzynwzs6 c7sh26x5h+vTmYG6Guy6dp4so7g22sypcJPfQGqmKO8c7OBcjtivxIAsaQtU9FHSx7pg HsuNnEUmaxgJvH4swo+iWzpUqxlXGFEIFlAdaoFoX5YzT1sSnGbfnGBzhvg43Fv4wfU+ lBx9sgBywwqVB/3J5IgguPIUCFSKs9fjzl8s+kuWfNgOgH2+c3/mNOaSQxcNyGhdtR4b Sgil39la05KTKbtFaUpUc4DkobyOxV0H/7sSvkXaVE57hd0nAjxAmesmDRprDHsWh1FT OdhQ== X-Gm-Message-State: AOAM532ErpMb3VytMnF1YPlYhHNwQKtFHxawGda9dYIzzuQi69C8sHu7 OL5cczWMUHhdgOFh6xIZhIg= X-Google-Smtp-Source: ABdhPJzdE3+QUCC1zBgJEn+QtXIkglsaGTRALpTVjmZGTBM3gLEPvN1m4rll/7NuFhyVg6LvlAT6kA== X-Received: by 2002:a17:902:a70f:b029:ea:d4a8:6a84 with SMTP id w15-20020a170902a70fb02900ead4a86a84mr22665442plq.42.1622499118954; Mon, 31 May 2021 15:11:58 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id gz18sm308809pjb.19.2021.05.31.15.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 15:11:58 -0700 (PDT) From: Punit Agrawal To: linux-rockchip@lists.infradead.org, linux-pci@vger.kernel.org Cc: Punit Agrawal , linux-arm-kernel@lists.infradead.org, linux-kernel@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, helgaas@kernel.org, robh+dt@kernel.org, Vidya Sagar Subject: [PATCH v2 2/4] PCI: of: Relax the condition for warning about non-prefetchable memory aperture size Date: Tue, 1 Jun 2021 07:10:55 +0900 Message-Id: <20210531221057.3406958-3-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531221057.3406958-1-punitagrawal@gmail.com> References: <20210531221057.3406958-1-punitagrawal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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 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 e2e64c5c55cb..c2a57c61f1d1 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -574,7 +574,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 May 31 22:10: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: 12290101 X-Patchwork-Delegate: bhelgaas@google.com 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 62495C47080 for ; Mon, 31 May 2021 22:12:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 405116128A for ; Mon, 31 May 2021 22:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232228AbhEaWNu (ORCPT ); Mon, 31 May 2021 18:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232262AbhEaWNt (ORCPT ); Mon, 31 May 2021 18:13:49 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786F5C061574; Mon, 31 May 2021 15:12:09 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id z26so5882989pfj.5; Mon, 31 May 2021 15:12:09 -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=GljEIu7jIiK5mN+vwX9RD16rs+gsfiwk0Od3Nc7rcMA=; b=vNvhfeWt5cFD8gkB4sUI7nF6V2E/QEdfYsExlwI595NuvXT3oIvH3xZNLviBnX4zDN nuR04B1NXsc3Jhe6NFFmU1xquEyA26aLCG2DqHFvRiLvTHBY4DS7rS9QMlqGLcwWL56j qf34Kc2OvKjY6sJRKe5LN79I2oNo8sihnnkTlb/NYeMaI4sA0na2qNzGmlCUmYblWHPk 06RNlK5AeluOY4dQYH7lsutCEehI4Guj2sGqbJ23hStHORh9mO3r30ipUYFVqhlSLTwK dMxSvewN9Y0aGJOOc99hYFlq7vhfNeEXNDi0RFK/ay2235wQntfmfFcOdqg2vkpcngyI D0jg== 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=GljEIu7jIiK5mN+vwX9RD16rs+gsfiwk0Od3Nc7rcMA=; b=Nw+AnZFjFtx0AVuuSiLTQo9MlBU26sIRaE1xhx5ZutaszMQCFlhlJxK52bPKqDtA7g Go8+dHz+o7v+TJFmK2j4Hz5gOQOjOXE7/wpRzfypLhnnnOHZ9tpVj6TXgUy2R15HVi1i ntx14igjg7w5IaWMV36FsVRpycKDikDEqc45aEgOAvwTgxXGJi4pmjNq72IEUf6cFMd2 tQlY9C3MUS9amG5GiswBuobjOLFkuBqgK4yYndj6nufPE4FPV7Lll9Tv0JThGhSBsDJM 2yMY8DwO55S6NqoP0qPycDfphYoi9e0H/kHtdbcNt/E4qqgoQjiwy1JW6q4MZ5szH2Jb Na5w== X-Gm-Message-State: AOAM5338PRAEYg4yjYyLAD5rzUH+f1vetucBgqBflWPPtGQ6B8N1VvVL yH7GwfKp5y6Ow/YcdGvAfxo= X-Google-Smtp-Source: ABdhPJy1PBZt9zgv9B4tloqR1PSuGex00FScff7o1LZFYY4Dcj9PLvG31McWKUKnJHay1fqAP8grxw== X-Received: by 2002:a62:7fc5:0:b029:2de:5813:8890 with SMTP id a188-20020a627fc50000b02902de58138890mr18721295pfd.60.1622499129035; Mon, 31 May 2021 15:12:09 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id n23sm11879008pff.93.2021.05.31.15.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 15:12:08 -0700 (PDT) From: Punit Agrawal To: linux-rockchip@lists.infradead.org, linux-pci@vger.kernel.org Cc: Punit Agrawal , linux-arm-kernel@lists.infradead.org, linux-kernel@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, helgaas@kernel.org, robh+dt@kernel.org, Vidya Sagar Subject: [PATCH v2 3/4] PCI: of: Refactor the check for non-prefetchable 32-bit window Date: Tue, 1 Jun 2021 07:10:56 +0900 Message-Id: <20210531221057.3406958-4-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531221057.3406958-1-punitagrawal@gmail.com> References: <20210531221057.3406958-1-punitagrawal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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 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 c2a57c61f1d1..836d2787510f 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -348,11 +348,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"); + } } } @@ -572,12 +576,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 May 31 22:10:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 12290103 X-Patchwork-Delegate: bhelgaas@google.com 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 3D251C47082 for ; Mon, 31 May 2021 22:12:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 182DF6128A for ; Mon, 31 May 2021 22:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232262AbhEaWN7 (ORCPT ); Mon, 31 May 2021 18:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232363AbhEaWN6 (ORCPT ); Mon, 31 May 2021 18:13:58 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15754C06174A; Mon, 31 May 2021 15:12:18 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 133so4184481pgf.2; Mon, 31 May 2021 15:12:18 -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=A93D3Jz/qTgixftb1ASsD8T5vX2ZHOxs7SEr20+q3E4=; b=HTLnK1XWJOcuYF3R+7sQnyXy23CUZ3FTl9vIaAzRylyOyYuZ/pHaPGo0oSyZ04i3uT bNqPOfNvw1vDI9q1dl7wGhCESH0zbF8BtGH7F36YPlA7Bh8mC8Xl5fpilxoR1y6IAgYC m7deMyiiwJQ5+2uL0oXn5OHWNrfnFxEsi2m2OsqtuGMZmFcCutR/SVl7/P+3LVbNotGe CmeD1YEQRaOPbRWSAyYYZ9WT3t37qmLwd1WHClkNBgG95xqMSzx5ylaY7rIucgruhb7l XX5FA+vgcdxRAEO2w8rMx5IoA7vJKSPE9yHDysSSnromn/hn7Vk5VDKJKwlXRFq6dH8o tBLg== 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=A93D3Jz/qTgixftb1ASsD8T5vX2ZHOxs7SEr20+q3E4=; b=s/Cvo14fLu+iFuaOEiHbuJbwuhteIAOoczAE26PbNSxmNdbQBv9nNjwbPNBhwZeOb5 SAGILlJaQPoPSRgDQGpGc+Z7+8Na1HGbXiHWkcprTlfbG4qJOAxK5O6iwt7FQqVwiu0X MedY1b+gLvvSqn1VYEYBnPCiPmb1pQsYxF2vmVsXHG5IM+KCy4ATVouFi4d7qcxXNbBR cKEIPCY/eUuhE0KJb95+qjTVQcWTgQyPejs7WHcq/VB42jKi24zSuvtdmzyER2SG3JC5 PGEqv/FMwnkIXd6RnZxjAT+A2kvzbNBvaZlOyrpjcc08x8fORzh17/lfDCCNF6Y8ofmf MWgA== X-Gm-Message-State: AOAM5304//lOJt5alU+DnY5okgiMwrwQOhhFL/PBWeK4VqzbjVl8HcVc Vf9zSZzXaQ9ErGb4x8VBxWSZBRM9lfShOg== X-Google-Smtp-Source: ABdhPJzaxMK1rdEP8xfRiv9p/10iq31iiVonl5FIBWNHvWwP4NcZfSugseh8JaT+fbY0SyaMDE5SGg== X-Received: by 2002:a63:5a19:: with SMTP id o25mr24462502pgb.122.1622499137637; Mon, 31 May 2021 15:12:17 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id j3sm11949637pfe.98.2021.05.31.15.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 15:12:17 -0700 (PDT) From: Punit Agrawal To: linux-rockchip@lists.infradead.org, linux-pci@vger.kernel.org Cc: Punit Agrawal , linux-arm-kernel@lists.infradead.org, linux-kernel@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, helgaas@kernel.org, robh+dt@kernel.org, Heiko Stuebner Subject: [PATCH v2 4/4] arm64: dts: rockchip: Update PCI host bridge window to 32-bit address memory Date: Tue, 1 Jun 2021 07:10:57 +0900 Message-Id: <20210531221057.3406958-5-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531221057.3406958-1-punitagrawal@gmail.com> References: <20210531221057.3406958-1-punitagrawal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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 Cc: Heiko Stuebner Cc: 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>,