]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/msm/msm_gpu.c
drm/msm: bigger synchronization hammer
[karo-tx-linux.git] / drivers / gpu / drm / msm / msm_gpu.c
index 71f105f0d8976c91c04dc31cdaf7f2b46dd5bd4f..0cfe3f426ee4f4523d9e34c85427cd7cd37649a1 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "msm_gpu.h"
 #include "msm_gem.h"
+#include "msm_mmu.h"
 
 
 /*
@@ -297,8 +298,6 @@ int msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
        struct msm_drm_private *priv = dev->dev_private;
        int i, ret;
 
-       mutex_lock(&dev->struct_mutex);
-
        submit->fence = ++priv->next_fence;
 
        gpu->submitted_fence = submit->fence;
@@ -330,7 +329,6 @@ int msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
                        msm_gem_move_to_active(&msm_obj->base, gpu, true, submit->fence);
        }
        hangcheck_timer_reset(gpu);
-       mutex_unlock(&dev->struct_mutex);
 
        return ret;
 }
@@ -353,6 +351,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
                struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs,
                const char *name, const char *ioname, const char *irqname, int ringsz)
 {
+       struct iommu_domain *iommu;
        int i, ret;
 
        gpu->dev = drm;
@@ -418,13 +417,14 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
         * and have separate page tables per context.  For now, to keep things
         * simple and to get something working, just use a single address space:
         */
-       gpu->iommu = iommu_domain_alloc(&platform_bus_type);
-       if (!gpu->iommu) {
-               dev_err(drm->dev, "failed to allocate IOMMU\n");
-               ret = -ENOMEM;
-               goto fail;
+       iommu = iommu_domain_alloc(&platform_bus_type);
+       if (iommu) {
+               dev_info(drm->dev, "%s: using IOMMU\n", name);
+               gpu->mmu = msm_iommu_new(drm, iommu);
+       } else {
+               dev_info(drm->dev, "%s: no IOMMU, fallback to VRAM carveout!\n", name);
        }
-       gpu->id = msm_register_iommu(drm, gpu->iommu);
+       gpu->id = msm_register_mmu(drm, gpu->mmu);
 
        /* Create ringbuffer: */
        gpu->rb = msm_ringbuffer_new(gpu, ringsz);
@@ -464,6 +464,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
                msm_ringbuffer_destroy(gpu->rb);
        }
 
-       if (gpu->iommu)
-               iommu_domain_free(gpu->iommu);
+       if (gpu->mmu)
+               gpu->mmu->funcs->destroy(gpu->mmu);
 }