diff options
author | Gavin Shan <gwshan@linux.vnet.ibm.com> | 2016-04-26 11:56:53 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-05-03 17:54:43 +1000 |
commit | 0d4d3355e00e5beee08123d6db6e08aa3d9e47c8 (patch) | |
tree | d41385ac7c927d0be5ca19718468a98676a401eb /hw/npu.c | |
parent | 00f3d2ca92b325db1c7832e4560b564359977202 (diff) | |
download | skiboot-0d4d3355e00e5beee08123d6db6e08aa3d9e47c8.zip skiboot-0d4d3355e00e5beee08123d6db6e08aa3d9e47c8.tar.gz skiboot-0d4d3355e00e5beee08123d6db6e08aa3d9e47c8.tar.bz2 |
PCI: Introduce phb_ops->phb_final_fixup()
phb_ops->device_node_fixup() was introduced for NPU1 so that the
chip backend can bind the emulated NPU device with the GPU device
and fixes the device-tree node accordingly. There're couple of
issues as I can image:
* In pci_fixup_nodes(), one PHB has only one level of device
depth in the hierarchy tree. It's true for NPU PHBs, but
false for other PHBs. That indicates the function can be
called for NPU PHBs.
* The callback name indicates the specific work to be done
there. That doesn't make sense. We need another name without
indicating the specific work to do. It will give the backend
on chip level more freedom. Similarly, the callback is called
on basis of PCI device. It's hard for backend to manuplate
the PHB. More freedom the backend will get with more bold
granularity.
This fixes above issues by replacing phb_ops->device_node_fixup()
with phb_ops->phb_final_fixup(). More freedom will be received in
the backends.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/npu.c')
-rw-r--r-- | hw/npu.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -585,7 +585,9 @@ static void npu_append_pci_phandle(struct dt_node *dn, u32 phandle) unlock(&pci_npu_phandle_lock); } -static void npu_dn_fixup(struct phb *phb, struct pci_device *pd) +static int npu_dn_fixup(struct phb *phb, + struct pci_device *pd, + void *data __unused) { struct npu *p = phb_to_npu(phb); struct npu_dev *dev; @@ -594,7 +596,7 @@ static void npu_dn_fixup(struct phb *phb, struct pci_device *pd) assert(dev); if (dev->phb || dev->pd) - return; + return 0; /* Bind the emulated PCI device with the real one, which can't * be done until the PCI devices are populated. Once the real @@ -610,6 +612,13 @@ static void npu_dn_fixup(struct phb *phb, struct pci_device *pd) dt_add_property_cells(pd->dn, "ibm,gpu", dev->pd->dn->phandle); } + + return 0; +} + +static void npu_phb_final_fixup(struct phb *phb) +{ + pci_walk_dev(phb, npu_dn_fixup, NULL); } static void npu_ioda_init(struct npu *p) @@ -1095,7 +1104,7 @@ static const struct phb_ops npu_ops = { .cfg_write32 = npu_dev_cfg_write32, .choose_bus = NULL, .device_init = NULL, - .device_node_fixup = npu_dn_fixup, + .phb_final_fixup = npu_phb_final_fixup, .presence_detect = NULL, .ioda_reset = npu_ioda_reset, .papr_errinjct_reset = NULL, |