summaryrefslogtreecommitdiff
path: root/drivers/vfio/fsl-mc/vfio_fsl_mc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vfio/fsl-mc/vfio_fsl_mc.c')
-rw-r--r--drivers/vfio/fsl-mc/vfio_fsl_mc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
index 8f3a625..eb40249 100644
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
@@ -229,9 +229,16 @@ static int vfio_fsl_mc_probe(struct fsl_mc_device *mc_dev)
goto free_vfio_device;
}
} else {
- /* Handling for Non-DPRC device to be added */
- ret = -EINVAL;
- goto free_vfio_device;
+ struct fsl_mc_device *mc_bus_dev;
+
+ /* Non-dprc devices share mc_io from the parent dprc */
+ mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
+ if (mc_bus_dev == NULL) {
+ vfio_del_group_dev(dev);
+ goto free_vfio_device;
+ }
+
+ mc_dev->mc_io = mc_bus_dev->mc_io;
}
return 0;
@@ -253,6 +260,8 @@ static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
if (strcmp(mc_dev->obj_desc.type, "dprc") == 0)
vfio_fsl_mc_cleanup_dprc(vdev);
+ mc_dev->mc_io = NULL;
+
vfio_iommu_group_put(mc_dev->dev.iommu_group, dev);
kfree(vdev);