All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI/ASPM: Remove redundant checking for pcie port type
@ 2015-05-19  3:41 Yijing Wang
  2015-05-20 19:48 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Yijing Wang @ 2015-05-19  3:41 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, mjg59, rwhite, alex.williamson, Yijing Wang

Only pcie root port or downstream port would allocate
a pcie_link_state when call alloc_pcie_link_state() in
pcie_aspm_init_link_state(). So when call another ASPM
functions to configure pcie_link_state, checking
pdev->link_state is enough, it's no need to check pcie
port type again in these functions.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/pcie/aspm.c |   19 ++++---------------
 1 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 8830740..16a1ffb 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -675,10 +675,7 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
 {
 	struct pcie_link_state *link = pdev->link_state;
 
-	if (aspm_disabled || !pci_is_pcie(pdev) || !link)
-		return;
-	if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
-	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
+	if (aspm_disabled || !link)
 		return;
 	/*
 	 * Devices changed PM state, we should recheck if latency
@@ -696,16 +693,12 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
 {
 	struct pcie_link_state *link = pdev->link_state;
 
-	if (aspm_disabled || !pci_is_pcie(pdev) || !link)
+	if (aspm_disabled || !link)
 		return;
 
 	if (aspm_policy != POLICY_POWERSAVE)
 		return;
 
-	if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
-	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
-		return;
-
 	down_read(&pci_bus_sem);
 	mutex_lock(&aspm_lock);
 	pcie_config_aspm_path(link);
@@ -906,9 +899,7 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
 {
 	struct pcie_link_state *link_state = pdev->link_state;
 
-	if (!pci_is_pcie(pdev) ||
-	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
-	     pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
+	if (!link_state)
 		return;
 
 	if (link_state->aspm_support)
@@ -923,9 +914,7 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
 {
 	struct pcie_link_state *link_state = pdev->link_state;
 
-	if (!pci_is_pcie(pdev) ||
-	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
-	     pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
+	if (!link_state)
 		return;
 
 	if (link_state->aspm_support)
-- 
1.7.1


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

* Re: [PATCH] PCI/ASPM: Remove redundant checking for pcie port type
  2015-05-19  3:41 [PATCH] PCI/ASPM: Remove redundant checking for pcie port type Yijing Wang
@ 2015-05-20 19:48 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2015-05-20 19:48 UTC (permalink / raw)
  To: Yijing Wang; +Cc: linux-pci, mjg59, rwhite, alex.williamson

On Tue, May 19, 2015 at 11:41:34AM +0800, Yijing Wang wrote:
> Only pcie root port or downstream port would allocate
> a pcie_link_state when call alloc_pcie_link_state() in
> pcie_aspm_init_link_state(). So when call another ASPM
> functions to configure pcie_link_state, checking
> pdev->link_state is enough, it's no need to check pcie
> port type again in these functions.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>

This is excellent simplification!  Applied to pci/aspm for v4.2, thanks!

> ---
>  drivers/pci/pcie/aspm.c |   19 ++++---------------
>  1 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> index 8830740..16a1ffb 100644
> --- a/drivers/pci/pcie/aspm.c
> +++ b/drivers/pci/pcie/aspm.c
> @@ -675,10 +675,7 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
>  {
>  	struct pcie_link_state *link = pdev->link_state;
>  
> -	if (aspm_disabled || !pci_is_pcie(pdev) || !link)
> -		return;
> -	if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
> -	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
> +	if (aspm_disabled || !link)
>  		return;
>  	/*
>  	 * Devices changed PM state, we should recheck if latency
> @@ -696,16 +693,12 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
>  {
>  	struct pcie_link_state *link = pdev->link_state;
>  
> -	if (aspm_disabled || !pci_is_pcie(pdev) || !link)
> +	if (aspm_disabled || !link)
>  		return;
>  
>  	if (aspm_policy != POLICY_POWERSAVE)
>  		return;
>  
> -	if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
> -	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
> -		return;
> -
>  	down_read(&pci_bus_sem);
>  	mutex_lock(&aspm_lock);
>  	pcie_config_aspm_path(link);
> @@ -906,9 +899,7 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
>  {
>  	struct pcie_link_state *link_state = pdev->link_state;
>  
> -	if (!pci_is_pcie(pdev) ||
> -	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
> -	     pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
> +	if (!link_state)
>  		return;
>  
>  	if (link_state->aspm_support)
> @@ -923,9 +914,7 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
>  {
>  	struct pcie_link_state *link_state = pdev->link_state;
>  
> -	if (!pci_is_pcie(pdev) ||
> -	    (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
> -	     pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state)
> +	if (!link_state)
>  		return;
>  
>  	if (link_state->aspm_support)
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-05-20 19:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19  3:41 [PATCH] PCI/ASPM: Remove redundant checking for pcie port type Yijing Wang
2015-05-20 19:48 ` Bjorn Helgaas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.