From: Alan Douglas <hidden> Date: 2018-10-11 16:17:17
If EP attempts to send an IRQ (legacy, MSI or MSI-X) while the
link is not up, return -EINVAL
Fixes: 37dddf14f1ae ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
Signed-off-by: Alan Douglas <redacted>
---
drivers/pci/controller/pcie-cadence-ep.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -370,6 +370,12 @@ static int cdns_pcie_ep_raise_irq(struct pci_epc *epc, u8 fn,u16interrupt_num){structcdns_pcie_ep*ep=epc_get_drvdata(epc);+u32link_status;++/* Can't send an IRQ if the link is down. */+link_status=cdns_pcie_readl(&ep->pcie,CDNS_PCIE_LM_BASE);+if(!(link_status&0x1))+return-EINVAL;switch(type){casePCI_EPC_IRQ_LEGACY:
On Thu, Oct 11, 2018 at 05:16:57PM +0100, Alan Douglas wrote:
quoted hunk
If EP attempts to send an IRQ (legacy, MSI or MSI-X) while the
link is not up, return -EINVAL
Fixes: 37dddf14f1ae ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
Signed-off-by: Alan Douglas <redacted>
---
drivers/pci/controller/pcie-cadence-ep.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -370,6 +370,12 @@ static int cdns_pcie_ep_raise_irq(struct pci_epc *epc, u8 fn,u16interrupt_num){structcdns_pcie_ep*ep=epc_get_drvdata(epc);+u32link_status;++/* Can't send an IRQ if the link is down. */+link_status=cdns_pcie_readl(&ep->pcie,CDNS_PCIE_LM_BASE);+if(!(link_status&0x1))+return-EINVAL;
This looks racy. What happens if the link goes down right after the
CDNS_PCIE_LM_BASE read, but before we get here?
From: Lorenzo Pieralisi <hidden> Date: 2018-10-16 13:53:32
On Mon, Oct 15, 2018 at 04:30:35PM -0500, Bjorn Helgaas wrote:
On Thu, Oct 11, 2018 at 05:16:57PM +0100, Alan Douglas wrote:
quoted
If EP attempts to send an IRQ (legacy, MSI or MSI-X) while the
link is not up, return -EINVAL
Fixes: 37dddf14f1ae ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
Signed-off-by: Alan Douglas <redacted>
---
drivers/pci/controller/pcie-cadence-ep.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -370,6 +370,12 @@ static int cdns_pcie_ep_raise_irq(struct pci_epc *epc, u8 fn,u16interrupt_num){structcdns_pcie_ep*ep=epc_get_drvdata(epc);+u32link_status;++/* Can't send an IRQ if the link is down. */+link_status=cdns_pcie_readl(&ep->pcie,CDNS_PCIE_LM_BASE);+if(!(link_status&0x1))+return-EINVAL;
This looks racy. What happens if the link goes down right after the
CDNS_PCIE_LM_BASE read, but before we get here?
I agree with Bjorn, this check does not seem very useful and honestly
I think this patch should be dropped, I should not have queued it in
the first place.
I wonder whether something can actually be done in the EP subsystem
to handle this in a cleaner way.
Unless I hear a compelling reason to keep it in the patch queue I
would drop this patch.
Lorenzo
From: Alan Douglas <hidden> Date: 2018-10-16 14:01:29
Hi,
On 16 October 2018 14:53, Lorenzo Pieralisi [off-list ref] wrote:
On Mon, Oct 15, 2018 at 04:30:35PM -0500, Bjorn Helgaas wrote:
quoted
On Thu, Oct 11, 2018 at 05:16:57PM +0100, Alan Douglas wrote:
quoted
If EP attempts to send an IRQ (legacy, MSI or MSI-X) while the
link is not up, return -EINVAL
Fixes: 37dddf14f1ae ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
Signed-off-by: Alan Douglas <redacted>
---
drivers/pci/controller/pcie-cadence-ep.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -370,6 +370,12 @@ static int cdns_pcie_ep_raise_irq(struct pci_epc *epc, u8 fn,u16interrupt_num){structcdns_pcie_ep*ep=epc_get_drvdata(epc);+u32link_status;++/* Can't send an IRQ if the link is down. */+link_status=cdns_pcie_readl(&ep->pcie,CDNS_PCIE_LM_BASE);+if(!(link_status&0x1))+return-EINVAL;
This looks racy. What happens if the link goes down right after the
CDNS_PCIE_LM_BASE read, but before we get here?
I agree with Bjorn, this check does not seem very useful and honestly
I think this patch should be dropped, I should not have queued it in
the first place.
I wonder whether something can actually be done in the EP subsystem
to handle this in a cleaner way.
Unless I hear a compelling reason to keep it in the patch queue I
would drop this patch.
Lorenzo
Makes sense to me, I was just preparing a reply. I need to find
a fix that will work for all cases, possibly using the handshake
for the D0->D3 Config write which should precede the link down. At
the moment I think we need to insist that the link is always up while
the EP driver is loaded.
Alan