nvidia: protect the vsc driver initialisation path

Using this patch we flashing the below crash issue by
protecting the initialisation path.
05:00:08: [   12.819857] Call trace:
05:00:08: [   12.820282]  swake_up_locked.part.0+0x24/0x60
05:00:08: [   12.820581]  swake_up_locked+0x38/0x50
05:00:08: [   12.820841]  complete+0x50/0x80
05:00:08: [   12.820937] tegra_hv_vblk tegra_virt_storage3: send config cmd to ivc #111
05:00:08: [   12.821000]  0xffff8000012f1714
05:00:08: [   12.821388] tegra_hv_vblk tegra_virt_storage20: allocate drvdata buffer
05:00:08: [   12.821455]  irq_forced_thread_fn+0x48/0xf0
05:00:08: [   12.822010]  irq_thread+0x198/0x2d0
05:00:08: [   12.822244]  kthread+0x198/0x1c0
05:00:08: [   12.822476]  ret_from_fork+0x10/0x20

Bug 4231381
Bug 4365516

Change-Id: I6de423edb18097f29c9983b23fd154b8ffc5f6e2
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3009693
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3010050
Reviewed-by: Gokul Vasan L J <gokull@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Manish Bhardwaj
2023-11-03 20:36:09 +00:00
committed by Jon Hunter
parent 16324a47de
commit c1e81c594f

View File

@@ -1596,12 +1596,11 @@ static void vblk_init_device(struct work_struct *ws)
return; return;
} }
mutex_unlock(&vblkdev->ivc_lock);
vblkdev->initialized = true;
/* read lcpu_affinity from dts */ /* read lcpu_affinity from dts */
if (of_property_read_u32_index(vblkdev->device->of_node, "lcpu_affinity", 0, if (of_property_read_u32_index(vblkdev->device->of_node, "lcpu_affinity", 0,
&lcpu_affinity)) { &lcpu_affinity)) {
dev_err(vblkdev->device, "Failed to read lcpu_affinity property\n"); dev_err(vblkdev->device, "Failed to read lcpu_affinity property\n");
mutex_unlock(&vblkdev->ivc_lock);
return; return;
} }
@@ -1611,6 +1610,7 @@ static void vblk_init_device(struct work_struct *ws)
vblkdev->devnum, vblkdev->config.priority); vblkdev->devnum, vblkdev->config.priority);
if (ret < 0) { if (ret < 0) {
dev_err(vblkdev->device, "snprint API failed\n"); dev_err(vblkdev->device, "snprint API failed\n");
mutex_unlock(&vblkdev->ivc_lock);
return; return;
} }
strncat(vblk_comm, ":%u", 3); strncat(vblk_comm, ":%u", 3);
@@ -1620,6 +1620,7 @@ static void vblk_init_device(struct work_struct *ws)
vblkdev->vcpu_affinity, vblk_comm); vblkdev->vcpu_affinity, vblk_comm);
if (IS_ERR(vblkdev->vblk_kthread)) { if (IS_ERR(vblkdev->vblk_kthread)) {
dev_err(vblkdev->device, "Cannot allocate vblk worker thread\n"); dev_err(vblkdev->device, "Cannot allocate vblk worker thread\n");
mutex_unlock(&vblkdev->ivc_lock);
return; return;
} }
@@ -1630,6 +1631,9 @@ static void vblk_init_device(struct work_struct *ws)
init_completion(&vblkdev->complete); init_completion(&vblkdev->complete);
wake_up_process(vblkdev->vblk_kthread); wake_up_process(vblkdev->vblk_kthread);
vblkdev->initialized = true;
mutex_unlock(&vblkdev->ivc_lock);
setup_device(vblkdev); setup_device(vblkdev);
return; return;
} }