From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4EF627A442 for ; Wed, 17 Dec 2025 15:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986952; cv=none; b=W1TCWAYeH1jEom/+h1q07uPV0Rqf+E3eWNTULvg+r9lQOz4GK7MvhpfhheDsMxlbUtRcK+SDluWSNDYgk7kJfVkMo12H1DWdM44x4aG1bh3Ml83Rfl+wEBoMLC7YG8zfQkcFh5/WAtvJ8mY4Prm1xlRjiFOlHcaEDwwthFtToAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765986952; c=relaxed/simple; bh=t2BdhGCUKECTZvq9FT1S9bm19iWbr/hwxfz0f81hx08=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mZXl4FY05/q3+X6g39dbdUjxLoz5w3yAMQaJNaI1U7Na9n4G07bblXgriSwhA/ibyuMoxtcXqbTCPGJMiB3Pb/t3Tt0lSh1woukjGi7zLYF6NtuhklfejQVMvhLAbk6CWaEGiBtWteujk4khcNME2XlEz0rsF/aFcVUdNXCTVVs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 730F2FEC; Wed, 17 Dec 2025 07:55:41 -0800 (PST) Received: from [10.57.45.201] (unknown [10.57.45.201]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6AF0B3F5CA; Wed, 17 Dec 2025 07:55:44 -0800 (PST) Message-ID: <42a3d2dc-1e1a-49ef-b3e7-c2fe604ca09a@arm.com> Date: Wed, 17 Dec 2025 15:55:42 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] drm/panthor: fix for dma-fence safe access rules To: Chia-I Wu , Boris Brezillon Cc: Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Grant Likely , Heiko Stuebner , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, tvrtko.ursulin@igalia.com References: <20251204174545.399059-1-olvaffe@gmail.com> <20251205134307.6a06f9e1@fedora> From: Steven Price Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 05/12/2025 18:45, Chia-I Wu wrote: > On Fri, Dec 5, 2025 at 4:43 AM Boris Brezillon > wrote: >> >> On Thu, 4 Dec 2025 09:45:45 -0800 >> Chia-I Wu wrote: >> >>> Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document >>> the rules") details the dma-fence safe access rules. The most common >>> culprit is that drm_sched_fence_get_timeline_name may race with >>> group_free_queue. >>> >>> Signed-off-by: Chia-I Wu >>> Reviewed-by: Boris Brezillon >>> Reviewed-by: Liviu Dudau >>> Reviewed-by: Steven Price >>> >>> --- >>> v2: collect R-bs and drop misleading Fixes: tag >> >> Should we at least >> >> Cc: stable@vger.kernel.org >> >> so this gets considered for backporting? > This can be considered a follow-up to commit 506aa8b02a8d6. I think > > Cc: stable@vger.kernel.org # v6.17+ > > is appropriate. (Not sure if I should send v3 or leave it to > maintainers, because I was once told to never add the line and always > leave it to maintainers). > > To help make the decision, commit 506aa8b02a8d6 itself narrowed the > race window greatly. This follow-up closes the remaining case where > panthor signals the fence and destroys the group while the consumer > holds the rcu read lock. > I've pushed this to drm-misc-next with the Cc tag. Thanks, Steve >> >>> --- >>> drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c >>> index 33b9ef537e359..a8b1347e4da71 100644 >>> --- a/drivers/gpu/drm/panthor/panthor_sched.c >>> +++ b/drivers/gpu/drm/panthor/panthor_sched.c >>> @@ -23,6 +23,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> >>> #include "panthor_devfreq.h" >>> #include "panthor_device.h" >>> @@ -923,6 +924,9 @@ static void group_release_work(struct work_struct *work) >>> release_work); >>> u32 i; >>> >>> + /* dma-fences may still be accessing group->queues under rcu lock. */ >>> + synchronize_rcu(); >>> + >>> for (i = 0; i < group->queue_count; i++) >>> group_free_queue(group, group->queues[i]); >>> >>