[Skiboot] [PATCH] hw/npu.c: NPU bdfn allocation bugfix

Alistair Popple alistair at popple.id.au
Wed Aug 24 12:49:35 AEST 2016

The bdfn of the emulated/fake nvlink PCIe devices is allocated based
on the topology of GPU connections. Nvlinks going to the same GPU are
allocated to unique functions within the same device number.

In the device-tree every collection of nvlinks going to the same GPU
are given a unique group number which is currently also used as the
device number. To allocate a sequentially unique function number the
code should find the maximum previously allocated function.

However currently the code only checks for a single previously
allocated function number. This works fine on Garrison systems which
only have two links per GPU, but other systems may have more links per
GPU which will result in several links being assigned an identical
function number, resulting boot failure.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
 hw/npu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/npu.c b/hw/npu.c
index e805f10..5b383e6 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -1600,10 +1600,8 @@ static uint32_t npu_allocate_bdfn(struct npu *p, uint32_t group)
 	int bdfn = (group << 3);
 	for (i = 0; i < p->total_devices; i++) {
-		if (p->devices[i].bdfn == bdfn) {
+		if ((p->devices[i].bdfn & 0xf8) == (bdfn & 0xf8))
-			break;
-		}
 	return bdfn;

More information about the Skiboot mailing list