From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C4A731F9B1 for ; Mon, 27 Apr 2026 07:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777275250; cv=none; b=adzysTALyNgYCPeDVUbs/lUs+mLDmC9OWBAWE3b/OhnzJqP9zSs1ZUOe2MR0kF+Z4x20DcydtgbALbc+u4wnAOJAZCSz0FCiVvsBynU7frAlbpdpoRejs/n5xBHqysEsSgPRLZKjVlvwzUGMTNFCAE4oBdhwfokJh+nTj2lCZ6I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777275250; c=relaxed/simple; bh=oG3t3J+0nLXnFLxmSYOt/+viYtGDD3nFENttdAE4Lak=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qBfQdHfLnbUCgc2afN5Mkn20Ysrf4TAnd6TwPeCiAFRbZz7iaSpdCyv8a/eHj3M7LcQu/xZ0UKx8HBmmb53FfnIExY21uBsle+G4LBINEmx1g4Lb72AR6a6tsvu9Kjsn4RCpw3v1tKfLo5WY3VzF3roepD5wdXi6PM4fPZN5xhY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=b5wYgxqp; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="b5wYgxqp" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-488dcaf2f2fso86357375e9.0 for ; Mon, 27 Apr 2026 00:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777275246; x=1777880046; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=oG3t3J+0nLXnFLxmSYOt/+viYtGDD3nFENttdAE4Lak=; b=b5wYgxqpByv7P3WTIfBw+Z55dT/anjzVJR8e2gibuo/3CSf/eaRIHl7uVH/FrSLfSX h9UiKVy/8r871XVZSpfKhfDVCJl26Qpgu2ui3F7+cgz+Fxs3dCQbamxXvboe5K6BKJju wIYK5qVGELSCKrtebLw3aABxyMsWUcba4WNnX4UYCsitnzn8VtWknR1d0kvYJqhvSDZ5 ssvu99lmtoczZ+aL+4aPNmGjcLrAZEenRyQa4qWMKC7g0P0uy0V4m+7gdXTAf4DT8Vak OSMdE/HXWDAWsSwgp1/y1F8zAmfXBT4J91d3+SU+o0hprqYo9uMxYUFvgvii11T/0E0P /dZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777275246; x=1777880046; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=oG3t3J+0nLXnFLxmSYOt/+viYtGDD3nFENttdAE4Lak=; b=N0/u/s0FtH14LR/50ywxL9UkXO1J27xiZjeYH/tVvmgqP62W/8S67WU9RAnkxiKJHc eUops1Ooxl06MF+F+u9AhU17TdJFhYTefLWNwWbfqppZI32y6wtdaU2cjO+y/Au0yY+R O6nh7QoadyC/rV1q0XjffL0JedEZtF2gD/IP97hbWK5bUMWwzepHsyGwqwraKXXKBofo iiD2aRYyt7z1cOoBG30zYYr0PpIjl049e7YpMaqVETyUDlVI3TYYQq9AgOSr28zFepVg iFgyGY4rs7l7NneLHtuPaeyO4awx7nwNmbHIbZXLjL5BaA/9ibq+dw5wzy8d/pf0PVl0 aLCg== X-Forwarded-Encrypted: i=1; AFNElJ+m7KJeuEW9xq0LoJFeUIQI/eg8Num3cXaK0ERyGLTlC1XvzVVBwgdqEnVNp30K526ljlLWEmRqHobJInM=@vger.kernel.org X-Gm-Message-State: AOJu0YzQ4xCkkk6sNDPc06tu9ZhLwtMKkJNYMpIa+ZRtyuVVBCt0IxVd RmpGnqWQIuji9w/isC4rkPx5Y9QKE3IEXC/ZdXgzRK6ZJ3oFlq1QI8SdNUwpFhRHF90Hu/sx1QZ Q5UXY2e3VXIezz8H8tA== X-Received: from wmhf5.prod.google.com ([2002:a7b:cc05:0:b0:48a:7385:f096]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3553:b0:48a:52f2:a0f1 with SMTP id 5b1f17b1804b1-48a52f2a5f0mr394264665e9.18.1777275245704; Mon, 27 Apr 2026 00:34:05 -0700 (PDT) Date: Mon, 27 Apr 2026 07:34:04 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260416-gpuvm-drm-dev-get-v1-1-f3bc06571e73@google.com> <544c97fe296f39da35e5349ba1fc0af05f2ff643.camel@linux.intel.com> <215f305ff04ddf8a426871e895aaf520b02e89bf.camel@linux.intel.com> Message-ID: Subject: Re: [PATCH] drm/gpuvm: take refcount on DRM device From: Alice Ryhl To: "Thomas =?utf-8?Q?Hellstr=C3=B6m?=" Cc: Danilo Krummrich , Matthew Brost , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 20, 2026 at 06:19:02PM +0200, Thomas Hellstr=C3=B6m wrote: > On Mon, 2026-04-20 at 17:08 +0200, Danilo Krummrich wrote: > > On Mon Apr 20, 2026 at 11:28 AM CEST, Thomas Hellstr=C3=B6m wrote: > > > I agree with your reasoning here, but current fact is that most (if > > > not > > > all) holders of a drm device reference (files, pagemaps, dma-bufs) > > > currently also hold a module reference to protect against this, and > > > drm_gpuvm would be an outlier. > >=20 > > I'm not convinced; if the DRM device has the requirement to not > > outlive the > > module it is associated with, then the DRM device code has to take > > care of this > > requirement, and not every caller of drm_dev_get(). > >=20 > > Besides that, if GPUVM holds the module reference count on behalf of > > the DRM > > device, it has the same effect that you rightfully point out below -- > > it breaks > > rmmod. > >=20 > > > To fix this properly (lifting that requirement) one could introduce > > > a > > > drm device count in the module and have the module exit function > > > wait > > > for it to become zero, *and* that the code that did the last > > > decrement > > > finished executing. > > >=20 > > > https://patchwork.freedesktop.org/patch/712146/?series=3D163298&rev= =3D1 > >=20 > > This looks like a reasonable fix to me. And it makes me conclude that > > we > > basically agree on everything. :) >=20 > Yes, unless we'd want to do a similar wait for gpuvms before returning > from the close() callback: If we assume all GPUVMs are tied to an open > drm file, that would conceptually be nicer IMO but I agree if gpuvm > drivers implement something like the above per-driver device count, > that would be unnecessary. Just to confirm, it sounds like no changes to my patch are required here? Alice