UYVY camera driver debug

I’m trying to port TC358748 driver from L4T 23.2 to L4T 24.2.1.
When using “V4L2_MBUS_FMT_SRGGB10_1X10” or “V4L2_MBUS_FMT_SRGGB12_1X12” as tc358748_DEFAULT_DATAFMT for:
common_data->colorfmt = camera_common_find_datafmt(tc358748_DEFAULT_DATAFMT);
in “tc358748.c”, I was able to capture frames.

I tried the following 3 pixel formats, but they all caused kernel crash:

#define tc358748_DEFAULT_DATAFMT V4L2_MBUS_FMT_UYVY8_2X8 // Kernel crash
#define tc358748_DEFAULT_DATAFMT V4L2_MBUS_FMT_YUYV8_2X8 // Kernel crash
#define tc358748_DEFAULT_DATAFMT V4L2_MBUS_FMT_YUYV8_1X16 // Kernel crash

The following are from console output before crash:

[    7.942622] vi vi: vi_probe: ++
[    7.951806] vi vi: initialized
[    7.959141] vi vi: parsing node /host1x/vi
[    7.967079] vi vi: handling endpoint /host1x/vi/ports/port@0/endpoint
[    7.977423] vi vi: parsing node /host1x/i2c@546c0000/tc35874x@0e
[    7.987271] vi vi: handling endpoint /host1x/i2c@546c0000/tc35874x@0e/ports/port@0/endpoint
[    7.999544] vi vi: subdev tc35874x 6-000e bound
[    8.007943] vi vi: notify complete, all subdevs registered
[    8.017298] vi vi: creating links for entity tc35874x 6-000e
[    8.026804] vi vi: processing endpoint /host1x/i2c@546c0000/tc35874x@0e/ports/port@0/endpoint
[    8.039268] vi vi: skipping channel port /host1x/i2c@546c0000/tc35874x@0e:0
[    8.050284] vi vi: creating links for channels
[    8.058630] vi vi: processing endpoint /host1x/vi/ports/port@0/endpoint
[    8.069172] vi vi: creating link for channel vi-output-0
[    8.078389] vi vi: creating tc35874x 6-000e:0 -> vi-output-0:0 link
[    8.088496] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    8.100430] pgd = ffffffc00007d000
[    8.107651] [00000000] *pgd=000000017fc05003, *pmd=000000017fc06003, *pte=00e0000050041407
[    8.119864] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[    8.129332] Enter nvdumper_crash_setup_regs
[    8.137418] nvdumper: all registers are saved.
[    8.137420] nvdumper: all registers are saved.
[    8.137422] nvdumper: all registers are saved.
[    8.162353] nvdumper: all registers are saved.

i.e., “Unable to handle kernel NULL pointer dereference at virtual address 00000000”

How could “common_data->colorfmt” in driver cause kernel crash?

I noticed in “camera_common.c”, only the following 3 formats are included:

static const struct camera_common_colorfmt camera_common_color_fmts = {

Thanks for troubleshooting suggestions.

Drivers run with privilege in kernel space and are free to behave badly…as the saying goes, “the buck stops here”…if the driver does not gracefully deal with NULL pointer dereferences, then nobody else does…the program crashes…that program is the kernel (if you’re running inside a virtual sandbox, then there may actually be another level of protection…but still that kernel is in trouble). Is common_data NULL? Is member colorfmt a pointer which might also be NULL and in need of allocation?

Thanks for the hint. The “common_data->colorfmt” is NULL because “camera_common_find_datafmt” was called but there are only 3 formats (SRGGB8_1X8, SRGGB10_1X10, SRGGB12_1X12) defined in “camera_common.c”.

TX1 on board ov5693 camera, Leopard Imaging IMX cameras and Pi cameras are all “SRGGB” color formats.

There is no example for UYVY cameras.

I had to add “V4L2_MBUS_FMT_UYVY8_2X8” to “camera_common.c” to make it work.