Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp152021pxb; Mon, 7 Feb 2022 08:17:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCuC3v7tu7fL/O/xX//DSGf4F4bO0bJqAqLfAdm7X+7Kaqbr2jqdkTfMi2KBwSQuq+0TaU X-Received: by 2002:a17:90a:5407:: with SMTP id z7mr330484pjh.7.1644250622832; Mon, 07 Feb 2022 08:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644250622; cv=none; d=google.com; s=arc-20160816; b=Df3vaQ/yET4WxYEPmZ77m7FdLmUib7Zzx+VuT5AW4gOPyFUZoJYMHv+gtUTGLjSAr0 VvvsmBpC5kTUcwtNJ5I+yLGDjs77ARQh7d1nI+q19PP5GnWnlck6nh6peoAnTjc3Wrx9 os6h69+t6GRCc6wmJMhDCkcWI+mVzpc05tz0Ysx/FbjG8XnC60JiNjq8zyyQSvZOJ/BL MNOxdTACNYjWOU30Lj0lTyoUWNZA/vcX/r8Po2WCGU3bAx8bUx+wFNvzqMk5wS6HzWpY BvWEVqbtfA7vMWtWhoMvATHyJNeKyY8Eqlatm4impT0cNA/GJKMXXszmWZR2IJIGBctM pe+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:mime-version; bh=bsyPHAO4UIpkH9Omo3GvW9iNJsY7sQGoibdbCqmLCQ4=; b=Sr1LYmCjiBAPBS7QgoZTo4QWWCD1Kgogy+j706gko5JpPNNIipBCD5Ac/LIXkCHIHn m36X8r9adpFoQu2u05eJb9O+GICIuRtl5JWS+yFEg7LqyzfO+mrZns037kvz5jPrgKw1 l3LB27MBV6rjGUUQ9CEPLsQP1qboFNKls59HNEtNET+UFvR8chwHJ4KZPz0pXkQG2qKk TN7qrhLG8i47rZIaFKb3dDCeOo5x3AvostY3WdVNhrnFzd3NApuzPkY/phgZwqa3Fn6e u8ttB9Z38ni61WJsCkPC04leEFg9OZUhZcF/5Ai95PbcEVkQwwerGTYv/cMiZ2s6p44x GkOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw14si23505555pjb.82.2022.02.07.08.16.51; Mon, 07 Feb 2022 08:17:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239831AbiBEI7Y (ORCPT + 99 others); Sat, 5 Feb 2022 03:59:24 -0500 Received: from imap2.colo.codethink.co.uk ([78.40.148.184]:36420 "EHLO imap2.colo.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231128AbiBEI7U (ORCPT ); Sat, 5 Feb 2022 03:59:20 -0500 Received: from [78.40.148.178] (helo=webmail.codethink.co.uk) by imap2.colo.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1nGGuX-0005XR-Vr; Sat, 05 Feb 2022 08:59:13 +0000 MIME-Version: 1.0 Date: Sat, 05 Feb 2022 08:59:13 +0000 From: Ben Dooks To: David Abdurachmanov Cc: Paul Walmsley , Greentime Hu , lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, linux-pci@vger.kernel.org, "linux-kernel@vger.kernel.org List" , linux-riscv , macro@orcam.me.uk Subject: Re: [PATCH] PCI: fu740: RFC: force gen1 and get devices probing In-Reply-To: References: <20220204183316.328937-1-ben.dooks@codethink.co.uk> Message-ID: <32a067b4a6b14fc4229c5f56e0280101@codethink.co.uk> X-Sender: ben.dooks@codethink.co.uk Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-02-04 19:12, David Abdurachmanov wrote: > On Fri, Feb 4, 2022 at 8:35 PM Ben Dooks > wrote: >> >> The dw pcie core does not probe devices unless this fix >> from u-boot is applied. The link must be changed to gen1 >> and then the system will see all the other pcie devices >> behind the unmatched board's bridge. >> >> This is a quick PoC to try and get our test farm working >> when a system does not have the pcie initialised by a >> u-boot script. >> >> I will look at a proper patch when I am back in the office > > Hi, > > Have you looked into the patches posted for Linux and U-Boot from > Maciej W. Rozycki? I haven't seen any u-boot patches, but I do know u-boot has been able to do this since 2021.08 release as a colleague has apparently know about needing to initialise PCIe under u-boot to get Linux to properly enumerate devices. Do you have a reference to these, trivial google searches did not show any patches. > On the Linux side (not reviewed yet): > [PATCH v3] pci: Work around ASMedia ASM2824 PCIe link training failures > https://www.spinics.net/lists/linux-pci/msg120112.html This is not the issue, we do not see even the ASMedia PCIe bridge if u-boot does not have PCIe initialisation done. > The U-Boot fix was merged a few days ago. Ok, but I think the kernel should also have this fix done as it seems bad to have to upgrade u-boot on all the machines for something that is not a large fix. > david > >> --- >> drivers/pci/controller/dwc/pcie-fu740.c | 37 >> +++++++++++++++++++++++++ >> 1 file changed, 37 insertions(+) >> >> diff --git a/drivers/pci/controller/dwc/pcie-fu740.c >> b/drivers/pci/controller/dwc/pcie-fu740.c >> index 960e58ead5f2..44f792764e45 100644 >> --- a/drivers/pci/controller/dwc/pcie-fu740.c >> +++ b/drivers/pci/controller/dwc/pcie-fu740.c >> @@ -181,11 +181,48 @@ static void fu740_pcie_init_phy(struct >> fu740_pcie *afp) >> fu740_phyregwrite(1, PCIEX8MGMT_PHY_LANE3_BASE, >> PCIEX8MGMT_PHY_INIT_VAL, afp); >> } >> >> +/* u-boot forces system to gen1 otherwise nothing probes... */ >> +static void pcie_sifive_force_gen1(struct dw_pcie *dw, struct >> fu740_pcie *afp ) >> +{ >> + unsigned val; >> + >> +#if 0 >> + /* u-boot code */ >> + /* ctrl_ro_wr_enable */ >> + val = readl(sv->dw.dbi_base + PCIE_MISC_CONTROL_1); >> + val |= DBI_RO_WR_EN; >> + writel(val, sv->dw.dbi_base + PCIE_MISC_CONTROL_1); >> + >> + /* configure link cap */ >> + linkcap = readl(sv->dw.dbi_base + PF0_PCIE_CAP_LINK_CAP); >> + linkcap |= PCIE_LINK_CAP_MAX_SPEED_MASK; >> + writel(linkcap, sv->dw.dbi_base + PF0_PCIE_CAP_LINK_CAP); >> + >> + /* ctrl_ro_wr_disable */ >> + val &= ~DBI_RO_WR_EN; >> + writel(val, sv->dw.dbi_base + PCIE_MISC_CONTROL_1); >> +#endif >> + >> + val = readl_relaxed(dw->dbi_base + PCIE_MISC_CONTROL_1_OFF); >> + val |= PCIE_DBI_RO_WR_EN; >> + writel_relaxed(val, dw->dbi_base + PCIE_MISC_CONTROL_1_OFF); I've found pre-made functions for these. >> + >> + val = readl(dw->dbi_base + 0x70 + 0x0c); >> + val |= 0xf; >> + writel(val, dw->dbi_base + 0x70 + 0x0c); Will fix to config-register 0x0c and try and find the relevant macros for this and the proper accessor macros for the dw driver. >> + >> + val = readl_relaxed(dw->dbi_base + PCIE_MISC_CONTROL_1_OFF); >> + val &= ~PCIE_DBI_RO_WR_EN; >> + writel_relaxed(val, dw->dbi_base + PCIE_MISC_CONTROL_1_OFF); >> +} >> + >> static int fu740_pcie_start_link(struct dw_pcie *pci) >> { >> struct device *dev = pci->dev; >> struct fu740_pcie *afp = dev_get_drvdata(dev); >> >> + pcie_sifive_force_gen1(pci, afp); I'll change this to fu740_pcie_force_gen1() >> + >> /* Enable LTSSM */ >> writel_relaxed(0x1, afp->mgmt_base + >> PCIEX8MGMT_APP_LTSSM_ENABLE); >> return 0; >> -- >> 2.34.1 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv