Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3180389pxj; Mon, 31 May 2021 22:51:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDNmvqslaV3Z2C6r3uiPTZJtaxvpVC9GYPFOD0VxO/SiuD3VL7kmd5M2wko8xP5JBZbH9r X-Received: by 2002:a17:906:6dd0:: with SMTP id j16mr27127348ejt.208.1622526676928; Mon, 31 May 2021 22:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622526676; cv=none; d=google.com; s=arc-20160816; b=RTKcC18Rb7wTXY6cPO2ENAjPfEJvHm4ft/7xIfkI3SO6nmaYKVzfgtVkyU2XaZpDvL XGyGsSMhFFK2PH6FcMH8OzvZE/D8x8aOHeAi1JHR705E/N801ltvajh//BkDyivFeybq DCGm+ckcKvRMkVJ0iFHmVULYZbBUo2ICu5hXTLaEn7Fw8OyOkCb0vNZ7gReJot8m8XQL arfJlujuuFK4V9BuWXjkY5Yn36qnmtrR3e2Y/OLCcS4UQfYtaHsRDsEfTiKf/5t08PKc itkFbpNatdfrC/+aTGdtTBQmPArHvs2/fCYXV1kc9j5GR/VoDZk7Dbv2hyakSuymfqyd AWYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=I6/apW5NhbIZfRwyiQ5OHmmzdyaUcQNDFPPEVnBzkZw=; b=CS7DSppLv7e1vqqsc7Bwqu+PVzv3SOz9uk71y5rDYLEfZiLw75WMQRmTjiw1/iUued TUZwY2cjIO+FKzQAy+ucuEKJBAna+MMNwT4BtqJHatoXOXJhEBhoKxsfdlT9aGZPoSza 8yFNzhC/Rxedk3AEvl9fC2BDd4rpQlrB/HUVH4/WmbEMrdV71efOiR5k/1HCVHDgk5DB isP+02duEhj/o+pQnXlmA9l+zJ/UiXSkdeMCknayLgNOQyg4Irg3dr1TDpsy6B1Kcz7n tW3tMX2iIfnOkT4kZxPRCNbDTyLdciyqLWcSecyShpwRApefS/Q4pZYRREMo9znij5cm dK1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZbBVaFHV; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si15354539edx.76.2021.05.31.22.50.54; Mon, 31 May 2021 22:51:16 -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=@kernel.org header.s=k20201202 header.b=ZbBVaFHV; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232725AbhFAFu6 (ORCPT + 99 others); Tue, 1 Jun 2021 01:50:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbhFAFu6 (ORCPT ); Tue, 1 Jun 2021 01:50:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 42CC4613AB; Tue, 1 Jun 2021 05:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622526557; bh=OPxQYwkHb+c8kRPYIMeJZ1NAST5RTo/Lc2MbCJ31+VY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZbBVaFHV/dOaGQ4wh+zmyN2lxHOP0Z/AjIO5zoJoUd2RuzjvOhtS9T96+JUNiNO/n +ojMNCmF2kpgkQgHWADV0M3+XGtH+Fn3yI/ANDSxmbIk4j5HUVS+Y7GpwW7hNVhAp9 tCx7VzAoEL1REgTQRv9EqKWSX14UwMjNIMYljUWBZrfd/OY0a4O9gDx8mLEW6w8tUe 6NDueNw7IEwmXcrKBoJMhBZVHTlKO5FHFu/cJtPXUTLKgXb6VJwegTxCp+cYDGlWTr WzqrpejvAEF1KyeM5LLrsdH8Ucc9Rs4ieM+b7LWUY6NooBUoNLtTco2zZylLbznxLj mw8MKPyuZJ06Q== Received: by mail-oi1-f172.google.com with SMTP id a13so8985979oid.9; Mon, 31 May 2021 22:49:17 -0700 (PDT) X-Gm-Message-State: AOAM530eJhDTlNRNDGDgw9OGQiXkSXK1hiRo1a6szNW3OogXAeZjjSgQ TKTMgjj/65WKFsVXzJOxVE9tsm6iXASG3jrWjeA= X-Received: by 2002:a54:460a:: with SMTP id p10mr1817105oip.47.1622526556632; Mon, 31 May 2021 22:49:16 -0700 (PDT) MIME-Version: 1.0 References: <20210531221057.3406958-1-punitagrawal@gmail.com> <20210531221057.3406958-2-punitagrawal@gmail.com> In-Reply-To: <20210531221057.3406958-2-punitagrawal@gmail.com> From: Ard Biesheuvel Date: Tue, 1 Jun 2021 07:49:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/4] PCI: of: Override 64-bit flag for non-prefetchable memory below 4GB To: Punit Agrawal Cc: "open list:ARM/Rockchip SoC..." , PCI , Linux ARM , Linux Kernel Mailing List , Alexandru Elisei , wqu@suse.com, Robin Murphy , Peter Geis , briannorris@chromium.org, shawn.lin@rock-chips.com, Bjorn Helgaas , Rob Herring , Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Punit, On Tue, 1 Jun 2021 at 00:11, Punit Agrawal wrote: > > Some host bridges advertise non-prefetable memory windows that are typo ^ > 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 It is the root port which is modeled as a P2P bridge. The root port(s) together with the host bridge is what makes up the root complex. > 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. > AIUI, the problem is not that the device requires a non-prefetchable bus address, but that it fails to allocate a 32-bit BAR from a 64-bit non-prefetchable window. > 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 >