From patchwork Fri Nov 2 10:31:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sharat Masetty X-Patchwork-Id: 10665239 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 47AD014E2 for ; Fri, 2 Nov 2018 10:31:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D252B8B1 for ; Fri, 2 Nov 2018 10:31:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19F842B8A2; Fri, 2 Nov 2018 10:31:47 +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 AE8C42B8D8 for ; Fri, 2 Nov 2018 10:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726084AbeKBTi0 (ORCPT ); Fri, 2 Nov 2018 15:38:26 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36092 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbeKBTi0 (ORCPT ); Fri, 2 Nov 2018 15:38:26 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AB6B06086A; Fri, 2 Nov 2018 10:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541154705; bh=10c5TuG+JlVpZBWL68UwagjfzV8PIVNDO2wy+GVXd5U=; h=From:To:Cc:Subject:Date:From; b=ksWc1WBEVyeqm7Jow2ABLEZM6xrzMvSkhDw6IUMr8hxDfikMORXjkjcvfsruVlOKt TxuwLkWdKv1aK6UjUaQIhgdlYb5d/cEdN+3HMajeZxBoUQFnThx1TR3Jhw93EAmTFj yZB68MzhQZjwZDOJnpoTQ1MaOM9Kn6BCUe+QRj1g= 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 DF3FC6034F; Fri, 2 Nov 2018 10:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541154704; bh=10c5TuG+JlVpZBWL68UwagjfzV8PIVNDO2wy+GVXd5U=; h=From:To:Cc:Subject:Date:From; b=OyGWiIeTIGDNk41CIbFo+zcS+mWegfM5dyrJc/P4RFlFzPR6fMoJXXxXRn84lFpkN WOKjc5zyLK1n4+5/OhrAtFVlH79IpmPBK4UMJKRDk5tUAcvXilxen7q5oFxJ8ibKKL NQznAcinjJOea2fm2GLDy+AFIj06bBYT35I0uKhU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DF3FC6034F 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, jcrouse@codeaurora.org, christian.koenig@amd.com, andrey.grodzovsky@amd.com, Sharat Masetty Subject: [PATCH 1/2] drm/scheduler: Set sched->thread to NULL on failure Date: Fri, 2 Nov 2018 16:01:32 +0530 Message-Id: <1541154693-29623-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 --- drivers/gpu/drm/scheduler/sched_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 1.9.1 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;