aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJordan Niethe <jniethe5@gmail.com>2019-08-09 14:12:20 +1000
committerOliver O'Halloran <oohall@gmail.com>2019-08-16 15:51:55 +1000
commite4e2aa9cc2cbaab9c6c0ee3a1f4e36292128762a (patch)
tree3baf40df5b7ccde86c729634583655252a478530 /hw
parentf68639c6fcdf9261290a4601eda1ae6a406ba95a (diff)
downloadskiboot-e4e2aa9cc2cbaab9c6c0ee3a1f4e36292128762a.zip
skiboot-e4e2aa9cc2cbaab9c6c0ee3a1f4e36292128762a.tar.gz
skiboot-e4e2aa9cc2cbaab9c6c0ee3a1f4e36292128762a.tar.bz2
pci: Use a macro for accessing PCI BDF Function Number
Currently when the Function Number bits of a BDF are needed the bit operations to get it are free coded. There are many places where the Function Number is used, so make a macro to use instead of free coding it everytime. Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/npu2.c6
-rw-r--r--hw/npu3-nvlink.c8
-rw-r--r--hw/phb3.c2
3 files changed, 8 insertions, 8 deletions
diff --git a/hw/npu2.c b/hw/npu2.c
index f561386..06eaf4d 100644
--- a/hw/npu2.c
+++ b/hw/npu2.c
@@ -584,10 +584,10 @@ static int npu2_assign_gmb(struct npu2_dev *ndev)
* the highest bdfn (fn = 6) and count back until we find a
* npu2_dev. */
for (bdfn = (ndev->bdfn & ~0x7) | NPU2_LINKS_PER_CHIP;
- (bdfn & 0x7) != 0x7; bdfn = (bdfn & ~0x7) | ((bdfn & 0x7) - 1))
+ PCI_FUNC(bdfn) != 0x7; bdfn = (bdfn & ~0x7) | (PCI_FUNC(bdfn) - 1))
if (npu2_bdf_to_dev(p, bdfn))
break;
- peers = bdfn & 0x7;
+ peers = PCI_FUNC(bdfn);
npu2_get_gpu_base(ndev, &base, &size);
@@ -625,7 +625,7 @@ static int npu2_assign_gmb(struct npu2_dev *ndev)
assert(0);
}
- mode += ndev->bdfn & 0x7;
+ mode += PCI_FUNC(ndev->bdfn);
val = SETFIELD(NPU2_MEM_BAR_MODE, val, mode);
gmb = NPU2_GPU0_MEM_BAR;
diff --git a/hw/npu3-nvlink.c b/hw/npu3-nvlink.c
index c61e1b7..3939f2c 100644
--- a/hw/npu3-nvlink.c
+++ b/hw/npu3-nvlink.c
@@ -30,7 +30,7 @@
(dev)->npu->nvlink.phb.opal_id, \
PCI_BUS_NUM((dev)->nvlink.pvd->bdfn), \
PCI_DEV((dev)->nvlink.pvd->bdfn), \
- (dev)->nvlink.pvd->bdfn & 0x7, ##a)
+ PCI_FUNC((dev)->nvlink.pvd->bdfn), ##a)
#define NPU3DEVDBG(dev, fmt, a...) NPU3DEVLOG(PR_DEBUG, dev, fmt, ##a)
#define NPU3DEVINF(dev, fmt, a...) NPU3DEVLOG(PR_INFO, dev, fmt, ##a)
#define NPU3DEVERR(dev, fmt, a...) NPU3DEVLOG(PR_ERR, dev, fmt, ##a)
@@ -614,7 +614,7 @@ static void npu3_dev_assign_gmb(struct npu3_dev *dev, uint64_t addr,
assert(0);
}
- mode += dev->nvlink.pvd->bdfn & 0x7;
+ mode += PCI_FUNC(dev->nvlink.pvd->bdfn);
val = NPU3_GPU_MEM_BAR_ENABLE |
NPU3_GPU_MEM_BAR_POISON;
@@ -1594,7 +1594,7 @@ int64_t npu3_init_context(struct phb *phb, uint64_t msr, uint64_t bdf)
lparshort = GETFIELD(NPU3_XTS_BDF_MAP_LPARSHORT, map);
NPU3DBG(npu, "Found LPARSHORT 0x%x for bdf %02llx:%02llx.%llx\n",
- lparshort, PCI_BUS_NUM(bdf), PCI_DEV(bdf), bdf & 0x7);
+ lparshort, PCI_BUS_NUM(bdf), PCI_DEV(bdf), PCI_FUNC(bdf));
rc = npu3_init_context_pid(npu, lparshort, msr);
if (rc)
@@ -1711,7 +1711,7 @@ int64_t npu3_map_lpar(struct phb *phb, uint64_t bdf, uint64_t lparid,
if (!dev || dev->nvlink.gpu->bdfn != bdf) {
NPU3ERR(npu, "Can't find a link for bdf %02llx:%02llx.%llx\n",
- PCI_BUS_NUM(bdf), PCI_DEV(bdf), bdf & 0x7);
+ PCI_BUS_NUM(bdf), PCI_DEV(bdf), PCI_FUNC(bdf));
rc = OPAL_PARAMETER;
goto out;
}
diff --git a/hw/phb3.c b/hw/phb3.c
index 03bcee8..efa8ad1 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -2146,7 +2146,7 @@ static int64_t phb3_set_pe(struct phb *phb,
all = (all << 1) | 0x1;
else {
mask |= 0x7;
- val |= (bdfn & 0x7);
+ val |= PCI_FUNC(bdfn);
}
/* Map or unmap the RTT range */