video: tegra: nvmap: Return error if any handles exist

When nvmap module is unloaded and if there are any existing handles then
return an error -EBUSY.

Bug 4603770

Change-Id: I74d9b0ee8d95a78c1784998e7b913578a83b3cef
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3149415
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Ashish Mhetre <amhetre@nvidia.com>
This commit is contained in:
Ketan Patil
2024-06-02 16:33:49 +00:00
committed by mobile promotions
parent ee37ee732d
commit caeb9cd1b8

View File

@@ -1483,10 +1483,13 @@ finish:
int nvmap_remove(struct platform_device *pdev)
{
struct nvmap_device *dev = platform_get_drvdata(pdev);
struct rb_node *n;
struct nvmap_handle *h;
int i;
if (dev && !RB_EMPTY_ROOT(&dev->handles)) {
pr_err("Can't remove nvmap module as handles exist\n");
return -EBUSY;
}
#ifdef NVMAP_CONFIG_SCIIPC
nvmap_sci_ipc_exit();
#endif
@@ -1497,11 +1500,6 @@ int nvmap_remove(struct platform_device *pdev)
nvmap_page_pool_clear();
nvmap_page_pool_fini(nvmap_dev);
#endif
while ((n = rb_first(&dev->handles))) {
h = rb_entry(n, struct nvmap_handle, node);
rb_erase(&h->node, &dev->handles);
kfree(h);
}
for (i = 0; i < dev->nr_carveouts; i++) {
struct nvmap_carveout_node *node = &dev->heaps[i];