linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* ks_dw_pcie_initiate_link_train() question
@ 2016-10-04 17:40 Bjorn Helgaas
  2016-10-04 21:52 ` Murali Karicheri
  0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Helgaas @ 2016-10-04 17:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Murali,

This code looks suspicious.  Can you comment?

    void ks_dw_pcie_initiate_link_train(struct keystone_pcie *ks_pcie)
    {
        u32 val;

        /* Disable Link training */
        val = readl(ks_pcie->va_app_base + CMD_STATUS);
        val &= ~LTSSM_EN_VAL;
        writel(LTSSM_EN_VAL | val,  ks_pcie->va_app_base + CMD_STATUS);

Here we cleared the LTSSM_EN_VAL bit in "val", but then we add it
right back in before writing it back to CMD_STATUS.

That looks like a cut and paste error to me, but of course I don't
know the hardware.

        /* Initiate Link Training */
        val = readl(ks_pcie->va_app_base + CMD_STATUS);
        writel(LTSSM_EN_VAL | val,  ks_pcie->va_app_base + CMD_STATUS);
    }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* ks_dw_pcie_initiate_link_train() question
  2016-10-04 17:40 ks_dw_pcie_initiate_link_train() question Bjorn Helgaas
@ 2016-10-04 21:52 ` Murali Karicheri
  0 siblings, 0 replies; 2+ messages in thread
From: Murali Karicheri @ 2016-10-04 21:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/04/2016 01:40 PM, Bjorn Helgaas wrote:
> Hi Murali,
> 
> This code looks suspicious.  Can you comment?
> 
>     void ks_dw_pcie_initiate_link_train(struct keystone_pcie *ks_pcie)
>     {
>         u32 val;
> 
>         /* Disable Link training */
>         val = readl(ks_pcie->va_app_base + CMD_STATUS);
>         val &= ~LTSSM_EN_VAL;
>         writel(LTSSM_EN_VAL | val,  ks_pcie->va_app_base + CMD_STATUS);
> 
> Here we cleared the LTSSM_EN_VAL bit in "val", but then we add it
> right back in before writing it back to CMD_STATUS.
> 
> That looks like a cut and paste error to me, but of course I don't
> know the hardware.
> 
>         /* Initiate Link Training */
>         val = readl(ks_pcie->va_app_base + CMD_STATUS);
>         writel(LTSSM_EN_VAL | val,  ks_pcie->va_app_base + CMD_STATUS);
>     }
> 
> 
Bjorn,

Good catch! That is a cut-n-paste error. Here is the description from
device manual

================
Disable link training by de-asserting the LTSSM_EN bit in the PCIESS
Command Status Register (CMD_STATUS[LTSSM_EN]=0). Upon reset, the
LTSSM_EN is de-asserted automatically by hardware.

Initiate link training can be initiated by asserting LTSSM_EN bit in the
CMD_STATUS register (CMD_STATUS[LTSSM_EN]=1).
================================================

Probably it works because it is de-asserted automatically upon
reset by hardware. Let me test this and send you a patch? 

-- 
Murali Karicheri
Linux Kernel, Keystone

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-04 21:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-04 17:40 ks_dw_pcie_initiate_link_train() question Bjorn Helgaas
2016-10-04 21:52 ` Murali Karicheri

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).