* [PATCH 0/2] PCI: Comment and PCIe capability accessor fixes
@ 2015-07-14 19:44 Bjorn Helgaas
2015-07-14 19:45 ` [PATCH 1/2] PCI: Fix pcie_port_device_resume() comment Bjorn Helgaas
2015-07-14 19:45 ` [PATCH 2/2] PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports) Bjorn Helgaas
0 siblings, 2 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2015-07-14 19:44 UTC (permalink / raw)
To: linux-pci; +Cc: Rafael J. Wysocki, Myron Stowe, Jiang Liu
These are a trivial comment fix and an almost as trivial accessor fix.
Arcanum for the day: when the PCIe spec says "Downstream Port," it means
both Root Ports and Switch Downstream Ports.
---
Bjorn Helgaas (2):
PCI: Fix pcie_port_device_resume() comment
PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports)
drivers/pci/access.c | 23 +++++++++++++----------
drivers/pci/pcie/portdrv_core.c | 2 +-
2 files changed, 14 insertions(+), 11 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] PCI: Fix pcie_port_device_resume() comment
2015-07-14 19:44 [PATCH 0/2] PCI: Comment and PCIe capability accessor fixes Bjorn Helgaas
@ 2015-07-14 19:45 ` Bjorn Helgaas
2015-07-14 22:25 ` Rafael J. Wysocki
2015-07-14 19:45 ` [PATCH 2/2] PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports) Bjorn Helgaas
1 sibling, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2015-07-14 19:45 UTC (permalink / raw)
To: linux-pci; +Cc: Rafael J. Wysocki, Myron Stowe, Jiang Liu
The function comment claimed this was pcie_port_device_suspend(), but it's
really pcie_port_device_resume(). Perils of cut and paste.
Use the correct function name in the comment.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/pcie/portdrv_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 2f0ce66..88122dc 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -448,7 +448,7 @@ static int resume_iter(struct device *dev, void *data)
}
/**
- * pcie_port_device_suspend - resume port services associated with a PCIe port
+ * pcie_port_device_resume - resume port services associated with a PCIe port
* @dev: PCI Express port to handle
*/
int pcie_port_device_resume(struct device *dev)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports)
2015-07-14 19:44 [PATCH 0/2] PCI: Comment and PCIe capability accessor fixes Bjorn Helgaas
2015-07-14 19:45 ` [PATCH 1/2] PCI: Fix pcie_port_device_resume() comment Bjorn Helgaas
@ 2015-07-14 19:45 ` Bjorn Helgaas
2015-07-14 22:26 ` Rafael J. Wysocki
1 sibling, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2015-07-14 19:45 UTC (permalink / raw)
To: linux-pci; +Cc: Rafael J. Wysocki, Myron Stowe, Jiang Liu
As used in the PCIe spec, "Downstream Port" includes both Root Ports and
Switch Downstream Ports. We sometimes checked for PCI_EXP_TYPE_DOWNSTREAM
when we should have checked for PCI_EXP_TYPE_ROOT_PORT or
PCI_EXP_TYPE_DOWNSTREAM.
For a Root Port without a slot, the effect of this was that using
pcie_capability_read_word() to read PCI_EXP_SLTSTA returned zero instead of
showing the Presence Detect State bit hardwired to one as the PCIe Spec,
r3.0, sec 7.8, requires. (This read is completed in software because
previous PCIe spec versions didn't require PCI_EXP_SLTSTA to exist at all.)
Nothing in the kernel currently depends on this (pciehp only reads
PCI_EXP_SLTSTA on ports with slots), so this is a cleanup and not a
functional change.
Add a pcie_downstream_port() helper function and use it.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/access.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index d9b64a1..79f0102 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -531,6 +531,14 @@ static inline int pcie_cap_version(const struct pci_dev *dev)
return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS;
}
+static bool pcie_downstream_port(constr struct pci_dev *dev)
+{
+ int type = pci_pcie_type(dev);
+
+ return type == PCI_EXP_TYPE_ROOT_PORT ||
+ type == PCI_EXP_TYPE_DOWNSTREAM;
+}
+
bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
{
int type = pci_pcie_type(dev);
@@ -546,10 +554,7 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
{
- int type = pci_pcie_type(dev);
-
- return (type == PCI_EXP_TYPE_ROOT_PORT ||
- type == PCI_EXP_TYPE_DOWNSTREAM) &&
+ return pcie_downstream_port(dev) &&
pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT;
}
@@ -628,10 +633,9 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
* State bit in the Slot Status register of Downstream Ports,
* which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8)
*/
- if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA &&
- pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
+ if (pci_is_pcie(dev) && pcie_downstream_port(dev) &&
+ pos == PCI_EXP_SLTSTA)
*val = PCI_EXP_SLTSTA_PDS;
- }
return 0;
}
@@ -657,10 +661,9 @@ int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)
return ret;
}
- if (pci_is_pcie(dev) && pos == PCI_EXP_SLTCTL &&
- pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
+ if (pci_is_pcie(dev) && pcie_downstream_port(dev) &&
+ pos == PCI_EXP_SLTSTA)
*val = PCI_EXP_SLTSTA_PDS;
- }
return 0;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] PCI: Fix pcie_port_device_resume() comment
2015-07-14 19:45 ` [PATCH 1/2] PCI: Fix pcie_port_device_resume() comment Bjorn Helgaas
@ 2015-07-14 22:25 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2015-07-14 22:25 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Myron Stowe, Jiang Liu
On 7/14/2015 9:45 PM, Bjorn Helgaas wrote:
> The function comment claimed this was pcie_port_device_suspend(), but it's
> really pcie_port_device_resume(). Perils of cut and paste.
>
> Use the correct function name in the comment.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
ACK
> ---
> drivers/pci/pcie/portdrv_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
> index 2f0ce66..88122dc 100644
> --- a/drivers/pci/pcie/portdrv_core.c
> +++ b/drivers/pci/pcie/portdrv_core.c
> @@ -448,7 +448,7 @@ static int resume_iter(struct device *dev, void *data)
> }
>
> /**
> - * pcie_port_device_suspend - resume port services associated with a PCIe port
> + * pcie_port_device_resume - resume port services associated with a PCIe port
> * @dev: PCI Express port to handle
> */
> int pcie_port_device_resume(struct device *dev)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports)
2015-07-14 19:45 ` [PATCH 2/2] PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports) Bjorn Helgaas
@ 2015-07-14 22:26 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2015-07-14 22:26 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Myron Stowe, Jiang Liu
On 7/14/2015 9:45 PM, Bjorn Helgaas wrote:
> As used in the PCIe spec, "Downstream Port" includes both Root Ports and
> Switch Downstream Ports. We sometimes checked for PCI_EXP_TYPE_DOWNSTREAM
> when we should have checked for PCI_EXP_TYPE_ROOT_PORT or
> PCI_EXP_TYPE_DOWNSTREAM.
>
> For a Root Port without a slot, the effect of this was that using
> pcie_capability_read_word() to read PCI_EXP_SLTSTA returned zero instead of
> showing the Presence Detect State bit hardwired to one as the PCIe Spec,
> r3.0, sec 7.8, requires. (This read is completed in software because
> previous PCIe spec versions didn't require PCI_EXP_SLTSTA to exist at all.)
>
> Nothing in the kernel currently depends on this (pciehp only reads
> PCI_EXP_SLTSTA on ports with slots), so this is a cleanup and not a
> functional change.
>
> Add a pcie_downstream_port() helper function and use it.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
ACK
> ---
> drivers/pci/access.c | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> index d9b64a1..79f0102 100644
> --- a/drivers/pci/access.c
> +++ b/drivers/pci/access.c
> @@ -531,6 +531,14 @@ static inline int pcie_cap_version(const struct pci_dev *dev)
> return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS;
> }
>
> +static bool pcie_downstream_port(constr struct pci_dev *dev)
> +{
> + int type = pci_pcie_type(dev);
> +
> + return type == PCI_EXP_TYPE_ROOT_PORT ||
> + type == PCI_EXP_TYPE_DOWNSTREAM;
> +}
> +
> bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
> {
> int type = pci_pcie_type(dev);
> @@ -546,10 +554,7 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
>
> static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
> {
> - int type = pci_pcie_type(dev);
> -
> - return (type == PCI_EXP_TYPE_ROOT_PORT ||
> - type == PCI_EXP_TYPE_DOWNSTREAM) &&
> + return pcie_downstream_port(dev) &&
> pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT;
> }
>
> @@ -628,10 +633,9 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
> * State bit in the Slot Status register of Downstream Ports,
> * which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8)
> */
> - if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA &&
> - pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
> + if (pci_is_pcie(dev) && pcie_downstream_port(dev) &&
> + pos == PCI_EXP_SLTSTA)
> *val = PCI_EXP_SLTSTA_PDS;
> - }
>
> return 0;
> }
> @@ -657,10 +661,9 @@ int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)
> return ret;
> }
>
> - if (pci_is_pcie(dev) && pos == PCI_EXP_SLTCTL &&
> - pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
> + if (pci_is_pcie(dev) && pcie_downstream_port(dev) &&
> + pos == PCI_EXP_SLTSTA)
> *val = PCI_EXP_SLTSTA_PDS;
> - }
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-14 22:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14 19:44 [PATCH 0/2] PCI: Comment and PCIe capability accessor fixes Bjorn Helgaas
2015-07-14 19:45 ` [PATCH 1/2] PCI: Fix pcie_port_device_resume() comment Bjorn Helgaas
2015-07-14 22:25 ` Rafael J. Wysocki
2015-07-14 19:45 ` [PATCH 2/2] PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports) Bjorn Helgaas
2015-07-14 22:26 ` Rafael J. Wysocki
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).