From patchwork Thu Sep 29 18:01:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12994523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2885C433F5 for ; Thu, 29 Sep 2022 18:02:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5390B10EBBC; Thu, 29 Sep 2022 18:02:00 +0000 (UTC) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by gabe.freedesktop.org (Postfix) with ESMTPS id E54FC10EBBD for ; Thu, 29 Sep 2022 18:01:54 +0000 (UTC) Received: by mail-ej1-x634.google.com with SMTP id dv25so4375343ejb.12 for ; Thu, 29 Sep 2022 11:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=LaEimOJ+lgAKHH6s6K+Wo5MzjV2hXKpsGHLUik//E4Q=; b=DVmma2ghf0EWkhqeApwGvXZR1uhJeLozlil7vTK+JcqOFFye6T3klz/n2SSy16LrWI w0AFDf4ZtjKifkcRt7ZQhnZZeRh4Dle3IONmmIW77q6/aLG/7/fR8ieE+oHHV/dDCbCG RAPQfFRnZlyJcFKj/jvRbLiFU1B1+qcFGb8AcZkl7U3ZBq8ByI5ZN3A82Blk7PM3crq0 2ouowjvnlCc5cYlGy1WOB6480eX7JFQN+6MDtk4PgXswT4kuG93W/4Hi/NfQ4PqWzb1C pKbWQ+9NEuNvL/YDGPrUsImEgGO8bns77f/M+WJzqiCrLbsgmIXo2A9/zbv9+PZrd2Zk MiqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=LaEimOJ+lgAKHH6s6K+Wo5MzjV2hXKpsGHLUik//E4Q=; b=xp2p3ats84+uI4KW723lq3qj3bcYhZEtXszp6f334M3JyV95yqXiYyWPokjSSFz8o/ hi5P4zG3WnW0kbOLSilYHOxMGSfBW+eI1v0ZyU+F/gwm7xD2CpHmwWnyORGK0xw5Cval TKYdum5iyG0MeKwEECGQnTtoECXBrsz7BfJ1Htv6TTbgGbi0Zna1jWleUlnQ4X1E1OiM 1I0kARXP3KTTYwnbi2a64qH+Pz8eGddZb+rYXFgjeBw/K7PvJ9lnFormVzwv+8b8lbD1 cTWkSfuEYRoclLFYlZg+y+h1pOStueb8Pvjp2+I6VwMXg/6yIRKgYK40ZraWiDu8M9SF 0sdQ== X-Gm-Message-State: ACrzQf3JHVKZCMgLL/hJ2wztQzdW7CeMH6r6A+SbOe4OZcfCUCTKTshT vvmOdidWgNO4uyWt3WzyBFQMp5zyVpI= X-Google-Smtp-Source: AMsMyM4hJLCLg+xey5xdCI6B4b/1qshoeMfP320v4CKZMWYaKnb66om+iXgEnhx9zz6pp9LZ6MPbqg== X-Received: by 2002:a17:907:3f8b:b0:782:3668:3d26 with SMTP id hr11-20020a1709073f8b00b0078236683d26mr3652100ejc.85.1664474513416; Thu, 29 Sep 2022 11:01:53 -0700 (PDT) Received: from able.fritz.box (p4fc20ebf.dip0.t-ipconnect.de. [79.194.14.191]) by smtp.gmail.com with ESMTPSA id u1-20020a1709061da100b0078194737761sm4255257ejh.124.2022.09.29.11.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 11:01:52 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: steven.price@arm.com, andrey.grodzovsky@amd.com, Arunpravin.PaneerSelvam@amd.com, luben.tuikov@amd.com, dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/scheduler: fix fence ref counting Date: Thu, 29 Sep 2022 20:01:50 +0200 Message-Id: <20220929180151.139751-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We leaked dependency fences when processes were beeing killed. Additional to that grab a reference to the last scheduled fence. Signed-off-by: Christian König --- drivers/gpu/drm/scheduler/sched_entity.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 6b25b2f4f5a3..7ef1a086a6fb 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -207,6 +207,7 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, struct drm_sched_job *job = container_of(cb, struct drm_sched_job, finish_cb); + dma_fence_put(f); INIT_WORK(&job->work, drm_sched_entity_kill_jobs_work); schedule_work(&job->work); } @@ -234,8 +235,10 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity) struct drm_sched_fence *s_fence = job->s_fence; /* Wait for all dependencies to avoid data corruptions */ - while ((f = drm_sched_job_dependency(job, entity))) + while ((f = drm_sched_job_dependency(job, entity))) { dma_fence_wait(f, false); + dma_fence_put(f); + } drm_sched_fence_scheduled(s_fence); dma_fence_set_error(&s_fence->finished, -ESRCH); @@ -250,6 +253,7 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity) continue; } + dma_fence_get(entity->last_scheduled); r = dma_fence_add_callback(entity->last_scheduled, &job->finish_cb, drm_sched_entity_kill_jobs_cb); From patchwork Thu Sep 29 18:01:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12994524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0B46C433F5 for ; Thu, 29 Sep 2022 18:02:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D782D10EBBE; Thu, 29 Sep 2022 18:02:15 +0000 (UTC) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by gabe.freedesktop.org (Postfix) with ESMTPS id 809C410EBBC for ; Thu, 29 Sep 2022 18:01:56 +0000 (UTC) Received: by mail-ej1-x629.google.com with SMTP id l14so4385009eja.7 for ; Thu, 29 Sep 2022 11:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=vKrojTcjZlq5ovm1PnlomIL4uPYCEBj7pdWzDdAXuVU=; b=S0Ve7O5awQLtxuoHxPScZBKhG0jjkU1ylWU2jel947LK4gh1H/Z8R9mBq0lH7db2+r SHYOF25ofWveZuZK+KSB4jZWtMFinIjwXQNQmfHH2VChGOO8SZdBTPI9XgDo0d+hYvbv bqwnq9QXiLMRmzL1hJCOIdyFBo6XV0Fw2V9/T+QqNoKTbqalP+JpBlgZxOw2D0ZWG2/Y 2UyaX7cNr4sGhRpafxDZD4pNGhWlzBv2ig+dY7WFey70nCg60VerGJ5bd6G0wcHsDh/D LYBV7xrMdWKdIvN6LEXPVFr7U8/nD9zn9n1R1dGE57/kmONCsbQZnE/DSQCxtwSIGnIW 4Z4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=vKrojTcjZlq5ovm1PnlomIL4uPYCEBj7pdWzDdAXuVU=; b=BACtf9h23jTp9ZIymaULVGPHasTnoHw81nzSWi3YYGvxeTtvsM8D5MpTdS8NcWsMO9 4hnw59AZKYddXnbRlchCL05wwkNnwe6ZUrnJ8BtgC/YcVZVCAWIMy8KoTTI0AKx4H4Lw KGfuUcFyzjtWzHmiQiG3rlrUdV2Hgzv6NqT4Bbdug9N2GsNme1j74v4nGryAmXUnNmEf gnDuujAaWipeo/EbtGrg7PAVGfNPCqrh9Iqx2ChLO1zo2IrMh8c+7RxFZOPCcdwEofNi kAHzDBk61Y6Q3H8HKRj62aiJeNkdsjJ/48XXo1zDboMVXIpBD/a3V6soZmgEhqeKHC8/ PDTQ== X-Gm-Message-State: ACrzQf3YvpnfO7ZLUYrIP8nI2615IgjpBk+GmcJgAEVi3N9W97J/18KW sLeNap+lbPxT+czZyIFBEPk= X-Google-Smtp-Source: AMsMyM4agEK4P11sLpEk4lMriKcGrbDCr33apCs3G+q+igvP8lryJyJAolio04D6h/ynis34LI8YVQ== X-Received: by 2002:a17:907:2c41:b0:787:6d66:b593 with SMTP id hf1-20020a1709072c4100b007876d66b593mr3761357ejc.401.1664474514662; Thu, 29 Sep 2022 11:01:54 -0700 (PDT) Received: from able.fritz.box (p4fc20ebf.dip0.t-ipconnect.de. [79.194.14.191]) by smtp.gmail.com with ESMTPSA id u1-20020a1709061da100b0078194737761sm4255257ejh.124.2022.09.29.11.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 11:01:54 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: steven.price@arm.com, andrey.grodzovsky@amd.com, Arunpravin.PaneerSelvam@amd.com, luben.tuikov@amd.com, dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/sched: add missing NULL check in drm_sched_get_cleanup_job Date: Thu, 29 Sep 2022 20:01:51 +0200 Message-Id: <20220929180151.139751-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220929180151.139751-1-christian.koenig@amd.com> References: <20220929180151.139751-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Otherwise we would crash if the job is not resubmitted. Signed-off-by: Christian König --- drivers/gpu/drm/scheduler/sched_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 4f2395d1a791..23e5e8275dc7 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -829,7 +829,8 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) job = list_first_entry_or_null(&sched->pending_list, struct drm_sched_job, list); - if (job && dma_fence_is_signaled(job->s_fence->parent)) { + if (job && (!job->s_fence->parent || + dma_fence_is_signaled(job->s_fence->parent))) { /* remove job from pending_list */ list_del_init(&job->list);