Skip to contentSkip to conversation

IPU bridge improvements for IPU6

PATCH New Sakari Ailus 1 participant 6 messages Feb 14, 2024

Subsystems (3)
lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

v3 cover IPU bridge improvements for IPU6

Hi folks,

Here are four simple patches, one to add support for ov01a10 in Dell XPS 9315 and the rest to improve reliability of driver probing on systems with IVSC.

since v2:

- Remove unused fwnode variable in the 2nd patch.

- Include the IPU 6 PCI ID header patch. This and the MEI CSI patch likely are going to be merged with the IPU 6 driver.

since v1:

- Instead of sleeping in IPU6 driver probe, instantiate the software nodes via IPU bridge init also from MEI CSI driver.

Sakari Ailus (5):
media: ipu-bridge: Add ov01a10 in Dell XPS 9315
media: ipu-bridge: Move graph checking to IPU bridge
media: ipu-bridge: Serialise calls to IPU bridge init
media: ipu6: Add PCI device table header
media: ivsc: csi: Use IPU bridge

 drivers/media/pci/intel/ipu-bridge.c     | 26 ++++++++++++++++++++
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 31 +++---------------------
 drivers/media/pci/intel/ivsc/mei_csi.c   | 20 +++++++++++++--
 include/media/ipu6-pci-table.h           | 28 +++++++++++++++++++++
 4 files changed, 75 insertions(+), 30 deletions(-)
 create mode 100644 include/media/ipu6-pci-table.h
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v3 1/5 media: ipu-bridge: Add ov01a10 in Dell XPS 9315

Add Omnivision ov01a10 sensor used in Dell XPS 9315, and use the driver default frequency.

---
 drivers/media/pci/intel/ipu-bridge.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +2 -0
index f980e3125a7b..b2cf80d62ba2 100644
@@ -60,6 +60,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {
 	IPU_SENSOR_CONFIG("OVTIDB10", 1, 560000000),
 	/* GalaxyCore GC0310 */
 	IPU_SENSOR_CONFIG("INT0310", 0),
+	/* Omnivision ov01a10 */
+	IPU_SENSOR_CONFIG("OVTI01A0", 1, 400000000),
 };
 
 static const struct ipu_property_names prop_names = {
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH v3 2/5 media: ipu-bridge: Move graph checking to IPU bridge

In reply to Sakari Ailus

Move checking the graph to the IPU bridge. This way the caller won't need to do it.

---
 drivers/media/pci/intel/ipu-bridge.c     | 20 +++++++++++++++
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 31 +++---------------------
 2 files changed, 23 insertions(+), 28 deletions(-)
drivers/media/pci/intel/ipu-bridge.c +20 -0
index b2cf80d62ba2..735c62c37c22 100644
@@ -2,6 +2,7 @@
 /* Author: Dan Scally <[email protected]> */
 
 #include <linux/acpi.h>
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/i2c.h>
 #include <linux/mei_cl_bus.h>
@@ -749,6 +750,22 @@ static int ipu_bridge_ivsc_is_ready(void)
 	return ready;
 }
 
+static int ipu_bridge_check_fwnode_graph(struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *endpoint;
+
+	if (IS_ERR_OR_NULL(fwnode))
+		return -EINVAL;
+
+	endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
+	if (endpoint) {
+		fwnode_handle_put(endpoint);
+		return 0;
+	}
+
+	return ipu_bridge_check_fwnode_graph(fwnode->secondary);
+}
+
 int ipu_bridge_init(struct device *dev,
 		    ipu_parse_sensor_fwnode_t parse_sensor_fwnode)
 {
@@ -757,6 +774,9 @@ int ipu_bridge_init(struct device *dev,
 	unsigned int i;
 	int ret;
 
+	if (!ipu_bridge_check_fwnode_graph(dev_fwnode(dev)))
+		return 0;
+
 	if (!ipu_bridge_ivsc_is_ready())
 		return -EPROBE_DEFER;
 
drivers/media/pci/intel/ipu3/ipu3-cio2.c +3 -28
index 83e29c56fe33..c42adc5a408d 100644
@@ -1667,29 +1667,12 @@ static void cio2_queues_exit(struct cio2_device *cio2)
 		cio2_queue_exit(cio2, &cio2->queue[i]);
 }
 
-static int cio2_check_fwnode_graph(struct fwnode_handle *fwnode)
-{
-	struct fwnode_handle *endpoint;
-
-	if (IS_ERR_OR_NULL(fwnode))
-		return -EINVAL;
-
-	endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
-	if (endpoint) {
-		fwnode_handle_put(endpoint);
-		return 0;
-	}
-
-	return cio2_check_fwnode_graph(fwnode->secondary);
-}
-
 /**************** PCI interface ****************/
 
 static int cio2_pci_probe(struct pci_dev *pci_dev,
 			  const struct pci_device_id *id)
 {
 	struct device *dev = &pci_dev->dev;
-	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	struct cio2_device *cio2;
 	int r;
 
@@ -1698,17 +1681,9 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
 	 * if the device has no endpoints then we can try to build those as
 	 * software_nodes parsed from SSDB.
 	 */
-	r = cio2_check_fwnode_graph(fwnode);
-	if (r) {
-		if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) {
-			dev_err(dev, "fwnode graph has no endpoints connected\n");
-			return -EINVAL;
-		}
-
-		r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb);
-		if (r)
-			return r;
-	}
+	r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb);
+	if (r)
+		return r;
 
 	cio2 = devm_kzalloc(dev, sizeof(*cio2), GFP_KERNEL);
 	if (!cio2)
Signature · 1 line
2.39.2
author maintainer
#3 lore raw

PATCH v3 3/5 media: ipu-bridge: Serialise calls to IPU bridge init

In reply to Sakari Ailus

The IPU bridge initialisation will be called from multiple locations in the future. Serialise the access to devices' fwnodes in this context.

---
 drivers/media/pci/intel/ipu-bridge.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +4 -0
index 735c62c37c22..e994db4f4d91 100644
@@ -766,6 +766,8 @@ static int ipu_bridge_check_fwnode_graph(struct fwnode_handle *fwnode)
 	return ipu_bridge_check_fwnode_graph(fwnode->secondary);
 }
 
+static DEFINE_MUTEX(ipu_bridge_mutex);
+
 int ipu_bridge_init(struct device *dev,
 		    ipu_parse_sensor_fwnode_t parse_sensor_fwnode)
 {
@@ -774,6 +776,8 @@ int ipu_bridge_init(struct device *dev,
 	unsigned int i;
 	int ret;
 
+	guard(mutex)(&ipu_bridge_mutex);
+
 	if (!ipu_bridge_check_fwnode_graph(dev_fwnode(dev)))
 		return 0;
 
Signature · 1 line
2.39.2
author maintainer
#4 lore raw

PATCH v3 4/5 media: ipu6: Add PCI device table header

In reply to Sakari Ailus

Add a header for the PCI device table of all IPU6 devices. This will be used by the IPU bridge as well so place the table in a header.

---
 include/media/ipu6-pci-table.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 include/media/ipu6-pci-table.h
include/media/ipu6-pci-table.h new file +28 -0
new file mode 100644
index 000000000000..40208785398a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2024 Intel Corporation
+ */
+
+#ifndef __IPU6_PCI_TBL_H__
+#define __IPU6_PCI_TBL_H__
+
+#include <linux/pci.h>
+
+#define PCI_DEVICE_ID_INTEL_IPU6		0x9a19
+#define PCI_DEVICE_ID_INTEL_IPU6SE		0x4e19
+#define PCI_DEVICE_ID_INTEL_IPU6EP_ADLP		0x465d
+#define PCI_DEVICE_ID_INTEL_IPU6EP_ADLN		0x462e
+#define PCI_DEVICE_ID_INTEL_IPU6EP_RPLP		0xa75d
+#define PCI_DEVICE_ID_INTEL_IPU6EP_MTL		0x7d19
+
+static const struct pci_device_id ipu6_pci_tbl[] = {
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IPU6) },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IPU6SE) },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IPU6EP_ADLP) },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IPU6EP_ADLN) },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IPU6EP_RPLP) },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IPU6EP_MTL) },
+	{ }
+};
+
+#endif /* __IPU6_PCI_TBL_H__ */
Signature · 1 line
2.39.2
author maintainer
#5 lore raw

PATCH v3 5/5 media: ivsc: csi: Use IPU bridge

In reply to Sakari Ailus

Use IPU bridge to instantiate software nodes for IPU6 related devices. If the IPU6 device is probed before the MEI CSI device is created, neither will probe unless there are further devices probed successfully which triggers re-probe of both IPU6 and MEI CSI.

This patch ensures the necessary software nodes are in place when the MEI CSI driver is probed.

---
 drivers/media/pci/intel/ivsc/mei_csi.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ivsc/mei_csi.c +18 -2
index 15b905f66ab7..b3f39c9a60d2 100644
@@ -19,12 +19,15 @@
 #include <linux/mei_cl_bus.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/pci.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/units.h>
 #include <linux/uuid.h>
 #include <linux/workqueue.h>
 
+#include <media/ipu-bridge.h>
+#include <media/ipu6-pci-table.h>
 #include <media/v4l2-async.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-fwnode.h>
@@ -716,11 +719,23 @@ static int mei_csi_probe(struct mei_cl_device *cldev,
 			 const struct mei_cl_device_id *id)
 {
 	struct device *dev = &cldev->dev;
+	struct pci_dev *ipu;
 	struct mei_csi *csi;
+	unsigned int i;
 	int ret;
 
-	if (!dev_fwnode(dev))
-		return -EPROBE_DEFER;
+	for (i = 0, ipu = NULL; !ipu && ipu6_pci_tbl[i].vendor; i++)
+		ipu = pci_get_device(ipu6_pci_tbl[i].vendor,
+				     ipu6_pci_tbl[i].device, NULL);
+
+	if (!ipu)
+		return -ENODEV;
+
+	ret = ipu_bridge_init(&ipu->dev, ipu_bridge_parse_ssdb);
+	if (ret < 0)
+		return ret;
+	if (WARN_ON(!dev_fwnode(dev)))
+		return -ENXIO;
 
 	csi = devm_kzalloc(dev, sizeof(struct mei_csi), GFP_KERNEL);
 	if (!csi)
@@ -841,6 +856,7 @@ static struct mei_cl_driver mei_csi_driver = {
 
 module_mei_cl_driver(mei_csi_driver);
 
+MODULE_IMPORT_NS(INTEL_IPU_BRIDGE);
 MODULE_AUTHOR("Wentong Wu <[email protected]>");
 MODULE_AUTHOR("Zhifeng Wang <[email protected]>");
 MODULE_DESCRIPTION("Device driver for IVSC CSI");
Signature · 1 line
2.39.2