Tegracam_device_unregister causes kernel oops

Board: Nvidia Jetson Xavier NX
L4T version: 32.5.1

Hello, I am developing a camera driver as a driver module, so it can be loaded and unloaded at will.

When unloading the kernel module, the _remove() function is called, see it below:

static int ar0231_remove(struct i2c_client *client) {
  struct camera_common_data *s_data = to_camera_common_data(&client->dev);
  struct ar0231 *priv               = (struct ar0231 *)s_data->priv;

  dev_info(&priv->i2c_client->dev, "-> %s\n", __func__);

  if (priv->v4l_subdev_registered) {
    // Unregister the sensor as a V4L2 subdevice.
    tegracam_v4l2subdev_unregister(priv->tc_dev);
  }

  if (priv->v4l_dev_registered) {
    // Unregister the driver from Jetson V4L2 Camera Framework.
    tegracam_device_unregister(priv->tc_dev);
  }

  mutex_destroy(&priv->streaming_lock);

  return 0;
}

tegracam_device_unregister causes an error:

[ 341.489319] ar0231 31-001b: → ar0231_remove
[ 341.489885] Unable to handle kernel paging request at virtual address dead000000000100
[ 341.490061] Mem abort info:
[ 341.490117] ESR = 0x96000004
[ 341.490176] Exception class = DABT (current EL), IL = 32 bits
[ 341.490279] SET = 0, FnV = 0
[ 341.490337] EA = 0, S1PTW = 0
[ 341.490394] Data abort info:
[ 341.490447] ISV = 0, ISS = 0x00000004
[ 341.490516] CM = 0, WnR = 0
[ 341.490576] [dead000000000100] address between user and kernel address ranges
[ 341.490704] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[ 341.490806] Modules linked in: ar0231(O-) fuse zram overlay spidev userspace_alert nvgpu bluedroid_pm ip_tables x_tables
[ 341.491108] CPU: 2 PID: 7999 Comm: rmmod Tainted: G O 4.9.201-tegra #2
[ 341.491243] Hardware name: NVIDIA Jetson Xavier NX Developer Kit (DT)
[ 341.491658] task: ffffffc1e731d400 task.stack: ffffffc1caf1c000
[ 341.492099] PC is at tegracam_device_unregister+0x88/0x120
[ 341.492507] LR is at tegracam_device_unregister+0x48/0x120
[ 341.492940] pc : [] lr : [] pstate: 20400045
[ 341.497734] sp : ffffffc1caf1fd00
[ 341.501228] x29: ffffffc1caf1fd00 x28: ffffffc1e731d400
[ 341.507001] x27: ffffff8008f72000 x26: 000000000000006a
[ 341.512599] x25: 0000000000000123 x24: 0000000000000015
[ 341.517785] x23: 0000000000000000 x22: ffffffc1e8da3018
[ 341.522850] x21: ffffff8009fbe000 x20: ffffffc1ee50e318
[ 341.528361] x19: dead0000000000f8 x18: 0000000000000000
[ 341.534212] x17: 0000007faf12d5c0 x16: ffffff80080b1450
[ 341.539899] x15: 000000000000002e x14: ffffffc1d9aaa91c
[ 341.545587] x13: ffffffc1d9aaa1ab x12: 0000000000000000
[ 341.551362] x11: 0000000000000006 x10: 0000000000000481
[ 341.556886] x9 : 0000000000000000 x8 : ffffffc1ffcd97a7
[ 341.562662] x7 : 0000000000000000 x6 : ffffffc1ffd34bf0
[ 341.568173] x5 : 000000000000003f x4 : 0000000000000000
[ 341.573763] x3 : ffffffc1ec9c25d8 x2 : dead0000000000f8
[ 341.579101] x1 : dead000000000100 x0 : ffffff8009fbeff8

[ 341.585852] Process rmmod (pid: 7999, stack limit = 0xffffffc1caf1c000)
[ 341.591968] Call trace:
[ 341.594337] [] tegracam_device_unregister+0x88/0x120
[ 341.600467] [] ar0231_remove+0x68/0x98 [ar0231]
[ 341.606584] [] i2c_device_remove+0x70/0xe0
[ 341.611662] [] __device_release_driver+0x9c/0x118
[ 341.617606] [] driver_detach+0xc4/0xc8
[ 341.622855] [] bus_remove_driver+0x64/0x118
[ 341.628192] [] driver_unregister+0x34/0x58
[ 341.633271] [] i2c_del_driver+0x30/0x68
[ 341.638608] [] ar0231_i2c_driver_exit+0x14/0x290 [ar0231]
[ 341.645082] [] SyS_delete_module+0x15c/0x208
[ 341.650770] [] el0_svc_naked+0x34/0x38
[ 341.656113] —[ end trace b6b62cee3978a755 ]—

Can you explain what is this error and what causes this Unable to handle kernel paging request at virtual address error?

I failed to find satisfying documentation or the source code of tegracam_device_unregister to try to troubleshoot this error.

Thanks !

hello user27558,

this is very old release version, it’s suggest moving to the latest rel-32 public release, (r32.7.4) for development.


here’s tegracam_device_unregister to remove the video node from registered devices.
please dig into the code for root cause.
for instance,
$public_sources/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_core.c