From patchwork Thu Nov 29 10:05:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sharat Masetty X-Patchwork-Id: 10704279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74EA2109C for ; Thu, 29 Nov 2018 10:05:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65FBB2E081 for ; Thu, 29 Nov 2018 10:05:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A6442E09B; Thu, 29 Nov 2018 10:05:32 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE7B2E081 for ; Thu, 29 Nov 2018 10:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726879AbeK2VKS (ORCPT ); Thu, 29 Nov 2018 16:10:18 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:45410 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbeK2VKS (ORCPT ); Thu, 29 Nov 2018 16:10:18 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0B26260B7A; Thu, 29 Nov 2018 10:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1543485930; bh=sHAJ9dA8QuV+S1Fh8N2VFAmtzlDXh7GsS0dH3RkMbVw=; h=From:To:Cc:Subject:Date:From; b=fT1CJ5KWqwjwMVY3B8pDlZBzZfYyxakWE0NlApup8OJu3ihEsQNB8cz9ycrIvA0vA pXIF0RWr7tcuYn5kGnUyu3gNflzMtUYC1DzNuwZm5//08U5CnaVEGRS4yCGNDpup+g FOPgZGQqdsErcAG1hYQIFjXqnyOPNZ1Ft2WFNKeA= Received: from smasetty-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: smasetty@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A007D601D1; Thu, 29 Nov 2018 10:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1543485929; bh=sHAJ9dA8QuV+S1Fh8N2VFAmtzlDXh7GsS0dH3RkMbVw=; h=From:To:Cc:Subject:Date:From; b=QQWDH8zM2A0qiJNdcPJux+pQH/NhsnPCreDdJUBztJHuxiRwszeqx6Pi4v4umLzwD zXF+/vvWHSJR++Zd54XJpXoVL/WHhVSVr12eid6OVLQnbqAQDmCr/VcvQfiRvXaKe4 EAcBUb7Ju22/1vSKXU9ALYPG9rTCGlaIAaiEf+RE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A007D601D1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=smasetty@codeaurora.org From: Sharat Masetty To: freedreno@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, christian.koenig@amd.com, Sharat Masetty Subject: [PATCH 1/2] drm/scheduler: Set sched->thread to NULL on failure Date: Thu, 29 Nov 2018 15:35:19 +0530 Message-Id: <1543485920-28037-1-git-send-email-smasetty@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In cases where the scheduler instance is used as a base object of another driver object, it's not clear if the driver can call scheduler cleanup on the fail path. So, Set the sched->thread to NULL, so that the driver can safely call drm_sched_fini() during cleanup. Signed-off-by: Sharat Masetty Reviewed-by: Christian König --- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 44fe587..c993d10 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -594,7 +594,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, long timeout, const char *name) { - int i; + int i, ret; sched->ops = ops; sched->hw_submission_limit = hw_submission; sched->name = name; @@ -615,8 +615,10 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, /* Each scheduler will run on a seperate kernel thread */ sched->thread = kthread_run(drm_sched_main, sched, sched->name); if (IS_ERR(sched->thread)) { + ret = PTR_ERR(sched->thread); + sched->thread = NULL; DRM_ERROR("Failed to create scheduler for %s.\n", name); - return PTR_ERR(sched->thread); + return ret; } return 0;