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 8BB8AC6FD18 for ; Sat, 22 Apr 2023 18:21:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 52FD586475; Sat, 22 Apr 2023 20:20:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kwiboo.se header.i=@kwiboo.se header.b="PZhaMrWB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD8EF86009; Sat, 22 Apr 2023 20:19:57 +0200 (CEST) Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3E0B286430 for ; Sat, 22 Apr 2023 20:19:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=zjQxzcavhnjWNKr21VBhcw97nKrEfMOrBOwekNT2MKs=; b=PZhaMrWBtgwAIi7R/IIimWpe7i9F21IH+Yiy5UZv35eEdCkIUCreXK/ehnXGxOz99goD y6TiFhmOZLHQQ/9CDsmVjfWgM7xE02NePwDUvw9paslYyXrCpyYF8U4JtcXrI3uhFawh/+ +ZWSk+WUj4/dQM36FtJXeTbWdkSn6l7+n5fkKptdj6jC+iswEcufZRhkv23EB3I/eP+uQB iQFKB3c2l4PzxNSJLKz+bVIPRU0WpYNofn8qFj+OHHBnpBv8lxu45OcJDDDYHQ5bXk+AgK bMyio4PsQo8ddPP1b6TP6yEFSmpX8YIQgPlS/ZHl2eNTDQi7AZJfcNJXnGAeBkFA== Received: by filterdrecv-68f8d557c9-xz5bb with SMTP id filterdrecv-68f8d557c9-xz5bb-1-64442546-2E 2023-04-22 18:19:50.798671327 +0000 UTC m=+5165202.989522435 Received: from bionic.localdomain (unknown) by geopod-ismtpd-6 (SG) with ESMTP id WG8g5QsFRRykQ19DtKgYNQ Sat, 22 Apr 2023 18:19:50.577 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 4/8] pci: pcie_dw_rockchip: Hide BARs of the root complex Date: Sat, 22 Apr 2023 18:19:50 +0000 (UTC) Message-Id: <20230422181943.889436-5-jonas@kwiboo.se> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230422181943.889436-1-jonas@kwiboo.se> References: <20230422181943.889436-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0hy3A7cj5BGXTMzADo?= =?us-ascii?Q?6m2RY=2FuCBXMUyqM4gP4snqk6dfhZpg5FC757oHZ?= =?us-ascii?Q?=2Fk37b2PDP2mn6MkQVMuI7h5xwPKgd=2FNFJQC++nX?= =?us-ascii?Q?1yh++kp3=2F=2FosXZPhxCD8n0U9bIFSXSkEWiNGcNE?= =?us-ascii?Q?phBk4f6WOAKhkGswd2os5l8St6pcZNbrHghV80?= To: Kever Yang , Simon Glass , Philipp Tomsich Cc: Eugen Hristev , u-boot@lists.denx.de, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 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 PCI Autoconfig read the Root Complex BARs and try to claim the entire 1 GiB memory region on RK3568, leaving no space for any attached device. Return an invalid value during config read of Root Complex BARs during autoconfig to work around such issue. Signed-off-by: Jonas Karlman --- drivers/pci/pcie_dw_rockchip.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c index fd3da47272b3..924ecb93e963 100644 --- a/drivers/pci/pcie_dw_rockchip.c +++ b/drivers/pci/pcie_dw_rockchip.c @@ -146,6 +146,32 @@ static inline void rk_pcie_writel_apb(struct rk_pcie *rk_pcie, u32 reg, __rk_pcie_write_apb(rk_pcie, rk_pcie->apb_base, reg, 0x4, val); } +/** + * The BARs of bridge should be hidden during enumeration to avoid + * allocation of the entire memory region by PCIe core on RK3568. + */ +static bool rk_pcie_hide_rc_bar(struct pcie_dw *pcie, pci_dev_t bdf, + uint offset) +{ + int bus = PCI_BUS(bdf) - pcie->first_busno; + + return bus == 0 && PCI_DEV(bdf) == 0 && PCI_FUNC(bdf) == 0 && + offset >= PCI_BASE_ADDRESS_0 && offset <= PCI_BASE_ADDRESS_1; +} + +static int rk_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, + uint offset, ulong *valuep, + enum pci_size_t size) +{ + struct pcie_dw *pcie = dev_get_priv(bus); + int ret = pcie_dw_read_config(bus, bdf, offset, valuep, size); + + if (!ret && rk_pcie_hide_rc_bar(pcie, bdf, offset)) + *valuep = pci_get_ff(size); + + return ret; +} + /** * rk_pcie_configure() - Configure link capabilities and speed * @@ -476,7 +502,7 @@ rockchip_pcie_probe_err_init_port: } static const struct dm_pci_ops rockchip_pcie_ops = { - .read_config = pcie_dw_read_config, + .read_config = rk_pcie_read_config, .write_config = pcie_dw_write_config, }; -- 2.40.0