From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 ACD1038D for ; Tue, 30 Jun 2026 08:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782809143; cv=none; b=NKuJqD2hcXuHsZjzR4UP0f4K9IgtxKH5kM3gSaPTPVTW7/Au3KvkS+h4gvDw24mEGYgyBIq7oOj6yZCyDUbSwIMEq84GKVhbVRH6BlOCGXS3ae04Gszb8HteA6oXfUTEjdOeCCFxhj03onyoehVtzN9//EWcfkQkzzJjCdOEaQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782809143; c=relaxed/simple; bh=NQJoj4RXxGBKdLNsE+Y8Kcx6U+VnFMWLFNdYPbYDydo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hpXhWxyNTL7vv1Lr41JnnAcOj2eBb3SoKI43EsIp4eyv2vi1e60NfnvpGEuRvA4hrRXeZthwem9F9c9cJ5Xq71e7O+7YmjQLnnYo+k22BOBa/ef6LyZkRdtgpM6lhN3GBMZgSa3GCmGQ63k9Rp2vfXqjVZT2U4410gMVMGdmxtc= 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=jC/tcYVu; arc=none smtp.client-ip=198.175.65.17 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="jC/tcYVu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782809142; x=1814345142; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=NQJoj4RXxGBKdLNsE+Y8Kcx6U+VnFMWLFNdYPbYDydo=; b=jC/tcYVuBcoKYMVR//5a7RE12s6iTnOk5sTtR+Hqg41TaTZYquHX+Vyg Qzi6iBOxGrcYDgnFsq2HsTdC83B+gwBQMAnd22X/Tu8ZVw6yABMGJic79 OmUIWD6JJdyujGXDzJ518tAYqefmxmSzaPjeIKBCSTQlUkzPnugygn17h E0YaRbBkM8uSA8ofeAfGJWscs1LrbAupGN2mkxeL5XtwoODhLUmUX5SIt 2HB91KOLvM1sKziW7l6OuBRh35cmpbGQ8jMohP+SK7xROJvWQVRsj8O2v HB++Xf1fGGL7HNiy7soKaU1/foUl7+MqE3h8mXAn+haXracG02yzLLd8K A==; X-CSE-ConnectionGUID: ZsPhLDZSQ0q2la0UMe9S7A== X-CSE-MsgGUID: K/HUi3abSp6tgktu6nKgpQ== X-IronPort-AV: E=McAfee;i="6800,10657,11832"; a="83542848" X-IronPort-AV: E=Sophos;i="6.24,233,1774335600"; d="scan'208";a="83542848" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2026 01:45:41 -0700 X-CSE-ConnectionGUID: qAUH+CnyT1GscJMT/NQ4+A== X-CSE-MsgGUID: GQyXDih3TyKmDBF5SBBGiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,233,1774335600"; d="scan'208";a="254119815" Received: from hrotuna-mobl2.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.245.116]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2026 01:45:40 -0700 Received: from kekkonen.localdomain (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with SMTP id A504311FAA5; Tue, 30 Jun 2026 11:45:40 +0300 (EEST) Date: Tue, 30 Jun 2026 11:45:40 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: Hans Verkuil Cc: linux-media@vger.kernel.org, Mauricio Faria de Oliveira Subject: Re: [PATCHv3 1/6] media: core: v4l2-async.c: unreg subdev if asc_list is empty Message-ID: References: <2cf4473a9c16d0715aa081e234bb36c70fefce3c.1782716154.git.hverkuil+cisco@kernel.org> <3fc7cf62-c7eb-45c0-a961-af2e47f0b589@kernel.org> Precedence: bulk X-Mailing-List: linux-media@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: <3fc7cf62-c7eb-45c0-a961-af2e47f0b589@kernel.org> Hi Hans, On the subject -- I'd write this as, to align with the existing practice: media: v4l2-async: Unregister sub-device if asc_list is empty On Tue, Jun 30, 2026 at 10:32:20AM +0200, Hans Verkuil wrote: > On 6/30/26 09:58, Sakari Ailus wrote: > > Hi Hans, > > > > Thanks for the patch. > > > > On Mon, Jun 29, 2026 at 08:55:49AM +0200, Hans Verkuil wrote: > >> In v4l2_device_unregister_subdev(), if sd->asc_list is empty, s/device/async/ ? > >> then v4l2_device_unregister_subdev() is never called, but that > >> should still happen. > >> > >> This causes crashes with em28xx that uses tvp5150: that i2c > >> module uses v4l2_async, but em28xx does not as it predates > >> v4l2_async. > > > > Isn't the sub-device unregistered via v4l2_device_unregister() or do I miss > > something? em28xx_v4l2_fini() calls it. > > > > Or do you mean the issue happens at tvp5150 unbind time? > > Yes, that's when it happens. The tvp5150 driver is removed, it calls > v4l2_async_unregister_subdev(), but that never calls > v4l2_device_unregister_subdev() since em28xx doesn't use v4l2-async > and so sd->asc_list is empty. > > This happens when unplugging the USB device. Ack. Could you add this to the commit message? It'd help understanding what really goes on here. I'd also add a comment, see below. > > > > >> > >> So if sd->asc_list is empty, then just call > >> v4l2_device_unregister_subdev(). > >> > >> Fixes: 28a1295795d8 ("media: v4l: async: Allow multiple connections between entities") > > It was introduced by commit 28a1295795d8, before that commit this was done correctly. > > Regards, > > Hans > > >> Signed-off-by: Hans Verkuil > >> --- > >> drivers/media/v4l2-core/v4l2-async.c | 10 +++++++--- > >> 1 file changed, 7 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c > >> index 888a2e213b08..d7437c958028 100644 > >> --- a/drivers/media/v4l2-core/v4l2-async.c > >> +++ b/drivers/media/v4l2-core/v4l2-async.c > >> @@ -898,9 +898,13 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) > >> sd->subdev_notifier = NULL; > >> > >> if (sd->asc_list.next) { > >> - list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list, > >> - asc_subdev_entry) { > >> - v4l2_async_unbind_subdev_one(asc->notifier, asc); > >> + if (list_empty(&sd->asc_list)) { How about: /* * If the sub-device was registered through other means * than v4l2-async, there are no async connections but * the sub-device may still well be registered. * Unregister it now. */ > >> + v4l2_device_unregister_subdev(sd); > >> + } else { > >> + list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list, > >> + asc_subdev_entry) { > >> + v4l2_async_unbind_subdev_one(asc->notifier, asc); > >> + } These braces are redundant. > >> } > >> } > >> > > > -- Regards, Sakari Ailus