drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
Subsystems (2)
Maarten Lankhorst
maintainerPATCH 1/1 drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
lock_all_ctx in setplane_internal may return -EINTR, and __setplane_internal could return -EDEADLK. Making more special cases for fb would make the code even harder to read, so the easiest solution is not taking over the fb refcount, and making callers responsible for dropping the ref.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102707
Testcase: kms_atomic_interruptible
--- drivers/gpu/drm/drm_plane.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_plane.c +20 -22
@@ -558,11 +558,10 @@ int drm_plane_check_pixel_format(const struct drm_plane *plane, u32 format) }/* -* setplane_internal - setplane handler for internal callers +* __setplane_internal - setplane handler for internal callers * -* Note that we assume an extra reference has already been taken on fb. If the -* update fails, this reference will be dropped before return; if it succeeds, -* the previous framebuffer (if any) will be unreferenced instead. +* This function will take a reference on the new fb for the plane +* on success. * * src_{x,y,w,h} are provided in 16.16 fixed point format */
@@ -630,14 +629,12 @@ static int __setplane_internal(struct drm_plane *plane,if (!ret) { plane->crtc = crtc; plane->fb = fb; - fb =NULL ; +drm_framebuffer_get (plane->fb); }else { plane->old_fb =NULL ; } out: -if (fb) -drm_framebuffer_put (fb);if (plane->old_fb)drm_framebuffer_put (plane->old_fb); plane->old_fb =NULL ;
@@ -685,6 +682,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_plane *plane;struct drm_crtc *crtc =NULL ;struct drm_framebuffer *fb =NULL ; +int ret;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -717,15 +715,16 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } } -/* -* setplane_internal will take care of deref'ing either the old or new -* framebuffer depending on success. -*/ -return setplane_internal (plane, crtc, fb, - plane_req->crtc_x, plane_req->crtc_y, - plane_req->crtc_w, plane_req->crtc_h, - plane_req->src_x, plane_req->src_y, - plane_req->src_w, plane_req->src_h); + ret =setplane_internal (plane, crtc, fb, + plane_req->crtc_x, plane_req->crtc_y, + plane_req->crtc_w, plane_req->crtc_h, + plane_req->src_x, plane_req->src_y, + plane_req->src_w, plane_req->src_h); + +if (fb) +drm_framebuffer_put (fb); + +return ret; } static int drm_mode_cursor_universal(struct drm_crtc *crtc,
@@ -788,13 +787,12 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, src_h = fb->height <<16 ; } -/* -* setplane_internal will take care of deref'ing either the old or new -* framebuffer depending on success. -*/ ret =__setplane_internal (crtc->cursor, crtc, fb, - crtc_x, crtc_y, crtc_w, crtc_h, -0 ,0 , src_w, src_h, ctx); + crtc_x, crtc_y, crtc_w, crtc_h, +0 ,0 , src_w, src_h, ctx); + +if (fb) +drm_framebuffer_put (fb);/* Update successful; save new cursor position, if necessary */ if (ret ==0 && req->flags &DRM_MODE_CURSOR_MOVE ) {
Signature · 6 lines
2.15.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · Maarten Lankhorst
lock_all_ctxinsetplane_internalmay return-EINTR, and__setplane_internalcould return-EDEADLK. Making more special cases for fb would make the code even harder to read, so the easiest solution is not taking over the fb refcount, and making callers responsible for dropping the ref.Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102707
Fixes 13736ba3b38b ("drm/legacy: Convert setplane ioctl locking to interruptible.")Testcase:
kms_atomic_interruptibleSigned-off-by Maarten Lankhorst <[email protected]>
Please push to drm-misc-fixes as soon as CI approves it fully (which is probably next Monday, no rush).
-Daniel
Quoted 99 lines
--- drivers/gpu/drm/drm_plane.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)drivers/gpu/drm/drm_plane.c +20
-22@@ -558,11 +558,10 @@ int drm_plane_check_pixel_format(const struct drm_plane *plane, u32 format) }/* -* setplane_internal - setplane handler for internal callers +* __setplane_internal - setplane handler for internal callers * -* Note that we assume an extra reference has already been taken on fb. If the -* update fails, this reference will be dropped before return; if it succeeds, -* the previous framebuffer (if any) will be unreferenced instead. +* This function will take a reference on the new fb for the plane +* on success. * * src_{x,y,w,h} are provided in 16.16 fixed point format */ @@ -630,14 +629,12 @@ static int __setplane_internal(struct drm_plane *plane,if (!ret) { plane->crtc = crtc; plane->fb = fb; - fb =NULL ; +drm_framebuffer_get (plane->fb); }else { plane->old_fb =NULL ; } out: -if (fb) -drm_framebuffer_put (fb);if (plane->old_fb)drm_framebuffer_put (plane->old_fb); plane->old_fb =NULL ;@@ -685,6 +682,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_plane *plane;struct drm_crtc *crtc =NULL ;struct drm_framebuffer *fb =NULL ; +int ret;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -717,15 +715,16 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } } -/* -* setplane_internal will take care of deref'ing either the old or new -* framebuffer depending on success. -*/ -return setplane_internal (plane, crtc, fb, - plane_req->crtc_x, plane_req->crtc_y, - plane_req->crtc_w, plane_req->crtc_h, - plane_req->src_x, plane_req->src_y, - plane_req->src_w, plane_req->src_h); + ret =setplane_internal (plane, crtc, fb, + plane_req->crtc_x, plane_req->crtc_y, + plane_req->crtc_w, plane_req->crtc_h, + plane_req->src_x, plane_req->src_y, + plane_req->src_w, plane_req->src_h); + +if (fb) +drm_framebuffer_put (fb); + +return ret; } static int drm_mode_cursor_universal(struct drm_crtc *crtc,@@ -788,13 +787,12 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, src_h = fb->height <<16 ; } -/* -* setplane_internal will take care of deref'ing either the old or new -* framebuffer depending on success. -*/ ret =__setplane_internal (crtc->cursor, crtc, fb, - crtc_x, crtc_y, crtc_w, crtc_h, -0 ,0 , src_w, src_h, ctx); + crtc_x, crtc_y, crtc_w, crtc_h, +0 ,0 , src_w, src_h, ctx); + +if (fb) +drm_framebuffer_put (fb);/* Update successful; save new cursor position, if necessary */ if (ret ==0 && req->flags &DRM_MODE_CURSOR_MOVE ) {Signature · 6 lines
2.15.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
URL : https://patchwork.freedesktop.org/series/35077/
State : success
== Summary ==
Series 35077v1 drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
https://patchwork.freedesktop.org/api/1.0/series/35077/revisions/1/mbox/
Test debugfs_test:
Subgroup read_all_entries:
dmesg-warn -> DMESG-FAIL (fi-elk-e7500) fdo#103989
dmesg-warn -> PASS (fi-bdw-gvtdvm) fdo#103938 +1fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#103938 https://bugs.freedesktop.org/show_bug.cgi?id=103938
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:437s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:443s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:385s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:525s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:281s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:498s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:508s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:490s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:481s fi-elk-e7500 total:224 pass:163 dwarn:14 dfail:1 fail:0 skip:45 fi-gdg-551 total:288 pass:178 dwarn:1 dfail:0 fail:1 skip:108 time:269s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:536s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:355s fi-hsw-4770r total:288 pass:224 dwarn:0 dfail:0 fail:0 skip:64 time:266s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:397s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:472s fi-ivb-3770 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:447s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:489s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:528s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:475s fi-kbl-r total:288 pass:260 dwarn:1 dfail:0 fail:0 skip:27 time:532s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:591s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:449s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:537s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:566s fi-skl-6700k total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:515s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:496s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:451s fi-snb-2520m total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:549s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:410s Blacklisted hosts: fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:608s fi-cnl-y total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:627s fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:487s
7f090d915d4f2f0f5788d40eba402ae9bf878d43 drm-tip: 2017y-12m-08d-10h-31m-00s UTC integration manifest e8944d703dcf drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7451/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✓ Fi.CI.BAT: success for drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
Quoting Patchwork (2017-12-08 11:35:05)
Quoted 11 lines
== Series Details ==
Series: drm/plane: Make framebuffer refcounting the responsibility of
setplane_internalcallers
URL : https://patchwork.freedesktop.org/series/35077/
State : success== Summary ==
Series 35077v1 drm/plane: Make framebuffer refcounting the responsibility of
setplane_internalcallers
https://patchwork.freedesktop.org/api/1.0/series/35077/revisions/1/mbox/
Quoted 7 lines
Test
debugfs_test:Subgroup read_all_entries: dmesg-warn -> DMESG-FAIL (fi-elk-e7500) fdo#103989 dmesg-warn -> PASS (fi-bdw-gvtdvm) fdo#103938 +1fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#103938 https://bugs.freedesktop.org/show_bug.cgi?id=103938
gdg still defeats us:
<7>[ 279.565692] [IGT] drv_module_reload: starting subtest basic-reload <7>[ 279.618846] [drm:intel_disable_pipe [i915]] disabling pipe A <7>[ 279.639614] [drm:i9xx_get_fifo_size [i915]] FIFO size - (0x00001d9c) A: 28 <7>[ 279.639663] [drm:i9xx_get_fifo_size [i915]] FIFO size - (0x00001d9c) B: 31 <7>[ 279.639707] [drm:i9xx_update_wm [i915]] FIFO watermarks - A: 26, B: 29 <7>[ 279.639753] [drm:i9xx_update_wm [i915]] Setting FIFO watermarks - A: 26, B: 29, C: 2, SR 1 <7>[ 279.639820] [drm:intel_atomic_commit_tail [i915]] [ENCODER:39:CRT] <7>[ 279.639882] [drm:intel_atomic_commit_tail [i915]] [ENCODER:40:SDVO B] <7>[ 279.639940] [drm:verify_connector_state.isra.77 [i915]] [CONNECTOR:38:VGA-1] <7>[ 279.640095] [drm:intel_atomic_commit_tail [i915]] [CRTC:32:pipe A] <4>[ 279.647674] WARNING: CPU: 0 PID: 2462 at drivers/gpu/drm/drm_mode_config.c:470 drm_mode_config_cleanup+0x28d/0x2b0 <4>[ 279.647680] Modules linked in: vgem i915(-) intel_powerclamp lpc_ich tg3 ptp pps_core prime_numbers [last unloaded: vgem] <4>[ 279.647718] CPU: 0 PID: 2462 Comm: drv_module_relo Tainted: G U 4.15.0-rc2-CI-Patchwork_7451+ #1 <4>[ 279.647722] Hardware name: Dell Inc. OptiPlex GX280 /0G8310, BIOS A04 02/09/2005 <4>[ 279.647726] task: 00000000134e8d08 task.stack: 000000005a052046 <4>[ 279.647731] RIP: 0010:drm_mode_config_cleanup+0x28d/0x2b0 <4>[ 279.647735] RSP: 0018:ffffc9000029bdb8 EFLAGS: 00010287 <4>[ 279.647742] RAX: ffff8800341f71c0 RBX: ffff880030690950 RCX: 0000000000000001 <4>[ 279.647746] RDX: ffff880030690978 RSI: 0000000000000000 RDI: ffff880030690950 <4>[ 279.647749] RBP: ffff880030690000 R08: 0000000000000000 R09: 0000000000000000 <4>[ 279.647752] R10: 0000000000000000 R11: 0000000000000000 R12: ffff880030690748 <4>[ 279.647756] R13: ffffffffa0233750 R14: ffff88003d1625a8 R15: ffffffffa02337c8 <4>[ 279.647760] FS: 00007f7e93c6a8c0(0000) GS:ffff88003f400000(0000) knlGS:0000000000000000 <4>[ 279.647764] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 <4>[ 279.647768] CR2: 00007f78efc3b000 CR3: 000000003b4f7000 CR4: 00000000000006f0 <4>[ 279.647772] Call Trace: <4>[ 279.647875] intel_modeset_cleanup+0x89/0xd0 [i915] <4>[ 279.647918] i915_driver_unload+0x98/0x180 [i915] <4>[ 279.647961] i915_pci_remove+0x10/0x20 [i915] <4>[ 279.647969] pci_device_remove+0x31/0xa0 <4>[ 279.647977] device_release_driver_internal+0x15b/0x230 <4>[ 279.647985] driver_detach+0x35/0x70 <4>[ 279.647993] bus_remove_driver+0x53/0xd0 <4>[ 279.647999] pci_unregister_driver+0x39/0xa0 <4>[ 279.648010] SyS_delete_module+0x180/0x1d0 <4>[ 279.648021] entry_SYSCALL_64_fastpath+0x1c/0x89 <4>[ 279.648026] RIP: 0033:0x7f7e92182287 <4>[ 279.648029] RSP: 002b:00007fff782ed478 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0 <4>[ 279.648036] RAX: ffffffffffffffda RBX: 00005558d2c0bfe0 RCX: 00007f7e92182287 <4>[ 279.648040] RDX: 0000000000000001 RSI: 0000000000000800 RDI: 00005558d2c0b878 <4>[ 279.648044] RBP: 00007f7e92437400 R08: 0000000000000000 R09: 0000000000000080 <4>[ 279.648047] R10: 0000000000000885 R11: 0000000000000206 R12: 0000000000000000 <4>[ 279.648050] R13: 00005558d2c08410 R14: 00005558d2c0bfe0 R15: 00007fff782ec448 <4>[ 279.648068] Code: 48 89 da 31 f6 48 c7 c7 2e c6 c6 81 e8 5d f5 ff ff 48 89 e7 e8 d5 a7 ff ff 48 85 c0 75 de 48 89 e7 e8 a8 a8 ff ff e9 0b fe ff ff <0f> ff e9 f6 fe ff ff 0f ff 48 83 c4 28 5b 5d 41 5c 41 5d 41 5e <4>[ 279.648257] ---[ end trace b879a808700d8111 ]--- <7>[ 279.648264] [leaked fb] framebuffer[49]: <7>[ 279.648268] [leaked fb] refcount=63 <7>[ 279.648275] [leaked fb] format=XR24 little-endian (0x34325258) <7>[ 279.648280] [leaked fb] modifier=0x0 <7>[ 279.648284] [leaked fb] size=1024x768 <7>[ 279.648288] [leaked fb] layers: <7>[ 279.648292] [leaked fb] size[0]=1024x768 <7>[ 279.648296] [leaked fb] pitch[0]=4096 <7>[ 279.648300] [leaked fb] offset[0]=0 <7>[ 279.648304] [leaked fb] obj[0]:(null)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
In reply to Maarten Lankhorst== Series Details ==
== Series Details ==
Series: drm/plane: Make framebuffer refcounting the responsibility of setplane_internal callers
URL : https://patchwork.freedesktop.org/series/35077/
State : success
== Summary ==
Test kms_flip:
Subgroup flip-vs-panning:
pass -> INCOMPLETE (shard-hsw) fdo#103540
Test drv_module_reload:
Subgroup basic-reload:
dmesg-warn -> PASS (shard-hsw) fdo#102707
Test drv_selftest:
Subgroup live_hangcheck:
pass -> INCOMPLETE (shard-snb) fdo#103880
Test kms_cursor_crc:
Subgroup cursor-256x256-suspend:
pass -> SKIP (shard-snb) fdo#103375 +2
Test pm_rpm:
Subgroup fences:
skip -> PASS (shard-hsw)
Test kms_cursor_legacy:
Subgroup basic-flip-before-cursor-legacy:
skip -> PASS (shard-hsw)
Subgroup flip-vs-cursor-toggle:
skip -> PASS (shard-snb)
Test kms_chv_cursor_fail:
Subgroup pipe-c-128x128-right-edge:
skip -> PASS (shard-hsw)
Test kms_atomic_transition:
Subgroup 1x-modeset-transitions-nonblocking-fencing:
skip -> PASS (shard-hsw)
Test kms_busy:
Subgroup extended-modeset-hang-oldfb-with-reset-render-b:
skip -> PASS (shard-snb)
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-pri-shrfb-draw-blt:
fail -> PASS (shard-hsw) fdo#101623 +1
Test gem_eio:
Subgroup in-flight-contexts:
pass -> DMESG-WARN (shard-snb) fdo#104058fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#103880 https://bugs.freedesktop.org/show_bug.cgi?id=103880
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058
shard-hsw total:2671 pass:1528 dwarn:1 dfail:0 fail:10 skip:1131 time:9023s shard-snb total:2661 pass:1287 dwarn:2 dfail:0 fail:12 skip:1359 time:7967s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7451/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx