Skip to content

Commit 3ea4410

Browse files
committed
drm/mipi-dbi: Move drm_dev_{enter, exit}() out from fb_dirty functions
Call drm_dev_enter() and drm_dev_exit() in the outer-most callbacks of the modesetting pipeline. If drm_dev_enter() fails, the driver can thus avoid unnecessary work. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Noralf Trønnes <noralf@tronnes.org> Tested-by: Javier Martinez Canillas <javierm@redhat.com> Tested-by: Noralf Trønnes <noralf@tronnes.org> # drm/tiny/mi0283qt Link: https://patchwork.freedesktop.org/patch/msgid/20221202125644.7917-9-tzimmermann@suse.de
1 parent 69c63e8 commit 3ea4410

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

drivers/gpu/drm/drm_mipi_dbi.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,10 @@ static void mipi_dbi_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
259259
unsigned int width = rect->x2 - rect->x1;
260260
struct mipi_dbi *dbi = &dbidev->dbi;
261261
bool swap = dbi->swap_bytes;
262-
int idx, ret = 0;
262+
int ret = 0;
263263
bool full;
264264
void *tr;
265265

266-
if (!drm_dev_enter(fb->dev, &idx))
267-
return;
268-
269266
full = width == fb->width && height == fb->height;
270267

271268
DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect));
@@ -288,8 +285,6 @@ static void mipi_dbi_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
288285
err_msg:
289286
if (ret)
290287
drm_err_once(fb->dev, "Failed to update display %d\n", ret);
291-
292-
drm_dev_exit(idx);
293288
}
294289

295290
/**
@@ -325,15 +320,21 @@ void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
325320
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(state);
326321
struct drm_framebuffer *fb = state->fb;
327322
struct drm_rect rect;
323+
int idx;
328324

329325
if (!pipe->crtc.state->active)
330326
return;
331327

332328
if (WARN_ON(!fb))
333329
return;
334330

331+
if (!drm_dev_enter(fb->dev, &idx))
332+
return;
333+
335334
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
336335
mipi_dbi_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
336+
337+
drm_dev_exit(idx);
337338
}
338339
EXPORT_SYMBOL(mipi_dbi_pipe_update);
339340

drivers/gpu/drm/tiny/ili9225.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,10 @@ static void ili9225_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
8787
bool swap = dbi->swap_bytes;
8888
u16 x_start, y_start;
8989
u16 x1, x2, y1, y2;
90-
int idx, ret = 0;
90+
int ret = 0;
9191
bool full;
9292
void *tr;
9393

94-
if (!drm_dev_enter(fb->dev, &idx))
95-
return;
96-
9794
full = width == fb->width && height == fb->height;
9895

9996
DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect));
@@ -156,8 +153,6 @@ static void ili9225_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
156153
err_msg:
157154
if (ret)
158155
dev_err_once(fb->dev->dev, "Failed to update display %d\n", ret);
159-
160-
drm_dev_exit(idx);
161156
}
162157

163158
static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -167,12 +162,18 @@ static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
167162
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(state);
168163
struct drm_framebuffer *fb = state->fb;
169164
struct drm_rect rect;
165+
int idx;
170166

171167
if (!pipe->crtc.state->active)
172168
return;
173169

170+
if (!drm_dev_enter(fb->dev, &idx))
171+
return;
172+
174173
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
175174
ili9225_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
175+
176+
drm_dev_exit(idx);
176177
}
177178

178179
static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,

drivers/gpu/drm/tiny/st7586.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ static void st7586_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
113113
{
114114
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
115115
struct mipi_dbi *dbi = &dbidev->dbi;
116-
int start, end, idx, ret = 0;
117-
118-
if (!drm_dev_enter(fb->dev, &idx))
119-
return;
116+
int start, end, ret = 0;
120117

121118
/* 3 pixels per byte, so grow clip to nearest multiple of 3 */
122119
rect->x1 = rounddown(rect->x1, 3);
@@ -145,8 +142,6 @@ static void st7586_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
145142
err_msg:
146143
if (ret)
147144
dev_err_once(fb->dev->dev, "Failed to update display %d\n", ret);
148-
149-
drm_dev_exit(idx);
150145
}
151146

152147
static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -156,12 +151,18 @@ static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
156151
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(state);
157152
struct drm_framebuffer *fb = state->fb;
158153
struct drm_rect rect;
154+
int idx;
159155

160156
if (!pipe->crtc.state->active)
161157
return;
162158

159+
if (!drm_dev_enter(fb->dev, &idx))
160+
return;
161+
163162
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
164163
st7586_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
164+
165+
drm_dev_exit(idx);
165166
}
166167

167168
static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,

0 commit comments

Comments
 (0)