linux-stable/include/drm
Javier Martinez Canillas d6591da5f3
drm/fb-helper: Use a per-driver FB deferred I/O handler
The DRM fbdev emulation layer sets the struct fb_info .fbdefio field to
a struct fb_deferred_io pointer, that is shared across all drivers that
use the generic drm_fbdev_generic_setup() helper function.

It is a problem because the fbdev core deferred I/O logic assumes that
the struct fb_deferred_io data is not shared between devices, and it's
stored there state such as the list of pages touched and a mutex that
is use to synchronize between the fb_deferred_io_track_page() function
that track the dirty pages and fb_deferred_io_work() workqueue handler
doing the actual deferred I/O.

The latter can lead to the following error, since it may happen that two
drivers are probed and then one is removed, which causes the mutex bo be
destroyed and not existing anymore by the time the other driver tries to
grab it for the fbdev deferred I/O logic:

[  369.756553] ------------[ cut here ]------------
[  369.756604] DEBUG_LOCKS_WARN_ON(lock->magic != lock)
[  369.756631] WARNING: CPU: 2 PID: 1023 at kernel/locking/mutex.c:582 __mutex_lock+0x348/0x424
[  369.756744] Modules linked in: nf_conntrack_netbios_ns nf_conntrack_broadcast nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ip
v6 nf_defrag_ipv4 ip_set nf_tables nfnetlink qrtr btsdio bluetooth sunrpc brcmfmac snd_soc_hdmi_codec cpufreq_dt cfg80211 vfat fat vc4 rfkill brcmutil raspberrypi_cpufreq i2c_bcm2835 iproc_rng200 bcm2711_thermal snd_soc_core snd_pcm_dmaen
gine leds_gpio nvmem_rmem joydev hid_cherry uas usb_storage gpio_raspberrypi_exp v3d snd_pcm raspberrypi_hwmon gpu_sched bcm2835_wdt broadcom bcm_phy_lib snd_timer genet snd mdio_bcm_unimac clk_bcm2711_dvp soundcore drm_display_helper pci
e_brcmstb cec ip6_tables ip_tables fuse
[  369.757400] CPU: 2 PID: 1023 Comm: fbtest Not tainted 5.19.0-rc6+ #94
[  369.757455] Hardware name: raspberrypi,4-model-b Raspberry Pi 4 Model B Rev 1.4/Raspberry Pi 4 Model B Rev 1.4, BIOS 2022.10 10/01/2022
[  369.757538] pstate: 00400005 (nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  369.757596] pc : __mutex_lock+0x348/0x424
[  369.757635] lr : __mutex_lock+0x348/0x424
[  369.757672] sp : ffff80000953bb00
[  369.757703] x29: ffff80000953bb00 x28: ffff17fdc087c000 x27: 0000000000000002
[  369.757771] x26: ffff17fdc349f9b0 x25: fffffc5ff72e0100 x24: 0000000000000000
[  369.757838] x23: 0000000000000000 x22: 0000000000000002 x21: ffffa618df636f10
[  369.757903] x20: ffff80000953bb68 x19: ffffa618e0f18138 x18: 0000000000000001
[  369.757968] x17: 0000000020000000 x16: 0000000000000002 x15: 0000000000000000
[  369.758032] x14: 0000000000000000 x13: 284e4f5f4e524157 x12: 5f534b434f4c5f47
[  369.758097] x11: 00000000ffffdfff x10: ffffa618e0c79f88 x9 : ffffa618de472484
[  369.758162] x8 : 000000000002ffe8 x7 : c0000000ffffdfff x6 : 00000000000affa8
[  369.758227] x5 : 0000000000001fff x4 : 0000000000000000 x3 : 0000000000000027
[  369.758292] x2 : 0000000000000001 x1 : ffff17fdc087c000 x0 : 0000000000000028
[  369.758357] Call trace:
[  369.758383]  __mutex_lock+0x348/0x424
[  369.758420]  mutex_lock_nested+0x4c/0x5c
[  369.758459]  fb_deferred_io_mkwrite+0x78/0x1d8
[  369.758507]  do_page_mkwrite+0x5c/0x19c
[  369.758550]  wp_page_shared+0x70/0x1a0
[  369.758590]  do_wp_page+0x3d0/0x510
[  369.758628]  handle_pte_fault+0x1c0/0x1e0
[  369.758670]  __handle_mm_fault+0x250/0x380
[  369.758712]  handle_mm_fault+0x17c/0x3a4
[  369.758753]  do_page_fault+0x158/0x530
[  369.758792]  do_mem_abort+0x50/0xa0
[  369.758831]  el0_da+0x78/0x19c
[  369.758864]  el0t_64_sync_handler+0xbc/0x150
[  369.758904]  el0t_64_sync+0x190/0x194
[  369.758942] irq event stamp: 11395
[  369.758973] hardirqs last  enabled at (11395): [<ffffa618de472554>] __up_console_sem+0x74/0x80
[  369.759042] hardirqs last disabled at (11394): [<ffffa618de47254c>] __up_console_sem+0x6c/0x80
[  369.760554] softirqs last  enabled at (11392): [<ffffa618de330a74>] __do_softirq+0x4c4/0x6b8
[  369.762060] softirqs last disabled at (11383): [<ffffa618de3c9124>] __irq_exit_rcu+0x104/0x214
[  369.763564] ---[ end trace 0000000000000000 ]---

Fixes: d536540f30 ("drm/fb-helper: Add generic fbdev emulation .fb_probe function")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230121192418.2814955-4-javierm@redhat.com
2023-01-24 11:13:08 +01:00
..
bridge drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver 2022-04-19 18:23:48 +02:00
display Merge tag 'amd-drm-next-6.1-2022-09-08' of https://gitlab.freedesktop.org/agd5f/linux into drm-next 2022-09-12 19:17:41 +10:00
i2c
ttm drm/ttm: fix undefined behavior in bit shift for TTM_TT_FLAG_PRIV_POPULATED 2022-11-02 10:23:07 +01:00
amd_asic_type.h drm/amdgpu: add new asic_type for IP discovery 2021-10-04 15:23:01 -04:00
drm_accel.h accel: add dedicated minor for accelerator devices 2022-11-22 13:14:44 +02:00
drm_aperture.h drm/aperture: Pass DRM driver structure instead of driver name 2021-07-01 11:11:55 +02:00
drm_atomic.h drm/atomic: fix warning of unused variable 2022-06-09 16:09:46 +02:00
drm_atomic_helper.h drm/atomic-helper: Replace drm_atomic_helper_check_crtc_state() 2022-10-08 15:26:55 +02:00
drm_atomic_state_helper.h drm/atomic-helper: Rename drm_atomic_helper_connector_tv_reset to avoid ambiguity 2022-10-10 13:55:47 +02:00
drm_atomic_uapi.h drm: handle kernel fences in drm_gem_plane_helper_prepare_fb v2 2022-05-02 09:01:51 +02:00
drm_audio_component.h ALSA: hda/i915 - fix list corruption with concurrent probes 2020-10-09 16:46:04 +02:00
drm_auth.h drm: clarify usage of drm leases 2021-07-29 09:12:01 +02:00
drm_blend.h
drm_bridge.h drm/vc4: Add explicit declaration of 'drmm_of_get_bridge' 2022-07-21 12:15:56 +02:00
drm_bridge_connector.h
drm_buddy.h drm/selftests: add drm buddy alloc range testcase 2022-02-23 10:44:43 +01:00
drm_cache.h LoongArch: Add writecombine support for drm 2022-06-03 20:09:27 +08:00
drm_client.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
drm_color_mgmt.h
drm_connector.h drm-misc-next for 6.2: 2022-11-22 09:21:17 +10:00
drm_crtc.h drm/crtc: Introduce drmm_crtc_init_with_planes 2022-07-13 10:46:05 +02:00
drm_crtc_helper.h drm/crtc-helper: Add a drm_crtc_helper_atomic_check() helper 2022-10-13 09:17:05 +02:00
drm_damage_helper.h drm/plane: Move drm_plane_enable_fb_damage_clips into core 2021-07-27 12:21:22 +02:00
drm_debugfs.h
drm_debugfs_crc.h
drm_device.h accel: add dedicated minor for accelerator devices 2022-11-22 13:14:44 +02:00
drm_displayid.h drm/displayid: convert to drm_edid 2022-05-13 18:55:13 +03:00
drm_drv.h accel: add dedicated minor for accelerator devices 2022-11-22 13:14:44 +02:00
drm_edid.h drm/edid: move edid load declarations to internal header 2022-10-26 09:53:56 +03:00
drm_encoder.h drm/encoder: Introduce drmm_encoder_init 2022-07-13 10:46:05 +02:00
drm_encoder_slave.h drm: Remove linux/i2c.h from drm_crtc.h 2022-07-05 21:15:23 +03:00
drm_fb_dma_helper.h drm/gem: rename GEM CMA helpers to GEM DMA helpers 2022-08-03 18:31:49 +02:00
drm_fb_helper.h drm/fb-helper: Use a per-driver FB deferred I/O handler 2023-01-24 11:13:08 +01:00
drm_fbdev_generic.h drm/fb-helper: Move generic fbdev emulation into separate source file 2022-11-05 17:12:04 +01:00
drm_file.h accel: add dedicated minor for accelerator devices 2022-11-22 13:14:44 +02:00
drm_fixed.h
drm_flip_work.h
drm_format_helper.h drm/format-helper: Add drm_fb_build_fourcc_list() helper 2022-09-12 09:15:49 +02:00
drm_fourcc.h drm/fourcc: Add drm_format_info.is_color_indexed flag 2022-07-09 15:00:08 +02:00
drm_framebuffer.h drm/fb: Improve drm_framebuffer.offsets documentation 2022-07-09 15:58:52 +02:00
drm_gem.h Merge drm/drm-next into drm-misc-next 2022-10-18 15:00:03 +02:00
drm_gem_atomic_helper.h drm/gem: Implement shadow-plane {begin, end}_fb_access with vmap 2022-11-08 17:10:41 +01:00
drm_gem_dma_helper.h drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr} 2022-08-03 18:32:27 +02:00
drm_gem_framebuffer_helper.h drm/gem: Ignore color planes that are unused by framebuffer format 2022-05-19 19:25:02 +02:00
drm_gem_shmem_helper.h drm: correct comments 2022-07-21 12:16:10 +02:00
drm_gem_ttm_helper.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
drm_gem_vram_helper.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
drm_ioctl.h drm: unexport drm_ioctl_permit 2021-08-13 17:50:48 +02:00
drm_lease.h
drm_legacy.h drm: Declare hashtable as legacy 2021-11-30 09:41:28 +01:00
drm_managed.h drm: Add DRM-managed mutex_init() 2022-05-05 09:04:10 +02:00
drm_mipi_dbi.h drm/probe-helper: Add drm_crtc_helper_mode_valid_fixed() 2022-09-12 09:14:26 +02:00
drm_mipi_dsi.h Merge tag 'drm-msm-next-2022-09-22' of https://gitlab.freedesktop.org/drm/msm into drm-next 2022-09-28 11:35:25 +10:00
drm_mm.h drm: Replace kernel.h with the necessary inclusions 2021-12-09 13:46:13 +01:00
drm_mode_config.h drm: Remove drm_mode_config::fb_base 2022-10-19 21:46:16 -04:00
drm_mode_object.h drm/object: Add drm_object_property_get_default_value() function 2022-02-25 17:55:42 +01:00
drm_modes.h drm/modes: Add initializer macro DRM_MODE_INIT() 2022-09-12 09:14:59 +02:00
drm_modeset_helper.h
drm_modeset_helper_vtables.h drm/atomic-helper: Add {begin,end}_fb_access to plane helpers 2022-11-08 17:10:27 +01:00
drm_modeset_lock.h drm/locking: fix drm_modeset_acquire_ctx kernel-doc 2022-01-20 14:41:25 +02:00
drm_module.h drm: Provide platform module-init macro 2022-01-19 18:40:18 +01:00
drm_of.h drm: of: Mark empty drm_of_get_data_lanes_count and drm_of_get_data_lanes_ep static 2022-06-12 16:07:05 +02:00
drm_panel.h drm/panel: drop DSC pps pointer 2022-09-18 09:38:06 -07:00
drm_pciids.h
drm_plane.h drm/plane: Allocate planes with drm_universal_plane_alloc() 2022-09-20 09:41:06 +02:00
drm_plane_helper.h drm/plane-helper: Add the missing declaration of drm_atomic_state 2022-12-16 10:23:11 +01:00
drm_prime.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
drm_print.h drm_print: add _ddebug descriptor to drm_*dbg prototypes 2022-09-24 15:02:02 +02:00
drm_privacy_screen_consumer.h drm/privacy-screen: Add notifier support (v2) 2021-10-14 13:12:25 +02:00
drm_privacy_screen_driver.h drm/privacy_screen: Add drvdata in drm_privacy_screen 2022-01-10 12:17:37 +01:00
drm_privacy_screen_machine.h drm/privacy-screen: Add X86 specific arch init code 2021-10-14 13:12:24 +02:00
drm_probe_helper.h drm/probe-helper: Add drm_crtc_helper_mode_valid_fixed() 2022-09-12 09:14:26 +02:00
drm_property.h drm: document drm_property_enum.value for bitfields 2021-07-26 10:08:22 +02:00
drm_rect.h drm/rect: Add DRM_RECT_INIT() macro 2022-06-27 13:45:48 +02:00
drm_self_refresh_helper.h
drm_simple_kms_helper.h drm/atomic-helper: Add {begin,end}_fb_access to plane helpers 2022-11-08 17:10:27 +01:00
drm_syncobj.h
drm_sysfs.h drm/sysfs: introduce drm_sysfs_connector_hotplug_event 2021-11-02 14:27:06 +01:00
drm_util.h
drm_utils.h
drm_vblank.h drm/vblank: Document drm_crtc_vblank_restore constraints 2021-02-10 12:38:55 +01:00
drm_vblank_work.h
drm_vma_manager.h drm/drm_vma_manager: Add drm_vma_node_allow_once() 2023-01-19 14:16:55 +01:00
drm_writeback.h drm: introduce drm_writeback_connector_init_with_encoder() API 2022-05-02 02:12:59 +03:00
gma_drm.h
gpu_scheduler.h Merge tag 'amd-drm-next-6.2-2022-11-18' of https://gitlab.freedesktop.org/agd5f/linux into drm-next 2022-11-22 13:41:11 +10:00
gud.h drm/gud: Add GUD_PIXEL_FORMAT_RGB888 2021-10-04 12:06:14 +02:00
i915_component.h drm/i915/pxp: Define PXP component interface 2021-10-04 13:09:53 -04:00
i915_drm.h drm/i915: include uapi/drm/i915_drm.h directly where needed 2022-03-17 20:06:04 +02:00
i915_mei_hdcp_interface.h drm/display: Move HDCP helpers into display-helper module 2022-04-25 11:19:36 +02:00
i915_pciids.h drm/i915: Add new ADL-S pci id 2022-08-26 05:46:23 -07:00
i915_pxp_tee_interface.h mei: pxp: add command streamer API to the PXP driver 2022-10-03 11:29:11 -07:00
intel-gtt.h agp/intel: Rename intel-gtt symbols 2022-06-22 15:52:55 -07:00
intel_lpe_audio.h
spsc_queue.h
task_barrier.h