From patchwork Fri Dec 23 05:46:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Du, Changbin" X-Patchwork-Id: 9487211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F333601C0 for ; Fri, 23 Dec 2016 05:47:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EA0726E69 for ; Fri, 23 Dec 2016 05:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 700382756B; Fri, 23 Dec 2016 05:47:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F40E226E69 for ; Fri, 23 Dec 2016 05:47:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 98CBA6E04D; Fri, 23 Dec 2016 05:47:56 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C7A26E025; Fri, 23 Dec 2016 05:47:54 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 22 Dec 2016 21:47:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,392,1477983600"; d="scan'208"; a="1085810392" Received: from vgt-dell.bj.intel.com ([10.238.135.60]) by fmsmga001.fm.intel.com with ESMTP; 22 Dec 2016 21:47:51 -0800 From: changbin.du@intel.com To: daniel.vetter@intel.com Date: Fri, 23 Dec 2016 13:46:36 +0800 Message-Id: <20161223054636.3924-1-changbin.du@intel.com> X-Mailer: git-send-email 2.7.4 Cc: airlied@linux.ie, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH] drm/i915: check if execlist_port is empty before using its content X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: "Du, Changbin" This patch fix a crash in function reset_common_ring. In this case, the port[0].request is null when reset the render ring, so a null dereference exception is raised. We need to check execlist_port status first. [ 35.748034] BUG: unable to handle kernel NULL pointer dereference at 0000000000000070 [ 35.749567] IP: [] reset_common_ring+0xbe/0x150 [ 35.749567] Call Trace: [ 35.749567] [] i915_gem_reset+0x150/0x270 [ 35.749567] [] i915_reset+0x8a/0xe0 [ 35.749567] [] i915_reset_and_wakeup+0x131/0x160 [ 35.749567] [] ? gen5_read8+0x110/0x110 [ 35.749567] [] i915_handle_error+0xca/0x5a0 [ 35.749567] [] ? scnprintf+0x3d/0x70 [ 35.749567] [] i915_hangcheck_elapsed+0x213/0x510 [ 35.749567] [] process_one_work+0x15b/0x470 [ 35.749567] [] worker_thread+0x43/0x4d0 [ 35.749567] [] ? process_one_work+0x470/0x470 [ 35.749567] [] ? process_one_work+0x470/0x470 [ 35.749567] [] ? call_usermodehelper_exec_async+0x12e/0x130 [ 35.749567] [] kthread+0xc5/0xe0 [ 35.749567] [] ? kthread_park+0x60/0x60 [ 35.749567] [] ? umh_complete+0x40/0x40 [ 35.749567] [] ret_from_fork+0x22/0x30 Signed-off-by: Changbin Du --- drivers/gpu/drm/i915/intel_lrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 0a09024..81a9b0b 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -1450,7 +1450,7 @@ static void reset_common_ring(struct intel_engine_cs *engine, /* Catch up with any missed context-switch interrupts */ I915_WRITE(RING_CONTEXT_STATUS_PTR(engine), _MASKED_FIELD(0xffff, 0)); - if (request->ctx != port[0].request->ctx) { + if (!execlists_elsp_idle(engine) && request->ctx != port[0].request->ctx) { i915_gem_request_put(port[0].request); port[0] = port[1]; memset(&port[1], 0, sizeof(port[1]));