mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 09:00:58 +07:00
3176ff49bc
This gets rid of the following lockdep splat: ====================================================== WARNING: possible circular locking dependency detected 4.15.0-rc2-CI-Patchwork_7428+ #1 Not tainted ------------------------------------------------------ debugfs_test/1351 is trying to acquire lock: (&dev->struct_mutex){+.+.}, at: [<000000009d90d1a3>] i915_mutex_lock_interruptible+0x47/0x130 [i915] but task is already holding lock: (&mm->mmap_sem){++++}, at: [<000000005df01c1e>] __do_page_fault+0x106/0x560 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #6 (&mm->mmap_sem){++++}: __might_fault+0x63/0x90 _copy_to_user+0x1e/0x70 filldir+0x8c/0xf0 dcache_readdir+0xeb/0x160 iterate_dir+0xe6/0x150 SyS_getdents+0xa0/0x130 entry_SYSCALL_64_fastpath+0x1c/0x89 -> #5 (&sb->s_type->i_mutex_key#5){++++}: lockref_get+0x9/0x20 -> #4 ((completion)&req.done){+.+.}: wait_for_common+0x54/0x210 devtmpfs_create_node+0x130/0x150 device_add+0x5ad/0x5e0 device_create_groups_vargs+0xd4/0xe0 device_create+0x35/0x40 msr_device_create+0x22/0x40 cpuhp_invoke_callback+0xc5/0xbf0 cpuhp_thread_fun+0x167/0x210 smpboot_thread_fn+0x17f/0x270 kthread+0x173/0x1b0 ret_from_fork+0x24/0x30 -> #3 (cpuhp_state-up){+.+.}: cpuhp_issue_call+0x132/0x1c0 __cpuhp_setup_state_cpuslocked+0x12f/0x2a0 __cpuhp_setup_state+0x3a/0x50 page_writeback_init+0x3a/0x5c start_kernel+0x393/0x3e2 secondary_startup_64+0xa5/0xb0 -> #2 (cpuhp_state_mutex){+.+.}: __mutex_lock+0x81/0x9b0 __cpuhp_setup_state_cpuslocked+0x4b/0x2a0 __cpuhp_setup_state+0x3a/0x50 page_alloc_init+0x1f/0x26 start_kernel+0x139/0x3e2 secondary_startup_64+0xa5/0xb0 -> #1 (cpu_hotplug_lock.rw_sem){++++}: cpus_read_lock+0x34/0xa0 apply_workqueue_attrs+0xd/0x40 __alloc_workqueue_key+0x2c7/0x4e1 intel_guc_submission_init+0x10c/0x650 [i915] intel_uc_init_hw+0x29e/0x460 [i915] i915_gem_init_hw+0xca/0x290 [i915] i915_gem_init+0x115/0x3a0 [i915] i915_driver_load+0x9a8/0x16c0 [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){+.+.}: lock_acquire+0xaf/0x200 __mutex_lock+0x81/0x9b0 i915_mutex_lock_interruptible+0x47/0x130 [i915] i915_gem_fault+0x201/0x760 [i915] __do_fault+0x15/0x70 __handle_mm_fault+0x85b/0xe40 handle_mm_fault+0x14f/0x2f0 __do_page_fault+0x2d1/0x560 page_fault+0x22/0x30 other info that might help us debug this: Chain exists of: &dev->struct_mutex --> &sb->s_type->i_mutex_key#5 --> &mm->mmap_sem Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&mm->mmap_sem); lock(&sb->s_type->i_mutex_key#5); lock(&mm->mmap_sem); lock(&dev->struct_mutex); *** DEADLOCK *** 1 lock held by debugfs_test/1351: #0: (&mm->mmap_sem){++++}, at: [<000000005df01c1e>] __do_page_fault+0x106/0x560 stack backtrace: CPU: 2 PID: 1351 Comm: debugfs_test Not tainted 4.15.0-rc2-CI-Patchwork_7428+ #1 Hardware name: /NUC6i5SYB, BIOS SYSKLi35.86A.0057.2017.0119.1758 01/19/2017 Call Trace: dump_stack+0x5f/0x86 print_circular_bug+0x230/0x3b0 check_prev_add+0x439/0x7b0 ? lockdep_init_map_crosslock+0x20/0x20 ? unwind_get_return_address+0x16/0x30 ? __lock_acquire+0x1385/0x15a0 __lock_acquire+0x1385/0x15a0 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/0x760 [i915] __do_fault+0x15/0x70 __handle_mm_fault+0x85b/0xe40 handle_mm_fault+0x14f/0x2f0 __do_page_fault+0x2d1/0x560 page_fault+0x22/0x30 RIP: 0033:0x7f98d6f49116 RSP: 002b:00007ffd6ffc3278 EFLAGS: 00010283 RAX: 00007f98d39a2bc0 RBX: 0000000000000000 RCX: 0000000000001680 RDX: 0000000000001680 RSI: 00007ffd6ffc3400 RDI: 00007f98d39a2bc0 RBP: 00007ffd6ffc33a0 R08: 0000000000000000 R09: 00000000000005a0 R10: 000055e847c2a830 R11: 0000000000000002 R12: 0000000000000001 R13: 000055e847c1d040 R14: 00007ffd6ffc3400 R15: 00007f98d6752ba0 v2: Init preempt_work unconditionally (Chris) v3: Mention that we need the enable_guc=1 for lockdep splat (Chris) Testcase: igt/debugfs_test/read_all_entries # with i915.enable_guc=1 Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20171213221352.7173-2-michal.winiarski@intel.com
136 lines
4.3 KiB
C
136 lines
4.3 KiB
C
/*
|
|
* Copyright © 2014-2017 Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef _INTEL_GUC_H_
|
|
#define _INTEL_GUC_H_
|
|
|
|
#include "intel_uncore.h"
|
|
#include "intel_guc_fw.h"
|
|
#include "intel_guc_fwif.h"
|
|
#include "intel_guc_ct.h"
|
|
#include "intel_guc_log.h"
|
|
#include "intel_guc_reg.h"
|
|
#include "intel_uc_fw.h"
|
|
#include "i915_vma.h"
|
|
|
|
struct guc_preempt_work {
|
|
struct work_struct work;
|
|
struct intel_engine_cs *engine;
|
|
};
|
|
|
|
/*
|
|
* Top level structure of GuC. It handles firmware loading and manages client
|
|
* pool and doorbells. intel_guc owns a intel_guc_client to replace the legacy
|
|
* ExecList submission.
|
|
*/
|
|
struct intel_guc {
|
|
struct intel_uc_fw fw;
|
|
struct intel_guc_log log;
|
|
struct intel_guc_ct ct;
|
|
|
|
/* Log snapshot if GuC errors during load */
|
|
struct drm_i915_gem_object *load_err_log;
|
|
|
|
/* intel_guc_recv interrupt related state */
|
|
bool interrupts_enabled;
|
|
|
|
struct i915_vma *ads_vma;
|
|
struct i915_vma *stage_desc_pool;
|
|
void *stage_desc_pool_vaddr;
|
|
struct ida stage_ids;
|
|
struct i915_vma *shared_data;
|
|
void *shared_data_vaddr;
|
|
|
|
struct intel_guc_client *execbuf_client;
|
|
struct intel_guc_client *preempt_client;
|
|
|
|
struct guc_preempt_work preempt_work[I915_NUM_ENGINES];
|
|
struct workqueue_struct *preempt_wq;
|
|
|
|
DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
|
|
/* Cyclic counter mod pagesize */
|
|
u32 db_cacheline;
|
|
|
|
/* GuC's FW specific registers used in MMIO send */
|
|
struct {
|
|
u32 base;
|
|
unsigned int count;
|
|
enum forcewake_domains fw_domains;
|
|
} send_regs;
|
|
|
|
/* To serialize the intel_guc_send actions */
|
|
struct mutex send_mutex;
|
|
|
|
/* GuC's FW specific send function */
|
|
int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
|
|
|
|
/* GuC's FW specific notify function */
|
|
void (*notify)(struct intel_guc *guc);
|
|
};
|
|
|
|
static
|
|
inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
|
|
{
|
|
return guc->send(guc, action, len);
|
|
}
|
|
|
|
static inline void intel_guc_notify(struct intel_guc *guc)
|
|
{
|
|
guc->notify(guc);
|
|
}
|
|
|
|
/*
|
|
* GuC does not allow any gfx GGTT address that falls into range [0, WOPCM_TOP),
|
|
* which is reserved for Boot ROM, SRAM and WOPCM. Currently this top address is
|
|
* 512K. In order to exclude 0-512K address space from GGTT, all gfx objects
|
|
* used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM.
|
|
*/
|
|
static inline u32 guc_ggtt_offset(struct i915_vma *vma)
|
|
{
|
|
u32 offset = i915_ggtt_offset(vma);
|
|
|
|
GEM_BUG_ON(offset < GUC_WOPCM_TOP);
|
|
GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
|
|
|
|
return offset;
|
|
}
|
|
|
|
void intel_guc_init_early(struct intel_guc *guc);
|
|
void intel_guc_init_send_regs(struct intel_guc *guc);
|
|
void intel_guc_init_params(struct intel_guc *guc);
|
|
int intel_guc_init_wq(struct intel_guc *guc);
|
|
void intel_guc_fini_wq(struct intel_guc *guc);
|
|
int intel_guc_init(struct intel_guc *guc);
|
|
void intel_guc_fini(struct intel_guc *guc);
|
|
int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
|
|
int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
|
|
int intel_guc_sample_forcewake(struct intel_guc *guc);
|
|
int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
|
|
int intel_guc_suspend(struct drm_i915_private *dev_priv);
|
|
int intel_guc_resume(struct drm_i915_private *dev_priv);
|
|
struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
|
|
u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
|
|
|
|
#endif
|