From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049778; b=MVMphF/8v/maB/Q542Mh4iNtoTgu4XsOYOQ5VfcJkIH88ubD/qHpPaycg0mh/VwaX2Sv +EZdbwZ783Mhw0EAYglr98Hyqu/FO7TIs97qlo7SZJ0inyivFbFOlWiGUM/8H05qa+kXn 1h+IWoiN/Rk3SK+C7dG7ik91z5hNGYYsd5vVKyRBLxgV0MqySets9QtOMHgfOZvjlW3DY MnadV5oVQpUIwzoxtkAEUmgDYP7hIpL7foC0qzGpjnPRuVNIVmOytv+4yVuTuTFzhC1+x 3l/aUlTkft2e3DAcXUHJDTUbm2G/ViMju3Oja0K2/mvBBOMk/urk1wVGXyJ6hcFSvcg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049778; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Spam-Info: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Authority-Analysis: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=Ln6UMekFmYUSbIaEnVx0fH1X3GstT1MwWiQcz+q98E4=; b=m8JQ/39AemgYBwMGfX0ZHkVFOnlastNcZBV5jKJqdGNN0iY0AsTya9RkF3WcEzW7cEju lVHn7m+0OrYNwGgCWGKNQf22jGaB3YuCCioU5KaaXbQj53LZgwAb3AChimI/mTmckr2Fj JtO1LWxQxygTK2Lc/ucS4gjuTqQeJ3eTXcZ3qQtFRhg3xJYx53rdhSxcytYgySQHxlucz xrVzHmTRycmqcOPldJFA7pGmY9lY54r/Ty6RZffCthHaX4Oe6CLOU0e+MMvm6AThuGk83 VrMc/u019huteM9PG2B7YoMJi0tf+KShcenjZV0AG3SpXfqXMw7n5SdIIgkQKI8a00w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ke1x5DPw; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=US35DEUx; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12FD4606A333 for ; Mon, 30 Nov 2026 14:42:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12FD4606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ke1x5DPw; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=US35DEUx Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUD9aon220630 for ; Mon, 30 Nov 2026 14:42:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Ln6UMekFmYUSbIaEnVx0fH1X3GstT1MwWiQcz+q98E4=; b=ke1x5DPw/IaFUkW1 AHxSAqxmARcaBUPWXTb7RFT0YmN1C8KLZfvsEOyYj3O51Amr7PZyyyPuh91Teu5y R8mtlc3AVLBG8eMa84LYNG1or1nk1s07VTrYX4hjCWNNGvvGuCOgE0aeKRwTgnva gFQnXduoLdZ64xauJI5RDBjJFsen5HFHBLTn9hN4ONZdogtMi0qzYvntRNgfe96J Ny0BcpytTPrkeA6hTyr1pbPGA+OF805I1f1vyx4okZS6QppXZSaq2/jK1NV5G373 ddrt/nAFxD73WxXBVph+lbX6kFCIjdq6+HHGPiiUcdi9gHibIs7Tys6DisGBJVDh HD05Ig== Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j8skykb30-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 14:42:55 +0000 (GMT) Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-5ec3e192929so2431884e0c.2 for ; Mon, 30 Nov 2026 06:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796049775; x=1796654575; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Ln6UMekFmYUSbIaEnVx0fH1X3GstT1MwWiQcz+q98E4=; b=US35DEUxpubC1vnEPNmNOpSwcRrJuGENEgjM5nng3EmtCPPiB0nRgLKRDIe9D0cRVN SbZXrL6NbVYRfVm6juSd+pi7U5gIybpljnkqvmzsEOSuHM023WTt3JOD/4y+QA6ulgvV /pQz4NHJUGQEKvhPCB/Q6bKAqwN08QxMgBuMT7Oj0mwUOXVsmk9r/A2xnI+a+xwL6O4x zLUYOVk6+ImFrkoKHHFw260LuoKgqPTFAhyByPTpLyJF5iCaXdq2nj6EwYx82YPcFvAG CkNbbPJlOJUpGZCHr9mF/LoCyaOq3imts9cDTrAVeGk68/IJCu6taudkToLWm4NGwJbV jpPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049775; x=1796654575; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Ln6UMekFmYUSbIaEnVx0fH1X3GstT1MwWiQcz+q98E4=; b=kTVdj/e75S7U/fOXdCKoVQf36/16rCcCLWJiU7I57pS2HR9hUV1kBtACd9XFywoLM3 lR3EUatkeUtxDXMrO0zVJN0Ovyh1LkWR3Oj4A71wcPKSsLreeu9T1NOyJcqw/kh/dad6 7cgR+bYg485o6t/0OdOSnyOL2jFTqmyyUjx1jXi66MI5DxsCqN9T+u1B478bPsSsumLu KEOHwQdHU6pXm7ZlFCWV2R4fNR03JnvKUU1uMPOqfys3eGw9gCGnlVmoBBt/1tmzhJJ9 QqkfGaZ2P2Qlb37iMYbgxjYb+6drYIonMR6wbd2gye2FGta7AhR553QhWfGu99fA/CDb dDOA== X-Forwarded-Encrypted: i=1; AL+hErGTBy+g12ogR3qh3tXwr8z8faRQbyqJxRdtc3G5lRTHMgSBOqoYOAYH6VTZUXzEZMhvlCFVtdzoUo/ICEY=@vger.kernel.org X-Gm-Message-State: APuU4Z9c4mjsmrQ9QX56xSr88bwDublBXAOUR7Z7eIa7rN7Fz8ueaGcd PsHW7UDjRbgFarf+7fNtPgvWy2q5U9jzIwOwycdXUlD8W+QjDTiqxvdy5Lf5VVlrCtUXsF4hYA4 AFttdSEU7wto0foLl1KJuN+nkekmB9s+DbaV6bqAl0sYxgYkHZMIS4GHVEEU9EYXj7vk= X-Gm-Gg: AZFdTZer4G0Y/q/WbT97SHQJNY+STM+W5WbTM5N1C5xkwjOml1H3UqCg2hbOtN11ypn RcVYfXLpnlsVHAd7MYv/FhmJgnvZviFLATLorYNqREvGOVgT/xdTfCoIjaaxxg1vRey5ie7hDEc ox4yjadqcHj+pdsPEa26RL2TFRdqa18SOz/iWB1hFkMnMBOoWOmJ1ceMIpLKDACi6NQ+K8D2Yqc 4QutTxAfAWpNaTcEPqa8QwWRQbLJDBhLkWywjUr0jmELAYp0JRwr/OI7hZ7+AePThxBxuSGrVOV GmT7a7trKglCbQG0a7reml1REsMOJEFtGjLVkNrDihPp/3OcwOBKwQwieCXqvHWKYjQ2+mGHfVo CY3ejkaSw7SJHNcpwHfaucTsKD1+8xxyHTtC2L5zlrQPAFw5mUAIJ/RSfwDQeh/HGo7EKFXY= X-Received: by 2002:a05:6122:c1c8:b0:5ef:cbcb:3e68 with SMTP id 71dfb90a1353d-5efcbcb4582mr9766623e0c.23.1796049774921; Mon, 30 Nov 2026 06:42:54 -0800 (PST) X-Received: by 2002:a05:6122:c1c8:b0:5ef:cbcb:3e68 with SMTP id 71dfb90a1353d-5efcbcb4582mr9766556e0c.23.1796049774096; Mon, 30 Nov 2026 06:42:54 -0800 (PST) Received: from [10.40.99.77] ([78.108.130.194]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6bb11ff543fsm7126500a12.2.2026.11.30.06.42.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 06:42:52 -0800 (PST) Message-ID: <462ca475-5b95-4804-83b9-15e7040a9997@oss.qualcomm.com> Date: Mon, 30 Nov 2026 15:42:51 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] media: v4l2-async: link ancillary device runtime PM to the sensor's To: =?UTF-8?Q?C=C3=A9dric_Bellegarde?= , Sakari Ailus , Mauro Carvalho Chehab , kieran.bingham@ideasonboard.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, libcamera devel References: <20260922-sensors_pm-v1-1-05adf2098b5e@adishatz.org> From: Hans de Goede Content-Language: en-US, nl In-Reply-To: <20260922-sensors_pm-v1-1-05adf2098b5e@adishatz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA1OCBTYWx0ZWRfX/WcIoosEhqQF 7Y1wm6EJ3q341EVwvDHRrkudqgCSGHr9cw6BKdkQHvjxgThm5YEtm1zhRFTRHJHBtQ0WHV6ZvXA aI8NHUyGY9G0h0yuTx7nLKv2erahEnO9n3u21zmzUBvj77GLs/5bzDaFwn2uENHM/IBr2rz5qXq qbKqzn0B+hEQxwf+O/NoQO7wKS8OqImFoG3d/lRNlUJo5rS8Y5qRP61KXwCJHZDyMB2v3syt9oQ y2h+85me2ibYmEEOE5iYkLeRrPOjr6WCaPFQH2RbgF9sYNQ7iRIeQG38ciCa11ImD9WnqdgsQ01 cUMLjIT6zuK1UxpQklNSJXlZ9iWeaX0Wz19wWEjIVI7c6oXGw0xqNczCGmASAC6muwDSx9UnBsl U2s414uaTBplcFGwbLYAnzuG71t5mnlJp6878cS9Rv9KfAAfKPcpbfI58hgG7gF6NfmHTumClup +1YzyboV8riFWhnGOvQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA1OCBTYWx0ZWRfXxUrd9nR3lK4m xHgOxDxrpPfVt30JDIp2hWz9JzlOHchugvcCA5AjiVQfSaAB5vpMDTuKxfbqh/TGamRme8GKaFL oNJsQuStUHYHhe7pHQbORf0ku35xqTg= X-Proofpoint-ORIG-GUID: uMNcipklpSXdPUCedqu3-yv3BgU3zoSr X-Proofpoint-GUID: uMNcipklpSXdPUCedqu3-yv3BgU3zoSr X-Authority-Analysis: v=2.4 cv=Ie4Symqa c=1 sm=1 tr=0 ts=6b0d8b6f cx=c_pps a=1Os3MKEOqt8YzSjcPV0cFA==:117 a=rrvG0T/C2D967D07Ol03YQ==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=p0WdMEafAAAA:8 a=LCWlJkpBAAAA:8 a=aCi4MdHnMIqXM8Acie8A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=hhpmQAJR8DioWGSBphRh:22 a=z1lahxahPt366DkPXCx7:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 clxscore=1015 impostorscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300058 Hi, On 22-Sep-26 21:39, Cédric Bellegarde wrote: > When a sensor's fwnode references an ancillary lens or flash device > (e.g. via the "lens-focus" or "flash-leds" properties), > v4l2_async_create_ancillary_links() already creates a media controller > link between the two entities, but their runtime PM states remain > independent. > > This is a problem for devices such as VCM lens actuators, which are > typically spring-loaded: holding a position away from the spring's > rest point requires continuous power, and the position is not retained > once power is cut. If such an actuator is allowed to runtime-suspend > independently of the sensor, the lens can drift back to its rest > position during an otherwise active capture session. In my experience at the moment we actually mostly have the reverse problem, on x86_64 devices a runtime-pm link is created from the VCM device to the sensor device, because they are both powered on through the ACPI power-on sequences from the sensor. And VCM drivers power-on the VCM as soon as the /dev/v4l-subdev# device for the VCM is opened, which now also powers the sensor on leading to undesirable power-consumption especially since libcamera typically opens all v4l-subdev# devices as soon as a libcamera context is created which e.g. pipewire does. I do like this patch though since I think it can solve all of the above problems in one go. What we are seeing on x86 at least is that camera-modules are designed with regulators, but also e.g. power-down / reset pins shared between sensor and VCM, assuming that the sensor + vcm are always powered on/off together. And sensors are already powered-on only when streaming (vs the VCM drivers powering them on as soon as the /dev/v4l-subdev# device is open). So what I think we should do is: 1. Add this patch to always automatically power-up the VCM when a sensor powers up (so when streaming for proper sensor drivers) 2. Drop the runtime_pm_get() and put() calls from the open()/close() v4l2_subdev_internal_ops for VCM devices so that they no longer are always on as soon as userspace has the /dev/v4l-subdev# VCM node open. This also requires no longer probing / powering up during probe() as this will fail when patch 3 is added into the mix. 3. Drop the runtime-pm link added by drivers/media/pci/intel/ipu-bridge.c, removing: device_link_add(&vcm_client->dev, data->sensor, DL_FLAG_PM_RUNTIME); which is in essence the same link from this patch in the other direction. Note: 3a) This needs to be last to avoid regressions. 3b) Maybe we should not drop this, avoiding the need for changes to probe() in VCM drivers. Although IMHO just delaying the VCM detect code till first power-on would be better. Assuming we can all agree as the way forward to solve the power-management issues surrounding VCM devices then a series implementing this would be very welcome! Regards, Hans > Add V4L2_SUBDEV_FL_PM_LINK to allow an ancillary subdevice to request > that its runtime PM state be linked to the associated sensor. > > Signed-off-by: Cédric Bellegarde > --- > Link runtime PM of ancillary devices such as lens actuators to their associated sensor, > while allowing actuators to autosuspend when idle. > > Example usage: > https://gitlab.com/gnumdk/linux/-/commit/82b2d71415a1d95b2170e19ce025afc8bbdcf145 > --- > drivers/media/v4l2-core/v4l2-async.c | 18 ++++++++++++++---- > include/media/v4l2-subdev.h | 7 +++++++ > 2 files changed, 21 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c > index 460bf3dbbb88..22df627153b8 100644 > --- a/drivers/media/v4l2-core/v4l2-async.c > +++ b/drivers/media/v4l2-core/v4l2-async.c > @@ -318,6 +318,7 @@ static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n, > { > #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) > struct media_link *link; > + struct device_link *devlink; > > if (sd->entity.function != MEDIA_ENT_F_LENS && > sd->entity.function != MEDIA_ENT_F_FLASH) > @@ -331,11 +332,20 @@ static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n, > } > > link = media_create_ancillary_link(&n->sd->entity, &sd->entity); > - > - return IS_ERR(link) ? PTR_ERR(link) : 0; > -#else > - return 0; > + if (IS_ERR(link)) > + return PTR_ERR(link); > + > + if (sd->flags & V4L2_SUBDEV_FL_PM_LINK) { > + devlink = device_link_add(n->sd->dev, sd->dev, > + DL_FLAG_PM_RUNTIME | > + DL_FLAG_AUTOREMOVE_CONSUMER); > + if (!devlink) > + dev_warn(notifier_dev(n), > + "failed to link power management of %s to %s\n", > + dev_name(sd->dev), dev_name(n->sd->dev)); > + } > #endif > + return 0; > } > > static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h > index d256b7ec8f84..9f64b10afd10 100644 > --- a/include/media/v4l2-subdev.h > +++ b/include/media/v4l2-subdev.h > @@ -972,6 +972,13 @@ struct v4l2_subdev_internal_ops { > * - Multiple streams per pad are supported > */ > #define V4L2_SUBDEV_FL_STREAMS (1U << 4) > +/* > + * Set this flag to keep the subdevice active while its associated sensor is active. > + * > + * This is intended for ancillary devices, such as lens actuators, whose > + * hardware state or physical position cannot be retained while powered off. > + */ > +#define V4L2_SUBDEV_FL_PM_LINK (1U << 5) > > struct regulator_bulk_data; > > > --- > base-commit: df2908090cda368b01ff43709f51890076c56157 > change-id: 20260911-sensors_pm-787eac01aa18 > > Best regards,