aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJordan Niethe <jniethe5@gmail.com>2019-08-09 14:12:18 +1000
committerOliver O'Halloran <oohall@gmail.com>2019-08-16 15:51:55 +1000
commitdf15dcfc8acc83591889fa3b33100734a6b6bdb7 (patch)
treeb509dfc81f1b0bd02a46aba513c49260865b6998 /hw
parent4acb8fe7960acbf13545ccafac691fe95047c714 (diff)
downloadskiboot-df15dcfc8acc83591889fa3b33100734a6b6bdb7.zip
skiboot-df15dcfc8acc83591889fa3b33100734a6b6bdb7.tar.gz
skiboot-df15dcfc8acc83591889fa3b33100734a6b6bdb7.tar.bz2
pci: Use a macro for accessing PCI BDF Bus Number
Currently when the Bus Number bits of a BDF are needed the bit operations to get it are free coded. There are many places where the Bus 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/npu.c2
-rw-r--r--hw/npu3-nvlink.c8
-rw-r--r--hw/phb3.c6
-rw-r--r--hw/phb4.c6
4 files changed, 11 insertions, 11 deletions
diff --git a/hw/npu.c b/hw/npu.c
index b0c23f7..03a4a29 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -784,7 +784,7 @@ static int64_t npu_set_pe(struct phb *phb,
* bus number is zero.
*/
dev = bdfn_to_npu_dev(p, bdfn);
- if ((bdfn >> 8) || !dev)
+ if (PCI_BUS_NUM(bdfn) || !dev)
return OPAL_PARAMETER;
link_idx = dev->index;
diff --git a/hw/npu3-nvlink.c b/hw/npu3-nvlink.c
index 7e7a10e..3297125 100644
--- a/hw/npu3-nvlink.c
+++ b/hw/npu3-nvlink.c
@@ -28,8 +28,8 @@
#define NPU3DEVLOG(l, dev, fmt, a...) \
prlog(l, "NPU#%04x:%02x:%02x.%x " fmt, \
(dev)->npu->nvlink.phb.opal_id, \
- (dev)->nvlink.pvd->bdfn >> 8 & 0xff, \
- (dev)->nvlink.pvd->bdfn >> 3 & 0x1f, \
+ PCI_BUS_NUM((dev)->nvlink.pvd->bdfn), \
+ (dev)->nvlink.pvd->bdfn >> 3 & 0x1f, \
(dev)->nvlink.pvd->bdfn & 0x7, ##a)
#define NPU3DEVDBG(dev, fmt, a...) NPU3DEVLOG(PR_DEBUG, dev, fmt, ##a)
#define NPU3DEVINF(dev, fmt, a...) NPU3DEVLOG(PR_INFO, dev, fmt, ##a)
@@ -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, bdf >> 8 & 0xff, bdf >> 3 & 0x1f, bdf & 0x7);
+ lparshort, PCI_BUS_NUM(bdf), bdf >> 3 & 0x1f, bdf & 0x7);
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",
- bdf >> 8 & 0xff, bdf >> 3 & 0x1f, bdf & 0x7);
+ PCI_BUS_NUM(bdf), bdf >> 3 & 0x1f, bdf & 0x7);
rc = OPAL_PARAMETER;
goto out;
}
diff --git a/hw/phb3.c b/hw/phb3.c
index ee127c1..03bcee8 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -126,7 +126,7 @@ static int64_t phb3_pcicfg_check(struct phb3 *p, uint32_t bdfn,
* error state if we try to probe beyond that, so let's
* avoid that and just return an error to Linux
*/
- if ((bdfn >> 8) == 0 && (bdfn & 0xff))
+ if (PCI_BUS_NUM(bdfn) == 0 && (bdfn & 0xff))
return OPAL_HARDWARE;
/* Check PHB state */
@@ -3278,7 +3278,7 @@ static int64_t phb3_err_inject_cfg(struct phb3 *p, uint64_t pe_number,
if (prefer == 0xffffull) {
if (is_bus_pe) {
m = PHB_PAPR_ERR_INJ_MASK_CFG;
- prefer = SETFIELD(m, 0x0ull, (bdfn >> 8));
+ prefer = SETFIELD(m, 0x0ull, PCI_BUS_NUM(bdfn));
} else {
m = PHB_PAPR_ERR_INJ_MASK_CFG_ALL;
prefer = SETFIELD(m, 0x0ull, bdfn);
@@ -3293,7 +3293,7 @@ static int64_t phb3_err_inject_cfg(struct phb3 *p, uint64_t pe_number,
}
if (is_bus_pe &&
- GETFIELD(PHB_PAPR_ERR_INJ_MASK_CFG, addr) == (bdfn >> 8)) {
+ GETFIELD(PHB_PAPR_ERR_INJ_MASK_CFG, addr) == PCI_BUS_NUM(bdfn)) {
a = addr;
break;
}
diff --git a/hw/phb4.c b/hw/phb4.c
index 1b618d0..631c8ed 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -258,7 +258,7 @@ static int64_t phb4_pcicfg_check(struct phb4 *p, uint32_t bdfn,
* error state if we try to probe beyond that, so let's
* avoid that and just return an error to Linux
*/
- if ((bdfn >> 8) == 0 && (bdfn & 0xff))
+ if (PCI_BUS_NUM(bdfn) == 0 && (bdfn & 0xff))
return OPAL_HARDWARE;
/* Check PHB state */
@@ -3815,7 +3815,7 @@ static int64_t phb4_err_inject_cfg(struct phb4 *phb, uint64_t pe_number,
if (prefer == 0xffffull) {
if (is_bus_pe) {
m = PHB_PAPR_ERR_INJ_MASK_CFG;
- prefer = SETFIELD(m, 0x0ull, (bdfn >> 8));
+ prefer = SETFIELD(m, 0x0ull, PCI_BUS_NUM(bdfn));
} else {
m = PHB_PAPR_ERR_INJ_MASK_CFG_ALL;
prefer = SETFIELD(m, 0x0ull, bdfn);
@@ -3830,7 +3830,7 @@ static int64_t phb4_err_inject_cfg(struct phb4 *phb, uint64_t pe_number,
}
if (is_bus_pe &&
- GETFIELD(PHB_PAPR_ERR_INJ_MASK_CFG, addr) == (bdfn >> 8)) {
+ GETFIELD(PHB_PAPR_ERR_INJ_MASK_CFG, addr) == PCI_BUS_NUM(bdfn)) {
a = addr;
break;
}