linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: Apply _HPX link control for all supported pcie device
@ 2014-11-11 20:09 Yinghai Lu
  2014-11-13 17:26 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Yinghai Lu @ 2014-11-11 20:09 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-kernel, Yinghai Lu

With commit 6cd33649fa83 ("PCI: Add pci_configure_device() during enumeration")
and following commits, we apply _HPX for pci devices.

that is called via pci_scan_slot
			==>pci_scan_single_device
				==>pci_device_add
					==>pci_configure_device
						==>program_hpp_type2
and dev->subordinate is not allocated yet.

So that link control setup get skipped.

Acoording to ACPI spec, there is no requirement that need to be set to pcie
root port or downstream port.

We could just change to pcie_cap_has_lnkctl to cover all pcie devices with
link control cap.

-v2: Do not move pcie_cap_has_lnkctl() out of pci/access.c according to Bjorn.

Fixes: 6cd33649fa83 ("PCI: Add pci_configure_device() during enumeration")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/access.c |    2 +-
 drivers/pci/pci.h    |    2 ++
 drivers/pci/probe.c  |    2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -1323,7 +1323,7 @@ static void program_hpp_type2(struct pci
 			~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
 
 	/* Initialize Link Control Register */
-	if (dev->subordinate)
+	if (pcie_cap_has_lnkctl(dev))
 		pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
 			~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
 
Index: linux-2.6/drivers/pci/pci.h
===================================================================
--- linux-2.6.orig/drivers/pci/pci.h
+++ linux-2.6/drivers/pci/pci.h
@@ -6,6 +6,8 @@
 
 extern const unsigned char pcie_link_speed[];
 
+bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
+
 /* Functions internal to the PCI core code */
 
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
Index: linux-2.6/drivers/pci/access.c
===================================================================
--- linux-2.6.orig/drivers/pci/access.c
+++ linux-2.6/drivers/pci/access.c
@@ -444,7 +444,7 @@ static inline int pcie_cap_version(const
 	return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS;
 }
 
-static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
+bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
 {
 	int type = pci_pcie_type(dev);
 

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

* Re: [PATCH v2] PCI: Apply _HPX link control for all supported pcie device
  2014-11-11 20:09 [PATCH v2] PCI: Apply _HPX link control for all supported pcie device Yinghai Lu
@ 2014-11-13 17:26 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2014-11-13 17:26 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, linux-kernel

On Tue, Nov 11, 2014 at 12:09:46PM -0800, Yinghai Lu wrote:
> With commit 6cd33649fa83 ("PCI: Add pci_configure_device() during enumeration")
> and following commits, we apply _HPX for pci devices.
> 
> that is called via pci_scan_slot
> 			==>pci_scan_single_device
> 				==>pci_device_add
> 					==>pci_configure_device
> 						==>program_hpp_type2
> and dev->subordinate is not allocated yet.
> 
> So that link control setup get skipped.
> 
> Acoording to ACPI spec, there is no requirement that need to be set to pcie
> root port or downstream port.
> 
> We could just change to pcie_cap_has_lnkctl to cover all pcie devices with
> link control cap.
> 
> -v2: Do not move pcie_cap_has_lnkctl() out of pci/access.c according to Bjorn.
> 
> Fixes: 6cd33649fa83 ("PCI: Add pci_configure_device() during enumeration")
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

Applied to for-linus for v3.18, thanks!

> ---
>  drivers/pci/access.c |    2 +-
>  drivers/pci/pci.h    |    2 ++
>  drivers/pci/probe.c  |    2 +-
>  3 files changed, 4 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/pci/probe.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/probe.c
> +++ linux-2.6/drivers/pci/probe.c
> @@ -1323,7 +1323,7 @@ static void program_hpp_type2(struct pci
>  			~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
>  
>  	/* Initialize Link Control Register */
> -	if (dev->subordinate)
> +	if (pcie_cap_has_lnkctl(dev))
>  		pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
>  			~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
>  
> Index: linux-2.6/drivers/pci/pci.h
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pci.h
> +++ linux-2.6/drivers/pci/pci.h
> @@ -6,6 +6,8 @@
>  
>  extern const unsigned char pcie_link_speed[];
>  
> +bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
> +
>  /* Functions internal to the PCI core code */
>  
>  int pci_create_sysfs_dev_files(struct pci_dev *pdev);
> Index: linux-2.6/drivers/pci/access.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/access.c
> +++ linux-2.6/drivers/pci/access.c
> @@ -444,7 +444,7 @@ static inline int pcie_cap_version(const
>  	return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS;
>  }
>  
> -static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
> +bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
>  {
>  	int type = pci_pcie_type(dev);
>  

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

end of thread, other threads:[~2014-11-13 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 20:09 [PATCH v2] PCI: Apply _HPX link control for all supported pcie device Yinghai Lu
2014-11-13 17:26 ` 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).