virt_storage: Update calling of ivc_reset()

Below race condition can happen during boot
1) Server calls sivc_reset()
2) Storage client driver has IVC event handler registered, so it gets the event
   and it calls ivc_notified()
3) Server gets ivc event, it calls ivc_notified()
   ( this makes server local state to established )
4) Storage cliend driver also goes to established state
5) After this, storage client driver continued with probe() and
   calls ivc_reset() which results in disconnecting the
   already established connection.

To fix this race condition, perform ivc_reset in storage client
driver right after tegra_hv_ivc_reserve() before registering
the IVC IRQ handler.

Bug 4125055

Change-Id: I36e6db3479f34fb649bdb8d890f24b1783d10cb9
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2943766
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: Sanjith T D <std@nvidia.com>
Reviewed-by: Vipin Kumar <vipink@nvidia.com>
Tested-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
This commit is contained in:
Sanjith T D
2023-07-24 15:35:04 +00:00
committed by mobile promotions
parent 0f0dc2e6c1
commit 8975fb1f4b

View File

@@ -1439,7 +1439,7 @@ static int tegra_hv_vblk_probe(struct platform_device *pdev)
ret = -ENODEV;
goto fail;
}
tegra_hv_ivc_channel_reset(vblkdev->ivck);
vblkdev->initialized = false;
vblkdev->wq = alloc_workqueue("vblk_req_wq%d",
@@ -1478,7 +1478,6 @@ static int tegra_hv_vblk_probe(struct platform_device *pdev)
}
mutex_lock(&vblkdev->ivc_lock);
tegra_hv_ivc_channel_reset(vblkdev->ivck);
if (vblk_send_config_cmd(vblkdev)) {
dev_err(dev, "Failed to send config cmd\n");
ret = -EACCES;
@@ -1558,11 +1557,6 @@ static int tegra_hv_vblk_suspend(struct device *dev)
disable_irq(vblkdev->ivck->irq);
flush_workqueue(vblkdev->wq);
/* Reset the channel */
mutex_lock(&vblkdev->ivc_lock);
tegra_hv_ivc_channel_reset(vblkdev->ivck);
mutex_unlock(&vblkdev->ivc_lock);
}
return 0;