Accessing user space memory outside uaccess.h

Hi,all
Recently I’ve been working on porting camera drivers on TX2.
I managed to light up a sensor with 10bit mipi data output.When I try to light up it with 12bit mipi data output,I got an error:

Accessing user space memory outside uaccess.h

looks like there was an error registering the device.
The only change I made in the device tree was:

csi_pixel_bit_depth = "10";  -------->csi_pixel_bit_depth = "12";

The driver.c(like imx219.c) doesn’t change.
Do I need to make any changes to light up the 12bit sensor?
Thank you for all your suggestions.

It’s compile error?

Have a check this document for device tree configure.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/camera_sensor_prog.47.1.html#wwpID0E0B60HA

Hi,Shane
Thank you for your reply.
Not a compile error.
When I insert the module, The terminal display:
Segmentation fault(core dumped).
dmesg shows like:

[   37.802438] ov5693 2-0030: tegracam sensor driver:ov5693_v2.0.6
[   37.834009] ov5693 2-0030: sc850sl_board_setup: invalid sensor model id: bd1e
[   37.843357] tegra-vi4 15700000.vi: subdev ov5693 2-0030 bound
[   37.844220] Internal error: Accessing user space memory outside uaccess.h routines: 96000005 [#1] PREEMPT SMP
[   37.854141] Modules linked in: ov5693(+) bnep fuse xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter bcmdhd zram bluedroid_pm userspace_alert cfg80211 overlay nvgpu ip_tables x_tables [last unloaded: ov5693]
[   37.860021] CPU: 5 PID: 8641 Comm: insmod Not tainted 4.9.253-tegra #4
[   37.860025] Hardware name: quill (DT)
[   37.860031] task: ffffffc182c35400 task.stack: ffffffc182c14000
[   37.860054] PC is at camera_common_g_fmt+0x44/0xc8
[   37.860061] LR is at camera_common_g_fmt+0x30/0xc8
[   37.860066] pc : [<ffffff8008b43904>] lr : [<ffffff8008b438f0>] pstate: 40400045
[   37.860069] sp : ffffffc182c176c0
[   37.860072] x29: ffffffc182c176c0 
[   37.860076] x28: 0000000000000018 
[   37.860081] x27: 00000000000000bd 
[   37.860084] x26: 0000000000000002 
[   37.860088] x25: 0000000000000038 
[   37.860091] x24: 0000000000000001 
[   37.860095] x23: ffffffc1b5536450 
[   37.860097] x22: ffffffc1b5536450 
[   37.860101] x21: ffffffc1b5536418 
[   37.860104] x20: 0000000000000000 
[   37.860108] x19: ffffffc182c17790 
[   37.860110] x18: 0000000000000001 
[   37.860114] x17: 0000000000000002 
[   37.860116] x16: 0000000000000000 
[   37.860120] x15: ffffffffffffffff 
[   37.860123] x14: ffffffc182c176c0 
[   37.860126] x13: ffffffc182c175c5 
[   37.860129] x12: ffffffffffffffff 
[   37.860133] x11: ffffffc182c17580 
[   37.860135] x10: ffffffc182c17580 
[   37.860139] x9 : 0000000000000002 
[   37.860142] x8 : 0000000000000002 
[   37.860146] x7 : ffffff8008fc7180 
[   37.860150] x6 : 0000000000000090 
[   37.860154] x5 : 000000000000008d 
[   37.860156] x4 : 0000000000000001 
[   37.860160] x3 : 0000000000000000 
[   37.860162] x2 : 0000000000000000 
[   37.860166] x1 : ffffffc182c35400 
[   37.860168] x0 : 0000000000000001 

[   37.860178] Process insmod (pid: 8641, stack limit = 0xffffffc182c14000)
[   37.860181] Call trace:
[   37.860193] [<ffffff8008b43904>] camera_common_g_fmt+0x44/0xc8
[   37.860203] [<ffffff8008b48cc0>] v4l2sd_get_fmt+0x28/0x38
[   37.860215] [<ffffff8008b31c4c>] tegra_channel_fmts_bitmap_init+0x13c/0x268
[   37.860224] [<ffffff8008b33464>] tegra_channel_init_subdevices+0x17c/0x790
[   37.860232] [<ffffff8008b346a0>] tegra_vi_graph_notify_complete+0x2e8/0x6e8
[   37.860242] [<ffffff8008b17d6c>] v4l2_async_test_notify+0x104/0x120
[   37.860249] [<ffffff8008b17fa8>] v4l2_async_register_subdev+0x88/0x100
[   37.860256] [<ffffff8008b48ae0>] tegracam_v4l2subdev_register+0xf0/0x190
[   37.860281] [<ffffff800110ccb0>] sc850sl_probe+0x240/0x378 [ov5693]
[   37.860292] [<ffffff8008ae4164>] i2c_device_probe+0x144/0x258
[   37.860306] [<ffffff800877fcf8>] driver_probe_device+0x298/0x448
[   37.860312] [<ffffff800877ff84>] __driver_attach+0xdc/0x128
[   37.860318] [<ffffff800877d5b4>] bus_for_each_dev+0x5c/0xa8
[   37.860324] [<ffffff800877f338>] driver_attach+0x30/0x40
[   37.860330] [<ffffff800877ed6c>] bus_add_driver+0x20c/0x2a8
[   37.860336] [<ffffff8008780ebc>] driver_register+0x6c/0x110
[   37.860343] [<ffffff8008ae4854>] i2c_register_driver+0x4c/0xb0
[   37.860358] [<ffffff8001111018>] sc850sl_i2c_driver_init+0x18/0x30 [ov5693]
[   37.860369] [<ffffff8008083b3c>] do_one_initcall+0x44/0x130
[   37.860381] [<ffffff8008f59eb4>] do_init_module+0x64/0x1b0
[   37.860393] [<ffffff80081569dc>] load_module+0x10ac/0x12e0
[   37.860398] [<ffffff8008156ec0>] SyS_finit_module+0xd8/0xf0
[   37.860403] [<ffffff8008083900>] el0_svc_naked+0x34/0x38
[   37.860412] ---[ end trace 742685dd49b6506a ]---

It works well if csi_pixel_bit_depth is set to 10.

Have trace …/kernel/nvidia/drivers/media/platform/tegra/camera/sensor_common.c to confirm the string pix_format

How to trace it?Could you please be more specific.
According to the source code,string pix_format should be “bayer_bggr12”.

	err = of_property_read_string(node, "pixel_t", &temp_str);
	if (err) {
		/* pixel_t missing is only an error if alternate not provided */

		/* check for alternative format string */
		err = of_property_read_string(node, "pixel_phase", &phase_str);
		if (err) {
			dev_err(dev,
				"%s:pixel_phase property missing.\n",
				__func__);
			dev_err(dev,
				"%s:Either pixel_t or alternate must be present.\n",
				__func__);
			goto fail;
		}
		err = of_property_read_string(node, "mode_type", &mode_str);
		if (err) {
			dev_err(dev,
				"%s:mode_type property missing.\n",
				__func__);
			dev_err(dev,
				"%s:Either pixel_t or alternate must be present.\n",
				__func__);
			goto fail;
		}
		err = read_property_u32(node, "csi_pixel_bit_depth", &depth);
		if (err) {
			dev_err(dev,
				"%s:csi_pixel_bit_depth property missing.\n",
				__func__);
			dev_err(dev,
				"%s:Either pixel_t or alternate must be present.\n",
				__func__);
			goto fail;
		}
		sprintf(pix_format, "%s_%s%d", mode_str, phase_str, depth);
		temp_str = pix_format;
	}

	err = extract_pixel_format(temp_str, &image->pixel_format);
	if (err) {
		dev_err(dev, "Unsupported pixel format\n");
		goto fail;
	}

Does your driver call camera_common_g_fmt()?
Please add debug message to camera_common_g_fmt{} to check which line cause the kernel panic.

Thank you for your reply.
Another question: Does TX2 support YUV-10bit sensor output?
From the source code below it seems only supported YUV-8bit.

static int extract_pixel_format(
	const char *pixel_t, u32 *format)
{
	size_t size = strnlen(pixel_t, OF_MAX_STR_LEN);

	if (strncmp(pixel_t, "bayer_bggr10", size) == 0)
		*format = V4L2_PIX_FMT_SBGGR10;
	else if (strncmp(pixel_t, "bayer_rggb10", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB10;
	else if (strncmp(pixel_t, "bayer_grbg10", size) == 0)
		*format = V4L2_PIX_FMT_SGRBG10;
	else if (strncmp(pixel_t, "bayer_gbrg10", size) == 0)
		*format = V4L2_PIX_FMT_SGBRG10;
	else if (strncmp(pixel_t, "bayer_bggr12", size) == 0)
		*format = V4L2_PIX_FMT_SBGGR12;
	else if (strncmp(pixel_t, "bayer_rggb12", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB12;
	else if (strncmp(pixel_t, "bayer_gbrg12", size) == 0)
		*format = V4L2_PIX_FMT_SGBRG12;
	else if (strncmp(pixel_t, "bayer_grbg12", size) == 0)
		*format = V4L2_PIX_FMT_SGRBG12;
	else if (strncmp(pixel_t, "rgb_rgb88824", size) == 0)
		*format = V4L2_PIX_FMT_RGB24;
	else if (strncmp(pixel_t, "bayer_wdr_pwl_rggb12", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB12;
	else if (strncmp(pixel_t, "bayer_wdr_pwl_gbrg12", size) == 0)
		*format = V4L2_PIX_FMT_SGBRG12;
	else if (strncmp(pixel_t, "bayer_wdr_pwl_grbg12", size) == 0)
		*format = V4L2_PIX_FMT_SGRBG12;
	else if (strncmp(pixel_t, "bayer_wdr_dol_rggb10", size) == 0)
		*format = V4L2_PIX_FMT_SRGGB10;
	else if (strncmp(pixel_t, "bayer_xbggr10p", size) == 0)
		*format = V4L2_PIX_FMT_XBGGR10P;
	else if (strncmp(pixel_t, "bayer_xrggb10p", size) == 0)
		*format = V4L2_PIX_FMT_XRGGB10P;
	else if (strncmp(pixel_t, "yuv_yuyv16", size) == 0)
		*format = V4L2_PIX_FMT_YUYV;
	else if (strncmp(pixel_t, "yuv_yvyu16", size) == 0)
		*format = V4L2_PIX_FMT_YVYU;
	else if (strncmp(pixel_t, "yuv_uyvy16", size) == 0)
		*format = V4L2_PIX_FMT_UYVY;
	else if (strncmp(pixel_t, "yuv_vyuy16", size) == 0)
		*format = V4L2_PIX_FMT_VYUY;
	else {
		pr_err("%s: Need to extend format%s\n", __func__, pixel_t);
		return -EINVAL;
	}

	return 0;
}

Sorry to tell don’t support YUV 10bit.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.