drm/etnaviv: remove the need for a gpu-subsystem DT node
[sfrench/cifs-2.6.git] / drivers / gpu / drm / etnaviv / etnaviv_drv.c
index 491eddf9b15022177bc3106181aef4cccaf89fa5..ab50090d066c60758595cbe089e9458494248cf4 100644 (file)
@@ -101,12 +101,25 @@ static void load_gpu(struct drm_device *dev)
 
 static int etnaviv_open(struct drm_device *dev, struct drm_file *file)
 {
+       struct etnaviv_drm_private *priv = dev->dev_private;
        struct etnaviv_file_private *ctx;
+       int i;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx)
                return -ENOMEM;
 
+       for (i = 0; i < ETNA_MAX_PIPES; i++) {
+               struct etnaviv_gpu *gpu = priv->gpu[i];
+
+               if (gpu) {
+                       drm_sched_entity_init(&gpu->sched,
+                               &ctx->sched_entity[i],
+                               &gpu->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL],
+                               32, NULL);
+                       }
+       }
+
        file->driver_priv = ctx;
 
        return 0;
@@ -126,6 +139,9 @@ static void etnaviv_postclose(struct drm_device *dev, struct drm_file *file)
                        if (gpu->lastctx == ctx)
                                gpu->lastctx = NULL;
                        mutex_unlock(&gpu->lock);
+
+                       drm_sched_entity_fini(&gpu->sched,
+                                             &ctx->sched_entity[i]);
                }
        }
 
@@ -172,7 +188,7 @@ static int etnaviv_mmu_show(struct etnaviv_gpu *gpu, struct seq_file *m)
 
 static void etnaviv_buffer_dump(struct etnaviv_gpu *gpu, struct seq_file *m)
 {
-       struct etnaviv_cmdbuf *buf = gpu->buffer;
+       struct etnaviv_cmdbuf *buf = &gpu->buffer;
        u32 size = buf->size;
        u32 *ptr = buf->vaddr;
        u32 i;
@@ -459,9 +475,6 @@ static int etnaviv_ioctl_pm_query_dom(struct drm_device *dev, void *data,
        struct drm_etnaviv_pm_domain *args = data;
        struct etnaviv_gpu *gpu;
 
-       /* reject as long as the feature isn't stable */
-       return -EINVAL;
-
        if (args->pipe >= ETNA_MAX_PIPES)
                return -EINVAL;
 
@@ -479,9 +492,6 @@ static int etnaviv_ioctl_pm_query_sig(struct drm_device *dev, void *data,
        struct drm_etnaviv_pm_signal *args = data;
        struct etnaviv_gpu *gpu;
 
-       /* reject as long as the feature isn't stable */
-       return -EINVAL;
-
        if (args->pipe >= ETNA_MAX_PIPES)
                return -EINVAL;
 
@@ -556,7 +566,7 @@ static struct drm_driver etnaviv_drm_driver = {
        .desc               = "etnaviv DRM",
        .date               = "20151214",
        .major              = 1,
-       .minor              = 1,
+       .minor              = 2,
 };
 
 /*
@@ -580,12 +590,6 @@ static int etnaviv_bind(struct device *dev)
        }
        drm->dev_private = priv;
 
-       priv->wq = alloc_ordered_workqueue("etnaviv", 0);
-       if (!priv->wq) {
-               ret = -ENOMEM;
-               goto out_wq;
-       }
-
        mutex_init(&priv->gem_lock);
        INIT_LIST_HEAD(&priv->gem_list);
        priv->num_gpus = 0;
@@ -607,9 +611,6 @@ static int etnaviv_bind(struct device *dev)
 out_register:
        component_unbind_all(dev, drm);
 out_bind:
-       flush_workqueue(priv->wq);
-       destroy_workqueue(priv->wq);
-out_wq:
        kfree(priv);
 out_unref:
        drm_dev_unref(drm);
@@ -624,9 +625,6 @@ static void etnaviv_unbind(struct device *dev)
 
        drm_dev_unregister(drm);
 
-       flush_workqueue(priv->wq);
-       destroy_workqueue(priv->wq);
-
        component_unbind_all(dev, drm);
 
        drm->dev_private = NULL;
@@ -655,25 +653,21 @@ static int compare_str(struct device *dev, void *data)
 static int etnaviv_pdev_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *node = dev->of_node;
        struct component_match *match = NULL;
 
        dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
 
-       if (node) {
+       if (!dev->platform_data) {
                struct device_node *core_node;
-               int i;
 
-               for (i = 0; ; i++) {
-                       core_node = of_parse_phandle(node, "cores", i);
-                       if (!core_node)
-                               break;
+               for_each_compatible_node(core_node, NULL, "vivante,gc") {
+                       if (!of_device_is_available(core_node))
+                               continue;
 
                        drm_of_component_match_add(&pdev->dev, &match,
                                                   compare_of, core_node);
-                       of_node_put(core_node);
                }
-       } else if (dev->platform_data) {
+       } else {
                char **names = dev->platform_data;
                unsigned i;
 
@@ -691,25 +685,18 @@ static int etnaviv_pdev_remove(struct platform_device *pdev)
        return 0;
 }
 
-static const struct of_device_id dt_match[] = {
-       { .compatible = "fsl,imx-gpu-subsystem" },
-       { .compatible = "marvell,dove-gpu-subsystem" },
-       {}
-};
-MODULE_DEVICE_TABLE(of, dt_match);
-
 static struct platform_driver etnaviv_platform_driver = {
        .probe      = etnaviv_pdev_probe,
        .remove     = etnaviv_pdev_remove,
        .driver     = {
                .name   = "etnaviv",
-               .of_match_table = dt_match,
        },
 };
 
 static int __init etnaviv_init(void)
 {
        int ret;
+       struct device_node *np;
 
        etnaviv_validate_init();
 
@@ -721,6 +708,19 @@ static int __init etnaviv_init(void)
        if (ret != 0)
                platform_driver_unregister(&etnaviv_gpu_driver);
 
+       /*
+        * If the DT contains at least one available GPU device, instantiate
+        * the DRM platform device.
+        */
+       for_each_compatible_node(np, NULL, "vivante,gc") {
+               if (!of_device_is_available(np))
+                       continue;
+
+               platform_device_register_simple("etnaviv", -1, NULL, 0);
+               of_node_put(np);
+               break;
+       }
+
        return ret;
 }
 module_init(etnaviv_init);