From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC265C4338F for ; Sun, 8 Aug 2021 00:56:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6437360EBC for ; Sun, 8 Aug 2021 00:56:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6437360EBC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jlekstrand.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C855989CD4; Sun, 8 Aug 2021 00:56:35 +0000 (UTC) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C04689CD4 for ; Sun, 8 Aug 2021 00:56:35 +0000 (UTC) Received: by mail-ot1-x32c.google.com with SMTP id v24-20020a0568300918b02904f3d10c9742so10312285ott.4 for ; Sat, 07 Aug 2021 17:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:date:message-id:in-reply-to:references:user-agent :subject:mime-version; bh=i/6vWg32QPyQ4//6RJebPl2hvp7J0WxK/H30S/OTM4o=; b=PNqe//k1WmXmza+OTQ8A/Cw2nv0Ak/fv8H3mIjckAMAtHn1edRo0Pfma69vPtiYY9E o/4riVqL7LAOFLsChWo9ID/WW+c0IwOadZP/IaOrw9xEzPM9gYqQ5r5YlWLE/WOHF/dg obfmW1/A6j2hU7J929ptWVjbirm2aFiwmd54nXnMP5n3SsTHfPqRj8QN0RxHH1DIQrjj xKwG12Co5JnGU03opW3io+Y2/TcWwZAefmPRPLw85eJ2VQ4b/4/CiXmwmQD8kR17Dsv9 M5ST+qh/2G9udbAlvzJ85kCWT4JIZOLe+wEUHPPSlhb8fcaANKcn6CLUfhi8o5XOKnOv Q3aw== 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:date:message-id:in-reply-to :references:user-agent:subject:mime-version; bh=i/6vWg32QPyQ4//6RJebPl2hvp7J0WxK/H30S/OTM4o=; b=nXUU+1oAMELjzk6qxIWI9Y9kcsZf7AZTQ/EOW8Bc28HV6osWttorl4hfBubNaLuFIr 2kFVbGl696xOgbGB4/4ePRhZHDpbXmB5ewd0A74thZ6GXh5g8qa0y2sDlktk0ty26SM6 qUEMV7yJArxcev8qakOTRSuVjRLkkYeZbuE/kAMfWB1SB7UhpVTLWgB9TDyHgMkFvVkF TlUq33DnKw3UO6isiM/6NkXS4PBEfH3bXfP1Eq3u5CnfmzPoOj40Q5jAMClRCbzFPEKn ihDX7Ko3QwUeBNok7sz2kM4hTsxyH2agVth55yr7ALisd5VphZ+LI7Rv/xgzeR6r0zXb bE+A== X-Gm-Message-State: AOAM531BrpKGlZHtTUfmA11FEnd67FHSGbpb7wZVg2C0MLRb7JPP/rzN RQTp3BeLuVcen/e9UJG89pKpWg== X-Google-Smtp-Source: ABdhPJzDfVkdZ0580/x/YMWLVFiS07sLwtxxd9OOkYVjDfQAnRQYUmimEnvlKvq2hYliTsq4e3AwOw== X-Received: by 2002:a05:6830:114:: with SMTP id i20mr11952964otp.306.1628384194242; Sat, 07 Aug 2021 17:56:34 -0700 (PDT) Received: from [192.168.5.100] ([68.203.99.148]) by smtp.gmail.com with ESMTPSA id g1sm2378747otk.21.2021.08.07.17.56.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Aug 2021 17:56:33 -0700 (PDT) From: Jason Ekstrand To: Daniel Vetter , Intel Graphics Development CC: DRI Development , Daniel Vetter , Chris Wilson , Tvrtko Ursulin , Joonas Lahtinen , Matthew Brost , Matthew Auld , Maarten Lankhorst , =?UTF-8?B?VGhvbWFzIEhlbGxzdHLDtm0=?= , Lionel Landwerlin , Dave Airlie Date: Sat, 07 Aug 2021 19:56:32 -0500 Message-ID: <17b2342e218.2817.c6988b7ea6112e3e892765a0d4287e0c@jlekstrand.net> In-Reply-To: <20210806201852.1345184-1-daniel.vetter@ffwll.ch> References: <20210806201852.1345184-1-daniel.vetter@ffwll.ch> User-Agent: AquaMail/1.30.1-1828 (build: 103001000) Subject: Re: [PATCH] drm/i915: Release ctx->syncobj on final put, not on ctx close MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="17b2342e62f3ecc28176037462" 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is a multi-part message in MIME format. --17b2342e62f3ecc28176037462 Content-Type: text/plain; format=flowed; charset="UTF-8" Content-Transfer-Encoding: 8bit On August 6, 2021 15:18:59 Daniel Vetter wrote: > gem context refcounting is another exercise in least locking design it > seems, where most things get destroyed upon context closure (which can > race with anything really). Only the actual memory allocation and the > locks survive while holding a reference. > > This tripped up Jason when reimplementing the single timeline feature > in > > commit 00dae4d3d35d4f526929633b76e00b0ab4d3970d > Author: Jason Ekstrand > Date: Thu Jul 8 10:48:12 2021 -0500 > > drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4) > > We could fix the bug by holding ctx->mutex, but it's cleaner to just What bug is this fixing, exactly? --Jason > > make the context object actually invariant over its _entire_ lifetime. > > Signed-off-by: Daniel Vetter > Fixes: 00dae4d3d35d ("drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4)") > Cc: Jason Ekstrand > Cc: Chris Wilson > Cc: Tvrtko Ursulin > Cc: Joonas Lahtinen > Cc: Matthew Brost > Cc: Matthew Auld > Cc: Maarten Lankhorst > Cc: "Thomas Hellström" > Cc: Lionel Landwerlin > Cc: Dave Airlie > --- > drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c > b/drivers/gpu/drm/i915/gem/i915_gem_context.c > index 754b9b8d4981..93ba0197d70a 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c > @@ -940,6 +940,9 @@ void i915_gem_context_release(struct kref *ref) > trace_i915_context_free(ctx); > GEM_BUG_ON(!i915_gem_context_is_closed(ctx)); > > + if (ctx->syncobj) > + drm_syncobj_put(ctx->syncobj); > + > mutex_destroy(&ctx->engines_mutex); > mutex_destroy(&ctx->lut_mutex); > > @@ -1159,9 +1162,6 @@ static void context_close(struct i915_gem_context *ctx) > if (vm) > i915_vm_close(vm); > > - if (ctx->syncobj) > - drm_syncobj_put(ctx->syncobj); > - > ctx->file_priv = ERR_PTR(-EBADF); > > /* > -- > 2.32.0 --17b2342e62f3ecc28176037462 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On August 6, 2021 15:18:= 59 Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

gem context refcounting is another exercise in least lock= ing design it
seems, where most things get destroyed upon context closu= re (which can
race with anything really). Only the actual memory alloca= tion and the
locks survive while holding a reference.

This tripped up Jason when reimplementing the single time= line feature
in

commit 00dae4d3d35d4f526929633b76e00b0ab4d3970d
Author: Jason Ekstrand <jason@jlekstrand.net>
Date:   Thu Jul 8 10:48:12 2021 -0500

    drm/i915: Implement SINGLE_TIMELINE with a = syncobj (v4)

We could fix the bug by holding ctx->mutex, but it's c= leaner to just

What bug is this fixing, exactly?

--Jason
=
<= br>
make the context object actually invariant over its _enti= re_ lifetime.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com&= gt;
Fixes: 00dae4d3d35d ("drm/i915: Implement SINGLE_TIMELINE= with a syncobj (v4)")
Cc: Jason Ekstrand <jason@jlekstrand.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com&g= t;
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.c= om>
Cc: "Thomas Hellstr=C3=B6m" <thomas.hellstrom@intel.co= m>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com&g= t;
Cc: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 +++= ---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c = b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 754b9b8d4981..93ba0197d70a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -940,6 +940,9 @@ void i915_gem_context_release(struct = kref *ref)
 =09trace_i915_context_free(ctx);
 =09GEM_BUG_ON(!i915_gem_context_is_closed(ctx));
 
+=09if (ctx->syncobj)
+=09=09drm_syncobj_put(ctx->syncobj);
+
 =09mutex_destroy(&ctx->engines_mutex);
 =09mutex_destroy(&ctx->lut_mutex);
 
@@ -1159,9 +1162,6 @@ static void context_close(struct i9= 15_gem_context *ctx)
 =09if (vm)
 =09=09i915_vm_close(vm);
 
-=09if (ctx->syncobj)
-=09=09drm_syncobj_put(ctx->syncobj);
-
 =09ctx->file_priv =3D ERR_PTR(-EBADF);
 
 =09/*
-- 
2.32.0

--17b2342e62f3ecc28176037462-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBC30C4338F for ; Sun, 8 Aug 2021 00:56:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 57DA060EBC for ; Sun, 8 Aug 2021 00:56:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 57DA060EBC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jlekstrand.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC49A89CD3; Sun, 8 Aug 2021 00:56:35 +0000 (UTC) Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DA0E89CD3 for ; Sun, 8 Aug 2021 00:56:35 +0000 (UTC) Received: by mail-ot1-x32a.google.com with SMTP id d10-20020a9d4f0a0000b02904f51c5004e3so9285357otl.9 for ; Sat, 07 Aug 2021 17:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:date:message-id:in-reply-to:references:user-agent :subject:mime-version; bh=i/6vWg32QPyQ4//6RJebPl2hvp7J0WxK/H30S/OTM4o=; b=PNqe//k1WmXmza+OTQ8A/Cw2nv0Ak/fv8H3mIjckAMAtHn1edRo0Pfma69vPtiYY9E o/4riVqL7LAOFLsChWo9ID/WW+c0IwOadZP/IaOrw9xEzPM9gYqQ5r5YlWLE/WOHF/dg obfmW1/A6j2hU7J929ptWVjbirm2aFiwmd54nXnMP5n3SsTHfPqRj8QN0RxHH1DIQrjj xKwG12Co5JnGU03opW3io+Y2/TcWwZAefmPRPLw85eJ2VQ4b/4/CiXmwmQD8kR17Dsv9 M5ST+qh/2G9udbAlvzJ85kCWT4JIZOLe+wEUHPPSlhb8fcaANKcn6CLUfhi8o5XOKnOv Q3aw== 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:date:message-id:in-reply-to :references:user-agent:subject:mime-version; bh=i/6vWg32QPyQ4//6RJebPl2hvp7J0WxK/H30S/OTM4o=; b=am9fvqR+Jou20LGCA8e3kXCw5feH8ytV7Al8tQwbwleYYLiI52JYJ++9pZN+H7B7Uk jrw2Yf1TwUv4YG1Z91Hb3AQmcvXVvj6oeGiWX0XQYqTs7HKrkbGY2sZCAdGHNQnqA8ji BPDzIv/OkfknxtbfbhL05T/9IvxLsh+SQLdUjxMtDxJFIt6owbvHWtxhcPE+SULhBlDk TORr27pfpZJCRRpK1kCwSgZOpmqfKQuFchnkYm1R0StS8zpOOjr1JaQvMn5G4ZAR+m/M 99EubTWSAqNNtM1Q9EUIfkPAZthWgXbrsx0lSvOGuWXFmKbAagFxTYcsncoCp4uz7RNq 9eTw== X-Gm-Message-State: AOAM530DgjcPGgl6U6h5KTrjNu77XaOMnIXai1DXPIdr9C8wrBiJkZMC QMGPT3mNtQtEW9Kb7rreLmk7Xw== X-Google-Smtp-Source: ABdhPJzDfVkdZ0580/x/YMWLVFiS07sLwtxxd9OOkYVjDfQAnRQYUmimEnvlKvq2hYliTsq4e3AwOw== X-Received: by 2002:a05:6830:114:: with SMTP id i20mr11952964otp.306.1628384194242; Sat, 07 Aug 2021 17:56:34 -0700 (PDT) Received: from [192.168.5.100] ([68.203.99.148]) by smtp.gmail.com with ESMTPSA id g1sm2378747otk.21.2021.08.07.17.56.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Aug 2021 17:56:33 -0700 (PDT) From: Jason Ekstrand To: Daniel Vetter , Intel Graphics Development CC: DRI Development , Daniel Vetter , Chris Wilson , Tvrtko Ursulin , Joonas Lahtinen , Matthew Brost , Matthew Auld , Maarten Lankhorst , =?UTF-8?B?VGhvbWFzIEhlbGxzdHLDtm0=?= , Lionel Landwerlin , Dave Airlie Date: Sat, 07 Aug 2021 19:56:32 -0500 Message-ID: <17b2342e218.2817.c6988b7ea6112e3e892765a0d4287e0c@jlekstrand.net> In-Reply-To: <20210806201852.1345184-1-daniel.vetter@ffwll.ch> References: <20210806201852.1345184-1-daniel.vetter@ffwll.ch> User-Agent: AquaMail/1.30.1-1828 (build: 103001000) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="17b2342e62f3ecc28176037462" Subject: Re: [Intel-gfx] [PATCH] drm/i915: Release ctx->syncobj on final put, not on ctx close X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This is a multi-part message in MIME format. --17b2342e62f3ecc28176037462 Content-Type: text/plain; format=flowed; charset="UTF-8" Content-Transfer-Encoding: 8bit On August 6, 2021 15:18:59 Daniel Vetter wrote: > gem context refcounting is another exercise in least locking design it > seems, where most things get destroyed upon context closure (which can > race with anything really). Only the actual memory allocation and the > locks survive while holding a reference. > > This tripped up Jason when reimplementing the single timeline feature > in > > commit 00dae4d3d35d4f526929633b76e00b0ab4d3970d > Author: Jason Ekstrand > Date: Thu Jul 8 10:48:12 2021 -0500 > > drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4) > > We could fix the bug by holding ctx->mutex, but it's cleaner to just What bug is this fixing, exactly? --Jason > > make the context object actually invariant over its _entire_ lifetime. > > Signed-off-by: Daniel Vetter > Fixes: 00dae4d3d35d ("drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4)") > Cc: Jason Ekstrand > Cc: Chris Wilson > Cc: Tvrtko Ursulin > Cc: Joonas Lahtinen > Cc: Matthew Brost > Cc: Matthew Auld > Cc: Maarten Lankhorst > Cc: "Thomas Hellström" > Cc: Lionel Landwerlin > Cc: Dave Airlie > --- > drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c > b/drivers/gpu/drm/i915/gem/i915_gem_context.c > index 754b9b8d4981..93ba0197d70a 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c > @@ -940,6 +940,9 @@ void i915_gem_context_release(struct kref *ref) > trace_i915_context_free(ctx); > GEM_BUG_ON(!i915_gem_context_is_closed(ctx)); > > + if (ctx->syncobj) > + drm_syncobj_put(ctx->syncobj); > + > mutex_destroy(&ctx->engines_mutex); > mutex_destroy(&ctx->lut_mutex); > > @@ -1159,9 +1162,6 @@ static void context_close(struct i915_gem_context *ctx) > if (vm) > i915_vm_close(vm); > > - if (ctx->syncobj) > - drm_syncobj_put(ctx->syncobj); > - > ctx->file_priv = ERR_PTR(-EBADF); > > /* > -- > 2.32.0 --17b2342e62f3ecc28176037462 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On August 6, 2021 15:18:= 59 Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

gem context refcounting is another exercise in least lock= ing design it
seems, where most things get destroyed upon context closu= re (which can
race with anything really). Only the actual memory alloca= tion and the
locks survive while holding a reference.

This tripped up Jason when reimplementing the single time= line feature
in

commit 00dae4d3d35d4f526929633b76e00b0ab4d3970d
Author: Jason Ekstrand <jason@jlekstrand.net>
Date:   Thu Jul 8 10:48:12 2021 -0500

    drm/i915: Implement SINGLE_TIMELINE with a = syncobj (v4)

We could fix the bug by holding ctx->mutex, but it's c= leaner to just

What bug is this fixing, exactly?

--Jason
=
<= br>
make the context object actually invariant over its _enti= re_ lifetime.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com&= gt;
Fixes: 00dae4d3d35d ("drm/i915: Implement SINGLE_TIMELINE= with a syncobj (v4)")
Cc: Jason Ekstrand <jason@jlekstrand.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com&g= t;
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.c= om>
Cc: "Thomas Hellstr=C3=B6m" <thomas.hellstrom@intel.co= m>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com&g= t;
Cc: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 6 +++= ---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c = b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 754b9b8d4981..93ba0197d70a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -940,6 +940,9 @@ void i915_gem_context_release(struct = kref *ref)
 =09trace_i915_context_free(ctx);
 =09GEM_BUG_ON(!i915_gem_context_is_closed(ctx));
 
+=09if (ctx->syncobj)
+=09=09drm_syncobj_put(ctx->syncobj);
+
 =09mutex_destroy(&ctx->engines_mutex);
 =09mutex_destroy(&ctx->lut_mutex);
 
@@ -1159,9 +1162,6 @@ static void context_close(struct i9= 15_gem_context *ctx)
 =09if (vm)
 =09=09i915_vm_close(vm);
 
-=09if (ctx->syncobj)
-=09=09drm_syncobj_put(ctx->syncobj);
-
 =09ctx->file_priv =3D ERR_PTR(-EBADF);
 
 =09/*
-- 
2.32.0

--17b2342e62f3ecc28176037462--