From patchwork Tue Sep 18 16:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10604551 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 BC4FC15A6 for ; Tue, 18 Sep 2018 16:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA2E22B241 for ; Tue, 18 Sep 2018 16:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C2152B391; Tue, 18 Sep 2018 16:17:53 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 3A68C2B241 for ; Tue, 18 Sep 2018 16:17:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 979C16E427; Tue, 18 Sep 2018 16:17:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BABA6E41D for ; Tue, 18 Sep 2018 16:17:49 +0000 (UTC) Received: by mail-pg1-x529.google.com with SMTP id 2-v6so1281486pgo.4 for ; Tue, 18 Sep 2018 09:17:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pOd8P2B8M0m+lrnS2r/Odp5h+t6o0LMKY07AdtvKJ3U=; b=J0NY5/BF9w+yybWNT8Q5JFN7+rH8lGnYt9NgrzMNvKqyIg84gVtdUH7JSUP5JaDyTZ rIkjYIoOCOvk5yti0SRh96xHFLcMaKgQfq58UxqRGHlnjyfM3hAOnXJc2+yNkjlIVcw1 2AkbdfL2v4ddEJfTRo4d6wovZSK1bNQy9Bq1brAkJ5CAXzuIN7zl5ZggNhCq/FAT9QId P4DgMYGd7vnsVEsukso7a6CeUAW5YyLamEYCNm3Um0DUANKEgt/BO6941LlFcI5tKXVZ kbuNuAwsOKwXvLrJKPNQHbQaWqYyw7aoAY/dcXxzrrFV9dVufWL+GJLFZeWbKHB0B4kP HV4w== X-Gm-Message-State: APzg51DZwENuLkuBHbCjgq0sv2ol085+HQXO71HpgqTb3+/MA+QB3XZh w2GKydgNSTGnF/IbDbC1HlUR+coM X-Google-Smtp-Source: ANB0VdZkjSqSMXyAV1lXgTi8c6dNYLg5xjF3vEOlrUJimDCy3NnsbJrTzPYgPFJdorh8vs/H6wqFLg== X-Received: by 2002:a63:4745:: with SMTP id w5-v6mr29092537pgk.140.1537287468527; Tue, 18 Sep 2018 09:17:48 -0700 (PDT) Received: from localhost.localdomain ([219.240.253.225]) by smtp.gmail.com with ESMTPSA id e14-v6sm20596416pgv.48.2018.09.18.09.17.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Sep 2018 09:17:47 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/scheduler: add a current job field to scheduler Date: Wed, 19 Sep 2018 01:17:09 +0900 Message-Id: <20180918161710.2669-1-nayan26deshmukh@gmail.com> X-Mailer: git-send-email 2.14.3 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nayan Deshmukh , christian.koenig@amd.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Which points to the job running on the hardware. This is useful when we need to access the currently executing job from the scheduler. Signed-off-by: Nayan Deshmukh --- drivers/gpu/drm/scheduler/sched_main.c | 17 +++++++++++------ include/drm/gpu_scheduler.h | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 9ca741f3a0bc..0e6ccc8243db 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -189,6 +189,7 @@ static void drm_sched_job_finish(struct work_struct *work) struct drm_sched_job *s_job = container_of(work, struct drm_sched_job, finish_work); struct drm_gpu_scheduler *sched = s_job->sched; + struct drm_sched_job *next; /* * Canceling the timeout without removing our job from the ring mirror @@ -201,10 +202,10 @@ static void drm_sched_job_finish(struct work_struct *work) spin_lock(&sched->job_list_lock); /* queue TDR for next job */ + next = list_next_entry(s_job, node); + sched->curr_job = next; if (sched->timeout != MAX_SCHEDULE_TIMEOUT && !list_is_last(&s_job->node, &sched->ring_mirror_list)) { - struct drm_sched_job *next = list_next_entry(s_job, node); - if (!dma_fence_is_signaled(&next->s_fence->finished)) schedule_delayed_work(&next->work_tdr, sched->timeout); } @@ -233,10 +234,12 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job) spin_lock(&sched->job_list_lock); list_add_tail(&s_job->node, &sched->ring_mirror_list); - if (sched->timeout != MAX_SCHEDULE_TIMEOUT && - list_first_entry_or_null(&sched->ring_mirror_list, - struct drm_sched_job, node) == s_job) - schedule_delayed_work(&s_job->work_tdr, sched->timeout); + if (list_first_entry_or_null(&sched->ring_mirror_list, + struct drm_sched_job, node) == s_job) { + if (sched->timeout != MAX_SCHEDULE_TIMEOUT) + schedule_delayed_work(&s_job->work_tdr, sched->timeout); + sched->curr_job = s_job; + } spin_unlock(&sched->job_list_lock); } @@ -316,6 +319,8 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) struct drm_sched_job, node); if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) schedule_delayed_work(&s_job->work_tdr, sched->timeout); + if (s_job) + sched->curr_job = s_job; list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { struct drm_sched_fence *s_fence = s_job->s_fence; diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index daec50f887b3..07e776b1ca42 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -252,6 +252,7 @@ struct drm_sched_backend_ops { * @timeout: the time after which a job is removed from the scheduler. * @name: name of the ring for which this scheduler is being used. * @sched_rq: priority wise array of run queues. + * @curr_job: points to the job currently running on the hardware * @wake_up_worker: the wait queue on which the scheduler sleeps until a job * is ready to be scheduled. * @job_scheduled: once @drm_sched_entity_do_release is called the scheduler @@ -274,6 +275,7 @@ struct drm_gpu_scheduler { long timeout; const char *name; struct drm_sched_rq sched_rq[DRM_SCHED_PRIORITY_MAX]; + struct drm_sched_job *curr_job; wait_queue_head_t wake_up_worker; wait_queue_head_t job_scheduled; atomic_t hw_rq_count; From patchwork Tue Sep 18 16:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nayan Deshmukh X-Patchwork-Id: 10604555 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 8905315E8 for ; Tue, 18 Sep 2018 16:17:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F5AC28B24 for ; Tue, 18 Sep 2018 16:17:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61A8E286C7; Tue, 18 Sep 2018 16:17: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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 5D3512B241 for ; Tue, 18 Sep 2018 16:17:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2D346E42A; Tue, 18 Sep 2018 16:17:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4311B6E42A for ; Tue, 18 Sep 2018 16:17:51 +0000 (UTC) Received: by mail-pl1-x642.google.com with SMTP id s17-v6so1238919plp.7 for ; Tue, 18 Sep 2018 09:17:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WsmYcL4/cNCbBnygsLBggY6fQYPaPadbRJV8jtyyagk=; b=XtAl2uXPfv0ESt03JaKOCAcNLDOs2WBhTa0nbETmkNilbDlM0olCZ2HkSDqpo5JuWA C0HzpEqlUxQrXdQJzpOTC7xQq/hS1vpozdcLGZFiTsAZNH4F1MM+3wt9YP3bP0ri+s4I VjIbDr4yGkNKxBTLZmIYN56ZWML1HMpymzlaxNSqnFyqpPfCNoeJlKP1gtT6wkqHArZn 06Pa0gnBU82AShdu4Pb8O/Xh5eTL5RGy0npkl+qzam77b2AtrZ7DHlJjlILlu42VKTUp g2l9qaoDGskSCADt/+n/Hz9l+98DS5YGGrfF32cE4DAWcPiYjVsKHGuW0CEs0SVDAtDp aT6Q== X-Gm-Message-State: APzg51Cz4fRXyPWZ1s1jaHDUGTPSj7hzVrRE2N4KbJCZFSR9TMGrtdoh GU62B4ljhrzG0idyiCqhU8rbibDb X-Google-Smtp-Source: ANB0VdascR/L1epSjbklDRBjDElmET2kn2WS0yCfijooPket2M5deq+d0zgCYaE0AeQQ9P3o9GpGdQ== X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr30754675plg.152.1537287470414; Tue, 18 Sep 2018 09:17:50 -0700 (PDT) Received: from localhost.localdomain ([219.240.253.225]) by smtp.gmail.com with ESMTPSA id e14-v6sm20596416pgv.48.2018.09.18.09.17.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Sep 2018 09:17:49 -0700 (PDT) From: Nayan Deshmukh To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/scheduler: remove timeout work_struct from drm_sched_job Date: Wed, 19 Sep 2018 01:17:10 +0900 Message-Id: <20180918161710.2669-2-nayan26deshmukh@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180918161710.2669-1-nayan26deshmukh@gmail.com> References: <20180918161710.2669-1-nayan26deshmukh@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nayan Deshmukh , christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP having a delayed work item per job is redundant as we only need one per scheduler to track the time out the currently executing job. Signed-off-by: Nayan Deshmukh Suggested-by: Christian König --- drivers/gpu/drm/scheduler/sched_main.c | 16 +++++++++------- include/drm/gpu_scheduler.h | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 0e6ccc8243db..f213b5c7f718 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -198,7 +198,7 @@ static void drm_sched_job_finish(struct work_struct *work) * manages to find this job as the next job in the list, the fence * signaled check below will prevent the timeout to be restarted. */ - cancel_delayed_work_sync(&s_job->work_tdr); + cancel_delayed_work_sync(&sched->work_tdr); spin_lock(&sched->job_list_lock); /* queue TDR for next job */ @@ -207,7 +207,7 @@ static void drm_sched_job_finish(struct work_struct *work) if (sched->timeout != MAX_SCHEDULE_TIMEOUT && !list_is_last(&s_job->node, &sched->ring_mirror_list)) { if (!dma_fence_is_signaled(&next->s_fence->finished)) - schedule_delayed_work(&next->work_tdr, sched->timeout); + schedule_delayed_work(&sched->work_tdr, sched->timeout); } /* remove job from ring_mirror_list */ list_del(&s_job->node); @@ -237,7 +237,7 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job) if (list_first_entry_or_null(&sched->ring_mirror_list, struct drm_sched_job, node) == s_job) { if (sched->timeout != MAX_SCHEDULE_TIMEOUT) - schedule_delayed_work(&s_job->work_tdr, sched->timeout); + schedule_delayed_work(&sched->work_tdr, sched->timeout); sched->curr_job = s_job; } spin_unlock(&sched->job_list_lock); @@ -245,8 +245,10 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job) static void drm_sched_job_timedout(struct work_struct *work) { - struct drm_sched_job *job = container_of(work, struct drm_sched_job, - work_tdr.work); + struct drm_gpu_scheduler *sched = container_of(work, + struct drm_gpu_scheduler, + work_tdr.work); + struct drm_sched_job *job = sched->curr_job; job->sched->ops->timedout_job(job); } @@ -318,7 +320,7 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) s_job = list_first_entry_or_null(&sched->ring_mirror_list, struct drm_sched_job, node); if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) - schedule_delayed_work(&s_job->work_tdr, sched->timeout); + schedule_delayed_work(&sched->work_tdr, sched->timeout); if (s_job) sched->curr_job = s_job; @@ -389,7 +391,6 @@ int drm_sched_job_init(struct drm_sched_job *job, INIT_WORK(&job->finish_work, drm_sched_job_finish); INIT_LIST_HEAD(&job->node); - INIT_DELAYED_WORK(&job->work_tdr, drm_sched_job_timedout); return 0; } @@ -580,6 +581,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched, INIT_LIST_HEAD(&sched->ring_mirror_list); spin_lock_init(&sched->job_list_lock); atomic_set(&sched->hw_rq_count, 0); + INIT_DELAYED_WORK(&sched->work_tdr, drm_sched_job_timedout); atomic_set(&sched->num_jobs, 0); atomic64_set(&sched->job_id_count, 0); diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 07e776b1ca42..9d50d7f3eaa4 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -175,8 +175,6 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f); * finished to remove the job from the * @drm_gpu_scheduler.ring_mirror_list. * @node: used to append this struct to the @drm_gpu_scheduler.ring_mirror_list. - * @work_tdr: schedules a delayed call to @drm_sched_job_timedout after the timeout - * interval is over. * @id: a unique id assigned to each job scheduled on the scheduler. * @karma: increment on every hang caused by this job. If this exceeds the hang * limit of the scheduler then the job is marked guilty and will not @@ -195,7 +193,6 @@ struct drm_sched_job { struct dma_fence_cb finish_cb; struct work_struct finish_work; struct list_head node; - struct delayed_work work_tdr; uint64_t id; atomic_t karma; enum drm_sched_priority s_priority; @@ -260,6 +257,8 @@ struct drm_sched_backend_ops { * finished. * @hw_rq_count: the number of jobs currently in the hardware queue. * @job_id_count: used to assign unique id to the each job. + * @work_tdr: schedules a delayed call to @drm_sched_job_timedout after the + * timeout interval is over. * @thread: the kthread on which the scheduler which run. * @ring_mirror_list: the list of jobs which are currently in the job queue. * @job_list_lock: lock to protect the ring_mirror_list. @@ -280,6 +279,7 @@ struct drm_gpu_scheduler { wait_queue_head_t job_scheduled; atomic_t hw_rq_count; atomic64_t job_id_count; + struct delayed_work work_tdr; struct task_struct *thread; struct list_head ring_mirror_list; spinlock_t job_list_lock;