diff mbox series

ibm-fsp/lxvpd: check for upstream port on slot labeling

Message ID 20200209014842.30189-1-klaus@linux.vnet.ibm.com
State Accepted
Headers show
Series ibm-fsp/lxvpd: check for upstream port on slot labeling | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (179d53dfcca30436777b0c748d530a979bbc8a45)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Klaus Heinrich Kiwi Feb. 9, 2020, 1:48 a.m. UTC
Certain FSP configurations include PCIe switches that can have LXVPD
slot map entries using the same switch-id and dev-id, even if they are
referring to different upstream and downstream ports of the same link.

The slot matching function (lxvpd_get_slot()) will match the first
occurence, that can be the upstream port with, and ignore the downstream
port.

The main symptom for the above is an incorrect label for those slots,
but I believe other slot attributes could be incorrect as well (as we
are associating a slot with an upstream port).

This patch picks-up an existing "upstream port" attribute from the 1005
version of the LXVPD slot map to prevent matching upstream ports on
the slot matching function.

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
---
 platforms/ibm-fsp/lxvpd.c | 9 +++++----
 platforms/ibm-fsp/lxvpd.h | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Oliver O'Halloran Feb. 17, 2020, 3:56 a.m. UTC | #1
On Sun, Feb 9, 2020 at 12:49 PM Klaus Heinrich Kiwi
<klaus@linux.vnet.ibm.com> wrote:
>
> Certain FSP configurations include PCIe switches that can have LXVPD
> slot map entries using the same switch-id and dev-id, even if they are
> referring to different upstream and downstream ports of the same link.
>
> The slot matching function (lxvpd_get_slot()) will match the first
> occurence, that can be the upstream port with, and ignore the downstream
> port.
>
> The main symptom for the above is an incorrect label for those slots,
> but I believe other slot attributes could be incorrect as well (as we
> are associating a slot with an upstream port).
>
> This patch picks-up an existing "upstream port" attribute from the 1005
> version of the LXVPD slot map to prevent matching upstream ports on
> the slot matching function.
>
> Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>

Merged as 99ce1bef50fc1f7a361e897e261a6eb8f6b36d97 with some fixups
for 80cols compliance.
diff mbox series

Patch

diff --git a/platforms/ibm-fsp/lxvpd.c b/platforms/ibm-fsp/lxvpd.c
index 81cb612e..f6d92370 100644
--- a/platforms/ibm-fsp/lxvpd.c
+++ b/platforms/ibm-fsp/lxvpd.c
@@ -111,8 +111,8 @@  void *lxvpd_get_slot(struct pci_slot *slot)
 			return s;
 		}
 
-		/* Match switch port with switch_id != 0 */
-		if (!is_phb && s->switch_id != 0 && s->dev_id == slot_num) {
+		/* Match downstream switch port with switch_id != 0 */
+		if (!is_phb && s->switch_id != 0 && !s->upstream_port && s->dev_id == slot_num) {
 			slot->data = s;
 			s->pci_slot = slot;
 			prlog(PR_DEBUG, "Found [%s] for slot %016llx\n",
@@ -251,6 +251,7 @@  static void lxvpd_parse_1005_map(struct phb *phb,
 		s->dev_id         = entry->switch_device_id;
 		s->pluggable      = (entry->p0.pluggable == 0);
 		s->power_ctl      = entry->p0.power_ctl;
+		s->upstream_port  = entry->p0.upstream_port;
 		s->bus_clock      = entry->p2.bus_clock;
 		s->connector_type = entry->p2.connector_type;
 		s->card_desc      = entry->p3.byte >> 6;
@@ -261,8 +262,8 @@  static void lxvpd_parse_1005_map(struct phb *phb,
 		if (s->wired_lanes > PCI_SLOT_WIRED_LANES_PCIE_X32)
 			s->wired_lanes = PCI_SLOT_WIRED_LANES_UNKNOWN;
 
-		prlog(PR_DEBUG, "1005 Platform data [%s] %02x %02x on PHB%04x\n",
-			  s->label, s->switch_id, s->dev_id, phb->opal_id);
+		prlog(PR_DEBUG, "1005 Platform data [%s] %02x %02x %s on PHB%04x\n",
+			  s->label, s->switch_id, s->dev_id, s->upstream_port ? "upstream" : "downstream", phb->opal_id);
 	}
 }
 
diff --git a/platforms/ibm-fsp/lxvpd.h b/platforms/ibm-fsp/lxvpd.h
index 46acf674..d0fddd28 100644
--- a/platforms/ibm-fsp/lxvpd.h
+++ b/platforms/ibm-fsp/lxvpd.h
@@ -142,6 +142,7 @@  struct lxvpd_pci_slot {
 	char		label[9];
 	bool		pluggable;
 	bool		power_ctl;
+	bool		upstream_port;
 	uint8_t		wired_lanes;
 	uint8_t		bus_clock;
 	uint8_t		connector_type;