Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp801272pxj; Thu, 27 May 2021 11:58:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/NGNh9KxrrL+90pgPWao8l48u0oRUG7r44DvdvggtYcX0FqvjSuDserbl4jtvMpHH0oaX X-Received: by 2002:a05:6402:40d0:: with SMTP id z16mr5932384edb.104.1622141880077; Thu, 27 May 2021 11:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622141880; cv=none; d=google.com; s=arc-20160816; b=iAym/8/C1ZcT0fjJRio7bts1ACVGSowJk031Wr03AKyTHGLGxj+/RE5HU2b1gZf1PT 2tLkKe30OtxvbjKIMEx7s1MGELsUFSgcE0tR7+7ABywsOQhMo64onRat2FZr79+0l9Sh V2KIEQaREHAoL3JgDAf0em0MQYTc1FXyJirsyrZRxtmhoVrHvIkkCObQkjqHeuyr1FIZ bksQBuunhRTf23XhutnetpLRT1Xl3UrAGhA/6vPfzJyLEuNPtUIuaZblMU+1OZEX7YPz y5rAwEcFEINS9HAOJfGvbzC3Gukr9CdFLulizSDluYRXaYJgauQkHb1BQy+RM1MRdKlz BBXQ== 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=5rL5GD+NbaaEqIeUyr3EdNmYvLxCh+7TICV0hGuxoW4=; b=biOk7+9es91JL5zRw5amEs94AHzvBTzdx1E5MYCGjIp1Hq0t/81PVaNevoRoBGvCn0 CGGcxHOT27cLD4MCr+BrVXWjdlJvcXkqVW4tCzVc9mILOvsaQfqbrVfddR33mWl+CGUT WQTJ1t1eu6oWsBtsJ26YPlPjClwBTAzGt8xe6V8r7Z342aj3zA6bBAF6J/WjcXvHvkV6 FfW93XXb+al6jbSv+yhZsu1t/EECC7jV8f5ijN9dOCllLdzt0GNij1N2fOrvafKS2ArK 95Q7sA8JIUht3YXPB9x8D52orwkasLtrYl8NwrB1Ig0HrY6OtpH/s+nXLl83MdToKviL 5ShA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HueSznr3; 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 kl10si2963278ejc.361.2021.05.27.11.57.35; Thu, 27 May 2021 11:58:00 -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=HueSznr3; 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 S236454AbhE0Qki (ORCPT + 99 others); Thu, 27 May 2021 12:40:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234278AbhE0Qke (ORCPT ); Thu, 27 May 2021 12:40:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61DF1613AF; Thu, 27 May 2021 16:39:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622133540; bh=5DJuW/bnBtUHJd7Q3Q7OZvGhMJUl8t5p1TVaOTuL/hg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HueSznr3Fu2IQEOByfQwL7tX83bW8Ryg5HdBSrz++Tm7FjPH2ctScG/Nq/RkVZ8D5 izO8mIqcIQ3S2LskbH0lCj+XnyXDzyK93cCQ9qYXTP8shcACOUu/pu7Hhe4QeeUBB3 80wews3XswhJMcUoKzBslppBq/q5nShlMtWl6FjODW26b0T2k6Ed1lHcIJm4r516Ex VfHUrt1LLnz6vmoZ5Khy2Q8jIoSMELpGLm1XnfkvDBp+kxyp2KWTYttvfRnUfdVThD LQRipXdRu+kqtOOAU1KrKb6QnvuHlpx1MwNn0C882gXjQVdHsfekWSoesWJzolbrrk rc+t2T80Ksovw== Received: by mail-ej1-f42.google.com with SMTP id z12so1194444ejw.0; Thu, 27 May 2021 09:39:00 -0700 (PDT) X-Gm-Message-State: AOAM532B52BVM57GUQrKsPIKunkLQ+SRw57DGVY0u1k0pPmWQ9TM9HWO TRkCRCPP+ZQMewhQc0cnlv29qzsLY3boeg1x2A== X-Received: by 2002:a17:906:7b88:: with SMTP id s8mr365002ejo.525.1622133538969; Thu, 27 May 2021 09:38:58 -0700 (PDT) MIME-Version: 1.0 References: <20210527150541.3130505-1-punitagrawal@gmail.com> <20210527150541.3130505-2-punitagrawal@gmail.com> In-Reply-To: <20210527150541.3130505-2-punitagrawal@gmail.com> From: Rob Herring Date: Thu, 27 May 2021 11:38:46 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] PCI: of: Override 64-bit flag for non-prefetchable memory below 4GB To: Punit Agrawal Cc: "open list:ARM/Rockchip SoC..." , PCI , linux-arm-kernel , "linux-kernel@vger.kernel.org" , Alexandru Elisei , wqu@suse.com, Robin Murphy , Peter Geis , Ard Biesheuvel , Brian Norris , Shawn Lin , Bjorn Helgaas , Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 27, 2021 at 10:06 AM Punit Agrawal wrote: > > 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-to-PCI bridges 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 are connected behind PCI host > bridges modelled as PCI-to-PCI bridge and 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 > --- > drivers/pci/of.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/of.c b/drivers/pci/of.c > index da5b414d585a..b9d0bee5a088 100644 > --- a/drivers/pci/of.c > +++ b/drivers/pci/of.c > @@ -565,10 +565,14 @@ static int pci_parse_request_of_pci_ranges(struct device *dev, > case IORESOURCE_MEM: > res_valid |= !(res->flags & IORESOURCE_PREFETCH); > > - if (!(res->flags & IORESOURCE_PREFETCH)) > + if (!(res->flags & IORESOURCE_PREFETCH)) { > if (upper_32_bits(resource_size(res))) > dev_warn(dev, "Memory resource size exceeds max for 32 bits\n"); Based on Ard's explanation, doesn't this need to also check for !IORESOURCE_MEM_64? > - > + if ((res->flags & IORESOURCE_MEM_64) && !upper_32_bits(res->end)) { res->end is the CPU address space. Isn't it the PCI address space we care about? > + dev_warn(dev, "Overriding 64-bit flag for non-prefetchable memory below 4GB\n"); > + res->flags &= ~IORESOURCE_MEM_64; > + } > + } > break; > } > } > -- > 2.30.2 >