Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp797899rwb; Mon, 26 Sep 2022 06:06:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YtffQUjzaM/tXK8i44iqKNR38z9wUZP9pmkE+wItw50sB63udaerOfQThytEbVuvGWHxa X-Received: by 2002:a17:907:160d:b0:782:bc5d:162e with SMTP id hb13-20020a170907160d00b00782bc5d162emr12908831ejc.291.1664197563222; Mon, 26 Sep 2022 06:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664197563; cv=none; d=google.com; s=arc-20160816; b=LK3i2rtrgPGmy8o73J6HYMBIPmX1N8Yfx452OP86pvLtAb0lmHmZHBHbZ3KQTOtEIL 50wyh5BoNp8zaell6X0fqnRNu2/Gm99NIrr827tAqlj1gX3d1vpEAOxWhQqqqxKfL2fV ZA5I7b6NiWtPUYFtClD0kKkXm0jl2QUtbS+5TR59JAoUSo7Pap+AZ8nQUJ0svmv/gXWz iE18YpOUnaDuZFYliZKaWkaiTm/Z2TqmzsCHXT721i4oiQYg6byRcDHWtsIX7PUJKFfS TqecCEK5048/4ClGojuub29WY1/+MNPzl9QA786R+kJCvJ1PEjB4LEZMbX6zLdzOV4GS ajiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yue39auaNjOTHwwJWKo5a4k0AsKVmuaHosyOgLEr0Gg=; b=uiPKV4TCygSFhxjZC/4Etw19VsRby8lhsqcFkVsp3WLotdYUP9SiiMMtjqQt+anucV xTqv+omXA2B7uumQxCQE1EE8vZOpjYd8WShOnT8ybzMAUlAZBXJ4bHCq+6owe1Y+mToK 5I5G4TJ4RZrXo603jVBVMdDwWwRpwTDjKvre2lftNHkVW/Iqqwv/HF2joIBgQgTKI/jV CPKlirCAdDMAAWd7w2sGD6MIbeYwjpmwUXaCGjCa9+0Ol8H+jrEIlNo+4d/5b95U6iOt g2BsfFmvwotH/rbo0IDAovxUSzfQgAMOZ/DvM0AY5IIpKC8YwP/zf0fuK1XbS92pGB4H DSHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iUOOOqZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa34-20020a17090786a200b007417e9a2c71si16071126ejc.352.2022.09.26.06.05.36; Mon, 26 Sep 2022 06:06:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iUOOOqZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234362AbiIZLlP (ORCPT + 99 others); Mon, 26 Sep 2022 07:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238213AbiIZLkr (ORCPT ); Mon, 26 Sep 2022 07:40:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EB8754CAB; Mon, 26 Sep 2022 03:45:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A695760B4A; Mon, 26 Sep 2022 10:44:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA022C433D6; Mon, 26 Sep 2022 10:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189048; bh=7JnsuAXEvBceyJsJFdQODT+KhmgkDfvrhwdZoOUtVDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUOOOqZhldmHl1SXzNHmLVUn2jhpB5MoiIqFM5nwDMu6KlWgbEkZTagGIEPHeEtIy EMrUeySG5A+weh2B9yTEu300cQUTaWMwS3QoGkVgB2Wf3HYWgsBxBbTQOtrOgX2Wg7 2Lpx88awrJkuwTRXiz7Vf67bw/SSGZb/5BjQMVMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Janusz Krzysztofik , Andi Shyti , Rodrigo Vivi , stable@kernel.org Subject: [PATCH 5.19 056/207] drm/i915/gem: Flush contexts on driver release Date: Mon, 26 Sep 2022 12:10:45 +0200 Message-Id: <20220926100809.117685854@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Janusz Krzysztofik commit 5ce8f7444f8fbb5adee644590c0e4e1890ab004c upstream. Due to i915_perf assuming that it can use the i915_gem_context reference to protect its i915->gem.contexts.list iteration, we need to defer removal of the context from the list until last reference to the context is put. However, there is a risk of triggering kernel warning on contexts list not empty at driver release time if we deleagate that task to a worker for i915_gem_context_release_work(), unless that work is flushed first. Unfortunately, it is not flushed on driver release. Fix it. Instead of additionally calling flush_workqueue(), either directly or via a new dedicated wrapper around it, replace last call to i915_gem_drain_freed_objects() with existing i915_gem_drain_workqueue() that performs both tasks. Fixes: 75eefd82581f ("drm/i915: Release i915_gem_context from a worker") Suggested-by: Chris Wilson Signed-off-by: Janusz Krzysztofik Reviewed-by: Andi Shyti Cc: stable@kernel.org # v5.16+ Signed-off-by: Andi Shyti Link: https://patchwork.freedesktop.org/patch/msgid/20220916092403.201355-2-janusz.krzysztofik@linux.intel.com (cherry picked from commit 1cec34442408a77ba5396b19725fed2c398005c3) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/i915_gem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1191,7 +1191,8 @@ void i915_gem_driver_release(struct drm_ intel_uc_cleanup_firmwares(&to_gt(dev_priv)->uc); - i915_gem_drain_freed_objects(dev_priv); + /* Flush any outstanding work, including i915_gem_context.release_work. */ + i915_gem_drain_workqueue(dev_priv); drm_WARN_ON(&dev_priv->drm, !list_empty(&dev_priv->gem.contexts.list)); }