Skip to contentSkip to conversation

media: staging: rkisp1: don't lock media's graph_mutex when calling rkisp1_create_links

PATCH In review Dafna Hirschfeld 3 participants 7 messages Feb 4, 2020 – Feb 14, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: staging: rkisp1: don't lock media's graph_mutex when calling rkisp1_create_links

The function rkisp1_create_links calls media_entity_get_fwnode_pad and media_create_pad_link in the mc api. Those calls don't require locking the graph_mutex so remove the locking.

---
 drivers/staging/media/rkisp1/rkisp1-dev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/media/rkisp1/rkisp1-dev.c +4 -6
index 9d866396a5de..64e61ab29143 100644
@@ -219,19 +219,17 @@ static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier)
 		container_of(notifier, struct rkisp1_device, notifier);
 	int ret;
 
-	mutex_lock(&rkisp1->media_dev.graph_mutex);
 	ret = rkisp1_create_links(rkisp1);
 	if (ret)
-		goto unlock;
+		return ret;
+
 	ret = v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev);
 	if (ret)
-		goto unlock;
+		return ret;
 
 	dev_dbg(rkisp1->dev, "Async subdev notifier completed\n");
 
-unlock:
-	mutex_unlock(&rkisp1->media_dev.graph_mutex);
-	return ret;
+	return 0;
 }
 
 static int rkisp1_fwnode_parse(struct device *dev,
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 media: staging: rkisp1: fix test of return value of media_entity_get_fwnode_pad

media_entity_get_fwnode_pad returns negative value on error and the pad numeber on success. Therefore change the error test from 'if (ret)' to 'if (ret < 0)' .

Fixes d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
---
 drivers/staging/media/rkisp1/rkisp1-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/rkisp1/rkisp1-dev.c +1 -1
index 21837d4dc9e1..9d866396a5de 100644
@@ -128,7 +128,7 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
 
 		ret = media_entity_get_fwnode_pad(&sd->entity, sd->fwnode,
 						  MEDIA_PAD_FL_SOURCE);
-		if (ret) {
+		if (ret < 0) {
 			dev_err(sd->dev, "failed to find src pad for %s\n",
 				sd->name);
 			return ret;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] media: staging: rkisp1: fix test of return value of media_entity_get_fwnode_pad

Quoted 6 lines · Dafna Hirschfeld

media_entity_get_fwnode_pad returns negative value on error and the pad numeber on success. Therefore change the error test from 'if (ret)' to 'if (ret < 0)' .

Fixes d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")

Thanks
Helen

Quoted 18 lines
---
 drivers/staging/media/rkisp1/rkisp1-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/rkisp1/rkisp1-dev.c +1 -1
index 21837d4dc9e1..9d866396a5de 100644
@@ -128,7 +128,7 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
 
 		ret = media_entity_get_fwnode_pad(&sd->entity, sd->fwnode,
 						  MEDIA_PAD_FL_SOURCE);
-		if (ret) {
+		if (ret < 0) {
 			dev_err(sd->dev, "failed to find src pad for %s\n",
 				sd->name);
 			return ret;
#3 lore raw

PATCH 1/1 media: staging: rkisp1: improve inner documentation in rkisp1-isp.c

In reply to Dafna Hirschfeld

Improve the documentation in the beginning of the file rkisp1-isp1.c

---
 drivers/staging/media/rkisp1/rkisp1-isp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/rkisp1/rkisp1-isp.c +3 -3
index 2b0513e826fe..844556389b0b 100644
@@ -28,9 +28,9 @@
 #define RKISP1_DIR_SINK_SRC (RKISP1_DIR_SINK | RKISP1_DIR_SRC)
 
 /*
- * NOTE: MIPI controller and input MUX are also configured in this file,
- * because ISP Subdev is not only describe ISP submodule(input size,format,
- * output size, format), but also a virtual route device.
+ * NOTE: MIPI controller and input MUX are also configured in this file.
+ * This is because ISP Subdev describes not only ISP submodule (input size,
+ * format, output size, format), but also a virtual route device.
  */
 
 /*
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#4 lore raw

Re: [PATCH] media: staging: rkisp1: improve inner documentation in rkisp1-isp.c

Quoted 4 lines · Dafna Hirschfeld

Improve the documentation in the beginning of the file rkisp1-isp1.c

Thanks
Helen

Quoted 22 lines
---
 drivers/staging/media/rkisp1/rkisp1-isp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/rkisp1/rkisp1-isp.c +3 -3
index 2b0513e826fe..844556389b0b 100644
@@ -28,9 +28,9 @@
 #define RKISP1_DIR_SINK_SRC (RKISP1_DIR_SINK | RKISP1_DIR_SRC)
 
 /*
- * NOTE: MIPI controller and input MUX are also configured in this file,
- * because ISP Subdev is not only describe ISP submodule(input size,format,
- * output size, format), but also a virtual route device.
+ * NOTE: MIPI controller and input MUX are also configured in this file.
+ * This is because ISP Subdev describes not only ISP submodule (input size,
+ * format, output size, format), but also a virtual route device.
  */
 
 /*
Acked-by on v1 1/1
#5 lore raw
In reply to Dafna Hirschfeld
Quoted 5 lines · Dafna Hirschfeld

The function rkisp1_create_links calls media_entity_get_fwnode_pad and media_create_pad_link in the mc api. Those calls don't require locking the graph_mutex so remove the locking.

Thanks
Helen

Quoted 33 lines
---
 drivers/staging/media/rkisp1/rkisp1-dev.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/media/rkisp1/rkisp1-dev.c +4 -6
index 9d866396a5de..64e61ab29143 100644
@@ -219,19 +219,17 @@ static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier)
 		container_of(notifier, struct rkisp1_device, notifier);
 	int ret;
 
-	mutex_lock(&rkisp1->media_dev.graph_mutex);
 	ret = rkisp1_create_links(rkisp1);
 	if (ret)
-		goto unlock;
+		return ret;
+
 	ret = v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev);
 	if (ret)
-		goto unlock;
+		return ret;
 
 	dev_dbg(rkisp1->dev, "Async subdev notifier completed\n");
 
-unlock:
-	mutex_unlock(&rkisp1->media_dev.graph_mutex);
-	return ret;
+	return 0;
 }
 
 static int rkisp1_fwnode_parse(struct device *dev,