[PATCH 6/6] media: qcom: camss: validate local/remote endpoint bus-type
From: Anusha Arun Nandi
Date: Fri Jul 17 2026 - 19:14:44 EST
A link is invalid if the local CSIPHY endpoint and the remote sensor
endpoint describe different bus types. Such a mismatch can otherwise go
undetected until later probe or streaming failures.
Parse the remote endpoint in camss_parse_endpoint_node() and compare its
bus-type with the local endpoint. Reject the link with -EINVAL if the two
ends disagree, so C-PHY/D-PHY mismatches are caught early during probe.
Co-developed-by: Jigarkumar Zala <jigarkumar.zala@xxxxxxxxxxxxxxxx>
Signed-off-by: Jigarkumar Zala <jigarkumar.zala@xxxxxxxxxxxxxxxx>
Signed-off-by: Anusha Arun Nandi <anusha.nandi@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss.c | 28 ++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index ebf8f21b5fa2..8013aafde6a9 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -4757,7 +4757,9 @@ static int camss_parse_endpoint_node(struct device *dev,
{
struct csiphy_lanes_cfg *lncfg = &csd->interface.csi2.lane_cfg;
struct v4l2_mbus_config_mipi_csi2 *mipi_csi2;
- struct v4l2_fwnode_endpoint vep = { { 0 } };
+ struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_UNKNOWN };
+ struct v4l2_fwnode_endpoint remote_vep = { .bus_type = V4L2_MBUS_UNKNOWN };
+ struct fwnode_handle *remote_ep;
unsigned int i;
int ret;
@@ -4774,6 +4776,30 @@ static int camss_parse_endpoint_node(struct device *dev,
return -EINVAL;
}
+ /* Get the remote (sensor) endpoint handle, e.g. imx686_ep1 */
+ remote_ep = fwnode_graph_get_remote_endpoint(ep);
+ if (!remote_ep) {
+ dev_dbg(dev, "No remote endpoint found for %pfw\n", ep);
+ return -ENODEV;
+ }
+
+ /* Parse the remote bus type and release the handle */
+ ret = v4l2_fwnode_endpoint_parse(remote_ep, &remote_vep);
+ fwnode_handle_put(remote_ep);
+ if (ret) {
+ dev_dbg(dev, "Failed to parse remote endpoint\n");
+ return ret;
+ }
+
+ /* The local (CSIPHY) and remote (sensor) ends must agree */
+ if (vep.bus_type != remote_vep.bus_type) {
+ dev_dbg(dev, "Bus type mismatch! Local (CSI-PHY): %u, Remote (Sensor): %u\n",
+ vep.bus_type, remote_vep.bus_type);
+ return -EINVAL;
+ }
+
+ dev_dbg(dev, "Verified link: both ends use bus-type %u\n", vep.bus_type);
+
csd->interface.csiphy_id = vep.base.port;
mipi_csi2 = &vep.bus.mipi_csi2;
--
2.34.1