Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2287415pxu; Fri, 18 Dec 2020 09:34:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2gHfoZjUtkq1g14pBJUYD8TW1o2Xm5AeBTnUP0+DirMX0xKizL1KYM6B4xoca8MbX1kgA X-Received: by 2002:a17:906:848:: with SMTP id f8mr4979274ejd.404.1608312856241; Fri, 18 Dec 2020 09:34:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312856; cv=none; d=google.com; s=arc-20160816; b=JmM9yonjAm3I1J+OI16mB6bfdRlX76fyQ1fvvcpFfqHyBLiNzlfSEOHrj0E4Dj79ru 2GHDeh5Po4PqQvkOktE1AYMBZV2ZtgDeGb1u9rXRdJPX+/BqbDDALPQFtnjZQOKsocXY Ay73wbc94OJ3eBk3UcaaZpXRb9DxkLe/cSJg51xJcOuA6QlOV39+lvIbC5rT8UCQH1K8 ojl5w3EebLffw9sl6DYVLT+feozk1LFTkzdYIqSYQRYBx7qkc15XIrFEFo+i6NG0JC3A BdE9RghfxQmXRXdAo+RgEoI7AqeK7ygWfe7ySnzbYhTCfESET/oRmVrizi1+ltqNQ33D awjg== 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=mzwsdc5YeVlIL3+XSfQWQcOYOWbwg5sXcmGXwC1l+a4=; b=jUp8z+9jPWQryk4M9BBSIFQTahbWTHCP5GX7w3fIrYqJzpOLVkBGJjCNGCMKYiwThZ VBVuERJMJU5ImmGOwqm8Yl005NpOi6CN8uXWvdaSowDTkKXrt6m85H0n5H9QNG3BiRf1 nQ1JRPLvUUE77nZwLqKefnovI1OhD5LfOte9DD5LbpNrCuzPK9kivL1AIHvdknbQkO1W ih/SaPqjfnIgkvSIeJnzFEuWcwuK3+s9MbBFj8yUUh06TMgaZ0pjWLvhoJFpsIDu327/ XTa7Z/Hl/JYGho2fXF/szC/7am4nQ5jm3GmO/LNeYXAmwvhmxGFCq/GScI9A2JpfayE7 vjhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cC9AQytU; 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 cx27si3418650edb.264.2020.12.18.09.33.52; Fri, 18 Dec 2020 09:34:16 -0800 (PST) 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=cC9AQytU; 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 S1730084AbgLRRcR (ORCPT + 99 others); Fri, 18 Dec 2020 12:32:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:37076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727787AbgLRRcR (ORCPT ); Fri, 18 Dec 2020 12:32:17 -0500 X-Gm-Message-State: AOAM530eYzdjIS03DeU23l1QN0UavYealEGwaEVsaREi6cWhayzQadiG Qq/APuihaVTN2/VnS0yyYq4Xtr6Ws7wgbfp7Mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608312696; bh=BGGQyU71jC8PHb+t5FSRSX4kcxy5gG40URfePe8J9nU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cC9AQytUFvAovKozDhlHSzCa40u9b51UDDu9DY6VQsEs2qwlTb7/eZ+duGTl5G1MJ ltk1VO2sg5dTfQ9/rD8rASKJc+I7GyP3U29GCpmR4vNcsvQhuTGV9xRWhbP9HVb3Cr GHcvUq6DPgtaiTnrm90fWn6uZTlOzXGvAz3ugrDpPpOwC9zbdWaT0hryRuRTgrwTal 8RHDiRRFV4faBB8B+E/aBqM+Qyr+AtKu47VmmKqT+pQW+ygXcKYgIsnYFKtt1PlFsj 2kRsozrN5SM3jDENsG6+VwteAIt6IsjRhBdaQHFUKX3GBUBFmwd3KMIUCI0udLN/Mh Rfjes/c6AAKKA== X-Received: by 2002:a17:906:d87:: with SMTP id m7mr5100609eji.108.1608312694596; Fri, 18 Dec 2020 09:31:34 -0800 (PST) MIME-Version: 1.0 References: <20201215070009.27937-1-kishon@ti.com> <1ec78477-dadc-cbef-406f-568f44b6c62d@ti.com> <96ca64cb-ec3a-bb83-2de3-775034ba844b@ti.com> In-Reply-To: <96ca64cb-ec3a-bb83-2de3-775034ba844b@ti.com> From: Rob Herring Date: Fri, 18 Dec 2020 11:31:22 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] PCI: cadence: Retrain Link to work around Gen2 training defect. To: Kishon Vijay Abraham I Cc: Tom Joseph , Bjorn Helgaas , Nadeem Athani , linux-omap , PCI , linux-arm-kernel , "linux-kernel@vger.kernel.org" , Milind Parab , Swapnil Kashinath Jakhade , Parshuram Raju Thombare Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 18, 2020 at 8:42 AM Kishon Vijay Abraham I wrote: > > Hi Rob, > > On 16/12/20 10:31 pm, Rob Herring wrote: > > On Wed, Dec 16, 2020 at 9:01 AM Kishon Vijay Abraham I wrote: > >> > >> Hi Rob, > >> > >> On 15/12/20 9:23 pm, Rob Herring wrote: > >>> On Tue, Dec 15, 2020 at 1:00 AM Kishon Vijay Abraham I wrote: > >>>> > >>>> From: Nadeem Athani > >>>> > >>>> Cadence controller will not initiate autonomous speed change if strapped as > >>>> Gen2. The Retrain Link bit is set as quirk to enable this speed change. > >>>> > >>>> Signed-off-by: Nadeem Athani > >>>> [kishon@ti.com: Enable the workaround for TI's J721E SoC] > >>>> Signed-off-by: Kishon Vijay Abraham I > >>>> --- > >>>> Hi Lorenzo, > >>>> The previous version of the patch can be found at [1]. > >>>> I slightly re-worked the patch from Nadeem > >>>> *) Removed additional Link Up Check > >>>> *) Removed quirk from pcie-cadence-plat.c > >>>> *) Also removed additional compatible > >>>> "cdns,cdns-pcie-host-quirk-retrain" added in that series > >>>> *) Enabled the quirk for J721E > >>>> [1] -> http://lore.kernel.org/r/20201211144236.3825-1-nadeem@cadence.com > >>>> > >>>> drivers/pci/controller/cadence/pci-j721e.c | 3 + > >>>> .../controller/cadence/pcie-cadence-host.c | 67 ++++++++++++++----- > >>>> drivers/pci/controller/cadence/pcie-cadence.h | 11 ++- > >>>> 3 files changed, 62 insertions(+), 19 deletions(-) > >>>> > >>>> diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c > >>>> index dac1ac8a7615..baf729850cb1 100644 > >>>> --- a/drivers/pci/controller/cadence/pci-j721e.c > >>>> +++ b/drivers/pci/controller/cadence/pci-j721e.c > >>>> @@ -64,6 +64,7 @@ enum j721e_pcie_mode { > >>>> > >>>> struct j721e_pcie_data { > >>>> enum j721e_pcie_mode mode; > >>>> + bool quirk_retrain_flag; > >>>> }; > >>>> > >>>> static inline u32 j721e_pcie_user_readl(struct j721e_pcie *pcie, u32 offset) > >>>> @@ -280,6 +281,7 @@ static struct pci_ops cdns_ti_pcie_host_ops = { > >>>> > >>>> static const struct j721e_pcie_data j721e_pcie_rc_data = { > >>>> .mode = PCI_MODE_RC, > >>>> + .quirk_retrain_flag = true, > >>>> }; > >>>> > >>>> static const struct j721e_pcie_data j721e_pcie_ep_data = { > >>>> @@ -388,6 +390,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) > >>>> > >>>> bridge->ops = &cdns_ti_pcie_host_ops; > >>>> rc = pci_host_bridge_priv(bridge); > >>>> + rc->quirk_retrain_flag = data->quirk_retrain_flag; > >>>> > >>>> cdns_pcie = &rc->pcie; > >>>> cdns_pcie->dev = dev; > >>>> diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c > >>>> index 811c1cb2e8de..773c0d1137ed 100644 > >>>> --- a/drivers/pci/controller/cadence/pcie-cadence-host.c > >>>> +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c > >>>> @@ -77,6 +77,50 @@ static struct pci_ops cdns_pcie_host_ops = { > >>>> .write = pci_generic_config_write, > >>>> }; > >>>> > >>>> +static int cdns_pcie_host_wait_for_link(struct cdns_pcie *pcie) > >>>> +{ > >>>> + struct device *dev = pcie->dev; > >>>> + int retries; > >>>> + > >>>> + /* Check if the link is up or not */ > >>>> + for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { > >>>> + if (cdns_pcie_link_up(pcie)) { > >>>> + dev_info(dev, "Link up\n"); > >>>> + return 0; > >>>> + } > >>>> + usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); > >>>> + } > >>>> + > >>>> + return -ETIMEDOUT; > >>>> +} > >>>> + > >>>> +static void cdns_pcie_retrain(struct cdns_pcie *pcie) > >>>> +{ > >>>> + u32 lnk_cap_sls, pcie_cap_off = CDNS_PCIE_RP_CAP_OFFSET; > >>>> + u16 lnk_stat, lnk_ctl; > >>>> + > >>>> + /* > >>>> + * Set retrain bit if current speed is 2.5 GB/s, > >>>> + * but the PCIe root port support is > 2.5 GB/s. > >>> > >>> If you don't have the retrain quirk, wouldn't this condition never > >>> happen and then the function is just a nop? So this could just be > >>> called unconditionally. > >> > >> Yeah, but only for the quirk we have to retrain to go to GEN2 speed > >> mode. Else the HW will automatically retrain and go to GEN2. > > > > Again, so you don't need a flag for this. Comparing the speed is > > enough. IOW, all you need is: > > > > if (current speed < advertised speed) > > do retrain > > > > The question is the condition ever true and you don't want to do a > > retrain? I could see higher speeds being unstable or something, but > > For all GEN1 cards there will be re-train (since the Cadence IP RC is > GEN2 or more say). This is going to be true for older Cadence IPs and > newer Cadence IPs (where Cadence has enabled HW re-training). > > The quirk will prevent SW re-training for newer Cadence IPs when a GEN1 > card is connected. Okay, got it. Reviewed-by: Rob Herring