From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com ([192.55.52.43]:47586 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732045AbeG0Dgy (ORCPT ); Thu, 26 Jul 2018 23:36:54 -0400 Subject: Re: [PATCH] drm/i915/gvt: initialize dmabuf mutex in vgpu_create To: intel-gvt-dev-bounces@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org Cc: stable@vger.kernel.org, tina.zhang@intel.com References: <1532603080-8896-1-git-send-email-hang.yuan@linux.intel.com> From: Hang Yuan Message-ID: <29c35f50-ad15-7695-d188-a86466015646@linux.intel.com> Date: Fri, 27 Jul 2018 10:13:12 +0800 MIME-Version: 1.0 In-Reply-To: <1532603080-8896-1-git-send-email-hang.yuan@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: Sorry please ignore this patch. It needs more investigation on the cause. Regards, Henry On 07/26/2018 07:04 PM, intel-gvt-dev-bounces@lists.freedesktop.org wrote: > From: Hang Yuan > > When create one vgpu device and then remove it, oops as below happens. > It's because dmabuf mutex is not initialized if don't open vgpu device. > This patch will initialize dmabuf mutex during creating vgpu to avoid > the oops. > > BUG: unable to handle kernel NULL pointer dereference at (null) > IP: [] __list_add+0x1b/0xc0 > PGD 0 > Oops: 0000 [#1] SMP > Workqueue: sysfsd sysfs_schedule_callback_work > task: ffff8944fdee1040 ti: ffff89405360c000 task.ti: ffff89405360c000 > RIP: 0010:[] [] __list_add+0x1b/0xc0 > RSP: 0018:ffff89405360fc88 EFLAGS: 00010246 > RAX: 00000000ffffffff RBX: ffff89405360fcb0 RCX: 0000000000000000 > RDX: ffffab1f4371abb8 RSI: 0000000000000000 RDI: ffff89405360fcb0 > RBP: ffff89405360fca0 R08: 0000000000000000 R09: 000000018040002e > R10: 0000000051ab3901 R11: ffffe5658e46acc0 R12: ffffab1f4371abb8 > R13: 0000000000000000 R14: 00000000ffffffff R15: ffffab1f4371abb8 > FS: 0000000000000000(0000) GS:ffff8945314c0000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000000000000000 CR3: 00000001eae0e000 CR4: 00000000003607e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > [] __mutex_lock_slowpath+0xa6/0x1d0 > [] ? __vunmap+0x94/0x100 > [] mutex_lock+0x1f/0x2f > [] intel_vgpu_dmabuf_cleanup+0x3a/0xe0 [i915] > [] intel_gvt_destroy_vgpu+0xa4/0x100 [i915] > [] intel_vgpu_remove+0x30/0x40 [kvmgt] > [] mdev_device_remove_ops+0x29/0x60 [mdev] > [] mdev_device_remove+0x96/0x130 [mdev] > [] remove_callback+0x14/0x30 [mdev] > [] sysfs_schedule_callback_work+0x1e/0x60 > [] process_one_work+0x17f/0x440 > [] worker_thread+0x126/0x3c0 > [] ? manage_workers.isra.24+0x2a0/0x2a0 > [] kthread+0xd1/0xe0 > [] ? insert_kthread_work+0x40/0x40 > [] ret_from_fork_nospec_begin+0x7/0x21 > [] ? insert_kthread_work+0x40/0x40 > Code: ff ff ff 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 55 48 89 e5 41 55 49 89 f5 41 54 49 89 d4 53 4c 8b 42 08 48 89 fb 49 39 f0 75 2a <4d> 8b 45 00 4d 39 c4 75 68 4c 39 e3 74 3e 4c 39 eb 74 39 49 89 > RIP [] __list_add+0x1b/0xc0 > > Fixes: e546e281d33d("drm/i915/gvt: Dmabuf support for GVT-g") > Signed-off-by: Hang Yuan > --- > drivers/gpu/drm/i915/gvt/kvmgt.c | 1 - > drivers/gpu/drm/i915/gvt/vgpu.c | 1 + > 2 files changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c > index a22d539..cbdf915e 100644 > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c > @@ -1615,7 +1615,6 @@ static int kvmgt_guest_init(struct mdev_device *mdev) > kvmgt_protect_table_init(info); > gvt_cache_init(vgpu); > > - mutex_init(&vgpu->dmabuf_lock); > init_completion(&vgpu->vblank_done); > > info->track_node.track_write = kvmgt_page_track_write; > diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c > index f6fa916..0bc1f1e 100644 > --- a/drivers/gpu/drm/i915/gvt/vgpu.c > +++ b/drivers/gpu/drm/i915/gvt/vgpu.c > @@ -361,6 +361,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, > vgpu->gvt = gvt; > vgpu->sched_ctl.weight = param->weight; > mutex_init(&vgpu->vgpu_lock); > + mutex_init(&vgpu->dmabuf_lock); > INIT_LIST_HEAD(&vgpu->dmabuf_obj_list_head); > INIT_RADIX_TREE(&vgpu->page_track_tree, GFP_KERNEL); > idr_init(&vgpu->object_idr); >