mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-20 13:57:40 +07:00
70deeaddc6
This patch fixes lockdep issue due to circular locking dependency of struct_mutex, i_mutex_key, mmap_sem, relay_channels_mutex. For GuC log relay channel we create debugfs file that requires i_mutex_key lock and we are doing that under struct_mutex. So we introduced newer dependency as: &dev->struct_mutex --> &sb->s_type->i_mutex_key#3 --> &mm->mmap_sem However, there is dependency from mmap_sem to struct_mutex. Hence we separate the relay create/destroy operation from under struct_mutex. Also added runtime check of relay buffer status. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> ====================================================== WARNING: possible circular locking dependency detected 4.15.0-rc6-CI-Patchwork_7614+ #1 Not tainted ------------------------------------------------------ debugfs_test/1388 is trying to acquire lock: (&dev->struct_mutex){+.+.}, at: [<00000000d5e1d915>] i915_mutex_lock_interruptible+0x47/0x130 [i915] but task is already holding lock: (&mm->mmap_sem){++++}, at: [<0000000029a9c131>] __do_page_fault+0x106/0x560 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&mm->mmap_sem){++++}: _copy_to_user+0x1e/0x70 filldir+0x8c/0xf0 dcache_readdir+0xeb/0x160 iterate_dir+0xdc/0x140 SyS_getdents+0xa0/0x130 entry_SYSCALL_64_fastpath+0x1c/0x89 -> #2 (&sb->s_type->i_mutex_key#3){++++}: start_creating+0x59/0x110 __debugfs_create_file+0x2e/0xe0 relay_create_buf_file+0x62/0x80 relay_late_setup_files+0x84/0x250 guc_log_late_setup+0x4f/0x110 [i915] i915_guc_log_register+0x32/0x40 [i915] i915_driver_load+0x7b6/0x1720 [i915] i915_pci_probe+0x2e/0x90 [i915] pci_device_probe+0x9c/0x120 driver_probe_device+0x2a3/0x480 __driver_attach+0xd9/0xe0 bus_for_each_dev+0x57/0x90 bus_add_driver+0x168/0x260 driver_register+0x52/0xc0 do_one_initcall+0x39/0x150 do_init_module+0x56/0x1ef load_module+0x231c/0x2d70 SyS_finit_module+0xa5/0xe0 entry_SYSCALL_64_fastpath+0x1c/0x89 -> #1 (relay_channels_mutex){+.+.}: relay_open+0x12c/0x2b0 intel_guc_log_runtime_create+0xab/0x230 [i915] intel_guc_init+0x81/0x120 [i915] intel_uc_init+0x29/0xa0 [i915] i915_gem_init+0x182/0x530 [i915] i915_driver_load+0xaa9/0x1720 [i915] i915_pci_probe+0x2e/0x90 [i915] pci_device_probe+0x9c/0x120 driver_probe_device+0x2a3/0x480 __driver_attach+0xd9/0xe0 bus_for_each_dev+0x57/0x90 bus_add_driver+0x168/0x260 driver_register+0x52/0xc0 do_one_initcall+0x39/0x150 do_init_module+0x56/0x1ef load_module+0x231c/0x2d70 SyS_finit_module+0xa5/0xe0 entry_SYSCALL_64_fastpath+0x1c/0x89 -> #0 (&dev->struct_mutex){+.+.}: __mutex_lock+0x81/0x9b0 i915_mutex_lock_interruptible+0x47/0x130 [i915] i915_gem_fault+0x201/0x790 [i915] __do_fault+0x15/0x70 __handle_mm_fault+0x677/0xdc0 handle_mm_fault+0x14f/0x2f0 __do_page_fault+0x2d1/0x560 page_fault+0x4c/0x60 other info that might help us debug this: Chain exists of: &dev->struct_mutex --> &sb->s_type->i_mutex_key#3 --> &mm->mmap_sem Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&mm->mmap_sem); lock(&sb->s_type->i_mutex_key#3); lock(&mm->mmap_sem); lock(&dev->struct_mutex); *** DEADLOCK *** 1 lock held by debugfs_test/1388: #0: (&mm->mmap_sem){++++}, at: [<0000000029a9c131>] __do_page_fault+0x106/0x560 stack backtrace: CPU: 2 PID: 1388 Comm: debugfs_test Not tainted 4.15.0-rc6-CI-Patchwork_7614+ #1 Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./J4205-ITX, BIOS P1.10 09/29/2016 Call Trace: dump_stack+0x5f/0x86 print_circular_bug.isra.18+0x1d0/0x2c0 __lock_acquire+0x14ae/0x1b60 ? lock_acquire+0xaf/0x200 lock_acquire+0xaf/0x200 ? i915_mutex_lock_interruptible+0x47/0x130 [i915] __mutex_lock+0x81/0x9b0 ? i915_mutex_lock_interruptible+0x47/0x130 [i915] ? i915_mutex_lock_interruptible+0x47/0x130 [i915] ? i915_mutex_lock_interruptible+0x47/0x130 [i915] i915_mutex_lock_interruptible+0x47/0x130 [i915] ? __pm_runtime_resume+0x4f/0x80 i915_gem_fault+0x201/0x790 [i915] __do_fault+0x15/0x70 ? _raw_spin_unlock+0x29/0x40 __handle_mm_fault+0x677/0xdc0 handle_mm_fault+0x14f/0x2f0 __do_page_fault+0x2d1/0x560 ? page_fault+0x36/0x60 page_fault+0x4c/0x60 v2: Added lock protection to guc->log.runtime.relay_chan (Chris) Fixed locking inside guc_flush_logs uncovered by new lockdep. v3: Locking guc_read_update_log_buffer entirely with relay_lock. (Chris) Prepared intel_guc_init_early. Moved relay_lock inside relay_create relay_destroy, relay_file_create, guc_read_update_log_buffer. (Michal) Removed struct_mutex lock around guc_log_flush and removed usage of guc_log_has_relay() from runtime_create path as it needs struct_mutex lock. v4: Handle NULL relay sub buffer pointer earlier in read_update_log_buffer (Chris). Fixed comment suffix **/. (Michal) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104693 Testcase: igt/debugfs_test/read_all_entries # with enable_guc=1 and guc_log_level=1 Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Marta Lofstedt <marta.lofstedt@intel.com> Cc: Michal Winiarski <michal.winiarski@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/1516808821-3638-3-git-send-email-sagar.a.kamble@intel.com |
||
---|---|---|
.. | ||
gvt | ||
selftests | ||
dvo_ch7xxx.c | ||
dvo_ch7017.c | ||
dvo_ivch.c | ||
dvo_ns2501.c | ||
dvo_sil164.c | ||
dvo_tfp410.c | ||
dvo.h | ||
i915_cmd_parser.c | ||
i915_debugfs.c | ||
i915_drv.c | ||
i915_drv.h | ||
i915_gem_batch_pool.c | ||
i915_gem_batch_pool.h | ||
i915_gem_clflush.c | ||
i915_gem_clflush.h | ||
i915_gem_context.c | ||
i915_gem_context.h | ||
i915_gem_dmabuf.c | ||
i915_gem_evict.c | ||
i915_gem_execbuffer.c | ||
i915_gem_fence_reg.c | ||
i915_gem_fence_reg.h | ||
i915_gem_gtt.c | ||
i915_gem_gtt.h | ||
i915_gem_internal.c | ||
i915_gem_object.c | ||
i915_gem_object.h | ||
i915_gem_render_state.c | ||
i915_gem_render_state.h | ||
i915_gem_request.c | ||
i915_gem_request.h | ||
i915_gem_shrinker.c | ||
i915_gem_stolen.c | ||
i915_gem_tiling.c | ||
i915_gem_timeline.c | ||
i915_gem_timeline.h | ||
i915_gem_userptr.c | ||
i915_gem.c | ||
i915_gem.h | ||
i915_gemfs.c | ||
i915_gemfs.h | ||
i915_gpu_error.c | ||
i915_ioc32.c | ||
i915_irq.c | ||
i915_memcpy.c | ||
i915_mm.c | ||
i915_oa_bdw.c | ||
i915_oa_bdw.h | ||
i915_oa_bxt.c | ||
i915_oa_bxt.h | ||
i915_oa_cflgt2.c | ||
i915_oa_cflgt2.h | ||
i915_oa_cflgt3.c | ||
i915_oa_cflgt3.h | ||
i915_oa_chv.c | ||
i915_oa_chv.h | ||
i915_oa_cnl.c | ||
i915_oa_cnl.h | ||
i915_oa_glk.c | ||
i915_oa_glk.h | ||
i915_oa_hsw.c | ||
i915_oa_hsw.h | ||
i915_oa_kblgt2.c | ||
i915_oa_kblgt2.h | ||
i915_oa_kblgt3.c | ||
i915_oa_kblgt3.h | ||
i915_oa_sklgt2.c | ||
i915_oa_sklgt2.h | ||
i915_oa_sklgt3.c | ||
i915_oa_sklgt3.h | ||
i915_oa_sklgt4.c | ||
i915_oa_sklgt4.h | ||
i915_params.c | ||
i915_params.h | ||
i915_pci.c | ||
i915_perf.c | ||
i915_pmu.c | ||
i915_pmu.h | ||
i915_pvinfo.h | ||
i915_reg.h | ||
i915_selftest.h | ||
i915_suspend.c | ||
i915_sw_fence.c | ||
i915_sw_fence.h | ||
i915_syncmap.c | ||
i915_syncmap.h | ||
i915_sysfs.c | ||
i915_trace_points.c | ||
i915_trace.h | ||
i915_utils.h | ||
i915_vgpu.c | ||
i915_vgpu.h | ||
i915_vma.c | ||
i915_vma.h | ||
intel_acpi.c | ||
intel_atomic_plane.c | ||
intel_atomic.c | ||
intel_audio.c | ||
intel_bios.c | ||
intel_bios.h | ||
intel_breadcrumbs.c | ||
intel_cdclk.c | ||
intel_color.c | ||
intel_crt.c | ||
intel_csr.c | ||
intel_ddi.c | ||
intel_device_info.c | ||
intel_device_info.h | ||
intel_display.c | ||
intel_display.h | ||
intel_dp_aux_backlight.c | ||
intel_dp_link_training.c | ||
intel_dp_mst.c | ||
intel_dp.c | ||
intel_dpio_phy.c | ||
intel_dpll_mgr.c | ||
intel_dpll_mgr.h | ||
intel_drv.h | ||
intel_dsi_dcs_backlight.c | ||
intel_dsi_pll.c | ||
intel_dsi_vbt.c | ||
intel_dsi.c | ||
intel_dsi.h | ||
intel_dvo.c | ||
intel_engine_cs.c | ||
intel_fbc.c | ||
intel_fbdev.c | ||
intel_fifo_underrun.c | ||
intel_frontbuffer.c | ||
intel_frontbuffer.h | ||
intel_guc_ads.c | ||
intel_guc_ads.h | ||
intel_guc_ct.c | ||
intel_guc_ct.h | ||
intel_guc_fw.c | ||
intel_guc_fw.h | ||
intel_guc_fwif.h | ||
intel_guc_log.c | ||
intel_guc_log.h | ||
intel_guc_reg.h | ||
intel_guc_submission.c | ||
intel_guc_submission.h | ||
intel_guc.c | ||
intel_guc.h | ||
intel_gvt.c | ||
intel_gvt.h | ||
intel_hangcheck.c | ||
intel_hdmi.c | ||
intel_hotplug.c | ||
intel_huc.c | ||
intel_huc.h | ||
intel_i2c.c | ||
intel_lpe_audio.c | ||
intel_lrc_reg.h | ||
intel_lrc.c | ||
intel_lrc.h | ||
intel_lspcon.c | ||
intel_lvds.c | ||
intel_mocs.c | ||
intel_mocs.h | ||
intel_modes.c | ||
intel_opregion.c | ||
intel_opregion.h | ||
intel_overlay.c | ||
intel_panel.c | ||
intel_pipe_crc.c | ||
intel_pm.c | ||
intel_psr.c | ||
intel_renderstate_gen6.c | ||
intel_renderstate_gen7.c | ||
intel_renderstate_gen8.c | ||
intel_renderstate_gen9.c | ||
intel_renderstate.h | ||
intel_ringbuffer.c | ||
intel_ringbuffer.h | ||
intel_runtime_pm.c | ||
intel_sdvo_regs.h | ||
intel_sdvo.c | ||
intel_sideband.c | ||
intel_sprite.c | ||
intel_tv.c | ||
intel_uc_fw.c | ||
intel_uc_fw.h | ||
intel_uc.c | ||
intel_uc.h | ||
intel_uncore.c | ||
intel_uncore.h | ||
intel_vbt_defs.h | ||
Kconfig | ||
Kconfig.debug | ||
Makefile |