The zpos property is used by userspace to sort the order of planes. While the property is not mandatory for drivers to implement, mixing planes with and without zpos confuses userspace, and shall not be allowed. Clarify this in the documentation and warn at runtime if the drivers mixes planes with and without zpos properties.
Signed-off-by: Laurent Pinchart laurent.pinchart+renesas@ideasonboard.com --- drivers/gpu/drm/drm_blend.c | 10 ++++++---- drivers/gpu/drm/drm_plane.c | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c index 88eedee018d3..f1dcad96f341 100644 --- a/drivers/gpu/drm/drm_blend.c +++ b/drivers/gpu/drm/drm_blend.c @@ -135,7 +135,9 @@ * are underneath planes with higher Z position values. Two planes with the * same Z position value have undefined ordering. Note that the Z position * value can also be immutable, to inform userspace about the hard-coded - * stacking of planes, see drm_plane_create_zpos_immutable_property(). + * stacking of planes, see drm_plane_create_zpos_immutable_property(). If + * any plane has a zpos property (either mutable or immutable), then all + * planes shall have a zpos property. * * pixel blend mode: * Pixel blend mode is set up with drm_plane_create_blend_mode_property(). @@ -344,10 +346,10 @@ EXPORT_SYMBOL(drm_rotation_simplify); * should be set to 0 and max to maximal number of planes for given crtc - 1. * * If zpos of some planes cannot be changed (like fixed background or - * cursor/topmost planes), driver should adjust min/max values and assign those - * planes immutable zpos property with lower or higher values (for more + * cursor/topmost planes), drivers shall adjust the min/max values and assign + * those planes immutable zpos properties with lower or higher values (for more * information, see drm_plane_create_zpos_immutable_property() function). In such - * case driver should also assign proper initial zpos values for all planes in + * case drivers shall also assign proper initial zpos values for all planes in * its plane_reset() callback, so the planes will be always sorted properly. * * See also drm_atomic_normalize_zpos(). diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index d6ad60ab0d38..efb9c16ddc21 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -289,6 +289,8 @@ EXPORT_SYMBOL(drm_universal_plane_init);
int drm_plane_register_all(struct drm_device *dev) { + unsigned int num_planes = 0; + unsigned int num_zpos = 0; struct drm_plane *plane; int ret = 0;
@@ -297,8 +299,15 @@ int drm_plane_register_all(struct drm_device *dev) ret = plane->funcs->late_register(plane); if (ret) return ret; + + if (plane->zpos_property) + num_zpos++; + num_planes++; }
+ drm_WARN(dev, num_planes != num_zpos, + "Mixing planes with and without zpos property is invalid\n"); + return 0; }
Hi Laurent.
On Sat, Apr 04, 2020 at 09:12:53PM +0300, Laurent Pinchart wrote:
Looks good. Acked-by: Sam Ravnborg sam@ravnborg.org
FYI, we noticed the following commit (built with gcc-7):
commit: bd61431ef20403f30510ecb4b9263a4894e357d8 ("[PATCH] drm: plane: Verify that no or all planes have a zpos property") url: https://github.com/0day-ci/linux/commits/Laurent-Pinchart/drm-plane-Verify-t... base: https://git.kernel.org/cgit/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next
in testcase: boot
on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G
caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):
+---------------------------------------------------------------------+------------+------------+ | | e2ed135564 | bd61431ef2 | +---------------------------------------------------------------------+------------+------------+ | boot_successes | 4 | 0 | | boot_failures | 0 | 4 | | WARNING:at_drivers/gpu/drm/drm_plane.c:#drm_plane_register_all[drm] | 0 | 4 | | RIP:drm_plane_register_all[drm] | 0 | 4 | +---------------------------------------------------------------------+------------+------------+
If you fix the issue, kindly add following tag Reported-by: kernel test robot lkp@intel.com
[ 17.466582] WARNING: CPU: 0 PID: 310 at drivers/gpu/drm/drm_plane.c:309 drm_plane_register_all+0x9d/0xb0 [drm] [ 17.467701] Modules linked in: parport_pc(+) parport bochs_drm(+) drm_vram_helper drm_ttm_helper ttm drm_kms_helper drm qemu_fw_cfg virtio_scsi joydev i2c_piix4 [ 17.469413] CPU: 0 PID: 310 Comm: modprobe Not tainted 5.6.0-rc5-01148-gbd61431ef2040 #1 [ 17.470188] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 [ 17.470978] RIP: 0010:drm_plane_register_all+0x9d/0xb0 [drm] [ 17.471513] Code: ec 74 29 49 8b 7e 18 48 8b 5f 50 48 85 db 75 03 48 8b 1f e8 c5 fa 50 cf 48 89 da 48 89 c6 48 c7 c7 b0 3e 1e c0 e8 43 b9 f2 ce <0f> 0b 5b 31 c0 5d 41 5c 41 5d 41 5e c3 66 0f 1f 44 00 00 66 66 66 [ 17.473966] RSP: 0018:ffffae9340253a68 EFLAGS: 00010282 [ 17.474464] RAX: 0000000000000000 RBX: ffff95b5e9e2b8f0 RCX: ffffffff90654ae8 [ 17.475104] RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000246 [ 17.475745] RBP: 0000000000000001 R08: 00000000000002df R09: 0720072007200720 [ 17.476389] R10: 0000000000000000 R11: 0720072007200720 R12: 0000000000000000 [ 17.477037] R13: ffff95b5a6ed22d0 R14: ffff95b5a6ed2000 R15: ffff95b5a7070fe0 [ 17.477925] FS: 00007f1c4af79700(0000) GS:ffff95b5ffc00000(0000) knlGS:0000000000000000 [ 17.479212] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 17.480013] CR2: 00007f4ca04bdb98 CR3: 00000001e9ea8000 CR4: 00000000000406f0 [ 17.481042] Call Trace: [ 17.481410] drm_modeset_register_all+0x12/0x80 [drm] [ 17.482114] drm_dev_register+0x143/0x1a0 [drm] [ 17.482742] bochs_pci_probe+0x118/0x150 [bochs_drm] [ 17.483411] local_pci_probe+0x42/0x90 [ 17.483936] ? _cond_resched+0x19/0x30 [ 17.484443] pci_device_probe+0x10b/0x1c0 [ 17.485108] really_probe+0xef/0x430 [ 17.485598] driver_probe_device+0x110/0x120 [ 17.494367] device_driver_attach+0x4f/0x60 [ 17.495127] __driver_attach+0x9a/0x140 [ 17.495818] ? device_driver_attach+0x60/0x60 [ 17.496590] bus_for_each_dev+0x76/0xc0 [ 17.497281] ? klist_add_tail+0x3b/0x70 [ 17.497979] bus_add_driver+0x144/0x220 [ 17.498484] ? 0xffffffffc0165000 [ 17.498925] driver_register+0x5b/0xf0 [ 17.499417] ? 0xffffffffc0165000 [ 17.499851] do_one_initcall+0x46/0x220 [ 17.500345] ? free_unref_page_commit+0x9f/0x120 [ 17.500938] ? _cond_resched+0x19/0x30 [ 17.501446] ? kmem_cache_alloc_trace+0x3b/0x240 [ 17.502224] do_init_module+0x5b/0x21d [ 17.502883] load_module+0x2650/0x2b20 [ 17.503566] ? __do_sys_init_module+0x17d/0x1b0 [ 17.504389] __do_sys_init_module+0x17d/0x1b0 [ 17.505161] do_syscall_64+0x5b/0x1e0 [ 17.505875] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 17.507032] RIP: 0033:0x7f1c4aa92bca [ 17.507779] Code: 48 8b 0d 79 32 2c 00 31 d2 48 29 c2 64 89 11 48 83 c8 ff eb ea 90 90 90 90 90 90 90 90 90 90 90 49 89 ca b8 af 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 46 32 2c 00 31 d2 48 29 c2 64 [ 17.511244] RSP: 002b:00007ffdb2035d28 EFLAGS: 00000246 ORIG_RAX: 00000000000000af [ 17.512685] RAX: ffffffffffffffda RBX: 000000000251c430 RCX: 00007f1c4aa92bca [ 17.514057] RDX: 000000000251e400 RSI: 0000000000046be9 RDI: 00007f1c4af31000 [ 17.515215] RBP: 000000000251e400 R08: 00000000ffffffff R09: 0000000000000001 [ 17.516197] R10: 00007f1c4aa85100 R11: 0000000000000246 R12: 000000000251c150 [ 17.517151] R13: 000000000251e670 R14: 0000000000000000 R15: 000000000251c448 [ 17.518278] ---[ end trace 4955140d38c871de ]---
To reproduce:
# build kernel cd linux cp config-5.6.0-rc5-01148-gbd61431ef2040 .config make HOSTCC=gcc-7 CC=gcc-7 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage
git clone https://github.com/intel/lkp-tests.git cd lkp-tests bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email
Thanks, lkp
On Sat, Apr 04, 2020 at 09:12:53PM +0300, Laurent Pinchart wrote:
0day spotted that you should change this to num_zpos && num_zpos == num_planes. Otherwise it doesn't really implement what you claim it does implement. With that fixed:
Reviewed-by: Daniel Vetter daniel.vetter@ffwll.ch
dri-devel@lists.freedesktop.org