diff mbox series

[2/3] drm/hibmc: Use drm_gem_fb_create

Message ID 20191127180035.416209-2-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/rockchip: Use drm_gem_fb_create_with_dirty | expand

Commit Message

Daniel Vetter Nov. 27, 2019, 6 p.m. UTC
Again we could delete a lot more if we'd switch over to the generic
fbdev stuff.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c    |  4 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   | 11 +---
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c |  5 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   | 62 +++++--------------
 4 files changed, 19 insertions(+), 63 deletions(-)

Comments

kernel test robot Nov. 28, 2019, 8:44 a.m. UTC | #1
Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v5.4 next-20191127]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Daniel-Vetter/drm-rockchip-Use-drm_gem_fb_create_with_dirty/20191128-023917
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: arm64-randconfig-a001-20191128 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c: In function 'hibmc_plane_atomic_update':
>> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c:107:28: error: 'fb' undeclared (first use in this function); did you mean 'mb'?
     gbo = drm_gem_vram_of_gem(fb->obj[0]);
                               ^~
                               mb
   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c:107:28: note: each undeclared identifier is reported only once for each function it appears in
--
   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c: In function 'hibmc_drm_fb_create':
>> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c:119:37: error: 'struct drm_framebuffer' has no member named 'fb'
     hi_fbdev->helper.fb = &hi_fbdev->fb->fb;
                                        ^~

vim +107 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c

    93	
    94	static void hibmc_plane_atomic_update(struct drm_plane *plane,
    95					      struct drm_plane_state *old_state)
    96	{
    97		struct drm_plane_state	*state	= plane->state;
    98		u32 reg;
    99		s64 gpu_addr = 0;
   100		unsigned int line_l;
   101		struct hibmc_drm_private *priv = plane->dev->dev_private;
   102		struct drm_gem_vram_object *gbo;
   103	
   104		if (!state->fb)
   105			return;
   106	
 > 107		gbo = drm_gem_vram_of_gem(fb->obj[0]);
   108	
   109		gpu_addr = drm_gem_vram_offset(gbo);
   110		if (WARN_ON_ONCE(gpu_addr < 0))
   111			return; /* Bug: we didn't pin the BO to VRAM in prepare_fb. */
   112	
   113		writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS);
   114	
   115		reg = state->fb->width * (state->fb->format->cpp[0]);
   116		/* now line_pad is 16 */
   117		reg = PADDING(16, reg);
   118	
   119		line_l = state->fb->width * state->fb->format->cpp[0];
   120		line_l = PADDING(16, line_l);
   121		writel(HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_WIDTH, reg) |
   122		       HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_OFFS, line_l),
   123		       priv->mmio + HIBMC_CRT_FB_WIDTH);
   124	
   125		/* SET PIXEL FORMAT */
   126		reg = readl(priv->mmio + HIBMC_CRT_DISP_CTL);
   127		reg &= ~HIBMC_CRT_DISP_CTL_FORMAT_MASK;
   128		reg |= HIBMC_FIELD(HIBMC_CRT_DISP_CTL_FORMAT,
   129				   state->fb->format->cpp[0] * 8 / 16);
   130		writel(reg, priv->mmio + HIBMC_CRT_DISP_CTL);
   131	}
   132	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Daniel Vetter Nov. 28, 2019, 10:14 a.m. UTC | #2
On Thu, Nov 28, 2019 at 04:44:32PM +0800, kbuild test robot wrote:
> Hi Daniel,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on drm-intel/for-linux-next]
> [also build test ERROR on v5.4 next-20191127]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
> 
> url:    https://github.com/0day-ci/linux/commits/Daniel-Vetter/drm-rockchip-Use-drm_gem_fb_create_with_dirty/20191128-023917
> base:   git://anongit.freedesktop.org/drm-intel for-linux-next
> config: arm64-randconfig-a001-20191128 (attached as .config)
> compiler: aarch64-linux-gcc (GCC) 7.4.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.4.0 make.cross ARCH=arm64 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):


Oops, I meant to drop this patch from this series, but forgot. It's
superseeded by the series Thomas has (which actually compiles).
-Daniel

> 
>    drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c: In function 'hibmc_plane_atomic_update':
> >> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c:107:28: error: 'fb' undeclared (first use in this function); did you mean 'mb'?
>      gbo = drm_gem_vram_of_gem(fb->obj[0]);
>                                ^~
>                                mb
>    drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c:107:28: note: each undeclared identifier is reported only once for each function it appears in
> --
>    drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c: In function 'hibmc_drm_fb_create':
> >> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c:119:37: error: 'struct drm_framebuffer' has no member named 'fb'
>      hi_fbdev->helper.fb = &hi_fbdev->fb->fb;
>                                         ^~
> 
> vim +107 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> 
>     93	
>     94	static void hibmc_plane_atomic_update(struct drm_plane *plane,
>     95					      struct drm_plane_state *old_state)
>     96	{
>     97		struct drm_plane_state	*state	= plane->state;
>     98		u32 reg;
>     99		s64 gpu_addr = 0;
>    100		unsigned int line_l;
>    101		struct hibmc_drm_private *priv = plane->dev->dev_private;
>    102		struct drm_gem_vram_object *gbo;
>    103	
>    104		if (!state->fb)
>    105			return;
>    106	
>  > 107		gbo = drm_gem_vram_of_gem(fb->obj[0]);
>    108	
>    109		gpu_addr = drm_gem_vram_offset(gbo);
>    110		if (WARN_ON_ONCE(gpu_addr < 0))
>    111			return; /* Bug: we didn't pin the BO to VRAM in prepare_fb. */
>    112	
>    113		writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS);
>    114	
>    115		reg = state->fb->width * (state->fb->format->cpp[0]);
>    116		/* now line_pad is 16 */
>    117		reg = PADDING(16, reg);
>    118	
>    119		line_l = state->fb->width * state->fb->format->cpp[0];
>    120		line_l = PADDING(16, line_l);
>    121		writel(HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_WIDTH, reg) |
>    122		       HIBMC_FIELD(HIBMC_CRT_FB_WIDTH_OFFS, line_l),
>    123		       priv->mmio + HIBMC_CRT_FB_WIDTH);
>    124	
>    125		/* SET PIXEL FORMAT */
>    126		reg = readl(priv->mmio + HIBMC_CRT_DISP_CTL);
>    127		reg &= ~HIBMC_CRT_DISP_CTL_FORMAT_MASK;
>    128		reg |= HIBMC_FIELD(HIBMC_CRT_DISP_CTL_FORMAT,
>    129				   state->fb->format->cpp[0] * 8 / 16);
>    130		writel(reg, priv->mmio + HIBMC_CRT_DISP_CTL);
>    131	}
>    132	
> 
> ---
> 0-DAY kernel test infrastructure                 Open Source Technology Center
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
diff mbox series

Patch

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 6527a97f68a3..2d0920ec4554 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -99,14 +99,12 @@  static void hibmc_plane_atomic_update(struct drm_plane *plane,
 	s64 gpu_addr = 0;
 	unsigned int line_l;
 	struct hibmc_drm_private *priv = plane->dev->dev_private;
-	struct hibmc_framebuffer *hibmc_fb;
 	struct drm_gem_vram_object *gbo;
 
 	if (!state->fb)
 		return;
 
-	hibmc_fb = to_hibmc_framebuffer(state->fb);
-	gbo = drm_gem_vram_of_gem(hibmc_fb->obj);
+	gbo = drm_gem_vram_of_gem(fb->obj[0]);
 
 	gpu_addr = drm_gem_vram_offset(gbo);
 	if (WARN_ON_ONCE(gpu_addr < 0))
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index e58ecd7edcf8..ab5b4a4a2095 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -20,14 +20,9 @@ 
 struct drm_device;
 struct drm_gem_object;
 
-struct hibmc_framebuffer {
-	struct drm_framebuffer fb;
-	struct drm_gem_object *obj;
-};
-
 struct hibmc_fbdev {
 	struct drm_fb_helper helper; /* must be first */
-	struct hibmc_framebuffer *fb;
+	struct drm_framebuffer *fb;
 	int size;
 };
 
@@ -47,8 +42,6 @@  struct hibmc_drm_private {
 	struct hibmc_fbdev *fbdev;
 };
 
-#define to_hibmc_framebuffer(x) container_of(x, struct hibmc_framebuffer, fb)
-
 void hibmc_set_power_mode(struct hibmc_drm_private *priv,
 			  unsigned int power_mode);
 void hibmc_set_current_gate(struct hibmc_drm_private *priv,
@@ -61,7 +54,7 @@  void hibmc_fbdev_fini(struct hibmc_drm_private *priv);
 
 int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
 		     struct drm_gem_object **obj);
-struct hibmc_framebuffer *
+struct drm_framebuffer *
 hibmc_framebuffer_init(struct drm_device *dev,
 		       const struct drm_mode_fb_cmd2 *mode_cmd,
 		       struct drm_gem_object *obj);
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
index b4c1cea051e8..446aeedc9e29 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
@@ -141,15 +141,14 @@  static int hibmc_drm_fb_create(struct drm_fb_helper *helper,
 
 static void hibmc_fbdev_destroy(struct hibmc_fbdev *fbdev)
 {
-	struct hibmc_framebuffer *gfb = fbdev->fb;
 	struct drm_fb_helper *fbh = &fbdev->helper;
 
 	drm_fb_helper_unregister_fbi(fbh);
 
 	drm_fb_helper_fini(fbh);
 
-	if (gfb)
-		drm_framebuffer_put(&gfb->fb);
+	if (fbdev->fb)
+		drm_framebuffer_put(fbdev->fb);
 }
 
 static const struct drm_fb_helper_funcs hibmc_fbdev_helper_funcs = {
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
index 21b684eab5c9..386033b0d3a2 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
@@ -16,6 +16,7 @@ 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_print.h>
 
 #include "hibmc_drm_drv.h"
@@ -97,74 +98,39 @@  int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
 	return 0;
 }
 
-static void hibmc_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-	struct hibmc_framebuffer *hibmc_fb = to_hibmc_framebuffer(fb);
-
-	drm_gem_object_put_unlocked(hibmc_fb->obj);
-	drm_framebuffer_cleanup(fb);
-	kfree(hibmc_fb);
-}
-
 static const struct drm_framebuffer_funcs hibmc_fb_funcs = {
-	.destroy = hibmc_user_framebuffer_destroy,
+	.destroy	= drm_gem_fb_destroy,
+	.create_handle	= drm_gem_fb_create_handle,
 };
 
-struct hibmc_framebuffer *
+struct drm_framebuffer *
 hibmc_framebuffer_init(struct drm_device *dev,
 		       const struct drm_mode_fb_cmd2 *mode_cmd,
 		       struct drm_gem_object *obj)
 {
-	struct hibmc_framebuffer *hibmc_fb;
+	struct drm_framebuffer *fb;
 	int ret;
 
-	hibmc_fb = kzalloc(sizeof(*hibmc_fb), GFP_KERNEL);
-	if (!hibmc_fb) {
-		DRM_ERROR("failed to allocate hibmc_fb\n");
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+	if (!fb) {
+		DRM_ERROR("failed to allocate fb\n");
 		return ERR_PTR(-ENOMEM);
 	}
 
-	drm_helper_mode_fill_fb_struct(dev, &hibmc_fb->fb, mode_cmd);
-	hibmc_fb->obj = obj;
-	ret = drm_framebuffer_init(dev, &hibmc_fb->fb, &hibmc_fb_funcs);
+	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
+	fb->obj[0] = obj;
+	ret = drm_framebuffer_init(dev, fb, &hibmc_fb_funcs);
 	if (ret) {
 		DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
-		kfree(hibmc_fb);
+		kfree(fb);
 		return ERR_PTR(ret);
 	}
 
-	return hibmc_fb;
-}
-
-static struct drm_framebuffer *
-hibmc_user_framebuffer_create(struct drm_device *dev,
-			      struct drm_file *filp,
-			      const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-	struct drm_gem_object *obj;
-	struct hibmc_framebuffer *hibmc_fb;
-
-	DRM_DEBUG_DRIVER("%dx%d, format %c%c%c%c\n",
-			 mode_cmd->width, mode_cmd->height,
-			 (mode_cmd->pixel_format) & 0xff,
-			 (mode_cmd->pixel_format >> 8)  & 0xff,
-			 (mode_cmd->pixel_format >> 16) & 0xff,
-			 (mode_cmd->pixel_format >> 24) & 0xff);
-
-	obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
-	if (!obj)
-		return ERR_PTR(-ENOENT);
-
-	hibmc_fb = hibmc_framebuffer_init(dev, mode_cmd, obj);
-	if (IS_ERR(hibmc_fb)) {
-		drm_gem_object_put_unlocked(obj);
-		return ERR_PTR((long)hibmc_fb);
-	}
-	return &hibmc_fb->fb;
+	return fb;
 }
 
 const struct drm_mode_config_funcs hibmc_mode_funcs = {
 	.atomic_check = drm_atomic_helper_check,
 	.atomic_commit = drm_atomic_helper_commit,
-	.fb_create = hibmc_user_framebuffer_create,
+	.fb_create = drm_gem_fb_create,
 };