diff options
Diffstat (limited to 'drivers/gpu/drm/v3d')
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_debugfs.c | 20 | ||||
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_drv.c | 53 | ||||
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_drv.h | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_gem.c | 17 | ||||
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_irq.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_mmu.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/v3d/v3d_sched.c | 10 |
7 files changed, 63 insertions, 72 deletions
diff --git a/drivers/gpu/drm/v3d/v3d_debugfs.c b/drivers/gpu/drm/v3d/v3d_debugfs.c index 9e953ce64ef7..e76b24bb8828 100644 --- a/drivers/gpu/drm/v3d/v3d_debugfs.c +++ b/drivers/gpu/drm/v3d/v3d_debugfs.c @@ -132,7 +132,7 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused) u32 ident0, ident1, ident2, ident3, cores; int ret, core; - ret = pm_runtime_get_sync(v3d->dev); + ret = pm_runtime_get_sync(v3d->drm.dev); if (ret < 0) return ret; @@ -187,8 +187,8 @@ static int v3d_v3d_debugfs_ident(struct seq_file *m, void *unused) (misccfg & V3D_MISCCFG_OVRTMUOUT) != 0); } - pm_runtime_mark_last_busy(v3d->dev); - pm_runtime_put_autosuspend(v3d->dev); + pm_runtime_mark_last_busy(v3d->drm.dev); + pm_runtime_put_autosuspend(v3d->drm.dev); return 0; } @@ -219,7 +219,7 @@ static int v3d_measure_clock(struct seq_file *m, void *unused) int measure_ms = 1000; int ret; - ret = pm_runtime_get_sync(v3d->dev); + ret = pm_runtime_get_sync(v3d->drm.dev); if (ret < 0) return ret; @@ -245,8 +245,8 @@ static int v3d_measure_clock(struct seq_file *m, void *unused) cycles / (measure_ms * 1000), (cycles / (measure_ms * 100)) % 10); - pm_runtime_mark_last_busy(v3d->dev); - pm_runtime_put_autosuspend(v3d->dev); + pm_runtime_mark_last_busy(v3d->drm.dev); + pm_runtime_put_autosuspend(v3d->drm.dev); return 0; } @@ -258,10 +258,10 @@ static const struct drm_info_list v3d_debugfs_list[] = { {"bo_stats", v3d_debugfs_bo_stats, 0}, }; -int +void v3d_debugfs_init(struct drm_minor *minor) { - return drm_debugfs_create_files(v3d_debugfs_list, - ARRAY_SIZE(v3d_debugfs_list), - minor->debugfs_root, minor); + drm_debugfs_create_files(v3d_debugfs_list, + ARRAY_SIZE(v3d_debugfs_list), + minor->debugfs_root, minor); } diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/v3d_drv.c index eaa8e9682373..82a7dfdd14c2 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.c +++ b/drivers/gpu/drm/v3d/v3d_drv.c @@ -25,6 +25,7 @@ #include <drm/drm_drv.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_helper.h> +#include <drm/drm_managed.h> #include <uapi/drm/v3d_drm.h> #include "v3d_drv.h" @@ -104,7 +105,7 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data, if (args->value != 0) return -EINVAL; - ret = pm_runtime_get_sync(v3d->dev); + ret = pm_runtime_get_sync(v3d->drm.dev); if (ret < 0) return ret; if (args->param >= DRM_V3D_PARAM_V3D_CORE0_IDENT0 && @@ -113,8 +114,8 @@ static int v3d_get_param_ioctl(struct drm_device *dev, void *data, } else { args->value = V3D_READ(offset); } - pm_runtime_mark_last_busy(v3d->dev); - pm_runtime_put_autosuspend(v3d->dev); + pm_runtime_mark_last_busy(v3d->drm.dev); + pm_runtime_put_autosuspend(v3d->drm.dev); return 0; } @@ -234,9 +235,9 @@ static int map_regs(struct v3d_dev *v3d, void __iomem **regs, const char *name) { struct resource *res = - platform_get_resource_byname(v3d->pdev, IORESOURCE_MEM, name); + platform_get_resource_byname(v3d_to_pdev(v3d), IORESOURCE_MEM, name); - *regs = devm_ioremap_resource(v3d->dev, res); + *regs = devm_ioremap_resource(v3d->drm.dev, res); return PTR_ERR_OR_ZERO(*regs); } @@ -250,20 +251,21 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) u32 ident1; - v3d = kzalloc(sizeof(*v3d), GFP_KERNEL); - if (!v3d) - return -ENOMEM; - v3d->dev = dev; - v3d->pdev = pdev; + v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm); + if (IS_ERR(v3d)) + return PTR_ERR(v3d); + drm = &v3d->drm; + platform_set_drvdata(pdev, drm); + ret = map_regs(v3d, &v3d->hub_regs, "hub"); if (ret) - goto dev_free; + return ret; ret = map_regs(v3d, &v3d->core_regs[0], "core0"); if (ret) - goto dev_free; + return ret; mmu_debug = V3D_READ(V3D_MMU_DEBUG_INFO); dev->coherent_dma_mask = @@ -281,45 +283,37 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ret = PTR_ERR(v3d->reset); if (ret == -EPROBE_DEFER) - goto dev_free; + return ret; v3d->reset = NULL; ret = map_regs(v3d, &v3d->bridge_regs, "bridge"); if (ret) { dev_err(dev, "Failed to get reset control or bridge regs\n"); - goto dev_free; + return ret; } } if (v3d->ver < 41) { ret = map_regs(v3d, &v3d->gca_regs, "gca"); if (ret) - goto dev_free; + return ret; } v3d->mmu_scratch = dma_alloc_wc(dev, 4096, &v3d->mmu_scratch_paddr, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO); if (!v3d->mmu_scratch) { dev_err(dev, "Failed to allocate MMU scratch page\n"); - ret = -ENOMEM; - goto dev_free; + return -ENOMEM; } pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, 50); pm_runtime_enable(dev); - ret = drm_dev_init(&v3d->drm, &v3d_drm_driver, dev); - if (ret) - goto dma_free; - - platform_set_drvdata(pdev, drm); - drm->dev_private = v3d; - ret = v3d_gem_init(drm); if (ret) - goto dev_destroy; + goto dma_free; ret = v3d_irq_init(v3d); if (ret) @@ -335,12 +329,8 @@ irq_disable: v3d_irq_disable(v3d); gem_destroy: v3d_gem_destroy(drm); -dev_destroy: - drm_dev_put(drm); dma_free: dma_free_wc(dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); -dev_free: - kfree(v3d); return ret; } @@ -353,9 +343,8 @@ static int v3d_platform_drm_remove(struct platform_device *pdev) v3d_gem_destroy(drm); - drm_dev_put(drm); - - dma_free_wc(v3d->dev, 4096, v3d->mmu_scratch, v3d->mmu_scratch_paddr); + dma_free_wc(v3d->drm.dev, 4096, v3d->mmu_scratch, + v3d->mmu_scratch_paddr); return 0; } diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h index ac2603334587..8a390738d65b 100644 --- a/drivers/gpu/drm/v3d/v3d_drv.h +++ b/drivers/gpu/drm/v3d/v3d_drv.h @@ -14,7 +14,6 @@ #include "uapi/drm/v3d_drm.h" struct clk; -struct device; struct platform_device; struct reset_control; @@ -47,8 +46,6 @@ struct v3d_dev { int ver; bool single_irq_line; - struct device *dev; - struct platform_device *pdev; void __iomem *hub_regs; void __iomem *core_regs[3]; void __iomem *bridge_regs; @@ -121,7 +118,7 @@ struct v3d_dev { static inline struct v3d_dev * to_v3d_dev(struct drm_device *dev) { - return (struct v3d_dev *)dev->dev_private; + return container_of(dev, struct v3d_dev, drm); } static inline bool @@ -130,6 +127,8 @@ v3d_has_csd(struct v3d_dev *v3d) return v3d->ver >= 41; } +#define v3d_to_pdev(v3d) to_platform_device((v3d)->drm.dev) + /* The per-fd struct, which tracks the MMU mappings. */ struct v3d_file_priv { struct v3d_dev *v3d; @@ -316,7 +315,7 @@ struct drm_gem_object *v3d_prime_import_sg_table(struct drm_device *dev, struct sg_table *sgt); /* v3d_debugfs.c */ -int v3d_debugfs_init(struct drm_minor *minor); +void v3d_debugfs_init(struct drm_minor *minor); /* v3d_fence.c */ extern const struct dma_fence_ops v3d_fence_ops; diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index 549dde83408b..09a7639cf161 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -370,8 +370,8 @@ v3d_job_free(struct kref *ref) dma_fence_put(job->irq_fence); dma_fence_put(job->done_fence); - pm_runtime_mark_last_busy(job->v3d->dev); - pm_runtime_put_autosuspend(job->v3d->dev); + pm_runtime_mark_last_busy(job->v3d->drm.dev); + pm_runtime_put_autosuspend(job->v3d->drm.dev); kfree(job); } @@ -439,7 +439,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, job->v3d = v3d; job->free = free; - ret = pm_runtime_get_sync(v3d->dev); + ret = pm_runtime_get_sync(v3d->drm.dev); if (ret < 0) return ret; @@ -458,7 +458,7 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, return 0; fail: xa_destroy(&job->deps); - pm_runtime_put_autosuspend(v3d->dev); + pm_runtime_put_autosuspend(v3d->drm.dev); return ret; } @@ -886,12 +886,12 @@ v3d_gem_init(struct drm_device *dev) */ drm_mm_init(&v3d->mm, 1, pt_size / sizeof(u32) - 1); - v3d->pt = dma_alloc_wc(v3d->dev, pt_size, + v3d->pt = dma_alloc_wc(v3d->drm.dev, pt_size, &v3d->pt_paddr, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO); if (!v3d->pt) { drm_mm_takedown(&v3d->mm); - dev_err(v3d->dev, + dev_err(v3d->drm.dev, "Failed to allocate page tables. " "Please ensure you have CMA enabled.\n"); return -ENOMEM; @@ -903,7 +903,7 @@ v3d_gem_init(struct drm_device *dev) ret = v3d_sched_init(v3d); if (ret) { drm_mm_takedown(&v3d->mm); - dma_free_coherent(v3d->dev, 4096 * 1024, (void *)v3d->pt, + dma_free_coherent(v3d->drm.dev, 4096 * 1024, (void *)v3d->pt, v3d->pt_paddr); } @@ -925,5 +925,6 @@ v3d_gem_destroy(struct drm_device *dev) drm_mm_takedown(&v3d->mm); - dma_free_coherent(v3d->dev, 4096 * 1024, (void *)v3d->pt, v3d->pt_paddr); + dma_free_coherent(v3d->drm.dev, 4096 * 1024, (void *)v3d->pt, + v3d->pt_paddr); } diff --git a/drivers/gpu/drm/v3d/v3d_irq.c b/drivers/gpu/drm/v3d/v3d_irq.c index 662e67279a7b..51b65263c657 100644 --- a/drivers/gpu/drm/v3d/v3d_irq.c +++ b/drivers/gpu/drm/v3d/v3d_irq.c @@ -128,7 +128,7 @@ v3d_irq(int irq, void *arg) * always-allowed mode. */ if (intsts & V3D_INT_GMPV) - dev_err(v3d->dev, "GMP violation\n"); + dev_err(v3d->drm.dev, "GMP violation\n"); /* V3D 4.2 wires the hub and core IRQs together, so if we & * didn't see the common one then check hub for MMU IRQs. @@ -189,7 +189,7 @@ v3d_hub_irq(int irq, void *arg) client = v3d41_axi_ids[axi_id]; } - dev_err(v3d->dev, "MMU error from client %s (%d) at 0x%llx%s%s%s\n", + dev_err(v3d->drm.dev, "MMU error from client %s (%d) at 0x%llx%s%s%s\n", client, axi_id, (long long)vio_addr, ((intsts & V3D_HUB_INT_MMU_WRV) ? ", write violation" : ""), @@ -217,16 +217,17 @@ v3d_irq_init(struct v3d_dev *v3d) V3D_CORE_WRITE(core, V3D_CTL_INT_CLR, V3D_CORE_IRQS); V3D_WRITE(V3D_HUB_INT_CLR, V3D_HUB_IRQS); - irq1 = platform_get_irq(v3d->pdev, 1); + irq1 = platform_get_irq(v3d_to_pdev(v3d), 1); if (irq1 == -EPROBE_DEFER) return irq1; if (irq1 > 0) { - ret = devm_request_irq(v3d->dev, irq1, + ret = devm_request_irq(v3d->drm.dev, irq1, v3d_irq, IRQF_SHARED, "v3d_core0", v3d); if (ret) goto fail; - ret = devm_request_irq(v3d->dev, platform_get_irq(v3d->pdev, 0), + ret = devm_request_irq(v3d->drm.dev, + platform_get_irq(v3d_to_pdev(v3d), 0), v3d_hub_irq, IRQF_SHARED, "v3d_hub", v3d); if (ret) @@ -234,7 +235,8 @@ v3d_irq_init(struct v3d_dev *v3d) } else { v3d->single_irq_line = true; - ret = devm_request_irq(v3d->dev, platform_get_irq(v3d->pdev, 0), + ret = devm_request_irq(v3d->drm.dev, + platform_get_irq(v3d_to_pdev(v3d), 0), v3d_irq, IRQF_SHARED, "v3d", v3d); if (ret) @@ -246,7 +248,7 @@ v3d_irq_init(struct v3d_dev *v3d) fail: if (ret != -EPROBE_DEFER) - dev_err(v3d->dev, "IRQ setup failed: %d\n", ret); + dev_err(v3d->drm.dev, "IRQ setup failed: %d\n", ret); return ret; } diff --git a/drivers/gpu/drm/v3d/v3d_mmu.c b/drivers/gpu/drm/v3d/v3d_mmu.c index 395e81d97163..3b81ea28c0bb 100644 --- a/drivers/gpu/drm/v3d/v3d_mmu.c +++ b/drivers/gpu/drm/v3d/v3d_mmu.c @@ -40,7 +40,7 @@ static int v3d_mmu_flush_all(struct v3d_dev *v3d) ret = wait_for(!(V3D_READ(V3D_MMU_CTL) & V3D_MMU_CTL_TLB_CLEARING), 100); if (ret) - dev_err(v3d->dev, "TLB clear wait idle pre-wait failed\n"); + dev_err(v3d->drm.dev, "TLB clear wait idle pre-wait failed\n"); V3D_WRITE(V3D_MMU_CTL, V3D_READ(V3D_MMU_CTL) | V3D_MMU_CTL_TLB_CLEAR); @@ -52,14 +52,14 @@ static int v3d_mmu_flush_all(struct v3d_dev *v3d) ret = wait_for(!(V3D_READ(V3D_MMU_CTL) & V3D_MMU_CTL_TLB_CLEARING), 100); if (ret) { - dev_err(v3d->dev, "TLB clear wait idle failed\n"); + dev_err(v3d->drm.dev, "TLB clear wait idle failed\n"); return ret; } ret = wait_for(!(V3D_READ(V3D_MMUC_CONTROL) & V3D_MMUC_CONTROL_FLUSHING), 100); if (ret) - dev_err(v3d->dev, "MMUC flush wait idle failed\n"); + dev_err(v3d->drm.dev, "MMUC flush wait idle failed\n"); return ret; } @@ -109,7 +109,7 @@ void v3d_mmu_insert_ptes(struct v3d_bo *bo) shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT); if (v3d_mmu_flush_all(v3d)) - dev_err(v3d->dev, "MMU flush timeout\n"); + dev_err(v3d->drm.dev, "MMU flush timeout\n"); } void v3d_mmu_remove_ptes(struct v3d_bo *bo) @@ -122,5 +122,5 @@ void v3d_mmu_remove_ptes(struct v3d_bo *bo) v3d->pt[page] = 0; if (v3d_mmu_flush_all(v3d)) - dev_err(v3d->dev, "MMU flush timeout\n"); + dev_err(v3d->drm.dev, "MMU flush timeout\n"); } diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c index 8c2df6d95283..0747614a78f0 100644 --- a/drivers/gpu/drm/v3d/v3d_sched.c +++ b/drivers/gpu/drm/v3d/v3d_sched.c @@ -403,7 +403,7 @@ v3d_sched_init(struct v3d_dev *v3d) msecs_to_jiffies(hang_limit_ms), "v3d_bin"); if (ret) { - dev_err(v3d->dev, "Failed to create bin scheduler: %d.", ret); + dev_err(v3d->drm.dev, "Failed to create bin scheduler: %d.", ret); return ret; } @@ -413,7 +413,7 @@ v3d_sched_init(struct v3d_dev *v3d) msecs_to_jiffies(hang_limit_ms), "v3d_render"); if (ret) { - dev_err(v3d->dev, "Failed to create render scheduler: %d.", + dev_err(v3d->drm.dev, "Failed to create render scheduler: %d.", ret); v3d_sched_fini(v3d); return ret; @@ -425,7 +425,7 @@ v3d_sched_init(struct v3d_dev *v3d) msecs_to_jiffies(hang_limit_ms), "v3d_tfu"); if (ret) { - dev_err(v3d->dev, "Failed to create TFU scheduler: %d.", + dev_err(v3d->drm.dev, "Failed to create TFU scheduler: %d.", ret); v3d_sched_fini(v3d); return ret; @@ -438,7 +438,7 @@ v3d_sched_init(struct v3d_dev *v3d) msecs_to_jiffies(hang_limit_ms), "v3d_csd"); if (ret) { - dev_err(v3d->dev, "Failed to create CSD scheduler: %d.", + dev_err(v3d->drm.dev, "Failed to create CSD scheduler: %d.", ret); v3d_sched_fini(v3d); return ret; @@ -450,7 +450,7 @@ v3d_sched_init(struct v3d_dev *v3d) msecs_to_jiffies(hang_limit_ms), "v3d_cache_clean"); if (ret) { - dev_err(v3d->dev, "Failed to create CACHE_CLEAN scheduler: %d.", + dev_err(v3d->drm.dev, "Failed to create CACHE_CLEAN scheduler: %d.", ret); v3d_sched_fini(v3d); return ret; |