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 CB787C77B75 for ; Tue, 9 May 2023 12:21:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3053D847DB; Tue, 9 May 2023 14:21:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C8BA985021; Tue, 9 May 2023 14:21:50 +0200 (CEST) Received: from mail-m11879.qiye.163.com (mail-m11879.qiye.163.com [115.236.118.79]) (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 A8B2980B9E for ; Tue, 9 May 2023 14:21:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@rock-chips.com Received: from [192.168.0.116] (unknown [112.49.211.222]) by mail-m11879.qiye.163.com (Hmail) with ESMTPA id 723C76805E6; Tue, 9 May 2023 20:19:12 +0800 (CST) Message-ID: Date: Tue, 9 May 2023 20:19:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 4/8] pci: pcie_dw_rockchip: Hide BARs of the root complex Content-Language: en-US To: Jonas Karlman , Simon Glass , Philipp Tomsich Cc: Eugen Hristev , u-boot@lists.denx.de, =?UTF-8?B?5p6X5rabKOW6leWxguW5s+WPsCk=?= , =?UTF-8?B?5p6X6byO5by6?= References: <20230422181943.889436-1-jonas@kwiboo.se> <20230422181943.889436-5-jonas@kwiboo.se> From: Kever Yang In-Reply-To: <20230422181943.889436-5-jonas@kwiboo.se> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCTEpNVk4YGUpDHk9DTktPHVUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSVVPQlVJSkpVSUlJWVdZFhoPEhUdFFlBWU9LSFVKTkxJSklVSktLVUpCWQY+ X-HM-Tid: 0a8800738c832eb5kusn723c76805e6 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PRg6Eio*PT0QIysNVhYVCjo6 M09PChBVSlVKTUNITUhPTE5IS0hMVTMWGhIXVRAeDR4JVQIaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlKSklVT0JVSUpKVUlJSVlXWQgBWUFPS0tDNwY+ 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 Jonas, On 2023/4/23 02:19, Jonas Karlman wrote: > 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. Could you share the error message without this workaround? I think the driver can works without this patch, the 1GiB memory BAR will assigned fail and has no affect to BAR allocate for attached device. Thanks, - Kever > > 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, > }; >