Re: [PATCH 4/4] drm/tinydrm: Use damage helper for dirtyfb

2019-01-11 Thread kbuild test robot
Hi Noralf,

url:
https://github.com/0day-ci/linux/commits/Noralf-Tr-nnes/drm-tinydrm-Use-damage-helper-for-dirtyfb/20190110-194410

New smatch warnings:
drivers/gpu/drm/tinydrm/mipi-dbi.c:305 mipi_dbi_enable_flush() warn: variable 
dereferenced before check 'fb' (see line 299)

Old smatch warnings:
drivers/gpu/drm/tinydrm/mipi-dbi.c:108 mipi_dbi_command_is_read() error: buffer 
overflow 'mipi->read_commands' 21 <= 254
drivers/gpu/drm/tinydrm/mipi-dbi.c:110 mipi_dbi_command_is_read() error: buffer 
overflow 'mipi->read_commands' 21 <= 254

# 
https://github.com/0day-ci/linux/commit/50dd14907581e982f534b7718bc3f8c903f46c88
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 50dd14907581e982f534b7718bc3f8c903f46c88
vim +/fb +305 drivers/gpu/drm/tinydrm/mipi-dbi.c

02dd95fe Noralf Trønnes 2017-01-22  281  
02dd95fe Noralf Trønnes 2017-01-22  282  /**
22edc8d3 Noralf Trønnes 2018-01-10  283   * mipi_dbi_enable_flush - MIPI 
DBI enable helper
22edc8d3 Noralf Trønnes 2018-01-10  284   * @mipi: MIPI DBI structure
5685ca0c Noralf Trønnes 2018-07-10  285   * @crtc_state: CRTC state
5685ca0c Noralf Trønnes 2018-07-10  286   * @plane_state: Plane state
22edc8d3 Noralf Trønnes 2018-01-10  287   *
22edc8d3 Noralf Trønnes 2018-01-10  288   * This function sets 
_dbi->enabled, flushes the whole framebuffer and
22edc8d3 Noralf Trønnes 2018-01-10  289   * enables the backlight. Drivers 
can use this in their
22edc8d3 Noralf Trønnes 2018-01-10  290   * 
_simple_display_pipe_funcs->enable callback.
22edc8d3 Noralf Trønnes 2018-01-10  291   */
e85d3006 Ville Syrjälä  2018-03-23  292  void mipi_dbi_enable_flush(struct 
mipi_dbi *mipi,
e85d3006 Ville Syrjälä  2018-03-23  293struct 
drm_crtc_state *crtc_state,
e85d3006 Ville Syrjälä  2018-03-23  294struct 
drm_plane_state *plane_state)
22edc8d3 Noralf Trønnes 2018-01-10  295  {
e85d3006 Ville Syrjälä  2018-03-23  296 struct drm_framebuffer *fb = 
plane_state->fb;
50dd1490 Noralf Trønnes 2019-01-09  297 struct drm_rect rect = {
50dd1490 Noralf Trønnes 2019-01-09  298 .x1 = 0,
50dd1490 Noralf Trønnes 2019-01-09 @299 .x2 = fb->width,
50dd1490 Noralf Trønnes 2019-01-09  300 .y1 = 0,
50dd1490 Noralf Trønnes 2019-01-09  301 .y2 = fb->height,
50dd1490 Noralf Trønnes 2019-01-09  302 };
22edc8d3 Noralf Trønnes 2018-01-10  303  
22edc8d3 Noralf Trønnes 2018-01-10  304 mipi->enabled = true;
22edc8d3 Noralf Trønnes 2018-01-10 @305 if (fb)
50dd1490 Noralf Trønnes 2019-01-09  306 mipi_dbi_fb_dirty(fb, 
);
22edc8d3 Noralf Trønnes 2018-01-10  307  
414147e8 Meghana Madhyastha 2018-01-24  308 
backlight_enable(mipi->backlight);
22edc8d3 Noralf Trønnes 2018-01-10  309  }
22edc8d3 Noralf Trønnes 2018-01-10  310  
EXPORT_SYMBOL(mipi_dbi_enable_flush);
22edc8d3 Noralf Trønnes 2018-01-10  311  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm/tinydrm: Use damage helper for dirtyfb

2019-01-11 Thread Noralf Trønnes


Den 11.01.2019 02.06, skrev David Lechner:
> On 1/9/19 11:49 AM, Noralf Trønnes wrote:
>> This switches to drm_atomic_helper_dirtyfb() as the framebuffer dirty
>> handler. All flushing will now happen in the pipe functions.
>>
>> Also enable the damage plane property for all except repaper which can
>> only do full updates.
>>
>> ili9225:
>> This change made ili9225_init() equal to mipi_dbi_init() so use it.
>>
>> Cc: David Lechner 
>> Cc: Eric Anholt 
>> Signed-off-by: Noralf Trønnes 
>> ---
> 
> ...
> 
>> +static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
>> +    struct drm_plane_state *old_state)
>> +{
>> +    struct drm_plane_state *state = pipe->plane.state;
>> +    struct drm_crtc *crtc = >crtc;
>> +    struct drm_rect rect;
>> +
>> +    if (drm_atomic_helper_damage_merged(old_state, state, ))
>> +    ili9225_fb_dirty(state->fb, );
>> +
>> +    if (crtc->state->event) {
>> +    spin_lock_irq(>dev->event_lock);
>> +    drm_crtc_send_vblank_event(crtc, crtc->state->event);
>> +    spin_unlock_irq(>dev->event_lock);
>> +    crtc->state->event = NULL;
>> +    }
>> +}
> 
> It looks like this function body is repeated 4 times with the only
> difference being the dirty function. Perhaps a helper function is
> called for?

I agree, this is used in several other drivers too. The problem is that
this is magic code to me so I wouldn't even know what to call the
function and certainly not what to put in the docs. So I left it out.
And the drm_crtc_arm_vblank_event() function used elsewhere adds even
more mystery to it all.

> 
> Also, I was going to test out this series the displays that I have,
> but I guess I will wait until it is easier to apply the patches.

I will send a version 2 when Maxime has backmerged -rc1.

Noralf.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm/tinydrm: Use damage helper for dirtyfb

2019-01-10 Thread David Lechner

On 1/9/19 11:49 AM, Noralf Trønnes wrote:

This switches to drm_atomic_helper_dirtyfb() as the framebuffer dirty
handler. All flushing will now happen in the pipe functions.

Also enable the damage plane property for all except repaper which can
only do full updates.

ili9225:
This change made ili9225_init() equal to mipi_dbi_init() so use it.

Cc: David Lechner 
Cc: Eric Anholt 
Signed-off-by: Noralf Trønnes 
---


...


+static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
+   struct drm_plane_state *old_state)
+{
+   struct drm_plane_state *state = pipe->plane.state;
+   struct drm_crtc *crtc = >crtc;
+   struct drm_rect rect;
+
+   if (drm_atomic_helper_damage_merged(old_state, state, ))
+   ili9225_fb_dirty(state->fb, );
+
+   if (crtc->state->event) {
+   spin_lock_irq(>dev->event_lock);
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   spin_unlock_irq(>dev->event_lock);
+   crtc->state->event = NULL;
+   }
+}


It looks like this function body is repeated 4 times with the only
difference being the dirty function. Perhaps a helper function is
called for?

Also, I was going to test out this series the displays that I have,
but I guess I will wait until it is easier to apply the patches.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/4] drm/tinydrm: Use damage helper for dirtyfb

2019-01-09 Thread Noralf Trønnes
This switches to drm_atomic_helper_dirtyfb() as the framebuffer dirty
handler. All flushing will now happen in the pipe functions.

Also enable the damage plane property for all except repaper which can
only do full updates.

ili9225:
This change made ili9225_init() equal to mipi_dbi_init() so use it.

Cc: David Lechner 
Cc: Eric Anholt 
Signed-off-by: Noralf Trønnes 
---
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c   |  21 +---
 .../gpu/drm/tinydrm/core/tinydrm-helpers.c|  91 +---
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c   |  30 --
 drivers/gpu/drm/tinydrm/hx8357d.c |   2 +-
 drivers/gpu/drm/tinydrm/ili9225.c | 101 ++
 drivers/gpu/drm/tinydrm/ili9341.c |   2 +-
 drivers/gpu/drm/tinydrm/mi0283qt.c|   2 +-
 drivers/gpu/drm/tinydrm/mipi-dbi.c|  72 -
 drivers/gpu/drm/tinydrm/repaper.c |  39 ---
 drivers/gpu/drm/tinydrm/st7586.c  |  50 +
 drivers/gpu/drm/tinydrm/st7735r.c |   2 +-
 include/drm/tinydrm/mipi-dbi.h|   2 +
 include/drm/tinydrm/tinydrm-helpers.h |  11 +-
 include/drm/tinydrm/tinydrm.h |  26 -
 14 files changed, 138 insertions(+), 313 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
index 01a6f2d42440..dca0f642fee6 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
@@ -36,31 +36,17 @@
  * and registers the DRM device using devm_tinydrm_register().
  */
 
-static struct drm_framebuffer *
-tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv,
- const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-   struct tinydrm_device *tdev = drm->dev_private;
-
-   return drm_gem_fb_create_with_funcs(drm, file_priv, mode_cmd,
-   tdev->fb_funcs);
-}
-
 static const struct drm_mode_config_funcs tinydrm_mode_config_funcs = {
-   .fb_create = tinydrm_fb_create,
+   .fb_create = drm_gem_fb_create_with_dirty,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit,
 };
 
 static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
-   const struct drm_framebuffer_funcs *fb_funcs,
struct drm_driver *driver)
 {
struct drm_device *drm;
 
-   mutex_init(>dirty_lock);
-   tdev->fb_funcs = fb_funcs;
-
/*
 * We don't embed drm_device, because that prevent us from using
 * devm_kzalloc() to allocate tinydrm_device in the driver since
@@ -83,7 +69,6 @@ static int tinydrm_init(struct device *parent, struct 
tinydrm_device *tdev,
 static void tinydrm_fini(struct tinydrm_device *tdev)
 {
drm_mode_config_cleanup(tdev->drm);
-   mutex_destroy(>dirty_lock);
tdev->drm->dev_private = NULL;
drm_dev_put(tdev->drm);
 }
@@ -97,7 +82,6 @@ static void devm_tinydrm_release(void *data)
  * devm_tinydrm_init - Initialize tinydrm device
  * @parent: Parent device object
  * @tdev: tinydrm device
- * @fb_funcs: Framebuffer functions
  * @driver: DRM driver
  *
  * This function initializes @tdev, the underlying DRM device and it's
@@ -108,12 +92,11 @@ static void devm_tinydrm_release(void *data)
  * Zero on success, negative error code on failure.
  */
 int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
- const struct drm_framebuffer_funcs *fb_funcs,
  struct drm_driver *driver)
 {
int ret;
 
-   ret = tinydrm_init(parent, tdev, fb_funcs, driver);
+   ret = tinydrm_init(parent, tdev, driver);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index d0ece6ad4a1c..2737b6fdadc8 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -17,104 +17,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
 
 static unsigned int spi_max;
 module_param(spi_max, uint, 0400);
 MODULE_PARM_DESC(spi_max, "Set a lower SPI max transfer size");
 
-/**
- * tinydrm_merge_clips - Merge clip rectangles
- * @dst: Destination clip rectangle
- * @src: Source clip rectangle(s)
- * @num_clips: Number of @src clip rectangles
- * @flags: Dirty fb ioctl flags
- * @max_width: Maximum width of @dst
- * @max_height: Maximum height of @dst
- *
- * This function merges @src clip rectangle(s) into @dst. If @src is NULL,
- * @max_width and @min_width is used to set a full @dst clip rectangle.
- *
- * Returns:
- * true if it's a full clip, false otherwise
- */
-bool tinydrm_merge_clips(struct drm_rect *dst,
-struct drm_clip_rect *src, unsigned int num_clips,
-unsigned int flags,