diff mbox series

[PATCHv5,16/20] PCI: mobiveil: Add link up condition check

Message ID 20190412083635.33626-17-Zhiqiang.Hou@nxp.com
State Not Applicable, archived
Headers show
Series PCI: mobiveil: fixes for Mobiveil PCIe Host Bridge IP driver | expand

Checks

Context Check Description
robh/checkpatch success

Commit Message

Z.Q. Hou April 12, 2019, 8:36 a.m. UTC
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>

Avoid to issue CFG transactions to link partner when the PCIe
link is not up.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
---
V5:
 - Corrected the subject.

 drivers/pci/controller/pcie-mobiveil.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Lorenzo Pieralisi June 11, 2019, 5:17 p.m. UTC | #1
NB: Please trim the CC list and keep it to concerned maintainers.

On Fri, Apr 12, 2019 at 08:36:48AM +0000, Z.q. Hou wrote:
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> 
> Avoid to issue CFG transactions to link partner when the PCIe
> link is not up.
> 
> Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> ---
> V5:
>  - Corrected the subject.
> 
>  drivers/pci/controller/pcie-mobiveil.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c
> index 621852078caf..1ee3ea2570c0 100644
> --- a/drivers/pci/controller/pcie-mobiveil.c
> +++ b/drivers/pci/controller/pcie-mobiveil.c
> @@ -283,6 +283,10 @@ static bool mobiveil_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)
>  {
>  	struct mobiveil_pcie *pcie = bus->sysdata;
>  
> +	/* If there is no link, then there is no device */
> +	if (bus->number > pcie->root_bus_nr && !mobiveil_pcie_link_up(pcie))

I think Bjorn mentioned this a million times already, eg:

https://lore.kernel.org/linux-pci/20190411201535.GS256045@google.com/

this is racy and gives a false sense of robustness. We have code in the
kernel that checks the link but adding more seems silly to me, so I am
inclined to drop this patch.

Lorenzo

> +		return false;
> +
>  	/* Only one device down on each root port */
>  	if ((bus->number == pcie->root_bus_nr) && (devfn > 0))
>  		return false;
> -- 
> 2.17.1
>
Z.Q. Hou June 12, 2019, 11:36 a.m. UTC | #2
Hi Lorenzo,

Thanks a lot for your comments!

> -----Original Message-----
> From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Sent: 2019年6月12日 1:18
> To: Z.q. Hou <zhiqiang.hou@nxp.com>; bhelgaas@google.com
> Cc: linux-pci@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org;
> robh+dt@kernel.org; mark.rutland@arm.com; l.subrahmanya@mobiveil.co.in;
> shawnguo@kernel.org; Leo Li <leoyang.li@nxp.com>;
> catalin.marinas@arm.com; will.deacon@arm.com; Mingkai Hu
> <mingkai.hu@nxp.com>; M.h. Lian <minghuan.lian@nxp.com>; Xiaowei Bao
> <xiaowei.bao@nxp.com>
> Subject: Re: [PATCHv5 16/20] PCI: mobiveil: Add link up condition check
> 
> NB: Please trim the CC list and keep it to concerned maintainers.
> 
> On Fri, Apr 12, 2019 at 08:36:48AM +0000, Z.q. Hou wrote:
> > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> >
> > Avoid to issue CFG transactions to link partner when the PCIe link is
> > not up.
> >
> > Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> > ---
> > V5:
> >  - Corrected the subject.
> >
> >  drivers/pci/controller/pcie-mobiveil.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/pci/controller/pcie-mobiveil.c
> > b/drivers/pci/controller/pcie-mobiveil.c
> > index 621852078caf..1ee3ea2570c0 100644
> > --- a/drivers/pci/controller/pcie-mobiveil.c
> > +++ b/drivers/pci/controller/pcie-mobiveil.c
> > @@ -283,6 +283,10 @@ static bool mobiveil_pcie_valid_device(struct
> > pci_bus *bus, unsigned int devfn)  {
> >  	struct mobiveil_pcie *pcie = bus->sysdata;
> >
> > +	/* If there is no link, then there is no device */
> > +	if (bus->number > pcie->root_bus_nr && !mobiveil_pcie_link_up(pcie))
> 
> I think Bjorn mentioned this a million times already, eg:
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.ke
> rnel.org%2Flinux-pci%2F20190411201535.GS256045%40google.com%2F&am
> p;data=02%7C01%7Czhiqiang.hou%40nxp.com%7Cffb4c8dcebe4493a375908
> d6ee90b471%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63695
> 8702637973543&amp;sdata=m%2FqV5zohqyBMUDT7zrVjF%2FLtYeJZO36rdY
> eMTPGGbHg%3D&amp;reserved=0
> 
> this is racy and gives a false sense of robustness. We have code in the kernel
> that checks the link but adding more seems silly to me, so I am inclined to
> drop this patch.
> 

Understand, drop it.

Thanks,
Zhiqiang

> Lorenzo
> 
> > +		return false;
> > +
> >  	/* Only one device down on each root port */
> >  	if ((bus->number == pcie->root_bus_nr) && (devfn > 0))
> >  		return false;
> > --
> > 2.17.1
> >
diff mbox series

Patch

diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c
index 621852078caf..1ee3ea2570c0 100644
--- a/drivers/pci/controller/pcie-mobiveil.c
+++ b/drivers/pci/controller/pcie-mobiveil.c
@@ -283,6 +283,10 @@  static bool mobiveil_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)
 {
 	struct mobiveil_pcie *pcie = bus->sysdata;
 
+	/* If there is no link, then there is no device */
+	if (bus->number > pcie->root_bus_nr && !mobiveil_pcie_link_up(pcie))
+		return false;
+
 	/* Only one device down on each root port */
 	if ((bus->number == pcie->root_bus_nr) && (devfn > 0))
 		return false;