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; From patchwork Fri Nov 2 10:31:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sharat Masetty X-Patchwork-Id: 10665243 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 62F4F14E2 for ; Fri, 2 Nov 2018 10:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 438502B7B4 for ; Fri, 2 Nov 2018 10:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 384322B919; Fri, 2 Nov 2018 10:31:51 +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 D0B162B7B4 for ; Fri, 2 Nov 2018 10:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726104AbeKBTia (ORCPT ); Fri, 2 Nov 2018 15:38:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36238 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbeKBTia (ORCPT ); Fri, 2 Nov 2018 15:38:30 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0BDD660B7F; Fri, 2 Nov 2018 10:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541154709; bh=K1KX/22MsF6RQU7q8IW7aYRS46i+xcwGkJVuD2a18bU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzOQjQ8WVQZV0PfgDkCY1l78R539U1BIC0vD85Mg/7gzlYE2g8rr2ez4h+OYHfaaI ootrzG5cjYv8tQJWUPHsmZU5V16x3PnXsAdhAq8GDK4WMR7l2psl1JShMNFjkYoIXb 41yIzpK+XsKY7jbN9oSC2ZDBIOLcv4gYOyDSZI8M= 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 0A6F16029D; Fri, 2 Nov 2018 10:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541154708; bh=K1KX/22MsF6RQU7q8IW7aYRS46i+xcwGkJVuD2a18bU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAmHP+iwm5jYAjCoEIrSanDQL47FggurT80B1VOIjqgvZKNhOjYZMrnAEp66jkcZX 9QzhBm0i0oPIl9R0CLcylLw5Bs2zvaO+7rDokW5pRwrA+ir/hO6A4gHW8Vpz/Uox2e KQTsE2RxpQCF4uisQlw5TseyFF4s4qVMa3T+ANN4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0A6F16029D 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 2/2] drm/scheduler: Add a start_timeout_notify() backend function Date: Fri, 2 Nov 2018 16:01:33 +0530 Message-Id: <1541154693-29623-2-git-send-email-smasetty@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541154693-29623-1-git-send-email-smasetty@codeaurora.org> References: <1541154693-29623-1-git-send-email-smasetty@codeaurora.org> 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 Add an optional backend function op which will let the scheduler clients know when the timeout got scheduled on the scheduler instance. This will help drivers with multiple schedulers(one per ring) measure time spent on the ring accurately, eventually helping with better timeout detection. Signed-off-by: Sharat Masetty --- Here is an example of how I plan to use this new function callback. [1] https://patchwork.freedesktop.org/patch/254227/ drivers/gpu/drm/scheduler/sched_main.c | 7 ++++++- include/drm/gpu_scheduler.h | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index c993d10..afd461e 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -192,8 +192,13 @@ bool drm_sched_dependency_optimized(struct dma_fence* fence, static void drm_sched_start_timeout(struct drm_gpu_scheduler *sched) { if (sched->timeout != MAX_SCHEDULE_TIMEOUT && - !list_empty(&sched->ring_mirror_list)) + !list_empty(&sched->ring_mirror_list)) { + schedule_delayed_work(&sched->work_tdr, sched->timeout); + + if (sched->ops->start_timeout_notify) + sched->ops->start_timeout_notify(sched); + } } /* job_finish is called after hw fence signaled diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index d87b268..faf28b4 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -239,6 +239,12 @@ struct drm_sched_backend_ops { * and it's time to clean it up. */ void (*free_job)(struct drm_sched_job *sched_job); + + /* + * (Optional) Called to let the driver know that a timeout detection + * timer has been started. + */ + void (*start_timeout_notify)(struct drm_gpu_scheduler *sched); }; /**