From c1e81c594f59557432239b80781ea356916de7f6 Mon Sep 17 00:00:00 2001 From: Manish Bhardwaj Date: Fri, 3 Nov 2023 20:36:09 +0000 Subject: [PATCH] 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 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3009693 Reviewed-by: Suresh Venkatachalam Reviewed-by: Sumeet Gupta GVS: Gerrit_Virtual_Submit Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3010050 Reviewed-by: Gokul Vasan L J GVS: buildbot_gerritrpt --- drivers/block/tegra_virt_storage/tegra_hv_vblk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c index 5344621f..6a00672e 100644 --- a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c +++ b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c @@ -1596,12 +1596,11 @@ static void vblk_init_device(struct work_struct *ws) return; } - mutex_unlock(&vblkdev->ivc_lock); - vblkdev->initialized = true; /* read lcpu_affinity from dts */ if (of_property_read_u32_index(vblkdev->device->of_node, "lcpu_affinity", 0, &lcpu_affinity)) { dev_err(vblkdev->device, "Failed to read lcpu_affinity property\n"); + mutex_unlock(&vblkdev->ivc_lock); return; } @@ -1611,6 +1610,7 @@ static void vblk_init_device(struct work_struct *ws) vblkdev->devnum, vblkdev->config.priority); if (ret < 0) { dev_err(vblkdev->device, "snprint API failed\n"); + mutex_unlock(&vblkdev->ivc_lock); return; } strncat(vblk_comm, ":%u", 3); @@ -1620,6 +1620,7 @@ static void vblk_init_device(struct work_struct *ws) vblkdev->vcpu_affinity, vblk_comm); if (IS_ERR(vblkdev->vblk_kthread)) { dev_err(vblkdev->device, "Cannot allocate vblk worker thread\n"); + mutex_unlock(&vblkdev->ivc_lock); return; } @@ -1630,6 +1631,9 @@ static void vblk_init_device(struct work_struct *ws) init_completion(&vblkdev->complete); wake_up_process(vblkdev->vblk_kthread); + vblkdev->initialized = true; + mutex_unlock(&vblkdev->ivc_lock); + setup_device(vblkdev); return; }