linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI/AER: Change to use helper pcie_aer_is_native() in some places
@ 2021-02-05  2:04 Xiaofei Tan
  2021-02-26 17:47 ` Kelley, Sean V
  2021-07-28 22:08 ` Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Xiaofei Tan @ 2021-02-05  2:04 UTC (permalink / raw)
  To: bhelgaas, sathyanarayanan.kuppuswamy, sean.v.kelley,
	Jonathan.Cameron, refactormyself
  Cc: Xiaofei Tan, linux-pci, linux-kernel, linuxarm

Use helper function pcie_aer_is_native() in some places to keep
the code tidy. No function changes.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>

---
Changes from v1 to v2:
- Add the fix suggested by Krzysztof.
---
 drivers/pci/pcie/aer.c          | 4 ++--
 drivers/pci/pcie/err.c          | 2 +-
 drivers/pci/pcie/portdrv_core.c | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 77b0f2c..03212d0 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1397,7 +1397,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
 	 */
 	aer = root ? root->aer_cap : 0;
 
-	if ((host->native_aer || pcie_ports_native) && aer) {
+	if (pcie_aer_is_native(dev) && aer) {
 		/* Disable Root's interrupt in response to error messages */
 		pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, &reg32);
 		reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
@@ -1417,7 +1417,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
 		pci_info(dev, "Root Port link has been reset (%d)\n", rc);
 	}
 
-	if ((host->native_aer || pcie_ports_native) && aer) {
+	if (pcie_aer_is_native(dev) && aer) {
 		/* Clear Root Error Status */
 		pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, &reg32);
 		pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32);
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 510f31f..1d6cfb9 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -237,7 +237,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 	 * this status.  In that case, the signaling device may not even be
 	 * visible to the OS.
 	 */
-	if (host->native_aer || pcie_ports_native) {
+	if (pcie_aer_is_native(dev)) {
 		pcie_clear_device_status(bridge);
 		pci_aer_clear_nonfatal_status(bridge);
 	}
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index e1fed664..3b3743e 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev)
 	}
 
 #ifdef CONFIG_PCIEAER
-	if (dev->aer_cap && pci_aer_available() &&
-	    (pcie_ports_native || host->native_aer)) {
+	if (pci_aer_available() && pcie_aer_is_native(dev)) {
 		services |= PCIE_PORT_SERVICE_AER;
 
 		/*
-- 
2.8.1


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

* Re: [PATCH v2] PCI/AER: Change to use helper pcie_aer_is_native() in some places
  2021-02-05  2:04 [PATCH v2] PCI/AER: Change to use helper pcie_aer_is_native() in some places Xiaofei Tan
@ 2021-02-26 17:47 ` Kelley, Sean V
  2021-07-28 22:08 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Kelley, Sean V @ 2021-02-26 17:47 UTC (permalink / raw)
  To: Xiaofei Tan, bhelgaas, sathyanarayanan.kuppuswamy,
	Jonathan.Cameron, refactormyself
  Cc: linux-pci, linux-kernel, linuxarm



On 2/4/21, 6:07 PM, "Xiaofei Tan" <tanxiaofei@huawei.com> wrote:

    Use helper function pcie_aer_is_native() in some places to keep
    the code tidy. No function changes.

    Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
    Reviewed-by: Krzysztof Wilczyński <kw@linux.com>


Nice use of the helper and good suggestion from Krzysztof.

Acked-by: Sean V Kelley <sean.v.kelley@intel.com>



    ---
    Changes from v1 to v2:
    - Add the fix suggested by Krzysztof.
    ---
     drivers/pci/pcie/aer.c          | 4 ++--
     drivers/pci/pcie/err.c          | 2 +-
     drivers/pci/pcie/portdrv_core.c | 3 +--
     3 files changed, 4 insertions(+), 5 deletions(-)

    diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
    index 77b0f2c..03212d0 100644
    --- a/drivers/pci/pcie/aer.c
    +++ b/drivers/pci/pcie/aer.c
    @@ -1397,7 +1397,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
     	 */
     	aer = root ? root->aer_cap : 0;

    -	if ((host->native_aer || pcie_ports_native) && aer) {
    +	if (pcie_aer_is_native(dev) && aer) {
     		/* Disable Root's interrupt in response to error messages */
     		pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, &reg32);
     		reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
    @@ -1417,7 +1417,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
     		pci_info(dev, "Root Port link has been reset (%d)\n", rc);
     	}

    -	if ((host->native_aer || pcie_ports_native) && aer) {
    +	if (pcie_aer_is_native(dev) && aer) {
     		/* Clear Root Error Status */
     		pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, &reg32);
     		pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32);
    diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
    index 510f31f..1d6cfb9 100644
    --- a/drivers/pci/pcie/err.c
    +++ b/drivers/pci/pcie/err.c
    @@ -237,7 +237,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
     	 * this status.  In that case, the signaling device may not even be
     	 * visible to the OS.
     	 */
    -	if (host->native_aer || pcie_ports_native) {
    +	if (pcie_aer_is_native(dev)) {
     		pcie_clear_device_status(bridge);
     		pci_aer_clear_nonfatal_status(bridge);
     	}
    diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
    index e1fed664..3b3743e 100644
    --- a/drivers/pci/pcie/portdrv_core.c
    +++ b/drivers/pci/pcie/portdrv_core.c
    @@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev)
     	}

     #ifdef CONFIG_PCIEAER
    -	if (dev->aer_cap && pci_aer_available() &&
    -	    (pcie_ports_native || host->native_aer)) {
    +	if (pci_aer_available() && pcie_aer_is_native(dev)) {
     		services |= PCIE_PORT_SERVICE_AER;

     		/*
    -- 
    2.8.1



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

* Re: [PATCH v2] PCI/AER: Change to use helper pcie_aer_is_native() in some places
  2021-02-05  2:04 [PATCH v2] PCI/AER: Change to use helper pcie_aer_is_native() in some places Xiaofei Tan
  2021-02-26 17:47 ` Kelley, Sean V
@ 2021-07-28 22:08 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2021-07-28 22:08 UTC (permalink / raw)
  To: Xiaofei Tan
  Cc: bhelgaas, sathyanarayanan.kuppuswamy, sean.v.kelley,
	Jonathan.Cameron, refactormyself, linux-pci, linux-kernel,
	linuxarm

On Fri, Feb 05, 2021 at 10:04:08AM +0800, Xiaofei Tan wrote:
> Use helper function pcie_aer_is_native() in some places to keep
> the code tidy. No function changes.
> 
> Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
> Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
> 
> ---
> Changes from v1 to v2:
> - Add the fix suggested by Krzysztof.
> ---
>  drivers/pci/pcie/aer.c          | 4 ++--
>  drivers/pci/pcie/err.c          | 2 +-
>  drivers/pci/pcie/portdrv_core.c | 3 +--
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 77b0f2c..03212d0 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -1397,7 +1397,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
>  	 */
>  	aer = root ? root->aer_cap : 0;
>  
> -	if ((host->native_aer || pcie_ports_native) && aer) {
> +	if (pcie_aer_is_native(dev) && aer) {

Are we guaranteed that "dev" has an AER capability?  I guess so,
because the function comment says "dev" is a Root Port, an RCEC, or an
RCiEP.  I *guess* that we only get here if "dev" has an AER
capability?  I wish this were a little more obvious from the code.

If "dev" does not have AER, we previously cleared
ROOT_PORT_INTR_ON_MESG_MASK, but after this patch we won't.

  pcie_aer_is_native(struct pci_dev *dev)
  {
    struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);

    if (!dev->aer_cap)
      return 0;

    return pcie_ports_native || host->native_aer;
  }

If we do decide this patch is correct, I think we can drop the "host",
which is no longer used in this function.

>  		/* Disable Root's interrupt in response to error messages */
>  		pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, &reg32);
>  		reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
> @@ -1417,7 +1417,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
>  		pci_info(dev, "Root Port link has been reset (%d)\n", rc);
>  	}
>  
> -	if ((host->native_aer || pcie_ports_native) && aer) {
> +	if (pcie_aer_is_native(dev) && aer) {
>  		/* Clear Root Error Status */
>  		pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, &reg32);
>  		pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32);
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 510f31f..1d6cfb9 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -237,7 +237,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
>  	 * this status.  In that case, the signaling device may not even be
>  	 * visible to the OS.
>  	 */
> -	if (host->native_aer || pcie_ports_native) {
> +	if (pcie_aer_is_native(dev)) {
>  		pcie_clear_device_status(bridge);

Is it guaranteed that "dev" has an AER capability here?  Again, it's
not obvious to me that it must; this path is used from DPC and EDR as
well as AER.

If it's not guaranteed, assume "dev" is a PCIe device with no AER
capability.  It still has a Device Status register, and previously we
called pcie_clear_device_status() to clear it.

Now we won't clear it.

>  		pci_aer_clear_nonfatal_status(bridge);
>  	}
> diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
> index e1fed664..3b3743e 100644
> --- a/drivers/pci/pcie/portdrv_core.c
> +++ b/drivers/pci/pcie/portdrv_core.c
> @@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev)
>  	}
>  
>  #ifdef CONFIG_PCIEAER
> -	if (dev->aer_cap && pci_aer_available() &&
> -	    (pcie_ports_native || host->native_aer)) {
> +	if (pci_aer_available() && pcie_aer_is_native(dev)) {
>  		services |= PCIE_PORT_SERVICE_AER;
>  
>  		/*
> -- 
> 2.8.1
> 

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

end of thread, other threads:[~2021-07-28 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05  2:04 [PATCH v2] PCI/AER: Change to use helper pcie_aer_is_native() in some places Xiaofei Tan
2021-02-26 17:47 ` Kelley, Sean V
2021-07-28 22:08 ` Bjorn Helgaas

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