From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E9AA30E847 for ; Mon, 27 Apr 2026 11:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777290248; cv=none; b=JcKJp2HnInrofzOI6Z9YjdgsesNKB0jc6IPHJvNTC/jNX2b+I8KmZ9ccATtzMFhZvbX+HpO3Ume05rqCpZ1BZBLIUyNVfS8Xq/UcDqCamifSBNKUmKBsUUlz1T1TVWO+hCi80MobjpHTHO9r13b6WsHkl+dYlPPaMd/0LMbARPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777290248; c=relaxed/simple; bh=Z5b1O9yrhWObNHRT9Q7Vrv8z158YKgJy0kzRx4N3wh0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=mLl3DVYKHCoDtKWTNXGxWUSNxbKrW/zMezFVDardwmX5M4RaTOaPNkBonTqYWf+qqZLejguPPO8Y5FxbwO8zQIJEVLAHlckjT3MeErVKgmOWcfDt781hhyaCxQZ81wUANRWxTXt4ZTPhX1EFK6fqNkPxDrSAHypR9ll95nBAOF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aHNVOTof; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aHNVOTof" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777290247; x=1808826247; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=Z5b1O9yrhWObNHRT9Q7Vrv8z158YKgJy0kzRx4N3wh0=; b=aHNVOTofwIWeTOmtu+jtzn3nGYpsWnYQG8JTgJ9Ytn+haWT38AWLov/z M5N78EfrLAsDLCdAFCnUO1fKT+xRBS4i26s9zZzNe83fHosagfoMEw+1G z4uX4iwJNVXy/Yj+imEqUf84XgeNTRf50iiaWgtPaqOkYUDgRMYuqVErZ MXQjQFATsHo31o/1hpRoqGxMss8JUGkqjviiyADqWNDztWg6/U+j4hdd/ KRw+qN/8vR/Dlo05CmAdqJcsvHgHl5WmVnS/IvrhH4uBTEdugbxdwSQS6 bLevwDYBsmETZCIQbQ1+ouX8jv+ASyG1mhP8PCs7yCZxBpkgXNP5T2E6L w==; X-CSE-ConnectionGUID: lxzdNzYkTPCn3wUfS5aAFg== X-CSE-MsgGUID: nM/hjneiQee9H61IOkQMOQ== X-IronPort-AV: E=McAfee;i="6800,10657,11768"; a="89554117" X-IronPort-AV: E=Sophos;i="6.23,202,1770624000"; d="scan'208";a="89554117" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2026 04:44:06 -0700 X-CSE-ConnectionGUID: N8fHVskVQ7C47MsCXSafsA== X-CSE-MsgGUID: EXlR1YHMQ8CFujcdt5vm6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,202,1770624000"; d="scan'208";a="233887836" Received: from egrumbac-mobl6.ger.corp.intel.com (HELO [10.245.244.36]) ([10.245.244.36]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2026 04:44:04 -0700 Message-ID: <13be208e3b31ef1e6697551b72901f92e17bb950.camel@linux.intel.com> Subject: Re: [PATCH] drm/gpuvm: take refcount on DRM device From: Thomas =?ISO-8859-1?Q?Hellstr=F6m?= To: Alice Ryhl Cc: Danilo Krummrich , Matthew Brost , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Mon, 27 Apr 2026 13:44:00 +0200 In-Reply-To: References: <20260416-gpuvm-drm-dev-get-v1-1-f3bc06571e73@google.com> <544c97fe296f39da35e5349ba1fc0af05f2ff643.camel@linux.intel.com> <215f305ff04ddf8a426871e895aaf520b02e89bf.camel@linux.intel.com> Organization: Intel Sweden AB, Registration Number: 556189-6027 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2026-04-27 at 07:34 +0000, Alice Ryhl wrote: > 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. >=20 > Just to confirm, it sounds like no changes to my patch are required > here? I guess not, Although in the end it currently just moves one potential bug to another, but as long as people involved are aware, that's OK from my POW. Thanks, Thomas >=20 > Alice