From nobody Fri Sep 25 10:05:31 2026 Received: from PNYPR01CU001.outbound.protection.outlook.com (mail-centralindiaazon11020092.outbound.protection.outlook.com [52.101.225.92]) (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 0E1CE4078CA; Mon, 14 Sep 2026 13:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.225.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392877; cv=fail; b=lU4xXLWSBA050qXn3vqYvcIwXTTDhhabLy52MK/bHcZBUq2qVHM6WoS4uc+MRjWDu6oaf6sVqX2aPXVZZgsN7nltGXRHq4ShU7ojZxHd14sabOozqvA/E+mCEJRrdP1x27CaSuul2fRpa7EfIx76FQ1j5WXH4O5+Atq4YyWh3Ic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392877; c=relaxed/simple; bh=A9cDvDliHQWTkCYAiXjOY/rOFGbBUnrgZEZV1RtlPDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mbVrzPMUrRPAOo/y3iSMzMclQsB+n7o4+G3AmMdWQwvR4rVrIfBeKsjHqHeS+MT/IILUG0Tv6fgIe9fL40v8cfhwPf/ryVXXapVi7oQg06YOROAVzlKVJaF0BPt6xuiQtpwCfFVsfEr94vTErQk3jDSjCxL3S1JX/29QunPy1pw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=52.101.225.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Eo0yrjgwKwbit2F2FwGoezyydNlVU4QwkQlb46VkUCj0XHiPAw0r/dwewcmShP3hgNCwXKhkPb/S7mzPhfnQNcekaYvA812YV/ZzYV5BDJFXmNBRwR0BqQ4LJR08fw0FL58ee0o7MjRyz/b9w6MVPk3/B+gEPYXtejp+wtaFS6ZN3c9Ar5tMi4xD1m3T5kejSxAMWPyHuWgqsl0SN0Sq1xVLZx3QRwSCQLHGGg9k1VGetP2b4gmrlRrpmlPxlmpZpzPX1sZfGOQabcLB/iijs5BY5maQ8TgPyELh5w2FQb1QLPH5Foc5KhVNi2Pidjw51oSqxueYrVzuFfSBr2tnOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DWj9UjbaMlM+WChAHjwIOH/jC7Uv0haZCHhm1bJjExo=; b=vWhCaWDDg7qKBM26UrfUzqoDTTZvmUe+dlZpSeY7C+HuTeS47CX59DVtQCWIjLhrHxYV/pCDoWQpF+HEthT7b9XPziOHemtcoIwEYotU19d3iPueuAtGVI09Dpfvf6TF9AlMZk3gwXzvXgqZQZNFzp9+EKY1DYnB/HPITEPeuzpLIpXR124MFiOHy0cEfsjtMZet/tu4jSRQJPwavwJMXgVt+yE0xTBNolY35zVLaSis+vbGppuYtOI+gB3aUjGLNrR/93ITqhsiPlSOUowDlfaAPa3LqfPXB3ZPRVhdduc6X/PUbjCYcUuRsW2Yug6pkQXEO2CzdYwchX9jT9kX5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PN2P287MB1360.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:127::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:32 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:32 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 1/8] media: qcom: camss: take the link frequency from the CSI-2 transmitter Date: Mon, 14 Sep 2026 19:04:09 +0530 Message-ID: <20260914133416.1030231-2-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PN2P287MB1360:EE_ X-MS-Office365-Filtering-Correlation-Id: 40e72e45-a9b0-47ad-6e0a-08df1264e8d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: Cr5azjh4YYdcnJVICYOaAlhavG+zTm/s+5MTXLcbMOYHUxtkDyRG+eg+uPg6Z93Zfk4GaXm2/ASRDdso2mghqnhNoLw3wqkey9F+W1kOfTacSdAngdKLs9LdJ68e/M4TuoYcP/wjW4LqxFxtvQdgOEa5FOxDkxWVyGuhKQNRdPxOjUel2U4pwAFUt0XyFfn7R5aFSCW76NpHI8mSc2hGVl3tK5DaGkLfReuEY9VtJasLM17mHNP2iGm5eqnhahmIEXpV4Gh1MZCfFUcXftxEl3oEL6bnGVKah2sSBR0icK7Y/WawZDQ4S9g4j2Q9ZckKX/3PpU/oXhHW9JSJZpp35KhF8g/oH9tqeXvrzmOtRXWEIRooV77H39696NvPWeqXKGdo+3AvfeX5IkE8neDCOAZEcFx3KJh4qF10XJfWcokycEXcRD5zSKw6svhLJmGsOoococs4uFbf3/m1XGiW221DFNVuEBuFiz3+3gFvT+Y+joAuocRMaKb0wIVaBXdf55iLQSiCPy/da5l5OLf5cV7G554UMOtMKr7up7HF3mMpmEuWIhfYZS4dOS+1S5Wv22Sdp1TvEh2kyAHNM/BDQdR+GF+DG3EgFdXkyXtwEEvH7KmttAkDrTYTu+ajYZrXvPp/v/dmsrtU1H5o9NPbdXjf4KkgySXWo2C3SpK/9gs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zrH3dxelMcN6TdnuIUNlhZsBg1qCVAfKZUcIaEKtxNrK+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MS-Exchange-AntiSpam-MessageData-1: llpbqeZvf9oPsg== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40e72e45-a9b0-47ad-6e0a-08df1264e8d0 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:32.2646 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: okZ95jIsFuqfghBrJG+ffzVt25O0TmnNarguJsFcYAaAPZsmjV2qYtO75D8UWZC1dmfVdJpbwU0+z+GSzodCXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB1360 Content-Type: text/plain; charset="utf-8" camss_get_link_freq() walks the pipeline to an entity whose function is MEDIA_ENT_F_CAM_SENSOR and reads the link frequency from there, to derive the CSIPHY settle count and the CSID clock. The rate the receiver has to be programmed for is the rate on the CSI-2 bus, which is a property of whatever drives that bus, not of the sensor at the far end of the pipeline. The two coincide only when the sensor is wired directly to the CSIPHY. With a CSI-2 to CSI-2 bridge in between, a GMSL or FPD-Link deserializer for instance, the bridge re-times the stream onto its own output: it may aggregate several sensors onto one link, forward a single sensor at a different rate, or generate a test pattern with no sensor involved at all. The sensor's rate is then simply not what arrives at the SoC, and the PHY does not lock. Walking to a MEDIA_ENT_F_CAM_SENSOR also fails outright on a deserializer that has one sink pad per serial link: the walk follows pad 0, while the sensor may be attached to any of the other sink pads, and streaming is refused with "Cannot get CSI2 transmitter's link frequency". Stop the walk at the first entity that is not a CAMSS receiver, i.e. at the external subdev feeding the CSIPHY, and query that pad with v4l2_get_link_freq(). This is what the helper is for: it asks the transmitter through .get_mbus_config first and falls back to its V4L2_CID_LINK_FREQ, then V4L2_CID_PIXEL_RATE controls. For a sensor connected straight to a CSIPHY the transmitter is the sensor itself, so the pad found and the value returned are the same as before. camss_find_sensor_pad() keeps walking to the sensor: its other users, camss_get_pixel_clock() and the frame skip query, do want the sensor. Signed-off-by: Hitesh Patel --- .../media/platform/qcom/camss/camss-csid.c | 2 +- .../media/platform/qcom/camss/camss-csiphy.c | 6 +- drivers/media/platform/qcom/camss/camss.c | 74 +++++++++++++++++-- drivers/media/platform/qcom/camss/camss.h | 4 +- 4 files changed, 73 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media= /platform/qcom/camss/camss-csid.c index 48459b46a..c631119e2 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -546,7 +546,7 @@ static int csid_set_clock_rates(struct csid_device *csi= d) =20 fmt =3D csid_get_fmt_entry(csid->res->formats->formats, csid->res->format= s->nformats, csid->fmt[MSM_CSIPHY_PAD_SINK].code); - link_freq =3D camss_get_link_freq(&csid->subdev.entity, fmt->bpp, + link_freq =3D camss_get_link_freq(csid->camss, &csid->subdev.entity, fmt-= >bpp, csid->phy.lane_cnt); if (link_freq < 0) link_freq =3D 0; diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/med= ia/platform/qcom/camss/camss-csiphy.c index 539ac4888..000fde129 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c @@ -145,7 +145,8 @@ static int csiphy_set_clock_rates(struct csiphy_device = *csiphy) csiphy->fmt[MSM_CSIPHY_PAD_SINK].code); u8 num_lanes =3D csiphy->cfg.csi2->lane_cfg.num_data; =20 - link_freq =3D camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); + link_freq =3D camss_get_link_freq(csiphy->camss, &csiphy->subdev.entity, + bpp, num_lanes); if (link_freq < 0) link_freq =3D 0; =20 @@ -272,7 +273,8 @@ static int csiphy_stream_on(struct csiphy_device *csiph= y) u8 num_lanes =3D csiphy->cfg.csi2->lane_cfg.num_data; u8 val; =20 - link_freq =3D camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); + link_freq =3D camss_get_link_freq(csiphy->camss, &csiphy->subdev.entity, + bpp, num_lanes); =20 if (link_freq < 0) { dev_err(csiphy->camss->dev, diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 2123f6388..16ad1c26c 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -4619,24 +4619,82 @@ struct media_pad *camss_find_sensor_pad(struct medi= a_entity *entity) } } =20 +/* + * camss_is_receiver_subdev - Test whether a subdev is a CAMSS CSI-2 recei= ver + * @camss: CAMSS device + * @sd: Subdevice to test + * + * Return true for a CSIPHY or CSID belonging to @camss, false for anything + * else, in particular for the external subdev transmitting to them. + */ +static bool camss_is_receiver_subdev(struct camss *camss, + struct v4l2_subdev *sd) +{ + unsigned int i; + + for (i =3D 0; i < camss->res->csiphy_num; i++) + if (sd =3D=3D &camss->csiphy[i].subdev) + return true; + + for (i =3D 0; i < camss->res->csid_num; i++) + if (sd =3D=3D &camss->csid[i].subdev) + return true; + + return false; +} + +/* + * camss_find_transmitter_pad - Find the pad of the CSI-2 transmitter + * @camss: CAMSS device + * @entity: Media entity in the current pipeline + * + * Walk the pipeline upstream through the CAMSS receiver subdevs and retur= n the + * source pad of the first entity that is not one of them: the CSI-2 + * transmitter driving the SoC. + * + * Return a pointer to the transmitter media pad or NULL if not found + */ +static struct media_pad *camss_find_transmitter_pad(struct camss *camss, + struct media_entity *entity) +{ + struct media_pad *pad; + + while (1) { + pad =3D &entity->pads[0]; + if (!(pad->flags & MEDIA_PAD_FL_SINK)) + return NULL; + + pad =3D media_pad_remote_pad_first(pad); + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) + return NULL; + + entity =3D pad->entity; + + if (!camss_is_receiver_subdev(camss, + media_entity_to_v4l2_subdev(entity))) + return pad; + } +} + /** - * camss_get_link_freq - Get link frequency from sensor + * camss_get_link_freq - Get link frequency from the CSI-2 transmitter + * @camss: CAMSS device * @entity: Media entity in the current pipeline * @bpp: Number of bits per pixel for the current format - * @lanes: Number of lanes in the link to the sensor + * @lanes: Number of lanes in the link to the transmitter * * Return link frequency on success or a negative error code otherwise */ -s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp, - unsigned int lanes) +s64 camss_get_link_freq(struct camss *camss, struct media_entity *entity, + unsigned int bpp, unsigned int lanes) { - struct media_pad *sensor_pad; + struct media_pad *tx_pad; =20 - sensor_pad =3D camss_find_sensor_pad(entity); - if (!sensor_pad) + tx_pad =3D camss_find_transmitter_pad(camss, entity); + if (!tx_pad) return -ENODEV; =20 - return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes); + return v4l2_get_link_freq(tx_pad, bpp, 2 * lanes); } =20 /* diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index 93d691c8a..39ea33e61 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -168,8 +168,8 @@ int camss_enable_clocks(int nclocks, struct camss_clock= *clock, struct device *dev); void camss_disable_clocks(int nclocks, struct camss_clock *clock); struct media_pad *camss_find_sensor_pad(struct media_entity *entity); -s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp, - unsigned int lanes); +s64 camss_get_link_freq(struct camss *camss, struct media_entity *entity, + unsigned int bpp, unsigned int lanes); int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock); int camss_pm_domain_on(struct camss *camss, int id); void camss_pm_domain_off(struct camss *camss, int id); --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from PNYPR01CU001.outbound.protection.outlook.com (mail-centralindiaazon11020092.outbound.protection.outlook.com [52.101.225.92]) (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 9BCC3470E8B; Mon, 14 Sep 2026 13:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.225.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392879; cv=fail; b=hFmoDpq41aAVr0omjdIk1p4XlGMHxbPSTCdj5GunXRjTaEtGqnA64AhhGKE9YPoh/M/nn/UNVN93hXD3eFrWF92pg4NoRerLvHBupCZ40lGEGw5M0BeGHoMaDQDI+6fbkYtNQDAobdrC+TWsiUydMc/mw/n+qiCbtUYCLQZYwnE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392879; c=relaxed/simple; bh=Qr71f091SwxMYgvjElRq6JammAMajrRZIhp79sEp8Sw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JyQvlt1WRzi2twOPE1emG/FpiTIdtcAdvU11S3W3zmnsHlJqe9YbgBFcJEI967DPHZl+ndQrpPr3L01w5mIh18JkBo+SgFggNSrFrnavxnlnqD9b1buTSZzDRklGpFX8tk07LzlAcg9uEp4GjWc1aHTUD6Eh9EPHTkV+ZgilFHw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=52.101.225.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hMT5u746QCvmf4bTd1lqL+ziCpL7CA1v+1UYLp4MI7Z+TGqJuhw5s+f5P/MWzmcVlJoWn4oj83vM2++joYCosS9UETtvJNQQoS6hqEMBXeqmdgOx1c2E1tS+G1siBMeG1+ytDDfvTSnr80cjnUR2YgMqT6m6bwGUEgHYkZCkDshUl9SXVCX3qbtQHefcupuQRkCqItFVsrC9rbgSdZq1PTdAh2j98e0adUjFsphaPQNvBBYymCkpo6pJp9GGC1dRw9CG8uym9+qtGSiLLu4nnQjlV90oSD7PnfHbhghAv0TV03Yiz50/OOHfmonnRntw9bAIo0by+o3Mf24KrzTXJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mvLOTocoDucB1qFfOBBinAedd45w+eiWtQHbojCyKvc=; b=vBKc4W8d2nQzkYerci/1abjzm5UK3u7/oVtqiwc811DcsidF/PwYhLoeRMOQpi5E/4oVX8sr+0zHhinuntlfShIEaHBrZHgoyTxgneJFmi3iK5lN4a6Ywx0y9eeIrmoG1A6qJdno0B1hxIQyNrSjckOeEoeDVZoPiVaRyyFGo7J3pjEsqsdxz3QgkGF9ZYrK0wNTIB3Lb5tTsH5plc0PdsSqlnCFVt+CVKKHhU/oMLRxMENQqxIeIqZUIm6VJFFQX1DmfOnB2hpJuwr/JFWSx1czuwMVche007VxEvhJX/plwaI184mBtI4O7Rcih1B8zFc45HXwj8MEy2d0QXJe4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PN2P287MB1360.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:127::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:35 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:35 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 2/8] media: qcom: camss: create the source to CSIPHY link per endpoint Date: Mon, 14 Sep 2026 19:04:10 +0530 Message-ID: <20260914133416.1030231-3-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PN2P287MB1360:EE_ X-MS-Office365-Filtering-Correlation-Id: d20e5760-108d-4994-1eb0-08df1264ead4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 8xt2IT3BsJEvdl14Zf/7U68FmilYsAO8nuZJEP40hIsAeDjNST7nNWV7/3tc/RsVkflkFgygpkU5X+N7SQcDgQ157nsS+K+tTtXNPkSR1IrAKDFmbE3BLAY9hDC1j7YeQwZHCLnT47WKyO1pImjTwOW7BIgL9Om5viNpapfCIaHrPtSTqGzWDNxug3umCxsdZb4WcY2xrZ2ztr+PCvt5P/jBgdzrdpUsoOK+wS/ZAQ2dut/hpmgMQD6WHGLJif4OISYrAwDceAGuI6Vya5va6L31JvzT8lOIW3edpxZcsEEBB5/6R90zzOE6+S2Cm1dsUoOkQMaDEXmyhXX7JmMy+Y+O41SXcLDDG+/d/dgIvDdsaz5nkcaTu6dqOTSbBVHyVxfpWArAUBz4K89MSGnxA9wMCu9FINCeZKolzlNqH9YkeurbJDhP8xLwDdCU4u1CEk6bwaWvFD4qY8ldYOgOeJpJZLW5PVVyvgKVL8BnPlr6faY1cdsLC4c9QGGXavd0VfcwTKfYVRvoEvznOPl2m9heXJP7UJcXPhOYW4L2uMylCdKFqtSH7CzUJqgBwldnPLfxwJzsDogScyxwAY3IzNW6dKrDh2kcRKZ901SFbcqxKmZ4SygVa4Nq/my2NqCkYK+VgKBWskjVuLz8F7GKV/1oWIn1qFO4vYF81R4Eck0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FHEQiqbYpG03whOyD2gj2du6S3lvF7IJ7qfnZpTX6VFGSm9prGQ833lZ5SDj?= =?us-ascii?Q?7MUrtkecA/vGWxbO3lwyUbPLeQqcJIkwoPRpBZbP3597naH4HCYHczU2rruC?= =?us-ascii?Q?6l6SefAJbYsv835njJov4avmpyTd/ooX5nRp7ISuJbkRijhGL++Zxawt/wM/?= =?us-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y9u+llDMGoEJUlxr?= =?us-ascii?Q?UworlF+u9DYBKXeFSRXfIbDLEQMtNOmX9GyZf13nQbwXMhyr5Dk8h1D6KJwn?= =?us-ascii?Q?dhxVvx1k1M+m0ahh9sQFqar48OemBZiA4LNBjXgnwuUq7DTa+emKneCgamvR?= =?us-ascii?Q?0tv0XWirKPmiJTR1Q6OyX346x0fC2k0pTuA6ZpsZfgF+7MO95VTMi/HMNeMi?= =?us-ascii?Q?+eAoACpyKli8/5W/v+URk/3OluK6K4nrrsEkVQmsNXnM3h6byJD6yRgIFMkO?= =?us-ascii?Q?6m5UfExTDLTveKKEAEXYAk0e6+u+38IOO6u45rr6R8k5eqax6EWycEW/nTBZ?= =?us-ascii?Q?9rD9VC7s3cUUBJsR1cLL8c+H3Xy2zMhSUlZxiaTJjX1jvr3YU0Hvl0copWA2?= =?us-ascii?Q?EGNfBO51HUApAjInR3X0n6S1wrZCDWVVqq+NYgXkk5UC09Avw7+GBvpGNXC9?= =?us-ascii?Q?p+KYdFqSFG3Pw1lccDC2EUTZPtvbAVLUHilRgd/UcB1O/NXQoF4OfE+wCubx?= =?us-ascii?Q?8ODJdqodnaGnMqFwsxf4B7gnwsGj7DGBiSZnEkEWOSXOtpdoftqT4M6tsMJU?= =?us-ascii?Q?77I+pauJy/+wU7WGi6keKUAfTcfYWetX3B1GXja1/9XcMGW9HbKgxnLtWDgs?= =?us-ascii?Q?Ibac8tluFPXJoPtM8NNMkeizLFnx93U/cyNfyKRe2gWLUfx+6qzly7LmNCrJ?= =?us-ascii?Q?E49na3Ins66alP25SFbTduOtwp5lt1YRQgfKLH23HRS9LflMwewT6vU1wxwF?= X-MS-Exchange-AntiSpam-MessageData-1: NBv7wpDHdmiuAg== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: d20e5760-108d-4994-1eb0-08df1264ead4 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:35.7002 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sNiOSWJFdtyEfQyO+1M+cfpIbmpLKlzKAbz78ZuCbnG75VIufomMmvQIndlYl6cogjSDviYzOjZ68TFp4vJNJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB1360 Content-Type: text/plain; charset="utf-8" The link from the external CSI-2 transmitter to the CSIPHY is created in the notifier .complete() callback by walking every registered subdev, reading the CSIPHY it was bound to from sd->host_priv and linking the subdev's first source pad to that CSIPHY. This assumes one transmitter feeds exactly one CSIPHY. A GMSL deserializer such as the MAX9296A has two independent CSI-2 output ports which, on the RB3 Gen2 vision mezzanine, are wired to two different SoC CSIPHYs. The same subdev is then bound once per CAMSS port endpoint, the second .bound() overwrites host_priv, and .complete() creates a single link from source pad 0 to the last CSIPHY. The second output port is left with no link at all, so a second camera can never be routed to the SoC. Move the link creation into .bound(), where both the endpoint and the CSIPHY are known, and resolve the transmitter's source pad from the endpoint fwnode with media_entity_get_fwnode_pad(). Each endpoint then gets its own link between the right source pad and the right CSIPHY. For a subdev that does not implement .get_fwnode_pad, media_entity_get_fwnode_pad() falls back to the first pad matching the requested direction, which is exactly what the .complete() loop did, so ordinary single-output sensors keep the same link as before. Signed-off-by: Hitesh Patel Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 51 ++++++++--------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 16ad1c26c..4cf736d80 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -5231,49 +5231,34 @@ static int camss_subdev_notifier_bound(struct v4l2_= async_notifier *async, container_of(asd, struct camss_async_subdev, asd); u8 id =3D csd->interface.csiphy_id; struct csiphy_device *csiphy =3D &camss->csiphy[id]; + struct media_entity *input =3D &csiphy->subdev.entity; + struct media_entity *sensor =3D &subdev->entity; + int pad, ret; =20 csiphy->cfg.csi2 =3D &csd->interface.csi2; subdev->host_priv =3D csiphy; =20 + pad =3D media_entity_get_fwnode_pad(sensor, asd->match.fwnode, + MEDIA_PAD_FL_SOURCE); + if (pad < 0) { + dev_err(camss->dev, "No source pad in external entity %s: %d\n", + sensor->name, pad); + return pad; + } + + ret =3D media_create_pad_link(sensor, pad, input, MSM_CSIPHY_PAD_SINK, + MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); + if (ret < 0) { + camss_link_err(camss, sensor->name, input->name, ret); + return ret; + } + return 0; } =20 static int camss_subdev_notifier_complete(struct v4l2_async_notifier *asyn= c) { struct camss *camss =3D container_of(async, struct camss, notifier); - struct v4l2_device *v4l2_dev =3D &camss->v4l2_dev; - struct v4l2_subdev *sd; - - list_for_each_entry(sd, &v4l2_dev->subdevs, list) { - struct csiphy_device *csiphy =3D sd->host_priv; - struct media_entity *input, *sensor; - unsigned int i; - int ret; - - if (!csiphy) - continue; - - input =3D &csiphy->subdev.entity; - sensor =3D &sd->entity; - - for (i =3D 0; i < sensor->num_pads; i++) { - if (sensor->pads[i].flags & MEDIA_PAD_FL_SOURCE) - break; - } - if (i =3D=3D sensor->num_pads) { - dev_err(camss->dev, - "No source pad in external entity\n"); - return -EINVAL; - } - - ret =3D media_create_pad_link(sensor, i, input, - MSM_CSIPHY_PAD_SINK, - MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - if (ret < 0) { - camss_link_err(camss, sensor->name, input->name, ret); - return ret; - } - } =20 return v4l2_device_register_subdev_nodes(&camss->v4l2_dev); } --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from PNYPR01CU001.outbound.protection.outlook.com (mail-centralindiaazon11020092.outbound.protection.outlook.com [52.101.225.92]) (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 312F3346E7A; Mon, 14 Sep 2026 13:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.225.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392884; cv=fail; b=lBRDREqWzzYPk08ysaJm0bFelKGLetPIkoKzmjYOCgT/7mAsIXh0FfeT9gRQV4dYjZtaIJRlcvgLn4Kr4udssmhUzmQqJa4UJt0XxiiS2zhIBza0PFXbOpL/CcZ4y7EMu8UIyq+/z+6cK/u9RkkUdiURUywau7GLFGXyctAOXdw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392884; c=relaxed/simple; bh=TQVKIzh5bH+lwvr9GKJjMwuX5ZadPOS4jONuOF/w0Ds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ohF+8fNXaLdDUTT5y6vAv1UpS0ruDRV/FFVhkZmVR9QvZU2Atrwgi30SLhhC2YjALRi9k0DZYufa+VEPaT9UV1JNdzBlIFXC1Mz6oJzfP+dAvO4iUrDApoji8OxxX6v2GJxZHbTOwVySXDNuQ4uWiKLfQkIXQNp8pODOgZVfmbw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=52.101.225.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RHCG3/WuFjhotGEuUHbvZLB+4SggxBVQHCj/0rGQsfmxlS/DvwPuQZJpz933Nu+jEaCh09pwAuaXsZY/AVuB+YsOlDwG/ARBgPHsIZt7BwWHToWD1Zl2ELLDQBvi6szYbUZ8WT9DevjEfc8V62la+0hymfBuuXgaCr3C4FbgUnddDtMNYyepF/BIdcgE2d8cVNQ1SZ9FGN8bYL21ByUCa0V4Gl+/KjomkgMTH8GN0RBk1/ErW1yj+TEE4aB4K4a6TUMRxmlTPU1KDEo2zzapK9/fgZ77Mr5b0haqszSXcqxnS6BvDZUhl1oE+unCikNvV5vfyOoU9rbktM7ZkEJfQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ojZ2mXdw32kVSt2/uLj7XldDPFmz5tzNJFnp6AwtOeI=; b=vKeLsQ3BmI0Ks6UdJg7l4zUAQ7y6y4OiLdtjEotZHSWldGwsK4hmln8OLdzbhJVNdkd+GGhEGyJr+o26mGMI7dPwBWOvffopiNbM+xPCZIQArv/Oh7IYEvzPZM9+WaF7dbAe3c7cJOiaGqdHx7SKp5BtYdON4N32PPPPnc8zNcPUcvkLCe9kuwNJGayfgPzu6bDePhDrSbrQZdN0S0PdTX9eDFwBr0xjShy/2uxXcFER9YDqQhgyvrpb5lEnXPEqBPSxkeXa7uoKGse3sE4yS0RqrMgOt0tVk4XTWVu11grCNpNqGqiUV1t+hFWQQrqddk0/2WrAklJ0h5u3NVEviA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PN2P287MB1360.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:127::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:37 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:37 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 3/8] media: qcom: camss: vfe-17x: do not gate write master done on IRQ_STATUS_0 Date: Mon, 14 Sep 2026 19:04:11 +0530 Message-ID: <20260914133416.1030231-4-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PN2P287MB1360:EE_ X-MS-Office365-Filtering-Correlation-Id: e962b17f-ec23-48e0-4b23-08df1264ebbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|56012099006|5023799004|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 3Z6Z+LJu+dl5KcsWY9cgrZxNurlSw1AGMh7k20HKJFr6uymMV2ZpIhWJXHV5JfVGVW+AxH815B6ZZPdWrLpEAAswRs1UQx2coeXzgZKiqppiCynuEO/pRAXugt76GYXEZGGAhgbdhQp3b/mY1TK171U2WRYrgGGXvQh8tvQXQIs10IIUSTXIvIENa3I8FO4HI6CuAbawey2QR7rGna4IlHFnw7ZTVnxHQWo778oAOm9X0IR4xKt7qyUW0DiYaa1oluACiTXju7KBN3lEfRwuwc74D6qGH937AoUggMeXjagt+0tCAM8uCP/aMfnNsoh90z5mXoTe/rltPYuassEI6TP4Hmc8tZu3fsMo1dG8zEFSvXTwdQm8ZevZ2fIE6Vk1GhT916oGdAiuVj4Dq/CBvMkc+IYYl52VR/tmPbucDgdfffm5Cz9nQUffBOl8Zr9Unr0U0QVPn7hiDZqLe/sS6JA1h9OX6mhQzPs/wBwfBJZHAoFbXTSVqFwaCZLBbpeBQ/j/WIpV9SCl76NRggBiJAOdXjKBLn5/h9pCbssb1qE11R5j40obyTH/VLdpW3ZFTMWGNyoC6qs4YQ0YTsAnJtzOSi5njUZZcIpTsacJyPz2EFCZjFhey+x5Xp64Vva0CThGQ1+9n9ZEt5fCKmfA1+OMMzQ8vQSBvw4eMcD1sUc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(56012099006)(5023799004)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zy3l3ZDQaUMlTVK+9XklhPHWNa96vn5NvenzBY0XSmWEDBKG2C0x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= X-MS-Exchange-AntiSpam-MessageData-1: QXmz9/9F8LdXiA== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: e962b17f-ec23-48e0-4b23-08df1264ebbb X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:37.1791 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: szyYeBR00vNRu78t6S0GQB3oPWM46LIes3H62sjaMH5khMFzQMzwvKWgF2UObOlKHQUViTWrdQI9GeZfOpLPmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB1360 Content-Type: text/plain; charset="utf-8" The VFE 17x interrupt handler reads and clears IRQ_STATUS_0/1 and then reads and clears every BUS_IRQ_STATUS register, unconditionally. It only acts on the per write master WM_CLIENT_BUF_DONE bits from BUS_IRQ_STATUS(1), however, when bit 9 of the previously sampled IRQ_STATUS_0 was set. That bit is the ping-pong flag of image master 1, which says nothing about the other masters. Those two reads are not atomic either. A buffer done that becomes pending after IRQ_STATUS_0 has been sampled but before BUS_IRQ_STATUS(1) is read, for example while the handler is entered for another line's RDI SOF or REG_UPDATE, is cleared by the bus status read and then dropped by the gate: wm_done() is never called for it, the buffer is never returned to userspace and that line stalls until the next frame happens to line up with the gate again. With a single RDI streaming the window is rarely hit. As soon as a second RDI of the same VFE streams, which is the case when a CSID demultiplexes two virtual channels to RDI0 and RDI1, the interrupt rate doubles and one of the two lines loses buffer done events continuously. The bus status is read-to-clear in this handler, so once read it is the authoritative record of which write masters completed. Act on it directly, as the gen2 VFE handler does, and drop the gate. The write master of a PIX line is skipped: its buffers are completed from the composite done above, through vfe_isr_comp_done(), and completing them here as well would return two buffers per frame. Signed-off-by: Hitesh Patel --- drivers/media/platform/qcom/camss/camss-vfe-17x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-17x.c index e5ee7e717..f62fdabbc 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c @@ -363,10 +363,13 @@ static irqreturn_t vfe_isr(int irq, void *dev) if (vfe_bus_status[0] & STATUS0_COMP_BUF_DONE(i)) vfe->isr_ops.comp_done(vfe, i); =20 - for (wm =3D 0; wm < MSM_VFE_IMAGE_MASTERS_NUM; wm++) - if (status0 & BIT(9)) - if (vfe_bus_status[1] & STATUS1_WM_CLIENT_BUF_DONE(wm)) - vfe->isr_ops.wm_done(vfe, wm); + for (wm =3D 0; wm < MSM_VFE_IMAGE_MASTERS_NUM; wm++) { + if (vfe->wm_output_map[wm] =3D=3D VFE_LINE_PIX) + continue; + + if (vfe_bus_status[1] & STATUS1_WM_CLIENT_BUF_DONE(wm)) + vfe->isr_ops.wm_done(vfe, wm); + } =20 return IRQ_HANDLED; } --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from PNYPR01CU001.outbound.protection.outlook.com (mail-centralindiaazon11020092.outbound.protection.outlook.com [52.101.225.92]) (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 9951E472527; Mon, 14 Sep 2026 13:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.225.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392886; cv=fail; b=gbh0IY6yZ7lEWbkLSGNwGF86ynx0ulv6ZFFeKulzjTTDiQRsBxVlTMxv/jpbaVsDR9tI5Wmikit5Xd1mcLHI3I7+3Ug39Rs8hjJAcNIzM7FfalFrI1hzUqULrL6i0BHX5YsYVVetDTFsIaVZVA6jV67ro+1obGgE+LAOd7BJirQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392886; c=relaxed/simple; bh=YJwWVq2CNUNPCmPHrbeCRebXO/0oPXHgr8pXHMI6OWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=pauBEnpOPZ/FQ1NvZyIm2id48qipRs4dzBffauMcD9nCP5TcGAM/HqP/IfVn+xIR7b4fSeD+baJnqResT3smCbSk2CZXfobZo1bxguFJDdAcnXDsBtNRcWBap5LYMIU6FbeuXfeWYa6QZRrYnB7Rh2ed0ErPK6rQLK/MawhEKtM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=52.101.225.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qIqF3JguZV2lIUiITPTmPmBZ6YtI51PgXaTbtw2M4Tbqp6tW0c6IJtL/ZqKvONzq+l0ylcdqWgSJ/xuz9XXJPlge5rEGH+qDY/raKDN9mxAUw20DRo1oKNz3IjksfTB16QIUiAcRMDEl9dczGVCp4OsMj0TYxp82+U9kH42xAMQ+dCx9+o9IeOLeaUhJBPwZNqZk3/gPotRny57C3GKoOzt3uknWg7L4fhIFPAyNtYABw2fPuV3KlAPvbjOT03bPkNluCJ+z3q4Wopa/nshNvQEyTl/8NvBUhxZOBxl5rXWdOhmJi8yRM8hFcAYWkzINBrWtGqU8utj0CCIdrfglTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Bg9rTlNHWVPDpyT5lQgGIzx0WcV7zZ66+/Jr7WxnGGw=; b=gpa2/FQHiLA+dH67BTnlGNOtKuskJkE6ZHW5QUpPdzkKLDW1qoI0nKehfGe9PVCUXIjeoMnLfCOE02vCpAiAGIikLvT2qj6lilMu/VTtm13unLl3nI81qZDLwNAil9csn2fXDZRTa4g35n2NIOONZJfZ6S0f1sHE0dfjmELumFfLsV94R/f/BQVUnL9AuGbKty8lKfBZ3bbKuWBvT9w2LoyYPM7ktbnsdsO3ZfkJiJ6JPDKdb2zeAlLqGwZXfIJJWBsY2JIoxuwQNbow6hbXkiBX+tF0OUP8QcS8MzhnUtJjLkARkij55fleDypJoOPPri02fAaUqhDjvqm6Ew1nMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PN2P287MB1360.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:127::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:38 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:38 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 4/8] media: qcom: camss: vfe-17x: use the write master matching the RDI line Date: Mon, 14 Sep 2026 19:04:12 +0530 Message-ID: <20260914133416.1030231-5-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PN2P287MB1360:EE_ X-MS-Office365-Filtering-Correlation-Id: d6423a39-da3e-49de-2d08-08df1264ec86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: NA5BlIQFzydpnGPHJOnbn1+XQ5l+a4Tv7skZ5wF/+KkOYZpnH/9iEza9xhbA16ysrje1huBAKk2WCy+HAP0Gmt1r0BeRpt+FPfSbQSKFx7S1IswME8vSnoUGZw6VXUct1aIZbfauZatp2Hou+xKSv4rG8+deDPBnD+LPlir1N2QOCh7KHFyw+9OKl3/aLNdXAOzSpjTE4/r0mUF6mh3aUB7CChWfNF/G9iwXqgm9j/C6Y4OEO7T9DEQecwhfZZXZnKCXGUoFHWv6ybWwoeEIm27reOFMO1i0JnmD5a9dxzpxM+0BFcVfqsO6dwAdx8nmUfSDocwyoR5P/iqu/lMpgxtfR9c5sWtaZDzX0cBMV1/XmbS6AbDp8cA7Ib1S3Tc2VgFUN6r/oxFTk8lLA5GlzKXG/Pl6kq4VsGoaP2wk4HmYvHg3r5241In3/0iKWTkAcvBeceoQqiI4iCF+Fyg/GhkYJU7JqjcZ6lC8QpQXi0FZ9/c26jM/W8ZFVUILr/sp0bTyJdfXYZ77Z8POCnF1mEphgK8F/OdF2Lstmmi+7fs3EwgOeAZpPnr1h5PtdNtfwtZ9wIBlYdb3rF0siy8lcCsgDViS0dNplzmCTXg5dEkQ342vr0RUGjcWIvLndcERvCln69UIcUJ+mWvc1qGkcZo2h0HgZ0PlYfs0KHhklNs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7+qfepLZ948UfdoQHf/K6WPJZlfrSlgidptPbLSMxRFsja4Ndik8+t0KV6Xw?= =?us-ascii?Q?neeOWZdVt2r0xRKRxmA0G2OpBjEDufeIhRK4Zeg1lB8peRWFCnvS1kr+V9YQ?= =?us-ascii?Q?Ob3dAO6jlBjUQ6jGURv5vsQ5UFMKowxYygPzaJjNYDxnT9iTITTatK26hq17?= =?us-ascii?Q?uhLH0v5diRkJMN8a6vKKKDn9yV6Ixb8HmH8kAM3d9tde2JoW+kcIzWwFJI7d?= =?us-ascii?Q?CJxpDKkBWloHDwj9gx6627183b+7CwfqYwkG4g7ua+BlMsUhwuu/Ag0AUz49?= =?us-ascii?Q?WY+utlN5fa7CngQHsDsO9rWKXx2AHyTF7rDjyPRIFNT+YQCrkNtpskldpg4B?=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1gB5gE16hbv2itDWKTd6lj9dAZpGmfx6KTqUhM6G?= =?us-ascii?Q?QFD7reXQOwfYJOsXMb/YpS9epk5EtXOdj2L/HFwyevh1CbqQRLXOqwj6lxTx?= =?us-ascii?Q?ihRg/03UXHW58xELOI1lET1Do/izekdP4TWMFVrQmnxFJvt2i4vTgdL7lJAe?= =?us-ascii?Q?LyXANMcPDSGbKi9pzTVKKiWufEjsLWiwQMgSUTdaXQkm8IZTqiR9I8mIM/cs?= =?us-ascii?Q?l/VkCqXk/1g+YffwRZn0T7P888YMe008r8DUn6Jv11Y2vV56QTPT9SHAb7sv?= =?us-ascii?Q?u+szoctYETKsW4PFuxPo0P1bJKbhROfZpQgTYLNdoEtWj+czPItlQggwkIlO?= =?us-ascii?Q?HfxlASNkqY52weKYHpXI9n29h87+gRAIL5CZ3siUsnCmahv4WlYGI0UZnsXY?= =?us-ascii?Q?F+pYJIYwJwQdYxNl1R+cJFZy/Xq/5XtpVUvPcSjnmb/LmQkgK5i/8jmAyEnV?= =?us-ascii?Q?FnapZelBfMnBrDx/OZaCUcW3BCkGLSzyrU3xEYJGyOqE8fssoQPjGX/GetE7?= =?us-ascii?Q?XV+1GCANxvKtWYGRsJdj1rASmkLslabkceP4LtzAtLw0tvDB5kRLgE7BaF3E?= X-MS-Exchange-AntiSpam-MessageData-1: Ie0QG4yFixOWjw== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6423a39-da3e-49de-2d08-08df1264ec86 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:38.5023 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: raOnZOsGTXdV9kHPTTPjx7u/KOI+1HC1XZazDtJwDF7n2izValk2GGA2U1QKLA9sK1pTJ3cRSP5ibHCvfOQpDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB1360 Content-Type: text/plain; charset="utf-8" vfe_get_output() on VFE 17x reserves a write master with vfe_reserve_wm(), which hands out the first free entry of wm_output_map. That only coincides with the line being started when lines are started in order and RDI0 goes first. There is no crossbar programmed on this bus: RDI n feeds bus write master client n, so the write master an RDI line uses is not a free choice. The mismatch is not visible as long as a single line of the VFE is streaming: RDI0 always gets write master 0. It breaks when a CSID demultiplexes two virtual channels to RDI0 and RDI1 on the same VFE. Whichever line starts second is handed the other line's write master, and both clients are then programmed with the wrong buffer address and frame size. Frames are truncated at the smaller of the two buffer sizes and the SMMU faults on the overrun of the larger one. Reserve write master line->id for RDI lines, as the gen2 VFE path in vfe_get_output_v2() already does, and fail if it is in use. A PIX line is not an RDI and its write master is not fixed by the same rule, so it keeps using vfe_reserve_wm(). This also removes the error_get_wm label, which released output->wm_idx[0] before it had been assigned. Signed-off-by: Hitesh Patel --- .../media/platform/qcom/camss/camss-vfe-17x.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/me= dia/platform/qcom/camss/camss-vfe-17x.c index f62fdabbc..0cfc24255 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c @@ -403,10 +403,20 @@ static int vfe_get_output(struct vfe_line *line) =20 output->wm_num =3D 1; =20 - wm_idx =3D vfe_reserve_wm(vfe, line->id); - if (wm_idx < 0) { - dev_err(vfe->camss->dev, "Can not reserve wm\n"); - goto error_get_wm; + if (line->id =3D=3D VFE_LINE_PIX) { + wm_idx =3D vfe_reserve_wm(vfe, line->id); + if (wm_idx < 0) { + dev_err(vfe->camss->dev, "Can not reserve wm\n"); + goto error; + } + } else { + wm_idx =3D line->id; + if (vfe->wm_output_map[wm_idx] !=3D VFE_LINE_NONE) { + dev_err(vfe->camss->dev, "Can not reserve wm %d\n", + wm_idx); + goto error; + } + vfe->wm_output_map[wm_idx] =3D line->id; } output->wm_idx[0] =3D wm_idx; =20 @@ -416,10 +426,8 @@ static int vfe_get_output(struct vfe_line *line) =20 return 0; =20 -error_get_wm: - vfe_release_wm(vfe, output->wm_idx[0]); - output->state =3D VFE_OUTPUT_OFF; error: + output->state =3D VFE_OUTPUT_OFF; spin_unlock_irqrestore(&vfe->output_lock, flags); =20 return -EINVAL; --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from PNYPR01CU001.outbound.protection.outlook.com (mail-centralindiaazon11020092.outbound.protection.outlook.com [52.101.225.92]) (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 E6C8D4746A6; Mon, 14 Sep 2026 13:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.225.92 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392888; cv=fail; b=XoPWvQabUMcqy/wia353+hwwx7rSyjV0Z0vXOen7knZHbuUEBuz7O3gbem9oTSmcXKvwXw94jBL3kU5FagVAJYu9NSKgIOc3Nz4QijHN5+OE2NGVvQwyrVheWnP0yV1b+VeFFObheghX6UB5mZZCfnRfRKe0EFQRlOTUYZxECNA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392888; c=relaxed/simple; bh=Xp5Rm+M1q7TJSmOa3t/5KZ4DbEzbAoyGVQQ4gz8viB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=GcW0igj2qHi7N6U1fP6F1vWF3rGPO6jOIWFq6CIyHk7WD6mmqFocUOnAlANpNtVPH0hbsWf/6aJqwWowi2TWjAUQ8R3D6a2LNRTKcJGBzxlvbOTsLzrm4cNqQIdyN7GXIqpzHygmplzmeUPcugq7yaVwbYrIHybNWA8j5wwcXGk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=52.101.225.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AkJmyGeNucSCzFrwRNQBhuM1YhoV1kre8lp8txs8FsaorFjnZp8L/rbNeJBlTpCWJ75MuzgVAyl53eEVMpf1Zxy8aApVWMEf+QzaT7FQVH6f1N8ESgk2DwfjpWHHBFd6GR1ZAqATd2sYzxPMPcgThYeEMZKljjcT0CiyaucaeSt6YS4DvrWqYwZHMokuoN48of5KvZlaPGk4bEWID+g/7kgmnN2NsS+oS1aGNw9s0K5SheLAlpLG7dRehI8ZwDAQAKLz7Sk/Ihiqezc4yZCNvniRJN/x0Stmy8x6Z9sljaXsqbT6iVDtDDlnxSDwJcoJZDNb1nz/iFoYEeWUkCfHGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UDeYSWfU0N3l/5oT/gglsOfaFHSnACHOTuVCvNFW6TQ=; b=vXeZFKEsZB/AxGwbW3sFv8p4E19nwxl6ZO68v8KMfHPEhQnIhH+e+Jz11XH3HFZHkkNu3epgD36T+YZdpz/q2gs8i5KE0wGFpypoPqxD9RSwEBhBm3ObV7181DDBf5dVCcFQs+H1zFPzSxa2OOxXxwEB+P9ZMS7fQld1LvdXQVkp5J3tPcev62G+UrJLPGqpnF/qiiIK+pk8De2wGIUNBcdlj67EITzaIbhU8mc4X9e1/oUhqxSw3wN3pIBY+kgKs1jdGnYuj+iV0yi5dwxrRWeqwrD6vN6u9GSdxNvS/Y6IcMuozA6YXDj+C4Z5YAG6i3s/Ce/aE5Z0ONHkVJV3Bg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PN2P287MB1360.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:127::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:41 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:39 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 5/8] media: qcom: camss: vfe: only reset the VFE when its last line stops Date: Mon, 14 Sep 2026 19:04:13 +0530 Message-ID: <20260914133416.1030231-6-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PN2P287MB1360:EE_ X-MS-Office365-Filtering-Correlation-Id: 10464b59-3a54-4882-95d3-08df1264ed43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|6133799003|3023799007|10067099003|56012099006|5023799004|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: xcRiXYEj6O/vNr3xd6xICTPzDaSqilK3t7VXKQndGXC/ZG9wv2S9KIxC0s6wssgy9N/X6+YLyGWtvH7p/jSpXTcKa3o8axDSzALX7X63b5I01h4kLQ7R4QJC7b+0DyqsSj0rgIbmOOeg1y2DAT6tErPFKSNR+RpOQxfAvIVJrEIzVLca3nxjiolB+ofvpBi+jD2xeC26s5vyPcqCB5/byTfsf+wkgy0wILT41puYtSmFvIAeN0yG3N8f/D5Wuj2XGDHbW+aylmCfCXwEb+t4yoAgYdF4XB6eVquGp/KzH7hnhB5mLM1TLDtaU4IBUL6yg2vtXFtljweKjlcvjOXy2Ho834Yz1m4LA+TV9NCLi3irji74lQleMfladuozJ1IplhTPvmZajmSjal2QJ7/hxvWkAS9RXo2oQvXCtCq3jCFuvUuEqK6nf8fMIIgOFU21eEf0q5RRXA/bXD9/GBHKwQvEkllGzaTDfLrxTFrXjZJ8is9a9t9pwkLxcJOuKbGB3gvESW940RO+4iDIU5jRdvB6sIRQiOcg+7XQp0UnTvip3NziwYxglpqrMEUOijPj+DJZoYKZJg1I0VFJp5At0DzxUyf/1kB3WV5K5/Bm+bGtDfB55X0N+tV4J3IwUtsJQebSkZHEaB6M1qYf/uR5L7FIoTa4V/LqeQgtXwrm1dw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(6133799003)(3023799007)(10067099003)(56012099006)(5023799004)(18002099003)(22082099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ulv468pVNomz86KiLyh3nzPzBbNEv9fsmzFjZv+W8RUA3+4OZQBw+dLFPWMc?= =?us-ascii?Q?iu/SPQmEGOkCDk7NsBGFXpT7jrIbo+xaxcY0+591VlMR3bnjMcLcGMz9qo7v?= =?us-ascii?Q?1egUG9i+rFN7vallBEBwO4BvLcm1gGrxb5NJWIqjMzuvxpQg09q6nS9wTF9p?= =?us-ascii?Q?X5DCjlwOJ01TtBeN+HHi5Q60I9147TKtMqkwUKeEeVMI54Vgos9O+mK24/y+?= =?us-ascii?Q?UXUWU7DCNXtP3Q/sEotYRmuu1fg4tuQYoLoDlZwqwnTTqcTQRc3+1xoSgams?= =?us-ascii?Q?5pAO02f5IB9rNjsZN9wbupZv13/hcRahsIDmvr38w9kPoVxqjCUQp0fCdJE8?= =?us-ascii?Q?jR2MsQpDVdIN1FMLH0Z5KjOA+NzvqiO0QkbAu4gPcw8qPMXimMZtl4UKBBCk?= =?us-ascii?Q?1hgMINuN0fyEV7WTeoJO1sQZEUIS/rnx+I5z0NTvq5j6/Hb6C+j4YKMAIovG?= =?us-ascii?Q?O384cMQyL/mHU1NpbQyQtOF2zkCi1POo1Bbor4L+3sf+W1e7ECFzQoCgZeAl?= =?us-ascii?Q?Yq3gqhCislPVFNNYmmDg0dWepc0LMARlmTvR3n7FoWg26ebGOck5+C1hhJB3?= =?us-ascii?Q?McypEvcmWA9d0Q5oHup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1/cZ+9QR?= =?us-ascii?Q?ThDFfMYG+JHRYTsCG93bv+PArZnHp/mrJS2gXFqRnrE/x5/a9TY4xXGFhWyX?= =?us-ascii?Q?GiUhhzK6waiqi0MgRLijDAaat4+h0u7YJmMwriWvq9OKYmSl7Jb+4gqnZ8mE?= =?us-ascii?Q?Fb1spkQnwAl5PXLVYzYV3mEmx3rIAjhC6JaB9REiGSasX9IQbRC/KSLl00yX?= =?us-ascii?Q?p3yNuw7HtjgVGfF7CZT84ooLedL8ZRIZ3Uc8nzAeqd8V/ldERTzLu07gG/9l?= =?us-ascii?Q?1ZA5BBZhQ/sg7Kh2Q68Jzgv6ug6oY0jE5N/HHyTTRnd+1VAx54EuFRvGyOtC?= X-MS-Exchange-AntiSpam-MessageData-1: gOKEiJpUDQG/Xw== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10464b59-3a54-4882-95d3-08df1264ed43 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:39.8030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YinxyTrAj4VEKI1VRlPIySYklaDFh7vjDaxS4VOLpPC44rg8zYhJynO5w/gjbWs304aPaWOg8A6yo332TCuutw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB1360 Content-Type: text/plain; charset="utf-8" vfe_disable_output() stops the write masters of the line being disabled and then issues a global VFE reset. The reset is not scoped to the line: it resets the whole block. Several lines of one VFE stream at the same time when a CSID demultiplexes virtual channels to different RDIs, e.g. two GMSL cameras aggregated by a MAX9296A onto one CSI-2 port, each on its own VC and RDI. Stopping one of them then resets the VFE underneath the other: its in-flight buffers are never completed, its write master configuration is gone and the block is left in a state where the next reset is not acknowledged, which surfaces as VFE reset timeout when the remaining camera is stopped or restarted. Only issue the reset when the line being disabled is the last one streaming on this VFE, as tracked by vfe->stream_count. Stopping the line's write masters is sufficient to quiesce it while other lines keep running. The single-line case resets exactly as before. Signed-off-by: Hitesh Patel --- drivers/media/platform/qcom/camss/camss-vfe.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/= platform/qcom/camss/camss-vfe.c index 319d19158..9cdf26671 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -814,6 +814,7 @@ static int vfe_disable_output(struct vfe_line *line) struct vfe_output *output =3D &line->output; unsigned long flags; unsigned int i; + bool last; =20 spin_lock_irqsave(&vfe->output_lock, flags); for (i =3D 0; i < output->wm_num; i++) @@ -821,6 +822,13 @@ static int vfe_disable_output(struct vfe_line *line) output->gen2.active_num =3D 0; spin_unlock_irqrestore(&vfe->output_lock, flags); =20 + mutex_lock(&vfe->stream_lock); + last =3D vfe->stream_count =3D=3D 1; + mutex_unlock(&vfe->stream_lock); + + if (!last) + return 0; + return vfe_reset(vfe); } =20 --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from MA0PR01CU012.outbound.protection.outlook.com (mail-southindiaazon11021110.outbound.protection.outlook.com [40.107.57.110]) (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 A6B1F472093; Mon, 14 Sep 2026 13:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.57.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392888; cv=fail; b=NlmsmCc/w3HeM5oil562loj6RAvi4QARqDGzZlfPFuszlL0tNoiXAgdVNxLREW+yRNKmQicm3cn2pfZTRNGOCD1LUWOIcntidOUi78pE9O3NqyNgWQYHInTkD7Fl9ByMd33C/x1MGxWTgo3mBZgIjfVuuPRwDO5jXj74gbzOVAQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392888; c=relaxed/simple; bh=NmUXMfjgwTSUO/mF1pPZEnlWDUMBDcfVo04Rnp5Fcus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=G3viP+4Y8uxwUcPEr18ItKdvDrB7es0lYClgWWsioy7STZq2Rb2DYGLG2obNi1tOzPMNI4YumDySotJ4PyBi92QM5vSj9H7bfm1QKcaQF+0qRDLhtM7VXnLxbBT7IWzkR8daNF1yiQYFmlsUYpvsAk3FmqV5gGPUHTaP/B0BoeI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=40.107.57.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pRZ7ZMXfm9KYAnRDghkrQr4czmM9w9F++wN4M4QAttWQVnRnI0RJt0KeezE9pTSQIbGPbvO+AP6O6BkRIvsKMctOoUWvEq6f3TSAU1CDCBm7tqmVAlsBqpRwnKaNtmXjamL4RHWa5z0jnKhnFDnZ2Z//8Nz6rGJngE7oNeOdB07veKqnEntE0IxUmDPzqzIgvdGfgNOwYbKe9lSwou3bD29ZsfiIva3d8nUS+gmel2dXqy8cIQU5zkHEorulq20lgw00/fr4ncNa4BbdMpQMe0GruyLH1prrbkoBqVGY2AZtWnS3k/xxcMFgxxHlXkuQmnSWKzQsHTQQBQQWJP64aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i4Nzdz8aQBnoC+2/XO0LXOe1x4iSdoIFJNSol4b0hIc=; b=NtKPVx/csZjSv4xktWHPGWPv7IIYT8EuT7hjsfTwzl1auPCLOYeRWJ9ACbX/D9tyazgmHQVpA68DwzMwsi+v950/27G6XoCQTdOAClgx9zkaErHWrsYQoe7GgySg7Kr/Ydhkq0gba4FpYPq4xNkoYKWoOWx0Fnpz0eKhTp0stUpxrm5UIhvUnSTvB8afn17RP34QT3SZnZQgt5Eyc8nsw1Oi9fP6J5wgLPWebPaMaG/8KbejtkBoDWZ0Xw4TY5814A0hVSePb/aPlZrAOPtONVxJqhNZ45U0hAapo5/zpgV5ghNudtaESp4lodK0m228Yl81kjpw4iUiFSbnX+mktw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PNVP287MB6090.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:34c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:42 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:42 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 6/8] media: qcom: camss: refcount streaming on the shared CSIPHY and CSID Date: Mon, 14 Sep 2026 19:04:14 +0530 Message-ID: <20260914133416.1030231-7-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PNVP287MB6090:EE_ X-MS-Office365-Filtering-Correlation-Id: 3252a35c-6bc2-43ec-bb7f-08df1264ee09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|5023799004|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: pXqxz0SQQ2hc+OfiNN0MTGhtdlBidhXIdaae1SHB1EDbX6ruUB6xt0T03b6C/yxTF5sahnL4aa+IAmx5RET/wCPH7U0HLcP5rNlGFfOKKpjh1hvKzPofCAZ98z54p7Dq9Yfyyao7tOSNOscxy8VLp7/kTehCuxgQosjFUc9H1MdxESD9MZ5uC/FWTBinl+W4jLbY1F+v4U2UHQ8f9zRV8b9jQwuXJVS6Jeg8OIhJ9TfZio+Kgq8IUHZPBDsiw2vCkmUZbMomoZpzrxp/toyifP2AhyTa7Xpo8LrpPqeV+uNYLlceidRQC1N8a+mJyZdgtnqXDtcSkhyxiIGjvCSzv0DZQrc+FpZ3hHfEX/H7Ue2K3Sg1t4JWozGRWxBwfubP3jJ/IkGfakRiK1zo2mCCXs+gs1msU0m2UR2obtp75tuJ8VCbg1MlWollWLyrEXDIMcSdGRI5QVT3Oc9DlclQbeVVbipcl5UTJbIh1o+PkPx0qmdFJFYLSAyC6xf0ZwdNgtqDdUpSvCwqg59fQkESggtMkvtHIFGOhEqpl7Fp3euMMuS4TLVVSRj6HVysXwkZo5seQaePdGAVoQ4Y0ILIpGJLlcJgYrMqARptFfT0UEcum59aOENjT/xliYmJ5Imke/u2O+VXxUASgOCSSQyH411yxV+dDVcQeBz3RZQXHt8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(5023799004)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9fnY/sG6oL3wMnsd8VLMB26KWaT25BJ/v4UEVc8c6PMkFj4PuDPtCck4SBvr?= =?us-ascii?Q?MTKklGqIfwFt81MP6jvryftZvrKpYIElDGPeAUuJ9dwkpako4iFTRe9A8IHo?= =?us-ascii?Q?LPKBekFC6xJDyosv1i/uATnFPYF4LZLHaY0tzBhRUK5dZOqMGKFG0ZeBjoYt?= =?us-ascii?Q?05vSoT4pstgWW4DRkkpUY/+sbgERwBjbf4zDgkxkByaZWcMPFAvylrR59U0h?= =?us-ascii?Q?SwFgV96a3lgUnpMSKOeQO20vqADA5x7j6g1UsziCZv+Smw3E3lSmyvpW7tIC?= =?us-ascii?Q?ZWy8jbgoEkGd6obkY1ZfS6tpPuF03AkfUaolcuY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JMh3IDNHaK/KflDk0rDhLu+t5BsKVKo1KSYLwW38reMRgRkgVSQEosrTD?= =?us-ascii?Q?7G+hefeLRltuXdIuDzKHy+OYvT9I7kN+41hPDQ+3yqhvzBFzqUegmUXuherr?= =?us-ascii?Q?RBB6r+MCPD3iZoAts3+KQZSk4XqxCSOlD/jAwqPGR6Q//+wXnQIs5SoHck04?= =?us-ascii?Q?fK3bpqp2kA6NAKaErl+Tpz35D3iD2Gpto2BMG3y5DaExelvlIwx0kBMcIscp?= =?us-ascii?Q?1iSJIUrQqQ4hheq/bTiEnNxvQbSOH4fRVqDAVR7B/LNYmyansRvMcBMYpVMy?= =?us-ascii?Q?fTLlSuGhR3dQQsBg43x1klyEkhOaqK6EK3KeUWNMIDkUEhzY/+GtjMFn4yv5?= =?us-ascii?Q?2gkc+BgFLI+JPGJl7E6MMAgGERPG+7VFQv+jJ0kOzdplmF/bpsdv2CLgPjVT?= =?us-ascii?Q?nroPLlp7d0BQmh7PPwRN1RY/KI2GPHn35LcFm0UqVaJq4fOuI3Gg/SPCz9eM?= =?us-ascii?Q?b0lwpLPm4k6fb3HeNr1+yevLv/IO8VK4EFOZl99FygJt2RglR/VBVmFKobii?= =?us-ascii?Q?a/Uq1Q9QAqAkP1ccjM5DEacmYU6NtOa+cRTFXzZudA7JxZHW7ZnppWNpYoQj?= X-MS-Exchange-AntiSpam-MessageData-1: aCGfLTBf4yWpJw== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3252a35c-6bc2-43ec-bb7f-08df1264ee09 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:41.0638 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GVHk+gCYLnJHFS0acKJ9vq7vwrtkPACumGv30OtA3NyierqDA/OGegnKLZXNMNWTBwp4L7YDAoRXpqQzvj8hKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PNVP287MB6090 Content-Type: text/plain; charset="utf-8" video_start_streaming() walks the pipeline from the video node upstream and calls video.s_stream on every subdev it finds; video_stop_streaming() does the same to stop. The core allows one transition per subdev: call_s_stream() keeps a single sd->s_stream_enabled flag and warns about, and drops, a start of a subdev that is already started or a stop of one already stopped. That is correct for a subdev with a single user, but the CSIPHY and the CSID are shared when a CSI-2 transmitter aggregates several cameras onto one port. A MAX9296A GMSL deserializer sends two cameras on one CSI-2 output as two virtual channels; the CSID demultiplexes them to RDI0 and RDI1, each of which is its own VFE line, video node and thus pipeline, and both pipelines traverse the same CSIPHY and CSID. Starting the second camera hits the core check: the CSIPHY and CSID s_stream(1) are dropped with a WARN, and while the hardware happens to be already running, stopping the first camera then calls s_stream(0) on both and tears the CSIPHY and CSID down underneath the second camera, which stops receiving frames. Count the pipelines streaming through each CSIPHY and CSID and only forward the first start and the last stop to the subdev. The count is updated under the media graph mutex, which serialises the two pipelines' start/stop against each other. All other subdevs of the pipeline are driven exactly as before, so the ordinary one camera per port case does not change. csid_set_stream() programs every virtual channel of the en_vc mask in one go, so a single start already covers all demultiplexed RDIs; nothing needs to change on the CSID or CSIPHY side. Signed-off-by: Hitesh Patel --- .../media/platform/qcom/camss/camss-csid.h | 2 + .../media/platform/qcom/camss/camss-csiphy.h | 2 + .../media/platform/qcom/camss/camss-video.c | 48 +++++++++++++++++-- drivers/media/platform/qcom/camss/camss.c | 28 +++++++---- drivers/media/platform/qcom/camss/camss.h | 2 + 5 files changed, 71 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media= /platform/qcom/camss/camss-csid.h index 5296b10f6..9e612ae99 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.h +++ b/drivers/media/platform/qcom/camss/camss-csid.h @@ -167,6 +167,8 @@ struct csid_device { struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl *testgen_mode; const struct csid_subdev_resources *res; + /* Number of pipelines streaming through this CSID */ + unsigned int stream_users; }; =20 struct camss_subdev_resources; diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/med= ia/platform/qcom/camss/camss-csiphy.h index 9d9657b82..b920fe670 100644 --- a/drivers/media/platform/qcom/camss/camss-csiphy.h +++ b/drivers/media/platform/qcom/camss/camss-csiphy.h @@ -114,6 +114,8 @@ struct csiphy_device { struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM]; const struct csiphy_subdev_resources *res; struct csiphy_device_regs *regs; + /* Number of pipelines streaming through this CSIPHY */ + unsigned int stream_users; }; =20 struct camss_subdev_resources; diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/platform/qcom/camss/camss-video.c index 0852eb6f1..16c5f3748 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -249,6 +249,49 @@ static int video_prepare_streaming(struct vb2_queue *q) return ret; } =20 +/* + * video_subdev_set_stream - Start or stop a subdev of the pipeline + * @video: CAMSS video device + * @subdev: Subdevice to start or stop + * @enable: Start when true, stop when false + * + * CSIPHY and CSID are shared between pipelines when a transmitter aggrega= tes + * several cameras onto one CSI-2 port. The core allows a single s_stream + * transition per subdev, so only forward the first start and the last stop + * to them. Every other subdev is driven unconditionally as before. + */ +static int video_subdev_set_stream(struct camss_video *video, + struct v4l2_subdev *subdev, bool enable) +{ + struct media_device *mdev =3D &video->camss->media_dev; + unsigned int *users; + bool forward; + int ret; + + users =3D camss_subdev_stream_users(video->camss, subdev); + if (!users) + return v4l2_subdev_call(subdev, video, s_stream, enable); + + mutex_lock(&mdev->graph_mutex); + if (enable) + forward =3D (*users)++ =3D=3D 0; + else + forward =3D !WARN_ON(!*users) && --(*users) =3D=3D 0; + mutex_unlock(&mdev->graph_mutex); + + if (!forward) + return 0; + + ret =3D v4l2_subdev_call(subdev, video, s_stream, enable); + if (enable && ret < 0 && ret !=3D -ENOIOCTLCMD) { + mutex_lock(&mdev->graph_mutex); + (*users)--; + mutex_unlock(&mdev->graph_mutex); + } + + return ret; +} + static int video_start_streaming(struct vb2_queue *q, unsigned int count) { struct camss_video *video =3D vb2_get_drv_priv(q); @@ -281,7 +324,7 @@ static int video_start_streaming(struct vb2_queue *q, u= nsigned int count) entity =3D pad->entity; subdev =3D media_entity_to_v4l2_subdev(entity); =20 - ret =3D v4l2_subdev_call(subdev, video, s_stream, 1); + ret =3D video_subdev_set_stream(video, subdev, true); if (ret < 0 && ret !=3D -ENOIOCTLCMD) goto error; } @@ -319,8 +362,7 @@ static void video_stop_streaming(struct vb2_queue *q) entity =3D pad->entity; subdev =3D media_entity_to_v4l2_subdev(entity); =20 - ret =3D v4l2_subdev_call(subdev, video, s_stream, 0); - + ret =3D video_subdev_set_stream(video, subdev, false); if (ret) { dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret); return; diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 4cf736d80..ca8101c2d 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -4620,27 +4620,39 @@ struct media_pad *camss_find_sensor_pad(struct medi= a_entity *entity) } =20 /* - * camss_is_receiver_subdev - Test whether a subdev is a CAMSS CSI-2 recei= ver + * camss_subdev_stream_users - Streaming user count of a CAMSS receiver su= bdev * @camss: CAMSS device * @sd: Subdevice to test * - * Return true for a CSIPHY or CSID belonging to @camss, false for anything - * else, in particular for the external subdev transmitting to them. + * CSIPHY and CSID are traversed by several pipelines at once when a CSI-2 + * transmitter aggregates several cameras onto one port: every virtual cha= nnel + * is demultiplexed to its own RDI and forms its own pipeline. The hardware + * must only be started by the first of them and stopped by the last. + * + * Return a pointer to the user count of @sd if it is a CSIPHY or CSID of + * @camss, NULL for any other subdev, in particular for the external subdev + * transmitting to them. */ -static bool camss_is_receiver_subdev(struct camss *camss, - struct v4l2_subdev *sd) +unsigned int *camss_subdev_stream_users(struct camss *camss, + struct v4l2_subdev *sd) { unsigned int i; =20 for (i =3D 0; i < camss->res->csiphy_num; i++) if (sd =3D=3D &camss->csiphy[i].subdev) - return true; + return &camss->csiphy[i].stream_users; =20 for (i =3D 0; i < camss->res->csid_num; i++) if (sd =3D=3D &camss->csid[i].subdev) - return true; + return &camss->csid[i].stream_users; =20 - return false; + return NULL; +} + +static bool camss_is_receiver_subdev(struct camss *camss, + struct v4l2_subdev *sd) +{ + return camss_subdev_stream_users(camss, sd); } =20 /* diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index 39ea33e61..00b8d5304 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -167,6 +167,8 @@ void camss_add_clock_margin(u64 *rate); int camss_enable_clocks(int nclocks, struct camss_clock *clock, struct device *dev); void camss_disable_clocks(int nclocks, struct camss_clock *clock); +unsigned int *camss_subdev_stream_users(struct camss *camss, + struct v4l2_subdev *sd); struct media_pad *camss_find_sensor_pad(struct media_entity *entity); s64 camss_get_link_freq(struct camss *camss, struct media_entity *entity, unsigned int bpp, unsigned int lanes); --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from MA0PR01CU012.outbound.protection.outlook.com (mail-southindiaazon11021110.outbound.protection.outlook.com [40.107.57.110]) (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 26FB24756AE; Mon, 14 Sep 2026 13:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.57.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392891; cv=fail; b=bDAKgjRd2m0guSNPoDv4Kbb1Y0OuM5sOfGCXL1G2+DBApQSwxnU7mp5k2DHNfe6O4Gd1Nps0YBVurqmwbCwZwG6O+evD8ieGT5qX7LEbdaJmwrOL3wLeTCIo8s2aJVssJn+7ToEc6kgXSOfRJZqlrenYVAOxcbRJ1+OQ8Nlv8fw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392891; c=relaxed/simple; bh=Az4P5pq13JWb0EGEizUV2Z2Cb+aFs60lIaIJZKcKoRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=VH3zcAFyk13l8bQSbwrQ+hxVTdrZ8lYdl3j6FB/bucj6l7ZKKHNqqbfa/E/qPBUfLQcKtVS+D1FzPqeDWomx2k056ugDFq8bvJN5KAZj6OVf/RJDcEspPUM0jQ2nVAV+eFUeVNwbKKMBVIRSs7qvFAkksV6R65vd3GYsy6QDiC0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=40.107.57.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hnzCbgQMgXnDekMCkdmdlCKx4bs4sk7/B2T7VCxFI9kE293H+SWw4nZBuCujJ1wKPutxfdJ4FXiGKSyhwL8adUtX/lnabWpZSLjOxh5TCXdmk+0RIXLnMltHmuL8v77w6L7DISi2s126iuiAfEa8QM0A7WJqrZBmfvOLaLAIjQ0gP9pYRpE0DaCeMgqmbAQEzqVGdrDEPLSVMggQc7ZsH7PSOReA94VcTAGMPB6RlLHth75DWr1PfpvUiYpD0XDaxHnf7AQR+98fwTzVtXfBoeaF4mb+D7Y8ggsyePyJuFCaPY+OyAreIB6uZNjL9N3A0s+zUiIro4XnvUEUb0I/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CErd0yv0odVFe1lmN7/C0xqjiE4ZrCZ3PVV6XzKQjh4=; b=PW602VNsmEq+omdt+gVyG25zroWYwpX7saZUFIVdjtz4YzkapA7b2ju89Cf9snzdm0Vzx4j2LxJAH8pSDeEmdR7Cwd+4jy23a4E2i2EZOfN0YXH02hDnJ81A7GWf1Xs8V7RVVNfFi92CCtWvOWOtuIeZnwkj8vtYYoGQ8+eVW4a8U7UgpAJAAeHWTzdNsMxHqcnj/ad865bcbVqzBbsWx9jc746fPBDsOJYOBu6mDHnu3u59i0z275+otWnySFPZqazirbsFoC+TqwiCxMjXUQmViRQaJquv8QrR8p/DyJiBme3LwfqlBLs279dHgG6HnT4Hn0r0PouDufmiVNo/6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PNVP287MB6090.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:34c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:43 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:43 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 7/8] media: qcom: camss: drive streams-aware transmitters through the streams API Date: Mon, 14 Sep 2026 19:04:15 +0530 Message-ID: <20260914133416.1030231-8-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PNVP287MB6090:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cfe2e39-964d-4901-a862-08df1264eef1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|5023799004|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: u2CX/UJe9xdvpj99/BpqqCO0xwDpAqRNiKTRa5kjCTZ2B4KuQ8IyVGRyDOcjzITks5O7G/N7rW43iZcYmqD1dHLsACC67YXKB8FKZgDqYlramlPFKAnzlLuIZGrYjnjMzjDoIOAj3y6H55Qb+kkE+reEOOAS7QbrP74zFIcrruFNyYAWc6UAtbLKFd3SClgdkqFuLMPaBd8NhUxDDmgJxL4F1IzBAw8SFn8+/PG5YL5nUlGVi2e4OxCiwNjjPzAKGGwZveh+rQThuwKPd00j2XSBmdtJIt3lGLpx7wQMRyyC/wcNk5G+4Zs21DZr1+/pwiKtox+zqxagIBQw2xBfAVVvJYRzNHvN09iXgNbE1e+ZLiapSRTpk8pzCYurDh9W9ZndtP3HEYFbcmr64nTLQs6T8amygtOkAIvXVZrtWVBcGjQ7zhpPvBgBT1hksHbKRJJUTTTKe6NbmgHBe2Ji7/jasA3jybTIq/NfKY/eSRyets755RzCQgIF3WJxBdq4n0JFimqTX/IhKRRnK2EUfxJnIvZ+GKnfQlbaDu9J8RylOeKs3GhLSUfltT6iZaZZDLatDZTqCPXPeIiPjf81vasxBz3JEATPXtZhxWu94N5t2uP1TB6M3yfeqTIRAkv52oUmM1rcdrQkLCxKzYlGEDqpdZfPdBkXRd2k2Ux0gVo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(5023799004)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Dotnq2Aa5qWMvOkIGgkKOysvKZu8ZawBvG2DN30GAyAGkMvOxaYBqjggJvia?= =?us-ascii?Q?vtbTfSvFufb1SAnd1Py2oQcUoB5hlLCGUxMnx4wIAf6xgWOr4152p2t8k15N?= =?us-ascii?Q?kofBuBiNS4NBz9iX2jWcDeNs1CcVGXD9aNSWE0K2hzuKMA68asQOhkGSy/g6?= =?us-ascii?Q?6A0ne3QFYF4hFuU3HLvmNGICrUobenj4W4XSlxbmjHpMkMgUJbKIYONTJf0r?= =?us-ascii?Q?fLPRolGSrvAkiTXfBXijp5gimi2gmNqAO+CBqTggXXEfef98A0YbMSnjVt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t/sQNxxOiu2w2MQN3S+rhnmTQjRz31wpQHIf8vf?= =?us-ascii?Q?stkXiLOCqoaO9Kw4roS1JcnKOuhijq2rPNQdLvlYOFKz19xLUjlnJjw0ixDk?= =?us-ascii?Q?arc/JhoVrkC1Qqx3qdI8SSLUTxxn6XhNJm2FOf5AlTISPMKm6ufeimsudI96?= =?us-ascii?Q?XAOybQd508p4685acUL3NrckNRUEu4+RP8XGE4ix48ZeOeRXLAcBj5pCs1eH?= =?us-ascii?Q?CXmW8RhLTBRLaRvfC+guMSCyKJqyqdJ9771KEy7eNrap7kfkWi5s9PqjOm+b?= =?us-ascii?Q?hmqS5zz1UfMY6NJn+t31NWuuWf4PEMUy2n+YAz6s3i21husjZlnqnb1XNs+W?= =?us-ascii?Q?HpRD7zb8pd1BecaDeE1aP8XOlAWzqMawt2LxRhc3iMzzezJtaWFcqQlV6Jl2?= =?us-ascii?Q?9QGMjsTESKVyDOh6iDUFT/ZupSfGsqtyKe/OJKa+JqzZFCWIhIvh1Cdr5H4Y?= =?us-ascii?Q?DOaFIcdq1pbWvEBuZNV7bcDa0Xf8NorH/7r42WxwzQpprGSPOxxrtb+5CzFX?= =?us-ascii?Q?NfUeXsD62HVQypIrX2YZNq+EZEh3pJMnuD8bV9fcB4E4LM4s9Bd878GE4dw4?= =?us-ascii?Q?RUR8oVF6sl64+Fu23C0DppKJi8vOataIv/HszMMB6wMGY4zCSZ1GpVpidz0F?= X-MS-Exchange-AntiSpam-MessageData-1: kzG4yz3vL8jpMw== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cfe2e39-964d-4901-a862-08df1264eef1 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:42.5425 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: glolvvOewYsfF+SHllJoTkOX7DHRSfxe/ROLSr2rmeM3ikX0saJPYWPLAkWmP7CHQoOUdpdKZa73ZlKPY5c89A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PNVP287MB6090 Content-Type: text/plain; charset="utf-8" video_start_streaming() and video_stop_streaming() drive every subdev of the pipeline through video.s_stream. That op is per subdev, and the core allows one transition per subdev, so a transmitter that is shared by two independent pipelines can only be started once and is stopped by the first pipeline that stops. A GMSL deserializer with two CSI-2 output ports, one camera routed to each, is exactly that case: the same subdev sits at the head of two pipelines that otherwise share nothing (each has its own CSIPHY, CSID and VFE). The second camera never starts, and stopping either one kills the other. Such transmitters implement the V4L2 streams API and advertise it with V4L2_SUBDEV_FL_STREAMS. For those, enable or disable only the streams routed to the source pad the pipeline arrived through, using v4l2_subdev_enable_streams()/v4l2_subdev_disable_streams(). The core refcounts enabled streams per pad, so the two pipelines no longer interfere. Enabling streams on a source pad propagates upstream to the sensor by itself, so the walk ends there rather than starting the rest of the chain a second time through s_stream. Subdevs without the flag keep using video.s_stream exactly as before. Signed-off-by: Hitesh Patel --- .../media/platform/qcom/camss/camss-video.c | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/platform/qcom/camss/camss-video.c index 16c5f3748..90f22ce76 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -249,6 +249,32 @@ static int video_prepare_streaming(struct vb2_queue *q) return ret; } =20 +/* + * video_source_pad_streams - Streams routed to a subdev source pad + * @sd: Streams-aware subdevice + * @pad: Source pad index on @sd + * + * Return the mask of streams of the active routes ending on @pad. + */ +static u64 video_source_pad_streams(struct v4l2_subdev *sd, u32 pad) +{ + struct v4l2_subdev_state *state; + struct v4l2_subdev_route *route; + u64 mask =3D 0; + + state =3D v4l2_subdev_lock_and_get_active_state(sd); + if (!state) + return 0; + + for_each_active_route(&state->routing, route) + if (route->source_pad =3D=3D pad) + mask |=3D BIT_ULL(route->source_stream); + + v4l2_subdev_unlock_state(state); + + return mask; +} + /* * video_subdev_set_stream - Start or stop a subdev of the pipeline * @video: CAMSS video device @@ -324,6 +350,20 @@ static int video_start_streaming(struct vb2_queue *q, = unsigned int count) entity =3D pad->entity; subdev =3D media_entity_to_v4l2_subdev(entity); =20 + if (subdev->flags & V4L2_SUBDEV_FL_STREAMS) { + u64 mask =3D video_source_pad_streams(subdev, pad->index); + + if (!mask) + break; + + ret =3D v4l2_subdev_enable_streams(subdev, pad->index, + mask); + if (ret && ret !=3D -EALREADY) + goto error; + + break; + } + ret =3D video_subdev_set_stream(video, subdev, true); if (ret < 0 && ret !=3D -ENOIOCTLCMD) goto error; @@ -362,6 +402,22 @@ static void video_stop_streaming(struct vb2_queue *q) entity =3D pad->entity; subdev =3D media_entity_to_v4l2_subdev(entity); =20 + if (subdev->flags & V4L2_SUBDEV_FL_STREAMS) { + u64 mask =3D video_source_pad_streams(subdev, pad->index); + + if (!mask) + break; + + ret =3D v4l2_subdev_disable_streams(subdev, pad->index, + mask); + if (ret && ret !=3D -EALREADY) + dev_err(video->camss->dev, + "Failed to disable streams %#llx on %s:%u: %d\n", + mask, subdev->name, pad->index, ret); + + break; + } + ret =3D video_subdev_set_stream(video, subdev, false); if (ret) { dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret); --=20 2.43.0 From nobody Fri Sep 25 10:05:31 2026 Received: from MA0PR01CU012.outbound.protection.outlook.com (mail-southindiaazon11021110.outbound.protection.outlook.com [40.107.57.110]) (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 76AE64718FF; Mon, 14 Sep 2026 13:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.57.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392896; cv=fail; b=L9zRlsntfziieMGRbsxMk9fCLy9KT+j7r4kJlqa+NRxEwa3w4H6fLoM0wsaEVu9qaMPmqR6gMy49msEYry20luhQPUbsm484NBqyCMgHYwG63hkfEX0XC8zrCfKa0ktTU4Lg68XHDmkYMOAsX8vo+/BluxKgT7JoLj5+Fcppjbw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789392896; c=relaxed/simple; bh=8WO6i/bfRdYgxmndgHzfnphIFGQVenOyz3VhXS7O7Xg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=WuDu2UgyzkGgFS0Nq4ha8raD0z/YGShzSuvwbgmTPMcY/lz7Egp1iWXURHW+Odw6Q0mI77DNiC48VlFa2S4AADpvMLa/kQpoviMSlhG8933Ih1HA4Jy1cDmb5JOyGcb2NFqtfdZxSj4oeP0xFr+Wn8CG9l/hpz0nbaCf325ZmJQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com; spf=pass smtp.mailfrom=ebytelogic.com; arc=fail smtp.client-ip=40.107.57.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ebytelogic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ebytelogic.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LSMOH5Jp4Uj53QN+FemWKzM//QroLMA1eRpmSx2ia9nOw3RTvmLfTuTWSyr3TvkxjLxyUl0LaQ4PBV3TwdIiyZNlad6vVc6qrWE2eui7fdvkf4yMvTrP6CPT5hgZbSGrmoGDB4/HHyt/ldH2yvBlj5P3ee2zWQF6FIVw5XnCzO+A6wsTG0r39I7nyskDrUC+9lxihyZ6fQauHqTcxK+Pojc6l66PWSN6xzpnKC+JnFqtPRi29ODfar5dGBJTJiT3CKwtlC06kFPikOmZkUuGm75CGaXMZ02fRabVu4r0lFvnrzU+wGZ3jtB/iEVRbl8vuFnjIBhphgU8lFwHPguchA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YJy3EIPLk9eWpIIwGUmrVB7SkTiDAXZuHl5SQCT6ZMY=; b=eZFWEJuMQT63vDXecTupFDOQvf49kYsm51NlKHGx6bY4XslN24Gl0+HXlvsacZvWpQtkPumR8PG2FC9so+NEiHWCYh9oKrRdhYkc8x0QKFNlOAoNij+IEk1KMuzycvnI4DrFHVAw0lFhQe9OQkpSE1J5TwfakNl8b5e5L4fdV80UDsb9IvZgPajX7YqhO45J3pKkWJEF+asLctwtWt1puCrxAmD/8Ne0AkzM6gEGDNx5MUe9upo8UKiOKHF2pDSR1anjSiVMOpF2na7mSLytwPWMG7Lq9BdhHBEhnO78Ll2+DfaQbSjVQ+z4gOjSqJO4eUdGFMSZBk8ueX4hoLoktg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ebytelogic.com; dmarc=pass action=none header.from=ebytelogic.com; dkim=pass header.d=ebytelogic.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ebytelogic.com; Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) by PNVP287MB6090.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:34c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Mon, 14 Sep 2026 13:34:44 +0000 Received: from PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e]) by PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM ([fe80::df75:6e8c:7def:a08e%6]) with mapi id 15.21.0406.007; Mon, 14 Sep 2026 13:34:44 +0000 From: Hitesh Patel To: linux-media@vger.kernel.org Cc: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, ravi@ebytelogic.com, Hitesh Patel Subject: [PATCH 8/8] media: qcom: camss: enable only the stream of the pipeline's virtual channel Date: Mon, 14 Sep 2026 19:04:16 +0530 Message-ID: <20260914133416.1030231-9-hitesh@ebytelogic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260914133416.1030231-1-hitesh@ebytelogic.com> References: <20260914133416.1030231-1-hitesh@ebytelogic.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PN5P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:262::11) To PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM (2603:1096:c04:1::97) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PPF28092842E:EE_|PNVP287MB6090:EE_ X-MS-Office365-Filtering-Correlation-Id: 2384936a-6657-479e-8324-08df1264efd6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|10070799003|23010399003|1800799024|366016|3023799007|10067099003|5023799004|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: p+MuidK+01qsx12Y4/enF7VPYsai7xY26PyMWN4/fYb9ComOmEExy39VCC40HKP9MZ9cfoWYx+DyWBBwhBOReC+jjW2CeHhFJXQJH963wr1akooI/+H4yrQBdfzoKOMpBWDMv6/12eJirqzi8QxFDNuPw4HVajdnXBXcKyRdeN78Q/MFVOtYd4/GwVSVOtJMNaNsLTaiyjP17nqaXIM7OebWRIGhBRidIXlBjmgma8YT9cntXQS6jxqtNDOohzPjGqbCMpRS65Ol5UNXP947Rh+sKfFVS2vsFX//H9N/TIuraAtQVCLtbwwIla6XfoNjDS8RiZkK/zHbcXHn5X4hUUKDCjXkLZKH4YhgF9zKBilSSouDfhs3nXaQdbkkGiuOikFbdmRF7DcrNOhn3qDODkakPu6XQgm6m0OK0bWAJQv3KD+G+nGsApG7P+DIc49A+6Rhz1UVwREl1qY30Jytzb7xmBHbWMcDGuDkInBFbtiT5lelKFo5/97iiILTlckBiMSldtGIrecIzQ5U9aOJrjd03WVE/y8MVpEaDLOmk9WOW2+UigD8BsgGPsr07YOLUYdphfT33v+lXOTN5MOcFS6fwnz4HFyH+aO/ty2We/kqKaTZ4b/h53IHn8BWC1XiQv9E9POfGRk69Q+F5JEaOrXiiO/+9FhwXBQp3DFx8YI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(10070799003)(23010399003)(1800799024)(366016)(3023799007)(10067099003)(5023799004)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?i3z242yvIfhowLvh+3Al0jWZ/zLqAD3OohhUGqv1syFfVbTv+e0ucuRfiKs7?= =?us-ascii?Q?yCaLPoo+INlyEByEmeZziHwGO6ihFpnQYtWv9Fpwi/xGi8J/VExeSlEyiZH5?= =?us-ascii?Q?wrH6I1ieKU/UOgO7GHAyB2P+ftBgu2guhbgxl42ZmRHcLMGa6q6h4ZAXpjN0?= =?us-ascii?Q?NKnUbYckRwDCB5cUxu1KJ7lu0OKr6ZyyP2XKnusjf4hkMB4q2rVbVQJO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IInwX6HxaTDrJ5ytVWPn?= =?us-ascii?Q?1xGVy9PLxaQ10HH7ItKHf1VH3yxbhJxOwuZ7HbjVzqEFNtne0J/rmDIlTpVr?= =?us-ascii?Q?V5XRquHm82dN+4V1eKlrqZQdH+M9hYVBgex5J1kLozxWVAgJNQKrCbwQwhPv?= =?us-ascii?Q?11I8P66Cr0AP8rB7qdccDpQSXdBaiuCxQPVDFOYr94R8cfQ12TEi+6oVFMEg?= =?us-ascii?Q?LLD+NkSq9jDZHZW0yGl22jIDWCuYxaeICdEmcSjQDBkmA+5PpcumR1i62G2u?= =?us-ascii?Q?Fwn4ycY0xbBkREZT0apKd5F/M65vw2eUQJ6sECZYZiGlRx/DfAlIJJukTcRU?= =?us-ascii?Q?QId2iW4R9yw+LSd3705Mt9bVRTPbTly5xwF88oFqhm2b9m3xK8cyo22fM6nJ?= =?us-ascii?Q?GAxsN4bF/w0yAZanqDVYKAop7PB3mW86U5N55K3Mt+4MP7ZILl2JZTlTPH6V?= =?us-ascii?Q?JP+nI1PgZzIaJvf2ngcir1cjpJzvQD0mAkLHReqvJ3RIEFogoZNrVKv86dg7?= =?us-ascii?Q?JZnYpouJ5vobgGuvQWkkKTsS7GHtyVes0IiAjhfGyKZBN7bgFzTn/uFYaLU6?= =?us-ascii?Q?36pJbYdxwisZzaPgf2JE4XX3gkoL0ZnciQ2TTDkUiLG2u5N65oXrKTLJVNfy?= =?us-ascii?Q?kjQo2QGv+wGCN5uXmfsmHpCpeLxw0H8QXAdGMvN6JSLZRFvR1OHeWuIUxvzw?= X-MS-Exchange-AntiSpam-MessageData-1: maCj/O+an+VztQ== X-OriginatorOrg: ebytelogic.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2384936a-6657-479e-8324-08df1264efd6 X-MS-Exchange-CrossTenant-AuthSource: PN3PPF28092842E.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 13:34:44.0983 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 13bdb17c-4ae8-490c-90c1-ec8121ef96ee X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +njrh7MaWu+VJ/4AlAhupDaEXIoXE1VNJG27vNy3ZPGiIU5c2GqzKIkXde5onoAFTdPKA8y1zZmmI0N8MnPN/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PNVP287MB6090 Content-Type: text/plain; charset="utf-8" When a streams-aware transmitter is found at the head of the pipeline, every stream routed to the source pad the pipeline arrived through is enabled at start and disabled at stop. That is right for a transmitter driving one camera per output pad, but not when it aggregates several cameras onto one output. A GMSL deserializer can send two cameras on a single CSI-2 port as two virtual channels, which the CSID demultiplexes to two RDIs and thus two pipelines. Both pipelines then reach the same source pad, and each of them enables and, worse, disables both cameras' streams: stopping one video node stops the other camera as well, and starting the second one has nothing left to enable. Identify the stream a pipeline owns from the CSID it went through: CSID source pad MSM_CSID_PAD_FIRST_SRC + n carries virtual channel n. Remember that virtual channel while walking upstream, ask the transmitter for the frame descriptor of its source pad, and only enable or disable the stream(s) it reports on that virtual channel. A pipeline that did not pass through a CSID source pad, or a transmitter without a CSI-2 frame descriptor, keeps enabling every stream of the pad as before. Signed-off-by: Hitesh Patel --- .../media/platform/qcom/camss/camss-video.c | 45 +++++++++++++++++-- drivers/media/platform/qcom/camss/camss.c | 30 +++++++++++++ drivers/media/platform/qcom/camss/camss.h | 2 + 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/platform/qcom/camss/camss-video.c index 90f22ce76..a261f7692 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -253,14 +253,39 @@ static int video_prepare_streaming(struct vb2_queue *= q) * video_source_pad_streams - Streams routed to a subdev source pad * @sd: Streams-aware subdevice * @pad: Source pad index on @sd + * @vc: Virtual channel of the pipeline, or -1 if unknown + * + * When a transmitter aggregates several cameras onto one output, that pad + * carries one stream per camera and each of them is a separate pipeline h= ere. + * Enabling or disabling the whole pad would start or stop every camera at + * once, so pick out the single stream this pipeline owns: the one the fra= me + * descriptor reports on the virtual channel the CSID demultiplexed it fro= m. + * With @vc unknown, or without a frame descriptor to map it, the whole pa= d is + * returned, which is the case for a transmitter driving one camera per ou= tput + * pad. * * Return the mask of streams of the active routes ending on @pad. */ -static u64 video_source_pad_streams(struct v4l2_subdev *sd, u32 pad) +static u64 video_source_pad_streams(struct v4l2_subdev *sd, u32 pad, int v= c) { struct v4l2_subdev_state *state; struct v4l2_subdev_route *route; + struct v4l2_mbus_frame_desc fd; + u64 vc_mask =3D ~0ULL; u64 mask =3D 0; + int ret; + + if (vc >=3D 0) { + ret =3D v4l2_subdev_call(sd, pad, get_frame_desc, pad, &fd); + if (!ret && fd.type =3D=3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2) { + unsigned int i; + + vc_mask =3D 0; + for (i =3D 0; i < fd.num_entries; i++) + if (fd.entry[i].bus.csi2.vc =3D=3D vc) + vc_mask |=3D BIT_ULL(fd.entry[i].stream); + } + } =20 state =3D v4l2_subdev_lock_and_get_active_state(sd); if (!state) @@ -270,6 +295,8 @@ static u64 video_source_pad_streams(struct v4l2_subdev = *sd, u32 pad) if (route->source_pad =3D=3D pad) mask |=3D BIT_ULL(route->source_stream); =20 + mask &=3D vc_mask; + v4l2_subdev_unlock_state(state); =20 return mask; @@ -325,6 +352,7 @@ static int video_start_streaming(struct vb2_queue *q, u= nsigned int count) struct media_entity *entity; struct media_pad *pad; struct v4l2_subdev *subdev; + int vc =3D -1; int ret; =20 ret =3D video_device_pipeline_alloc_start(vdev); @@ -350,8 +378,13 @@ static int video_start_streaming(struct vb2_queue *q, = unsigned int count) entity =3D pad->entity; subdev =3D media_entity_to_v4l2_subdev(entity); =20 + if (vc < 0) + vc =3D camss_csid_source_vc(video->camss, subdev, + pad->index); + if (subdev->flags & V4L2_SUBDEV_FL_STREAMS) { - u64 mask =3D video_source_pad_streams(subdev, pad->index); + u64 mask =3D video_source_pad_streams(subdev, pad->index, + vc); =20 if (!mask) break; @@ -387,6 +420,7 @@ static void video_stop_streaming(struct vb2_queue *q) struct media_entity *entity; struct media_pad *pad; struct v4l2_subdev *subdev; + int vc =3D -1; int ret; =20 entity =3D &vdev->entity; @@ -402,8 +436,13 @@ static void video_stop_streaming(struct vb2_queue *q) entity =3D pad->entity; subdev =3D media_entity_to_v4l2_subdev(entity); =20 + if (vc < 0) + vc =3D camss_csid_source_vc(video->camss, subdev, + pad->index); + if (subdev->flags & V4L2_SUBDEV_FL_STREAMS) { - u64 mask =3D video_source_pad_streams(subdev, pad->index); + u64 mask =3D video_source_pad_streams(subdev, pad->index, + vc); =20 if (!mask) break; diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index ca8101c2d..63cc81570 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -4655,6 +4655,36 @@ static bool camss_is_receiver_subdev(struct camss *c= amss, return camss_subdev_stream_users(camss, sd); } =20 +/* + * camss_csid_source_vc - Virtual channel behind a CSID source pad + * @camss: CAMSS device + * @sd: Subdevice to test + * @pad: Source pad index on @sd + * + * The CSID demultiplexes virtual channels to its source pads, source pad + * MSM_CSID_PAD_FIRST_SRC + n carrying virtual channel n (see the en_vc ma= sk + * maintained by csid_link_setup()). Walking a pipeline upstream, this tel= ls + * which virtual channel, and so which stream of a shared transmitter, the + * pipeline belongs to. + * + * Return the virtual channel, or -1 if @sd is not a CSID of @camss or @pa= d is + * not one of its source pads. + */ +int camss_csid_source_vc(struct camss *camss, struct v4l2_subdev *sd, + unsigned int pad) +{ + unsigned int i; + + if (pad < MSM_CSID_PAD_FIRST_SRC) + return -1; + + for (i =3D 0; i < camss->res->csid_num; i++) + if (sd =3D=3D &camss->csid[i].subdev) + return pad - MSM_CSID_PAD_FIRST_SRC; + + return -1; +} + /* * camss_find_transmitter_pad - Find the pad of the CSI-2 transmitter * @camss: CAMSS device diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/plat= form/qcom/camss/camss.h index 00b8d5304..14a7c737e 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -169,6 +169,8 @@ int camss_enable_clocks(int nclocks, struct camss_clock= *clock, void camss_disable_clocks(int nclocks, struct camss_clock *clock); unsigned int *camss_subdev_stream_users(struct camss *camss, struct v4l2_subdev *sd); +int camss_csid_source_vc(struct camss *camss, struct v4l2_subdev *sd, + unsigned int pad); struct media_pad *camss_find_sensor_pad(struct media_entity *entity); s64 camss_get_link_freq(struct camss *camss, struct media_entity *entity, unsigned int bpp, unsigned int lanes); --=20 2.43.0