linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: Athani Nadeem Ladkhan <nadeem@cadence.com>,
	"lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Tom Joseph <tjoseph@cadence.com>
Cc: Swapnil Kashinath Jakhade <sjakhade@cadence.com>,
	Milind Parab <mparab@cadence.com>
Subject: Re: [PATCH v3] PCI: cadence: Retrain Link to work around Gen2 training defect.
Date: Fri, 23 Oct 2020 12:26:52 +0530	[thread overview]
Message-ID: <d2aa5519-e207-c3e5-9d81-14209d856b54@ti.com> (raw)
In-Reply-To: <SN2PR07MB255715C886C2DC5B9044BC01D81E0@SN2PR07MB2557.namprd07.prod.outlook.com>

Hi Nadeem,

On 19/10/20 10:48 pm, Athani Nadeem Ladkhan wrote:
> Hi Kishon,
> 
>> -----Original Message-----
>> From: Kishon Vijay Abraham I <kishon@ti.com>
>> Sent: Monday, October 19, 2020 10:59 AM
>> To: Athani Nadeem Ladkhan <nadeem@cadence.com>;
>> lorenzo.pieralisi@arm.com; robh@kernel.org; bhelgaas@google.com; linux-
>> pci@vger.kernel.org; linux-kernel@vger.kernel.org; Tom Joseph
>> <tjoseph@cadence.com>
>> Cc: Swapnil Kashinath Jakhade <sjakhade@cadence.com>; Milind Parab
>> <mparab@cadence.com>
>> Subject: Re: [PATCH v3] PCI: cadence: Retrain Link to work around Gen2
>> training defect.
>>
>> EXTERNAL MAIL
>>
>>
>> Hi Nadeem,
>>
>> On 30/09/20 11:51 pm, Nadeem Athani wrote:
>>> 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 <nadeem@cadence.com>
>>> ---
>>> Changes in v3:
>>> - To set retrain link bit,checking device capability & link status.
>>> - 32bit read in place of 8bit.
>>> - Minor correction in patch comment.
>>> - Change in variable & macro name.
>>> Changes in v2:
>>> - 16bit read in place of 8bit.
>>>  drivers/pci/controller/cadence/pcie-cadence-host.c | 31
>> ++++++++++++++++++++++
>>>  drivers/pci/controller/cadence/pcie-cadence.h      |  9 ++++++-
>>>  2 files changed, 39 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c
>>> b/drivers/pci/controller/cadence/pcie-cadence-host.c
>>> index 4550e0d469ca..2b2ae4e18032 100644
>>> --- a/drivers/pci/controller/cadence/pcie-cadence-host.c
>>> +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c
>>> @@ -77,6 +77,36 @@ static struct pci_ops cdns_pcie_host_ops = {
>>>  	.write		= pci_generic_config_write,
>>>  };
>>>
>>> +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;
>>> +
>>> +	if (!cdns_pcie_link_up(pcie))
>>> +		return;
>>> +
>>
>> Is there a IP version that can be used to check if that quirk is applicable?
> There is no such provision.

hmm okay. Can we add a DT property to indicate the quirk then since
AFAIK this is not required in future revisions of IP.
>>> +	/*
>>> +	 * Set retrain bit if current speed is 2.5 GB/s,
>>> +	 * but the PCIe root port support is > 2.5 GB/s.
>>> +	 */
>>> +
>>> +	lnk_cap_sls = cdns_pcie_readl(pcie, (CDNS_PCIE_RP_BASE +
>> pcie_cap_off +
>>> +				      PCI_EXP_LNKCAP));
>>> +	if ((lnk_cap_sls & PCI_EXP_LNKCAP_SLS) <=
>> PCI_EXP_LNKCAP_SLS_2_5GB)
>>> +		return;
>>> +
>>> +	lnk_stat = cdns_pcie_rp_readw(pcie, pcie_cap_off +
>> PCI_EXP_LNKSTA);
>>> +	if ((lnk_stat & PCI_EXP_LNKSTA_CLS) == PCI_EXP_LNKSTA_CLS_2_5GB)
>> {
>>> +		lnk_ctl = cdns_pcie_rp_readw(pcie,
>>> +					     pcie_cap_off + PCI_EXP_LNKCTL);
>>> +		lnk_ctl |= PCI_EXP_LNKCTL_RL;
>>> +		cdns_pcie_rp_writew(pcie, pcie_cap_off + PCI_EXP_LNKCTL,
>>> +				    lnk_ctl);
>>> +
>>> +		if (!cdns_pcie_link_up(pcie))
>>
>> Should this rather be a cdns_pcie_host_wait_for_link()?
> The use of this api cdns_pcie_link_up was mentioned in earlier reviews.
> The mentioned api cdns_pcie_host_wait_for_link is a wrapper in which there are multiple checks.
> If insist, will replace with it.

yeah, I think we should give some time for the link up to succeed after
re-training.

Thanks
Kishon

  reply	other threads:[~2020-10-23  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 18:21 [PATCH v3] PCI: cadence: Retrain Link to work around Gen2 training defect Nadeem Athani
2020-10-19  5:28 ` Kishon Vijay Abraham I
2020-10-19 17:18   ` Athani Nadeem Ladkhan
2020-10-23  6:56     ` Kishon Vijay Abraham I [this message]
2020-10-26 19:20       ` Rob Herring
2020-11-26 13:58         ` Kishon Vijay Abraham I
2020-12-01 15:15           ` Athani Nadeem Ladkhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2aa5519-e207-c3e5-9d81-14209d856b54@ti.com \
    --to=kishon@ti.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mparab@cadence.com \
    --cc=nadeem@cadence.com \
    --cc=robh@kernel.org \
    --cc=sjakhade@cadence.com \
    --cc=tjoseph@cadence.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).