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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8CA33D44D55 for ; Wed, 6 Nov 2024 12:03:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99E3A10E6C2; Wed, 6 Nov 2024 12:03:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Z+732Y3V"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FA8810E6C2 for ; Wed, 6 Nov 2024 12:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730894595; x=1762430595; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=8ACCdXKSb4x9ULEg/UokXvVNenOb3X8u4nBOhsfFsqo=; b=Z+732Y3VyzKlB6QeY4x8SRz8xYz00CvKYNEJD46eT01qjpW7DLy5I7I1 ti84A868ujfu+0bjymzmOYWZ513Ii7gaW6Ycx908+dDrMx+01mhKXtUC7 bX9qlcvBXcmn8lzJw2jlFsWG9tiWiICIuY4UWuD1SHHvDFBYJcQMaLiFz qjTgvNO4pEkMUBfuf+f31VTfYxE2N6FHKLXSx6FrINIjLfBiOm2xO9q05 z284u4inEj1n4yBJApcDI8KO2+Vct69ki4moOaIpUq2g4Gzv+TCgniA5l EY5yCEarmjeMPAsXmhbliAz8MnpjdBYD7ZcXWeTmTSVLWLVXWFYGdSYlg g==; X-CSE-ConnectionGUID: Ez7XBpA4ThmAOCKADrfM9g== X-CSE-MsgGUID: SPVlDI3hSNWiYrYZfzd7Vg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30850744" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30850744" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2024 04:03:14 -0800 X-CSE-ConnectionGUID: dZX4gZZiTDi2h/NHcD26XQ== X-CSE-MsgGUID: m0f2rt31QtOqI5qY9Wfu1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,262,1725346800"; d="scan'208";a="84671686" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.246.143]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2024 04:03:10 -0800 From: Jani Nikula To: Luca Ceresoli , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli Subject: Re: [PATCH v2 3/4] drm/mode_object: add drm_mode_object_read_refcount() In-Reply-To: <20241106-drm-small-improvements-v2-3-f6e2aef86719@bootlin.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> <20241106-drm-small-improvements-v2-3-f6e2aef86719@bootlin.com> Date: Wed, 06 Nov 2024 14:03:08 +0200 Message-ID: <87wmhgfu2r.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain 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" On Wed, 06 Nov 2024, Luca Ceresoli wrote: > Add a wrapper to kref_read() just like the ones already in place for > kref_get() and kref_put(). This will be used for sanity checks on object > lifetime. > > Signed-off-by: Luca Ceresoli > --- > drivers/gpu/drm/drm_mode_object.c | 20 ++++++++++++++++++++ > include/drm/drm_mode_object.h | 1 + > 2 files changed, 21 insertions(+) > > diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c > index df4cc0e8e263d5887a799cf1a61d998234be7158..f990cc7e9b5d3bda3453123593314fa1ea2bf923 100644 > --- a/drivers/gpu/drm/drm_mode_object.c > +++ b/drivers/gpu/drm/drm_mode_object.c > @@ -217,6 +217,26 @@ void drm_mode_object_get(struct drm_mode_object *obj) > } > EXPORT_SYMBOL(drm_mode_object_get); > > +/** > + * drm_mode_object_get - read the refcount for a mode object > + * @obj: DRM mode object > + * > + * This function returns the current object's refcount if it is a > + * refcounted modeset object, or 0 on any other object. Returns: The current object's ... > + */ > +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj) > +{ > + unsigned int refcount = 0; > + > + if (obj->free_cb) { > + refcount = kref_read(&obj->refcount); > + DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, refcount); Please ditch the debug. > + } > + > + return refcount; > +} > +EXPORT_SYMBOL(drm_mode_object_read_refcount); > + > /** > * drm_object_attach_property - attach a property to a modeset object > * @obj: drm modeset object > diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h > index c68edbd126d04d51221f50aa2b4166475543b59f..3d2c739e703888bf4520c61594d480f128d50e56 100644 > --- a/include/drm/drm_mode_object.h > +++ b/include/drm/drm_mode_object.h > @@ -123,6 +123,7 @@ struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, > uint32_t id, uint32_t type); > void drm_mode_object_get(struct drm_mode_object *obj); > void drm_mode_object_put(struct drm_mode_object *obj); > +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj); > > int drm_object_property_set_value(struct drm_mode_object *obj, > struct drm_property *property, -- Jani Nikula, Intel