Skip to contentSkip to conversation

Allwinner A31/A83T CSI/ISP/MIPI CSI-2 media fixes

PATCH In review Paul Kocialkowski 2 participants 14 messages Dec 8, 2022 – Dec 17, 2022

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

v3 cover Allwinner A31/A83T CSI/ISP/MIPI CSI-2 media fixes

This series resolves reported smatch warnings against the recently-introduced Allwinner A31/A83T CSI, ISP and MIPI CSI-2 drivers.

Smatch was ran again on the updated tree and no longer shows any error or warning.

Changes since v2:
- Added isp params pending buffer fix;
- Added fixes tags where needed;
- Reworded cosmetic commits;
- Changed sunxi-isp to the proper sun6i-isp.

Changes since v1:
- Added fixes for static struct declarations;
- Fixed ISP commit titles by replacing bridge with proc.

Paul

Paul Kocialkowski (12):
media: sun6i-csi: bridge: Fix return code handling in stream off path
media: sun6i-csi: bridge: Error out on invalid port to fix warning
media: sunxi-csi: bridge: Declare subdev ops as static
media: sun6i-csi: capture: Remove useless ret initialization
media: sun6i-mipi-csi2: Clarify return code handling in stream off
path
media: sun8i-a83t-mipi-csi2: Clarify return code handling in stream
off path
media: sun6i-isp: proc: Fix return code handling in stream off path
media: sun6i-isp: proc: Error out on invalid port to fix warning
media: sun6i-isp: proc: Declare subdev ops as static
media: sun6i-isp: capture: Fix uninitialized variable use
media: sun6i-isp: params: Fix incorrect indentation
media: sun6i-isp: params: Unregister pending buffer on cleanup

 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 8 ++++----
 .../media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c    | 2 +-
 .../platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c      | 5 ++---
 .../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c     | 5 ++---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 4 ++--
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c  | 6 ++++--
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c    | 8 ++++----
 7 files changed, 19 insertions(+), 19 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH v3 1/12 media: sun6i-csi: bridge: Fix return code handling in stream off path

Explicitly set ret to zero on disable path to avoid a related smatch warning. This makes initialization at declaration useless.

Fixes 0d2b746b1bef ("media: sun6i-csi: Add bridge v4l2 subdev with port management")
---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c +2 -2
index 86d20c1c35ed..88df3a73ebfa 100644
@@ -415,8 +415,7 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on)
 	struct sun6i_csi_bridge_source *source;
 	struct v4l2_subdev *source_subdev;
 	struct media_pad *remote_pad;
-	/* Initialize to 0 to use both in disable label (ret != 0) and off. */
-	int ret = 0;
+	int ret;
 
 	/* Source */
 
@@ -436,6 +435,7 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on)
 
 	if (!on) {
 		v4l2_subdev_call(source_subdev, video, s_stream, 0);
+		ret = 0;
 		goto disable;
 	}
 
Signature · 1 line
2.38.1
#3 lore raw

PATCH v3 3/12 media: sunxi-csi: bridge: Declare subdev ops as static

In reply to Paul Kocialkowski

The static keyword is missing in the v4l2 subdev ops definition for the bridge.

Fixes 0d2b746b1bef ("media: sun6i-csi: Add bridge v4l2 subdev with port management")
---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c +1 -1
index 4517c0346eef..7fcb0815cb42 100644
@@ -587,7 +587,7 @@ static const struct v4l2_subdev_pad_ops sun6i_csi_bridge_pad_ops = {
 	.set_fmt	= sun6i_csi_bridge_set_fmt,
 };
 
-const struct v4l2_subdev_ops sun6i_csi_bridge_subdev_ops = {
+static const struct v4l2_subdev_ops sun6i_csi_bridge_subdev_ops = {
 	.video	= &sun6i_csi_bridge_video_ops,
 	.pad	= &sun6i_csi_bridge_pad_ops,
 };
Signature · 1 line
2.38.1
#4 lore raw

PATCH v3 4/12 media: sun6i-csi: capture: Remove useless ret initialization

In reply to Paul Kocialkowski

There is no particular need to assign ret when declaring it as it will be assigned before there is any chance to return it.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +1 -1
index 6d34f5c0768f..cf6aadbc130b 100644
@@ -832,7 +832,7 @@ static int sun6i_csi_capture_open(struct file *file)
 {
 	struct sun6i_csi_device *csi_dev = video_drvdata(file);
 	struct sun6i_csi_capture *capture = &csi_dev->capture;
-	int ret = 0;
+	int ret;
 
 	if (mutex_lock_interruptible(&capture->lock))
 		return -ERESTARTSYS;
Signature · 1 line
2.38.1
#2 lore raw

PATCH v3 2/12 media: sun6i-csi: bridge: Error out on invalid port to fix warning

In reply to Paul Kocialkowski

The enabled variable is only set for a valid port and used later, which triggers an uninitialized use smatch warning. Explicitly error out in that case to fix the warning.

Fixes 0d2b746b1bef ("media: sun6i-csi: Add bridge v4l2 subdev with port management")
---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c +1 -1
index 88df3a73ebfa..4517c0346eef 100644
@@ -663,7 +663,7 @@ sun6i_csi_bridge_notifier_bound(struct v4l2_async_notifier *notifier,
 		enabled = !bridge->source_parallel.expected;
 		break;
 	default:
-		break;
+		return -EINVAL;
 	}
 
 	source->subdev = remote_subdev;
Signature · 1 line
2.38.1
#5 lore raw

PATCH v3 5/12 media: sun6i-mipi-csi2: Clarify return code handling in stream off path

In reply to Paul Kocialkowski

Explicitly set ret to zero instead of assigning it and overwriting it later, which is a bit confusing to understand.

---
 .../media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c   | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c +2 -3
index 484ac5f054d5..a220ce849b41 100644
@@ -188,7 +188,8 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on)
 		return -ENODEV;
 
 	if (!on) {
-		ret = v4l2_subdev_call(source_subdev, video, s_stream, 0);
+		v4l2_subdev_call(source_subdev, video, s_stream, 0);
+		ret = 0;
 		goto disable;
 	}
 
@@ -280,8 +281,6 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on)
 	return 0;
 
 disable:
-	if (!on)
-		ret = 0;
 	phy_power_off(dphy);
 	sun6i_mipi_csi2_disable(csi2_dev);
 
Signature · 1 line
2.38.1
#6 lore raw

PATCH v3 6/12 media: sun8i-a83t-mipi-csi2: Clarify return code handling in stream off path

In reply to Paul Kocialkowski

Explicitly set ret to zero instead of assigning it and overwriting it later, which is a bit confusing to understand.

---
 .../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c        | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c +2 -3
index d993c09a4820..cd2e92ae2293 100644
@@ -220,7 +220,8 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on)
 		return -ENODEV;
 
 	if (!on) {
-		ret = v4l2_subdev_call(source_subdev, video, s_stream, 0);
+		v4l2_subdev_call(source_subdev, video, s_stream, 0);
+		ret = 0;
 		goto disable;
 	}
 
@@ -312,8 +313,6 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on)
 	return 0;
 
 disable:
-	if (!on)
-		ret = 0;
 	phy_power_off(dphy);
 	sun8i_a83t_mipi_csi2_disable(csi2_dev);
 
Signature · 1 line
2.38.1
#7 lore raw

PATCH v3 7/12 media: sun6i-isp: proc: Fix return code handling in stream off path

In reply to Paul Kocialkowski

Explicitly set ret to zero on disable path to avoid a related smatch warning. This makes initialization at declaration useless.

Fixes e3185e1d7c14 ("media: staging: media: Add support for the Allwinner A31 ISP")
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c +2 -2
index d69d2be0add2..a95709d2c573 100644
@@ -173,8 +173,7 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on)
 	struct sun6i_isp_proc_source *source;
 	struct v4l2_subdev *source_subdev;
 	struct media_pad *remote_pad;
-	/* Initialize to 0 to use both in disable label (ret != 0) and off. */
-	int ret = 0;
+	int ret;
 
 	/* Source */
 
@@ -195,6 +194,7 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on)
 	if (!on) {
 		sun6i_isp_proc_irq_disable(isp_dev);
 		v4l2_subdev_call(source_subdev, video, s_stream, 0);
+		ret = 0;
 		goto disable;
 	}
 
Signature · 1 line
2.38.1
#8 lore raw

PATCH v3 8/12 media: sun6i-isp: proc: Error out on invalid port to fix warning

In reply to Paul Kocialkowski

The enabled variable is only set for a valid port and used later, which triggers an uninitialized use smatch warning. Explicitly error out in that case to fix the warning.

Fixes e3185e1d7c14 ("media: staging: media: Add support for the Allwinner A31 ISP")
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c +1 -1
index a95709d2c573..4f34c1bc8be9 100644
@@ -416,7 +416,7 @@ static int sun6i_isp_proc_notifier_bound(struct v4l2_async_notifier *notifier,
 		enabled = !proc->source_csi0.expected;
 		break;
 	default:
-		break;
+		return -EINVAL;
 	}
 
 	source->subdev = remote_subdev;
Signature · 1 line
2.38.1
#9 lore raw

PATCH v3 9/12 media: sun6i-isp: proc: Declare subdev ops as static

In reply to Paul Kocialkowski

The static keyword is missing in the v4l2 subdev ops definition for the proc.

Fixes e3185e1d7c14 ("media: staging: media: Add support for the Allwinner A31 ISP")
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c +1 -1
index 4f34c1bc8be9..1ca4673df2b3 100644
@@ -342,7 +342,7 @@ static const struct v4l2_subdev_pad_ops sun6i_isp_proc_pad_ops = {
 	.set_fmt	= sun6i_isp_proc_set_fmt,
 };
 
-const struct v4l2_subdev_ops sun6i_isp_proc_subdev_ops = {
+static const struct v4l2_subdev_ops sun6i_isp_proc_subdev_ops = {
 	.video	= &sun6i_isp_proc_video_ops,
 	.pad	= &sun6i_isp_proc_pad_ops,
 };
Signature · 1 line
2.38.1
#10 lore raw

PATCH v3 10/12 media: sun6i-isp: capture: Fix uninitialized variable use

In reply to Paul Kocialkowski

While the stride_chroma variable was previously initialized to zero, it's actually stride_chroma_div4 that is set to hardware registers.

Initialize it to zero instead to avoid an uninitialized variable use and get rid of the associated smatch warning.

Fixes e3185e1d7c14 ("media: staging: media: Add support for the Allwinner A31 ISP")
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +2 -2
index 4b592820845a..1595a9607775 100644
@@ -108,8 +108,8 @@ sun6i_isp_capture_buffer_configure(struct sun6i_isp_device *isp_dev,
 void sun6i_isp_capture_configure(struct sun6i_isp_device *isp_dev)
 {
 	unsigned int width, height;
-	unsigned int stride_luma, stride_chroma = 0;
-	unsigned int stride_luma_div4, stride_chroma_div4;
+	unsigned int stride_luma, stride_chroma;
+	unsigned int stride_luma_div4, stride_chroma_div4 = 0;
 	const struct sun6i_isp_capture_format *format;
 	const struct v4l2_format_info *info;
 	u32 pixelformat;
Signature · 1 line
2.38.1
#11 lore raw

PATCH v3 11/12 media: sun6i-isp: params: Fix incorrect indentation

In reply to Paul Kocialkowski

Remove a heading whitespace that results in a smatch warning.

Fixes e3185e1d7c14 ("media: staging: media: Add support for the Allwinner A31 ISP")
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +2 -2
index 8039e311cb1c..7b41a13162b9 100644
@@ -183,8 +183,8 @@ void sun6i_isp_params_configure(struct sun6i_isp_device *isp_dev)
 	if (state->configured)
 		goto complete;
 
-	 sun6i_isp_params_configure_modules(isp_dev,
-					    &sun6i_isp_params_config_default);
+	sun6i_isp_params_configure_modules(isp_dev,
+					   &sun6i_isp_params_config_default);
 
 	state->configured = true;
 
Signature · 1 line
2.38.1
#12 lore raw

PATCH v3 12/12 media: sun6i-isp: params: Unregister pending buffer on cleanup

In reply to Paul Kocialkowski

The state cleanup helper should unregister the pending buffer from the state after returning it to v4l2, like it is done for other buffers in the wait queue.

Before this change, the pending buffer from a previous run might have been returned at the beginning of the next run, causing an error.

Fixes e3185e1d7c14 ("media: staging: media: Add support for the Allwinner A31 ISP")
---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +2 -0
index 7b41a13162b9..e28be895b486 100644
@@ -208,6 +208,8 @@ static void sun6i_isp_params_state_cleanup(struct sun6i_isp_device *isp_dev,
 		vb2_buffer = &state->pending->v4l2_buffer.vb2_buf;
 		vb2_buffer_done(vb2_buffer, error ? VB2_BUF_STATE_ERROR :
 				VB2_BUF_STATE_QUEUED);
+
+		state->pending = NULL;
 	}
 
 	list_for_each_entry(isp_buffer, &state->queue, list) {
Signature · 1 line
2.38.1
Reviewed-by on the v3 series
#13 lore raw
In reply to Paul Kocialkowski
Quoted 5 lines · On Thu, 08 Dec 2022 06:19:54 PST (-0800), [email protected] wrote:

This series resolves reported smatch warnings against the recently-introduced Allwinner A31/A83T CSI, ISP and MIPI CSI-2 drivers.

Smatch was ran again on the updated tree and no longer shows any error or warning.

Thanks. These also fix a handful of warnings I'm seeing when building with clang.

Quoted 36 lines

Changes since v2:
- Added isp params pending buffer fix;
- Added fixes tags where needed;
- Reworded cosmetic commits;
- Changed sunxi-isp to the proper sun6i-isp.

Changes since v1:
- Added fixes for static struct declarations;
- Fixed ISP commit titles by replacing bridge with proc.

Paul

Paul Kocialkowski (12):
media: sun6i-csi: bridge: Fix return code handling in stream off path
media: sun6i-csi: bridge: Error out on invalid port to fix warning
media: sunxi-csi: bridge: Declare subdev ops as static
media: sun6i-csi: capture: Remove useless ret initialization
media: sun6i-mipi-csi2: Clarify return code handling in stream off
path
media: sun8i-a83t-mipi-csi2: Clarify return code handling in stream
off path
media: sun6i-isp: proc: Fix return code handling in stream off path
media: sun6i-isp: proc: Error out on invalid port to fix warning
media: sun6i-isp: proc: Declare subdev ops as static
media: sun6i-isp: capture: Fix uninitialized variable use
media: sun6i-isp: params: Fix incorrect indentation
media: sun6i-isp: params: Unregister pending buffer on cleanup

 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 8 ++++----
 .../media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c    | 2 +-
 .../platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c      | 5 ++---
 .../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c     | 5 ++---
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 4 ++--
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c  | 6 ++++--
 drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c    | 8 ++++----
 7 files changed, 19 insertions(+), 19 deletions(-)