[Freedreno] [DPU PATCH 04/15] drm/msm: Remove more dpu-related code from msm_drv

Sean Paul seanpaul at chromium.org
Thu Jun 28 18:28:55 UTC 2018


This time the iomap/iounmap helper functions. Move map into dpu and
refactor it to reflect their actual use. iounmap wasn't useful, so
delete it and call iounmap directly.

Signed-off-by: Sean Paul <seanpaul at chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 38 +++++++++++++++++-------
 drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 13 ++++++--
 drivers/gpu/drm/msm/msm_drv.c            | 23 --------------
 drivers/gpu/drm/msm/msm_drv.h            |  2 --
 4 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 0b813a089cba..beba919a6ef6 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -77,6 +77,25 @@ bool dpu_is_custom_client(void)
 	return dpucustom;
 }
 
+static unsigned long dpu_iomap_size(struct platform_device *pdev,
+				    const char *name)
+{
+	struct resource *res;
+
+	if (!name) {
+		DRM_ERROR("Resource name unspecified\n");
+		return 0;
+	}
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+	if (!res) {
+		DRM_ERROR("failed to get memory resource: %s\n", name);
+		return 0;
+	}
+
+	return resource_size(res);
+}
+
 #ifdef CONFIG_DEBUG_FS
 static int _dpu_danger_signal_status(struct seq_file *s,
 		bool danger_status)
@@ -1056,15 +1075,15 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
 	dpu_kms->core_client = NULL;
 
 	if (dpu_kms->vbif[VBIF_NRT])
-		msm_iounmap(dpu_kms->pdev, dpu_kms->vbif[VBIF_NRT]);
+		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_NRT]);
 	dpu_kms->vbif[VBIF_NRT] = NULL;
 
 	if (dpu_kms->vbif[VBIF_RT])
-		msm_iounmap(dpu_kms->pdev, dpu_kms->vbif[VBIF_RT]);
+		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_RT]);
 	dpu_kms->vbif[VBIF_RT] = NULL;
 
 	if (dpu_kms->mmio)
-		msm_iounmap(dpu_kms->pdev, dpu_kms->mmio);
+		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->mmio);
 	dpu_kms->mmio = NULL;
 }
 
@@ -1429,7 +1448,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
 		goto error;
 	}
 	DRM_DEBUG("mapped dpu address space @%pK\n", dpu_kms->mmio);
-	dpu_kms->mmio_len = msm_iomap_size(dpu_kms->pdev, "mdp_phys");
+	dpu_kms->mmio_len = dpu_iomap_size(dpu_kms->pdev, "mdp_phys");
 
 	dpu_kms->vbif[VBIF_RT] = msm_ioremap(dpu_kms->pdev, "vbif_phys",
 								"vbif_phys");
@@ -1439,16 +1458,15 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
 		dpu_kms->vbif[VBIF_RT] = NULL;
 		goto error;
 	}
-	dpu_kms->vbif_len[VBIF_RT] = msm_iomap_size(dpu_kms->pdev,
-								"vbif_phys");
+	dpu_kms->vbif_len[VBIF_RT] = dpu_iomap_size(dpu_kms->pdev, "vbif_phys");
 	dpu_kms->vbif[VBIF_NRT] = msm_ioremap(dpu_kms->pdev, "vbif_nrt_phys",
 								"vbif_nrt_phys");
 	if (IS_ERR(dpu_kms->vbif[VBIF_NRT])) {
 		dpu_kms->vbif[VBIF_NRT] = NULL;
 		DPU_DEBUG("VBIF NRT is not defined");
 	} else {
-		dpu_kms->vbif_len[VBIF_NRT] = msm_iomap_size(dpu_kms->pdev,
-							"vbif_nrt_phys");
+		dpu_kms->vbif_len[VBIF_NRT] = dpu_iomap_size(dpu_kms->pdev,
+							     "vbif_nrt_phys");
 	}
 
 	dpu_kms->reg_dma = msm_ioremap(dpu_kms->pdev, "regdma_phys",
@@ -1457,8 +1475,8 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
 		dpu_kms->reg_dma = NULL;
 		DPU_DEBUG("REG_DMA is not defined");
 	} else {
-		dpu_kms->reg_dma_len = msm_iomap_size(dpu_kms->pdev,
-								"regdma_phys");
+		dpu_kms->reg_dma_len = dpu_iomap_size(dpu_kms->pdev,
+						      "regdma_phys");
 	}
 
 	dpu_kms->core_client = dpu_power_client_create(&dpu_kms->phandle,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
index 5c69c2cc5d10..5191c77cd907 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
@@ -162,7 +162,7 @@ static void dpu_mdss_destroy(struct drm_device *dev)
 	devm_kfree(&pdev->dev, mp->clk_config);
 
 	if (dpu_mdss->mmio)
-		msm_iounmap(pdev, dpu_mdss->mmio);
+		devm_iounmap(&pdev->dev, dpu_mdss->mmio);
 	dpu_mdss->mmio = NULL;
 
 	pm_runtime_disable(dev->dev);
@@ -179,6 +179,7 @@ int dpu_mdss_init(struct drm_device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev->dev);
 	struct msm_drm_private *priv = dev->dev_private;
+	struct resource *res;
 	struct dpu_mdss *dpu_mdss;
 	struct dss_module_power *mp;
 	int ret = 0;
@@ -192,7 +193,13 @@ int dpu_mdss_init(struct drm_device *dev)
 		return PTR_ERR(dpu_mdss->mmio);
 
 	DRM_DEBUG("mapped mdss address space @%pK\n", dpu_mdss->mmio);
-	dpu_mdss->mmio_len = msm_iomap_size(pdev, "mdss_phys");
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mdss_phys");
+	if (!res) {
+		DRM_ERROR("failed to get memory resource for mdss_phys\n");
+		return -ENOMEM;
+	}
+	dpu_mdss->mmio_len = resource_size(res);
 
 	mp = &dpu_mdss->mp;
 	ret = msm_dss_parse_clock(pdev, mp);
@@ -246,7 +253,7 @@ int dpu_mdss_init(struct drm_device *dev)
 	devm_kfree(&pdev->dev, mp->clk_config);
 clk_parse_err:
 	if (dpu_mdss->mmio)
-		msm_iounmap(pdev, dpu_mdss->mmio);
+		devm_iounmap(&pdev->dev, dpu_mdss->mmio);
 	dpu_mdss->mmio = NULL;
 	return ret;
 }
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 6177b3f18912..561617db7338 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -131,29 +131,6 @@ void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
 	return ptr;
 }
 
-unsigned long msm_iomap_size(struct platform_device *pdev, const char *name)
-{
-	struct resource *res;
-
-	if (name)
-		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
-	else
-		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get memory resource: %s\n",
-									name);
-		return 0;
-	}
-
-	return resource_size(res);
-}
-
-void msm_iounmap(struct platform_device *pdev, void __iomem *addr)
-{
-	devm_iounmap(&pdev->dev, addr);
-}
-
 void msm_writel(u32 data, void __iomem *addr)
 {
 	if (reglog)
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 9004530cc49a..da7daacc5eb8 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -416,8 +416,6 @@ static inline void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) {}
 struct clk *msm_clk_get(struct platform_device *pdev, const char *name);
 void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
 		const char *dbgname);
-unsigned long msm_iomap_size(struct platform_device *pdev, const char *name);
-void msm_iounmap(struct platform_device *dev, void __iomem *addr);
 void msm_writel(u32 data, void __iomem *addr);
 u32 msm_readl(const void __iomem *addr);
 
-- 
Sean Paul, Software Engineer, Google / Chromium OS



More information about the Freedreno mailing list