Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5289AC7618E for ; Mon, 24 Apr 2023 14:06:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A55E585A48; Mon, 24 Apr 2023 16:06:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=agner.ch Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=agner.ch header.i=@agner.ch header.b="mBBZX4DY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C99FC859AB; Mon, 24 Apr 2023 16:06:40 +0200 (CEST) Received: from mail.kmu-office.ch (mail.kmu-office.ch [IPv6:2a02:418:6a02::a2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 042918574D for ; Mon, 24 Apr 2023 16:06:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=agner.ch Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan@agner.ch Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 505015C4747; Mon, 24 Apr 2023 16:06:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1682345197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a89Dy0BePOFnhlQSsMaaEZ1UQ3QkSxrp+cTpaKT1qFU=; b=mBBZX4DYRDfX5TqnMT4YS1c2Z6/qRypeJT5R/pFmDPxpLro63UrUj6kj2OdgbIMwrwqhbJ Vxw45LgX7Lnuip/qqID5fa4t4EurL3yvTFRvdeAAf6zq2vYMWRJgV/iatp47lXp8TCHW3g Cb/UFm94+TYVAA63gRLCYshQKPOsr+s= MIME-Version: 1.0 Date: Mon, 24 Apr 2023 16:06:37 +0200 From: Stefan Agner To: Andrew Scull Cc: u-boot@lists.denx.de, sjg@chromium.org, bmeng.cn@gmail.com, adelva@google.com, keirf@google.com, ptosi@google.com Subject: Re: [PATCH v2 10/18] pci: Check region ranges are addressable In-Reply-To: <20220329165900.1139885-11-ascull@google.com> References: <20220329165900.1139885-1-ascull@google.com> <20220329165900.1139885-11-ascull@google.com> Message-ID: <34b420f79ee0ba83ee6975b249f4a10d@agner.ch> X-Sender: stefan@agner.ch Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hi Andrew, On 2022-03-29 18:58, Andrew Scull wrote: > When parsing the `ranges` DT node, check that both extremes of the > regions are addressable without overflow. This assumption can then be > safely made when processing the regions. I've bisected this patch to break USB support on 32-bit Raspberry Pi 4 builds. We've been using U-Boot v2022.01 so far with USB boot support. With the migration to U-Boot v2023.01, stopped booting with the following output: U-Boot 2023.01+ (Apr 24 2023 - 15:11:45 +0200) DRAM: 948 MiB (effective 7.9 GiB) RPI 4 Model B (0xd03114) Core: 207 devices, 15 uclasses, devicetree: board MMC: mmcnr@7e300000: 1, mmc@7e340000: 0 Loading Environment from nowhere... OK In: serial Out: serial Err: serial Net: eth0: ethernet@7d580000 PCIe BRCM: link up, 5.0 Gbps x1 (SSC) PCI Autoconfig: Found P2P bridge, device 0 PCI Autoconfig: BAR 0, Prf64, size=0x1000, No resource PCI: Failed autoconfig bar 10 starting USB... Bus xhci_pci: In this builds I've set #define DEBUG in drivers/pci/pci_auto(_common).c. Reverting this commit leads to: U-Boot 2023.01+ (Apr 24 2023 - 15:47:58 +0200) DRAM: 948 MiB (effective 7.9 GiB) RPI 4 Model B (0xd03114) Core: 207 devices, 15 uclasses, devicetree: board MMC: mmcnr@7e300000: 1, mmc@7e340000: 0 Loading Environment from nowhere... OK In: serial Out: serial Err: serial Net: eth0: ethernet@7d580000 PCIe BRCM: link up, 5.0 Gbps x1 (SSC) PCI Autoconfig: Bus Memory region: [c0000000-ffffffff], Physical Memory [600000000-63fffffff] PCI Autoconfig: Found P2P bridge, device 0 PCI Autoconfig: BAR 0, Mem64, size=0x1000, address=0xc0000000 bus_lower=0xc0001000 starting USB... Bus xhci_pci: Register 5000420 NbrPorts 5 Starting the controller USB XHCI 1.00 scanning bus xhci_pci for devices... 3 USB Device(s) found scanning usb for storage devices... 1 Storage Device(s) found ... The system boot successfully a bootable system. Note that this needs CONFIG_USB_XHCI_BRCM=y which is not set by default in rpi_4_32b_defconfig. I am guessing that the freeze is just a subsequent issue of not handling PCI: Failed autoconfig bar 10 properly. But in any case, I'd prefer to have a working PCIe in general. Is maybe the Raspberry Pi device tree not suited for 32-bit operation? Can't we use some sensible range in this case? -- Stefan > > Signed-off-by: Andrew Scull > Reviewed-by: Bin Meng > --- > drivers/pci/pci-uclass.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c > index 719656eb3a..d84d97d676 100644 > --- a/drivers/pci/pci-uclass.c > +++ b/drivers/pci/pci-uclass.c > @@ -1017,7 +1017,22 @@ static void decode_regions(struct > pci_controller *hose, ofnode parent_node, > > if (!IS_ENABLED(CONFIG_SYS_PCI_64BIT) && > type == PCI_REGION_MEM && upper_32_bits(pci_addr)) { > - debug(" - beyond the 32-bit boundary, ignoring\n"); > + debug(" - pci_addr beyond the 32-bit boundary, ignoring\n"); > + continue; > + } > + > + if (!IS_ENABLED(CONFIG_PHYS_64BIT) && upper_32_bits(addr)) { > + debug(" - addr beyond the 32-bit boundary, ignoring\n"); > + continue; > + } > + > + if (~((pci_addr_t)0) - pci_addr < size) { > + debug(" - PCI range exceeds max address, ignoring\n"); > + continue; > + } > + > + if (~((phys_addr_t)0) - addr < size) { > + debug(" - phys range exceeds max address, ignoring\n"); > continue; > }