Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2933473pxj; Mon, 31 May 2021 15:12:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAfuqfohffBwRCwT2RGW9hcj0M+dub7BvJaYbZSPCsE6zWGgl9Ncx6wxo+iO4fKAYg+S1U X-Received: by 2002:a05:6e02:1111:: with SMTP id u17mr7321622ilk.307.1622499171469; Mon, 31 May 2021 15:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622499171; cv=none; d=google.com; s=arc-20160816; b=MTnZxXweHMHqccKl4lBze1RqYy/kq7arCAFDuCp07M0ms6EdWP1Vcg64xdzS1K1avh etie5k0O7vjl+DVxbsVsXxrBrMXpsUZcOabY4qBKGewCpsZp9SIifpWL0+5LbbFyLyoc yTOy0/dBJzAuW3U9/Fzcy32SpUzQ+cPaGk8iC5jCWpmCvmDkVDpejSKT+7gikycjq/6i 2zsHKDcr5hErYOft6PzNDCQzbpyC48sYeRugBccJQha/AR06Y388OQxtSjHi3Xbvvrvw fVwWt7BtIHnSI1saAU2OjPODxyYxaw6cKDqqwr4buKZXrzpMUPIS5m0E25CNduqiqQ1i TERQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ObJnk/4SRS5pFYp9Ryi74xRKcVKBz9rodsuAFbTAcF0=; b=upuf2ugSn6Cafz9d5t6AzLmb35dncVJoSQhU4oOl+ZbjDmGYXwpe7ltTv0MwPGKUdc R8IOW0Ie7JILrqfBLGVd4CkW4VAgfxJogXzZJ9ZQf6bIYd7CuLI9JvAAMNdGIiIe4eNV 3e5/YBBzMB6hRVTrn2hDWhRlqLI7DIEuaH82zGMFq4bLZD1NuRnDh4wxfQL74L+M2FCs 7KLv5UfHRw2gjA+8DCntTx6HSqzXcnhX6cu8jv+p4AX04GVzBCb3saCMf1T8KvVYtbBo scdUbl7wzy+sYH6q/9zMNrr0K4tqoEmhd+0H35KxZifYU3WvgTC7YakjjcyRQXnsY6Ly a+WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NuJwoNvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si2835294ilg.30.2021.05.31.15.12.38; Mon, 31 May 2021 15:12:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NuJwoNvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232182AbhEaWNX (ORCPT + 99 others); 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-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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.30.2