Merge tag 'char-misc-5.15-rc1-lkdtm' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / drivers / vdpa / vdpa.c
index bb3f1d1..1dc121a 100644 (file)
@@ -34,15 +34,13 @@ static int vdpa_dev_probe(struct device *d)
        return ret;
 }
 
-static int vdpa_dev_remove(struct device *d)
+static void vdpa_dev_remove(struct device *d)
 {
        struct vdpa_device *vdev = dev_to_vdpa(d);
        struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver);
 
        if (drv && drv->remove)
                drv->remove(vdev);
-
-       return 0;
 }
 
 static struct bus_type vdpa_bus = {
@@ -71,6 +69,7 @@ static void vdpa_release_dev(struct device *d)
  * @config: the bus operations that is supported by this device
  * @size: size of the parent structure that contains private data
  * @name: name of the vdpa device; optional.
+ * @use_va: indicate whether virtual address must be used by this device
  *
  * Driver should use vdpa_alloc_device() wrapper macro instead of
  * using this directly.
@@ -80,7 +79,8 @@ static void vdpa_release_dev(struct device *d)
  */
 struct vdpa_device *__vdpa_alloc_device(struct device *parent,
                                        const struct vdpa_config_ops *config,
-                                       size_t size, const char *name)
+                                       size_t size, const char *name,
+                                       bool use_va)
 {
        struct vdpa_device *vdev;
        int err = -EINVAL;
@@ -91,6 +91,10 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
        if (!!config->dma_map != !!config->dma_unmap)
                goto err;
 
+       /* It should only work for the device that use on-chip IOMMU */
+       if (use_va && !(config->dma_map || config->set_map))
+               goto err;
+
        err = -ENOMEM;
        vdev = kzalloc(size, GFP_KERNEL);
        if (!vdev)
@@ -106,6 +110,7 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
        vdev->index = err;
        vdev->config = config;
        vdev->features_valid = false;
+       vdev->use_va = use_va;
 
        if (name)
                err = dev_set_name(&vdev->dev, "%s", name);