[Camera][VI][JP-6.0/r36.3] Fixes for raw image corruption (line artifacts) through VI-mode

hi all,

here’s a known issue with JP-6.0 GA/ l4t-r36.3.0, which images captured through VI-mode results in abnormal lines.
please refer to below snapshot for demonstration of such line artifacts.

besides, we’ve several similar topics has reported,
for instance,
Topic 299235: Jetpack 6.0: Clusters of null values on the captured camera image
Topic 295598: Video4Linux shows artifacts when nvgstcapture does not
Topic 292692: Vi error when update 36.3.0

this issue only repo’ed via VI mode, it should not seen by going through LibArgus.
also, this is due to memory issue. since upstream has changed the property name to "dma-noncoherent". if a device is coherent, the CPU/Device syncs are skipped by the kernel.

hence…
here’re two fixes to address the issue.
(1) device tree for tegra234-camera, to update DT property for VI HW.

---

diff --git a/nv-soc/tegra234-soc-camera.dtsi b/nv-soc/tegra234-soc-camera.dtsi
index 85dfb96..81d441c 100644
--- a/nv-soc/tegra234-soc-camera.dtsi
+++ b/nv-soc/tegra234-soc-camera.dtsi
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
+// SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
 
 /*
  * tegra234-soc-camera.dtsi: Camera RTCPU DTSI file.
@@ -28,7 +28,7 @@
 				iommus = <&smmu_iso TEGRA234_SID_ISO_VI>;
 				interconnects = <&mc TEGRA234_MEMORY_CLIENT_VIW &emc>;
 				interconnect-names = "write";
-				non-coherent;
+				dma-noncoherent;
 				status = "okay";
 			};
 
@@ -37,7 +37,7 @@
 				resets = <&bpmp TEGRA234_RESET_VI>;
 				reset-names = "vi0_thi";
 				iommus = <&smmu_iso TEGRA234_SID_ISO_VI>;
-				non-coherent;
+				dma-noncoherent;
 				interconnects = <&mc TEGRA234_MEMORY_CLIENT_VI2FALR &emc>,
 						<&mc TEGRA234_MEMORY_CLIENT_VI2FALW &emc>;
 				interconnect-names = "dma-mem", "write";
@@ -54,7 +54,7 @@
 				iommus = <&smmu_iso TEGRA234_SID_ISO_VI2>;
 				interconnects = <&mc TEGRA234_MEMORY_CLIENT_VI2W &emc>;
 				interconnect-names = "write";
-				non-coherent;
+				dma-noncoherent;
 				status = "okay";
 			};
 
@@ -63,7 +63,7 @@
 				resets = <&bpmp TEGRA234_RESET_VI2>;
 				reset-names = "vi1_thi";
 				iommus = <&smmu_iso TEGRA234_SID_ISO_VI2>;
-				non-coherent;
+				dma-noncoherent;
 				interconnects = <&mc TEGRA234_MEMORY_CLIENT_VIFALR &emc>,
 						<&mc TEGRA234_MEMORY_CLIENT_VIFALW &emc>;
 				interconnect-names = "dma-mem", "write";

(2) kernel logic to handle dma-noncoherent in of_dma_is_coherent()

---

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 4b0c036..b9b3685 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -1095,26 +1095,29 @@
  *
  * It returns true if "dma-coherent" property was found
  * for this device in the DT, or if DMA is coherent by
- * default for OF devices on the current platform.
+ * default for OF devices on the current platform and no
+ * "dma-noncoherent" property was found for this device.
  */
 bool of_dma_is_coherent(struct device_node *np)
 {
 	struct device_node *node;
-
-	if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
-		return true;
+	bool is_coherent = IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT);
 
 	node = of_node_get(np);
 
 	while (node) {
 		if (of_property_read_bool(node, "dma-coherent")) {
-			of_node_put(node);
-			return true;
+			is_coherent = true;
+			break;
+		}
+		if (of_property_read_bool(node, "dma-noncoherent")) {
+			is_coherent = false;
+			break;
 		}
 		node = of_get_next_dma_parent(node);
 	}
 	of_node_put(node);
-	return false;
+	return is_coherent;
 }
 EXPORT_SYMBOL_GPL(of_dma_is_coherent);

furthermore, we’ve done the code-review progress.
please also expect next Jetpack-6 public release version will also include the fixes.

4 Likes

Hello Jerry,

thank you for your patches !

However, is it normal that the first one does not apply cleanly to jetson_36.3 ?

$ git diff jetson_36.3 nv-soc/tegra234-soc-camera.dtsi
$ patch -p1 < VI-dts.patch
patching file nv-soc/tegra234-soc-camera.dtsi
Hunk #3 FAILED at 37.
Hunk #4 succeeded at 52 (offset -2 lines).
Hunk #5 FAILED at 63.
2 out of 5 hunks FAILED -- saving rejects to file nv-soc/tegra234-soc-camera.dtsi.rej
$

I doubt it’s mismatch of the SPDX-FileCopyrightText content, if yes, please ignore that.

Hello Jerry,

It’s really in the body.

$ cat nv-soc/tegra234-soc-camera.dtsi.rej
--- nv-soc/tegra234-soc-camera.dtsi
+++ nv-soc/tegra234-soc-camera.dtsi
@@ -37,7 +37,7 @@
                                resets = <&bpmp TEGRA234_RESET_VI>;
                                reset-names = "vi0_thi";
                                iommus = <&smmu_iso TEGRA234_SID_ISO_VI>;
-                               non-coherent;
+                               dma-noncoherent;
                                interconnects = <&mc TEGRA234_MEMORY_CLIENT_VI2FALR &emc>,
                                                <&mc TEGRA234_MEMORY_CLIENT_VI2FALW &emc>;
                                interconnect-names = "dma-mem", "write";
@@ -63,7 +63,7 @@
                                resets = <&bpmp TEGRA234_RESET_VI2>;
                                reset-names = "vi1_thi";
                                iommus = <&smmu_iso TEGRA234_SID_ISO_VI2>;
-                               non-coherent;
+                               dma-noncoherent;
                                interconnects = <&mc TEGRA234_MEMORY_CLIENT_VIFALR &emc>,
                                                <&mc TEGRA234_MEMORY_CLIENT_VIFALW &emc>;
                                interconnect-names = "dma-mem", "write";
$

The non-coherent properties do not exist in jetson_36.3’s version, and the order of the properties in the nodes is different.
Nevertheless I added the dma-noncoherent properties manually, and it really fixes the problem.

Thank you again

Hello Jerry,

Will this fix be included in JP6.1?

Thanks.

hello tobleronwater,

yes, it is included.
please check https://developer.nvidia.com/embedded/jetson-linux-r3640 for [Driver Package (BSP) Sources].

Thanks for sharing this update! It’s great to see a clear explanation of the issue and the fixes provided. Looking forward to the next Jetpack-6 release with these improvements!