mirror of https://gitee.com/openkylin/qemu.git
spapr_iommu: pass device to spapr_tce_new_table and use it to set owner
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5cb022a1bf
commit
84af6d9f97
|
@ -116,7 +116,7 @@ static MemoryRegionIOMMUOps spapr_iommu_ops = {
|
||||||
.translate = spapr_tce_translate_iommu,
|
.translate = spapr_tce_translate_iommu,
|
||||||
};
|
};
|
||||||
|
|
||||||
sPAPRTCETable *spapr_tce_new_table(uint32_t liobn, size_t window_size)
|
sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn, size_t window_size)
|
||||||
{
|
{
|
||||||
sPAPRTCETable *tcet;
|
sPAPRTCETable *tcet;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ sPAPRTCETable *spapr_tce_new_table(uint32_t liobn, size_t window_size)
|
||||||
"table @ %p, fd=%d\n", tcet, liobn, tcet->table, tcet->fd);
|
"table @ %p, fd=%d\n", tcet, liobn, tcet->table, tcet->fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memory_region_init_iommu(&tcet->iommu, NULL, &spapr_iommu_ops,
|
memory_region_init_iommu(&tcet->iommu, OBJECT(owner), &spapr_iommu_ops,
|
||||||
"iommu-spapr", UINT64_MAX);
|
"iommu-spapr", UINT64_MAX);
|
||||||
|
|
||||||
QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);
|
QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);
|
||||||
|
|
|
@ -646,7 +646,8 @@ static int spapr_phb_init(SysBusDevice *s)
|
||||||
|
|
||||||
sphb->dma_window_start = 0;
|
sphb->dma_window_start = 0;
|
||||||
sphb->dma_window_size = 0x40000000;
|
sphb->dma_window_size = 0x40000000;
|
||||||
sphb->tcet = spapr_tce_new_table(sphb->dma_liobn, sphb->dma_window_size);
|
sphb->tcet = spapr_tce_new_table(DEVICE(sphb), sphb->dma_liobn,
|
||||||
|
sphb->dma_window_size);
|
||||||
if (!sphb->tcet) {
|
if (!sphb->tcet) {
|
||||||
fprintf(stderr, "Unable to create TCE table for %s\n", sphb->dtbusname);
|
fprintf(stderr, "Unable to create TCE table for %s\n", sphb->dtbusname);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -455,7 +455,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)
|
||||||
|
|
||||||
if (pc->rtce_window_size) {
|
if (pc->rtce_window_size) {
|
||||||
uint32_t liobn = SPAPR_VIO_BASE_LIOBN | dev->reg;
|
uint32_t liobn = SPAPR_VIO_BASE_LIOBN | dev->reg;
|
||||||
dev->tcet = spapr_tce_new_table(liobn, pc->rtce_window_size);
|
dev->tcet = spapr_tce_new_table(qdev, liobn, pc->rtce_window_size);
|
||||||
address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet), qdev->id);
|
address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet), qdev->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,8 @@ typedef struct sPAPRTCETable sPAPRTCETable;
|
||||||
void spapr_iommu_init(void);
|
void spapr_iommu_init(void);
|
||||||
void spapr_events_init(sPAPREnvironment *spapr);
|
void spapr_events_init(sPAPREnvironment *spapr);
|
||||||
void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq);
|
void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq);
|
||||||
sPAPRTCETable *spapr_tce_new_table(uint32_t liobn, size_t window_size);
|
sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
|
||||||
|
size_t window_size);
|
||||||
MemoryRegion *spapr_tce_get_iommu(sPAPRTCETable *tcet);
|
MemoryRegion *spapr_tce_get_iommu(sPAPRTCETable *tcet);
|
||||||
void spapr_tce_free(sPAPRTCETable *tcet);
|
void spapr_tce_free(sPAPRTCETable *tcet);
|
||||||
void spapr_tce_reset(sPAPRTCETable *tcet);
|
void spapr_tce_reset(sPAPRTCETable *tcet);
|
||||||
|
|
Loading…
Reference in New Issue