spapr/pci: Generate FDT fragment at configure connector time
Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <155059667346.1466090.326696113231137772.stgit@bahia.lab.toulouse-stg.fr.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
345b12b99e
commit
46fd02990d
@ -691,6 +691,7 @@ static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
|
|||||||
drck->typename = "28";
|
drck->typename = "28";
|
||||||
drck->drc_name_prefix = "C";
|
drck->drc_name_prefix = "C";
|
||||||
drck->release = spapr_phb_remove_pci_device_cb;
|
drck->release = spapr_phb_remove_pci_device_cb;
|
||||||
|
drck->dt_populate = spapr_pci_dt_populate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
|
static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
|
||||||
|
@ -1408,6 +1408,17 @@ static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb,
|
|||||||
return spapr_drc_index(drc);
|
return spapr_drc_index(drc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int spapr_pci_dt_populate(sPAPRDRConnector *drc, sPAPRMachineState *spapr,
|
||||||
|
void *fdt, int *fdt_start_offset, Error **errp)
|
||||||
|
{
|
||||||
|
HotplugHandler *plug_handler = qdev_get_hotplug_handler(drc->dev);
|
||||||
|
sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(plug_handler);
|
||||||
|
PCIDevice *pdev = PCI_DEVICE(drc->dev);
|
||||||
|
|
||||||
|
*fdt_start_offset = spapr_create_pci_child_dt(sphb, pdev, fdt, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void spapr_pci_plug(HotplugHandler *plug_handler,
|
static void spapr_pci_plug(HotplugHandler *plug_handler,
|
||||||
DeviceState *plugged_dev, Error **errp)
|
DeviceState *plugged_dev, Error **errp)
|
||||||
{
|
{
|
||||||
@ -1417,8 +1428,6 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
|
|||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(pdev)));
|
PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(pdev)));
|
||||||
uint32_t slotnr = PCI_SLOT(pdev->devfn);
|
uint32_t slotnr = PCI_SLOT(pdev->devfn);
|
||||||
void *fdt = NULL;
|
|
||||||
int fdt_start_offset, fdt_size;
|
|
||||||
|
|
||||||
/* if DR is disabled we don't need to do anything in the case of
|
/* if DR is disabled we don't need to do anything in the case of
|
||||||
* hotplug or coldplug callbacks
|
* hotplug or coldplug callbacks
|
||||||
@ -1448,10 +1457,7 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdt = create_device_tree(&fdt_size);
|
spapr_drc_attach(drc, DEVICE(pdev), NULL, 0, &local_err);
|
||||||
fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0);
|
|
||||||
|
|
||||||
spapr_drc_attach(drc, DEVICE(pdev), fdt, fdt_start_offset, &local_err);
|
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1483,7 +1489,6 @@ static void spapr_pci_plug(HotplugHandler *plug_handler,
|
|||||||
out:
|
out:
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
g_free(fdt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +121,10 @@ sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid);
|
|||||||
PCIDevice *spapr_pci_find_dev(sPAPRMachineState *spapr, uint64_t buid,
|
PCIDevice *spapr_pci_find_dev(sPAPRMachineState *spapr, uint64_t buid,
|
||||||
uint32_t config_addr);
|
uint32_t config_addr);
|
||||||
|
|
||||||
/* PCI release callback. */
|
/* DRC callbacks */
|
||||||
void spapr_phb_remove_pci_device_cb(DeviceState *dev);
|
void spapr_phb_remove_pci_device_cb(DeviceState *dev);
|
||||||
|
int spapr_pci_dt_populate(sPAPRDRConnector *drc, sPAPRMachineState *spapr,
|
||||||
|
void *fdt, int *fdt_start_offset, Error **errp);
|
||||||
|
|
||||||
/* VFIO EEH hooks */
|
/* VFIO EEH hooks */
|
||||||
#ifdef CONFIG_LINUX
|
#ifdef CONFIG_LINUX
|
||||||
|
Loading…
Reference in New Issue
Block a user