diff mbox series

[1/5] PCI/DPC: Ignore devices with no AER Capability

Message ID 20201126011816.711106-2-helgaas@kernel.org (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series Simplify PCIe native ownership | expand

Commit Message

Bjorn Helgaas Nov. 26, 2020, 1:18 a.m. UTC
From: Bjorn Helgaas <bhelgaas@google.com>

Downstream Ports may support DPC regardless of whether they support AER
(see PCIe r5.0, sec 6.2.10.2).  Previously, if the user booted with
"pcie_ports=dpc-native", it was possible for dpc_probe() to succeed even if
the device had no AER Capability, but dpc_get_aer_uncorrect_severity()
depends on the AER Capability.

dpc_probe() previously failed if:

  !pcie_aer_is_native(pdev) && !pcie_ports_dpc_native
  !(pcie_aer_is_native() || pcie_ports_dpc_native)    # by De Morgan's law

so it succeeded if:

  pcie_aer_is_native() || pcie_ports_dpc_native

Fail dpc_probe() if the device has no AER Capability.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Olof Johansson <olof@lixom.net>
---
 drivers/pci/pcie/dpc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kuppuswamy Sathyanarayanan Nov. 26, 2020, 2:01 a.m. UTC | #1
On 11/25/20 5:18 PM, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> Downstream Ports may support DPC regardless of whether they support AER
> (see PCIe r5.0, sec 6.2.10.2).  Previously, if the user booted with
> "pcie_ports=dpc-native", it was possible for dpc_probe() to succeed even if
> the device had no AER Capability, but dpc_get_aer_uncorrect_severity()
> depends on the AER Capability.
> 
> dpc_probe() previously failed if:
> 
>    !pcie_aer_is_native(pdev) && !pcie_ports_dpc_native
>    !(pcie_aer_is_native() || pcie_ports_dpc_native)    # by De Morgan's law
> 
> so it succeeded if:
> 
>    pcie_aer_is_native() || pcie_ports_dpc_native
> 
> Fail dpc_probe() if the device has no AER Capability.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Olof Johansson <olof@lixom.net>
> ---
>   drivers/pci/pcie/dpc.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> index e05aba86a317..ed0dbc43d018 100644
> --- a/drivers/pci/pcie/dpc.c
> +++ b/drivers/pci/pcie/dpc.c
> @@ -287,6 +287,9 @@ static int dpc_probe(struct pcie_device *dev)
>   	int status;
>   	u16 ctl, cap;
>   
> +	if (!pdev->aer_cap)
> +		return -ENOTSUPP;
Don't we check aer_cap support in drivers/pci/pcie/portdrv_core.c ?

We don't enable DPC service, if AER service is not enabled. And AER
service is only enabled if AER capability is supported.

So dpc_probe() should not happen if AER capability is not supported?

206 static int get_port_device_capability(struct pci_dev *dev)
...
...
251         if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
252             host->native_dpc &&
253             (host->native_dpc || (services & PCIE_PORT_SERVICE_AER)))
254                 services |= PCIE_PORT_SERVICE_DPC;
255

> +
>   	if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
>   		return -ENOTSUPP;
>   
>
Bjorn Helgaas Nov. 28, 2020, 8:24 p.m. UTC | #2
On Wed, Nov 25, 2020 at 06:01:57PM -0800, Kuppuswamy, Sathyanarayanan wrote:
> On 11/25/20 5:18 PM, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <bhelgaas@google.com>
> > 
> > Downstream Ports may support DPC regardless of whether they support AER
> > (see PCIe r5.0, sec 6.2.10.2).  Previously, if the user booted with
> > "pcie_ports=dpc-native", it was possible for dpc_probe() to succeed even if
> > the device had no AER Capability, but dpc_get_aer_uncorrect_severity()
> > depends on the AER Capability.
> > 
> > dpc_probe() previously failed if:
> > 
> >    !pcie_aer_is_native(pdev) && !pcie_ports_dpc_native
> >    !(pcie_aer_is_native() || pcie_ports_dpc_native)    # by De Morgan's law
> > 
> > so it succeeded if:
> > 
> >    pcie_aer_is_native() || pcie_ports_dpc_native
> > 
> > Fail dpc_probe() if the device has no AER Capability.
> > 
> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> > Cc: Olof Johansson <olof@lixom.net>
> > ---
> >   drivers/pci/pcie/dpc.c | 3 +++
> >   1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> > index e05aba86a317..ed0dbc43d018 100644
> > --- a/drivers/pci/pcie/dpc.c
> > +++ b/drivers/pci/pcie/dpc.c
> > @@ -287,6 +287,9 @@ static int dpc_probe(struct pcie_device *dev)
> >   	int status;
> >   	u16 ctl, cap;
> > +	if (!pdev->aer_cap)
> > +		return -ENOTSUPP;
> Don't we check aer_cap support in drivers/pci/pcie/portdrv_core.c ?
> 
> We don't enable DPC service, if AER service is not enabled. And AER
> service is only enabled if AER capability is supported.
> 
> So dpc_probe() should not happen if AER capability is not supported?

I don't think that's always true.  If I'm reading this right, we have
this:

  get_port_device_capability(...)
  {
  #ifdef CONFIG_PCIEAER
    if (dev->aer_cap && ...)
      services |= PCIE_PORT_SERVICE_AER;
  #endif

    if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
        pci_aer_available() &&
        (pcie_ports_dpc_native || (services & PCIE_PORT_SERVICE_AER)))
      services |= PCIE_PORT_SERVICE_DPC;
  }

and in the case where:

  - CONFIG_PCIEAER=y
  - booted with "pcie_ports=dpc-native" (pcie_ports_dpc_native is true)
  - "dev" has no AER capability
  - "dev" has DPC capability

I think we do enable PCIE_PORT_SERVICE_DPC.

> 206 static int get_port_device_capability(struct pci_dev *dev)
> ...
> ...
> 251         if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
> 252             host->native_dpc &&
> 253             (host->native_dpc || (services & PCIE_PORT_SERVICE_AER)))
> 254                 services |= PCIE_PORT_SERVICE_DPC;
> 255
> 
> > +
> >   	if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
> >   		return -ENOTSUPP;
> > 
> 
> -- 
> Sathyanarayanan Kuppuswamy
> Linux Kernel Developer
diff mbox series

Patch

diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index e05aba86a317..ed0dbc43d018 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -287,6 +287,9 @@  static int dpc_probe(struct pcie_device *dev)
 	int status;
 	u16 ctl, cap;
 
+	if (!pdev->aer_cap)
+		return -ENOTSUPP;
+
 	if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
 		return -ENOTSUPP;