Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1336120lqm; Thu, 2 May 2024 11:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTy8Jh/dFsGVJu/2UWEyinB9QgDPbC3EQ03NJmSrIyZ0zLHwxkpp3lPIMSyYskQAA978fM1TsDF0f4i54S/gZ86o1x95i1m9C1j19Bwg== X-Google-Smtp-Source: AGHT+IFLiV1H72ojfzwCa/PUXYO3Lp/KH7t9V0uEVMZ/R9H247WQd8jSr5mlqNwo7dWEVw0sRGih X-Received: by 2002:a17:90a:4891:b0:2b1:b6f:e297 with SMTP id b17-20020a17090a489100b002b10b6fe297mr644831pjh.36.1714674432142; Thu, 02 May 2024 11:27:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714674432; cv=pass; d=google.com; s=arc-20160816; b=wFdxcc4N7bd0+3G2cPkVxg75ophEHzWpQ/LWr2bdZdrwyB/mk45bJmwFauxe/AoRbq Z6p5n8+KTajU7TVduW95hgzvggMS2whpZtX34MOZ2yDyiYsFga611jzdouT7kR7TsQaM 96TEjJqZsSW2gw/jv2UaoGlZsDi531V17EQ37NH+5EYvxcWDOV/8/nDsKNYgrGVrZC7M QIg9zQAQm81UanF41fb7gKZvNBYNRMsWdfoWNbTUIrn/8jPY9AlNXpK2wzr/CWtI/gad V+It0gFYTKPTuboQuZpmvK1DAxpwf6989I3iKidtkayzd/cia0AEjp72/1FDyMSY+57B HfTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=veJsmtR/8SsO/PV5IWnI4divqHEJExZunNKgv/ygH3g=; fh=bedqjpcyVmPTMGowvNer4dKgCGtZLVf532JH9/MihvE=; b=ypBLR0c5oRZQ7Zqv9KNEvRTKfZQr0EXi723TP/54glDypI2Moa+8ufKk5zglb58I+c axjg8t2ppfXVcaIy0wha9mBGjIvOmcg8vKY8f/umK5py6lS7fmOgDFK+JBK0A4JDI3lt YGMMMquhWxcMYpjVhh2wDwecmD75SrIkPGLTVI7p3aYcBiwNwb+0WLT6ytXoBJwEQfsy x9yoiMN3GRI7El/s1KEbA1smxmalYKB+LCjDzdPbAeL2Ond2B25MpYR7bI8Ab8O5thbm PH2eZtAmV8kx1DzF/+NGftBDPEDldr+2VIOYbR9mcM6LuEh3ZFWtskZHEniv0P/rLZrI HsDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CgHcTmTr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-166678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l5-20020a170903244500b001e431e864ebsi1503489pls.342.2024.05.02.11.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 11:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CgHcTmTr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-166678-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 802D6B2407C for ; Thu, 2 May 2024 16:02:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C17F15DBC4; Thu, 2 May 2024 16:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CgHcTmTr" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 A049315B97B; Thu, 2 May 2024 16:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714665721; cv=none; b=JO+tCJUPxHIxWT3bqZnIXOItKcEZmepldAHp/L1KhIY/7eHVYEUyU08X/1T2PTMuVYuyR73gJ8zKMdLZ66ev9L2OmO5Ylq/R7Sk7mSVWoDA9HDVwEVHotREG0Bxa38p9jyR4adYOFXxS80dJOLym5CpobjlPo+jVWkM2xgLqf2U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714665721; c=relaxed/simple; bh=ObIQatXLy+J9dMb/aQHo04fdKZEbIx2wJbwo8cGX7+4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h5A/KIw31/QZbwxgILwb7bMePa/lzJ329RIhyuc4avH4nrHklW2jTIRvHxQubgPmXRFozVswFIPMHinWvB0GDx5vbbipfqzGB4GKDURXAqfhP07SSigDjLhj54I7YNCY8sDl2y2nEEnq7IB5DnZRqGESORVC9u8GsomMGfxcJP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CgHcTmTr; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714665720; x=1746201720; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ObIQatXLy+J9dMb/aQHo04fdKZEbIx2wJbwo8cGX7+4=; b=CgHcTmTrbc5c7qQEHcEwcfWaU4iG3NBU7mI91RVxb/t37thaEo4AiRig /Sptg7/cJGrvCdfNO3D/IAQde7e7i7425vqtyE9TnRy8IrPGeceLgm69G P8u5+gORmkV2a9xnM1OcVqaswQVylAgO/+n0pY5SeBVE0nlfkZwBbip9u MzFkLvieSYfYMr8i1jBLW8DCA64kfRg6YIhnDVZsKamTQNqLgretr9Kd9 7E9ZJCKNP+YQNsbMYDvZeDJ5mWhA6tLCbKGV1Jhuuh59LBXUj+9Gy/sZX L82dR5LxLelkFODpnL6YiNbm7Vm2WaE+nTufWbSIBS50WgPkeXZt8Cd4g A==; X-CSE-ConnectionGUID: c80ohLDmSsWTPBh4KZT6Nw== X-CSE-MsgGUID: ELkn2uIhQu2RZNjPkkupZQ== X-IronPort-AV: E=McAfee;i="6600,9927,11062"; a="14249275" X-IronPort-AV: E=Sophos;i="6.07,247,1708416000"; d="scan'208";a="14249275" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2024 09:01:58 -0700 X-CSE-ConnectionGUID: DwJEOuh6RxCXX9j4YfsK9w== X-CSE-MsgGUID: JXeJGl7FR16JncEZC10HRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,247,1708416000"; d="scan'208";a="31831298" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2024 09:01:48 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 1C4E111FA94; Thu, 2 May 2024 19:01:45 +0300 (EEST) Date: Thu, 2 May 2024 16:01:45 +0000 From: Sakari Ailus To: Laurent Pinchart Cc: Julien Massot , Mauro Carvalho Chehab , Tomi Valkeinen , Jacopo Mondi , Kieran Bingham , Niklas =?iso-8859-1?Q?S=F6derlund?= , Benjamin Mugnier , Sylvain Petinot , Yong Zhi , Bingbu Cao , Dan Scally , Tianshu Qiu , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Maxime Ripard , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Robert Foss , Todor Tomov , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio , Fabrizio Castro , Dafna Hirschfeld , Heiko Stuebner , Sylwester Nawrocki , Krzysztof Kozlowski , Alim Akhtar , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Yong Deng , Paul Kocialkowski , Benoit Parrot , Jai Luthra , Philipp Zabel , Michal Simek , Greg Kroah-Hartman , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, linux-staging@lists.linux.dev, linux-tegra@vger.kernel.org Subject: Re: [PATCH 0/2] Introduce v4l2_async_nf_unregister_cleanup Message-ID: References: <20240502-master-v1-0-8bd109c6a3ba@collabora.com> <20240502155626.GD15807@pendragon.ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240502155626.GD15807@pendragon.ideasonboard.com> Hi Laurent, On Thu, May 02, 2024 at 06:56:26PM +0300, Laurent Pinchart wrote: > Hi Julien, > > On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote: > > Many drivers has > > v4l2_async_nf_unregister(¬ifier); > > v4l2_async_nf_cleanup(¬ifier); > > > > Introduce a helper function to call both functions in one line. > > Does this really go in the right direction ? For other objects (video > devices, media devices, ...), the unregistration should be done at > .remove() time, and the cleanup at .release() time (the operation called > when the last reference to the object is released). This is needed to > ensure proper lifetime management of the objects, and avoid a > use-after-free for objects that can be reached from userspace. > > It could be argued that the notifier isn't exposed to userspace, but can > we guarantee that no driver will have a need to access the notifier in a > code path triggered by a userspace operation ? I think it would be safer > to adopt the same split for the nofifier unregistration and cleanup. In > my opinion using the same rule across different APIs also make it easier > for driver authors and for reviewers to get it right. > > As shown by your series, lots of drivers call v4l2_async_nf_cleanup() > and .remove() time instead of .release(). That's because most drivers > get lifetime management wrong and don't even implement .release(). > That's something Sakari is addressing with ongoing work. This patch > series seems to go in the opposite direction. This still avoids the driver authors feeling they need to implement wrapper functions for v4l2_async_nf_{unregister,cleanup}. I'd be in favour merging this. I don't see this getting in the way of adding use counts as the code will need to be changed in any case. -- Regards, Sakari Ailus