* [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type
@ 2024-12-13 7:02 Gowthami Thiagarajan
2024-12-13 18:47 ` Bjorn Helgaas
2024-12-16 16:01 ` Ilpo Järvinen
0 siblings, 2 replies; 4+ messages in thread
From: Gowthami Thiagarajan @ 2024-12-13 7:02 UTC (permalink / raw)
To: bhelgaas, linux-pci, linux-kernel; +Cc: Gowthami Thiagarajan
When an invalid PCIe topology is detected, the set_pcie_port_type function
does not set the port type correctly. This issue can occur in
configurations such as:
Root Port ---> Downstream Port ---> Root Port
In such cases, the topology is identified as invalid and due to the incorrect
port type setting, the extended configuration space of the child device becomes
inaccessible.
Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>
---
v1->v2:
Updated commit description
drivers/pci/probe.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4f68414c3086..263ec21451d9 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1596,7 +1596,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
if (pcie_downstream_port(parent)) {
pci_info(pdev, "claims to be downstream port but is acting as upstream port, correcting type\n");
pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
- pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM;
+ pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM << 4;
}
} else if (type == PCI_EXP_TYPE_UPSTREAM) {
/*
@@ -1607,7 +1607,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
if (pci_pcie_type(parent) == PCI_EXP_TYPE_UPSTREAM) {
pci_info(pdev, "claims to be upstream port but is acting as downstream port, correcting type\n");
pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
- pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM;
+ pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM << 4;
}
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type
2024-12-13 7:02 [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type Gowthami Thiagarajan
@ 2024-12-13 18:47 ` Bjorn Helgaas
2024-12-16 8:10 ` Mika Westerberg
2024-12-16 16:01 ` Ilpo Järvinen
1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2024-12-13 18:47 UTC (permalink / raw)
To: Gowthami Thiagarajan
Cc: bhelgaas, linux-pci, linux-kernel, Mika Westerberg,
Andy Shevchenko
[+cc Mika, Andy]
On Fri, Dec 13, 2024 at 12:32:41PM +0530, Gowthami Thiagarajan wrote:
> When an invalid PCIe topology is detected, the set_pcie_port_type function
> does not set the port type correctly. This issue can occur in
> configurations such as:
>
> Root Port ---> Downstream Port ---> Root Port
>
> In such cases, the topology is identified as invalid and due to the
> incorrect port type setting, the extended configuration space of the
> child device becomes inaccessible.
From reading the code, it looks like the underlying problem is
components that advertise the wrong PCIe Device/Port Type.
set_pcie_port_type() already detects that incorrect Port Type and
tries to correct it, but it puts the corrected type in bits [3:0]
instead of [7:4] where it belongs.
This looks like a bug from ca78410403dd ("PCI: Get rid of
dev->has_secondary_link flag"). If so, we should add a Fixes: tag for
that and possibly a stable tag.
This looks like a clear bug. What system tripped over this? It's
useful to have bread crumbs like that in case we see other issues
caused by hardware/firmware defects like this.
> Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>
> ---
> v1->v2:
> Updated commit description
>
> drivers/pci/probe.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4f68414c3086..263ec21451d9 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1596,7 +1596,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
> if (pcie_downstream_port(parent)) {
> pci_info(pdev, "claims to be downstream port but is acting as upstream port, correcting type\n");
> pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
> - pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM;
> + pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM << 4;
> }
> } else if (type == PCI_EXP_TYPE_UPSTREAM) {
> /*
> @@ -1607,7 +1607,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
> if (pci_pcie_type(parent) == PCI_EXP_TYPE_UPSTREAM) {
> pci_info(pdev, "claims to be upstream port but is acting as downstream port, correcting type\n");
> pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
> - pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM;
> + pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM << 4;
> }
> }
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type
2024-12-13 18:47 ` Bjorn Helgaas
@ 2024-12-16 8:10 ` Mika Westerberg
0 siblings, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2024-12-16 8:10 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Gowthami Thiagarajan, bhelgaas, linux-pci, linux-kernel,
Andy Shevchenko
On Fri, Dec 13, 2024 at 12:47:00PM -0600, Bjorn Helgaas wrote:
> [+cc Mika, Andy]
>
> On Fri, Dec 13, 2024 at 12:32:41PM +0530, Gowthami Thiagarajan wrote:
> > When an invalid PCIe topology is detected, the set_pcie_port_type function
> > does not set the port type correctly. This issue can occur in
> > configurations such as:
> >
> > Root Port ---> Downstream Port ---> Root Port
> >
> > In such cases, the topology is identified as invalid and due to the
> > incorrect port type setting, the extended configuration space of the
> > child device becomes inaccessible.
>
> >From reading the code, it looks like the underlying problem is
> components that advertise the wrong PCIe Device/Port Type.
>
> set_pcie_port_type() already detects that incorrect Port Type and
> tries to correct it, but it puts the corrected type in bits [3:0]
> instead of [7:4] where it belongs.
>
> This looks like a bug from ca78410403dd ("PCI: Get rid of
> dev->has_secondary_link flag"). If so, we should add a Fixes: tag for
> that and possibly a stable tag.
Yeah agree, this is definitely a bug in that commit.
> This looks like a clear bug. What system tripped over this? It's
> useful to have bread crumbs like that in case we see other issues
> caused by hardware/firmware defects like this.
>
> > Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>
> > ---
> > v1->v2:
> > Updated commit description
> >
> > drivers/pci/probe.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> > index 4f68414c3086..263ec21451d9 100644
> > --- a/drivers/pci/probe.c
> > +++ b/drivers/pci/probe.c
> > @@ -1596,7 +1596,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
> > if (pcie_downstream_port(parent)) {
> > pci_info(pdev, "claims to be downstream port but is acting as upstream port, correcting type\n");
> > pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
> > - pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM;
> > + pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM << 4;
> > }
> > } else if (type == PCI_EXP_TYPE_UPSTREAM) {
> > /*
> > @@ -1607,7 +1607,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
> > if (pci_pcie_type(parent) == PCI_EXP_TYPE_UPSTREAM) {
> > pci_info(pdev, "claims to be upstream port but is acting as downstream port, correcting type\n");
> > pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
> > - pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM;
> > + pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM << 4;
> > }
> > }
> > }
> > --
> > 2.25.1
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type
2024-12-13 7:02 [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type Gowthami Thiagarajan
2024-12-13 18:47 ` Bjorn Helgaas
@ 2024-12-16 16:01 ` Ilpo Järvinen
1 sibling, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2024-12-16 16:01 UTC (permalink / raw)
To: Gowthami Thiagarajan; +Cc: bhelgaas, linux-pci, LKML
On Fri, 13 Dec 2024, Gowthami Thiagarajan wrote:
> When an invalid PCIe topology is detected, the set_pcie_port_type function
> does not set the port type correctly. This issue can occur in
> configurations such as:
>
> Root Port ---> Downstream Port ---> Root Port
>
> In such cases, the topology is identified as invalid and due to the incorrect
> port type setting, the extended configuration space of the child device becomes
> inaccessible.
>
> Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>
> ---
> v1->v2:
> Updated commit description
>
> drivers/pci/probe.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4f68414c3086..263ec21451d9 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1596,7 +1596,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
> if (pcie_downstream_port(parent)) {
> pci_info(pdev, "claims to be downstream port but is acting as upstream port, correcting type\n");
> pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
> - pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM;
> + pdev->pcie_flags_reg |= PCI_EXP_TYPE_UPSTREAM << 4;
Use FIELD_PREP() please.
--
i.
> }
> } else if (type == PCI_EXP_TYPE_UPSTREAM) {
> /*
> @@ -1607,7 +1607,7 @@ void set_pcie_port_type(struct pci_dev *pdev)
> if (pci_pcie_type(parent) == PCI_EXP_TYPE_UPSTREAM) {
> pci_info(pdev, "claims to be upstream port but is acting as downstream port, correcting type\n");
> pdev->pcie_flags_reg &= ~PCI_EXP_FLAGS_TYPE;
> - pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM;
> + pdev->pcie_flags_reg |= PCI_EXP_TYPE_DOWNSTREAM << 4;
> }
> }
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-16 16:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-13 7:02 [PATCH v2] PCI : Fix pcie_flag_reg in set_pcie_port_type Gowthami Thiagarajan
2024-12-13 18:47 ` Bjorn Helgaas
2024-12-16 8:10 ` Mika Westerberg
2024-12-16 16:01 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox