mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
camera: fix the kernel freeze after driver unbind
Kernel freeze is occurring due to incorrect cleanup in vi5.c. Fix for kernel freeze: 1 Don't call vi_channel_drv_unregister() and tegra_vi_media_controller_cleanup() in vi5_remove. 2 capture_vi_probe() is calling vi_channel_drv_register() and tegra_capture_vi_media_controller_init(), so capture_vi_remove() should call vi_channel_drv_unregister() and tegra_vi_media_controller_cleanup() 3 Use correct dev pointer in vi_channel_drv_unregister(). Code cleanup: 1 Remove use_legacy_path variable that was used for T186. 2 Removed unused t194_vi5_file_private struct. Bug 4415340 Change-Id: I6153f65d62a9f7f4fc5d04c2ace948a29396e404 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3077660 Reviewed-by: Shubham Chandra <shubhamc@nvidia.com> Reviewed-by: Ankur Pawar <ankurp@nvidia.com> Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com> Tested-by: Ankur Pawar <ankurp@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
61319aef4d
commit
29e88ed17e
@@ -1,10 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2017-2023 NVIDIA Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
/**
|
||||
* @file drivers/media/platform/tegra/camera/fusa-capture/capture-vi-channel.c
|
||||
*
|
||||
* @brief VI channel character device driver for the T186/T194 Camera RTCPU
|
||||
* @brief VI channel character device driver for the T234 Camera RTCPU
|
||||
* platform.
|
||||
*/
|
||||
|
||||
@@ -204,10 +204,6 @@ struct tegra_vi_channel *vi_channel_open_ex(
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
chan->drv = chan_drv;
|
||||
if (chan_drv->use_legacy_path) {
|
||||
chan->dev = chan_drv->dev;
|
||||
chan->ndev = chan_drv->ndev;
|
||||
} else
|
||||
chan->vi_capture_pdev = chan_drv->vi_capture_pdev;
|
||||
|
||||
chan->ops = chan_drv->ops;
|
||||
@@ -390,7 +386,6 @@ static long vi_channel_ioctl(
|
||||
if (copy_from_user(&setup, ptr, sizeof(setup)))
|
||||
break;
|
||||
|
||||
if (chan->drv->use_legacy_path == false) {
|
||||
vi_get_nvhost_device(chan, &setup);
|
||||
if (chan->dev == NULL) {
|
||||
dev_err(&chan->vi_capture_pdev->dev,
|
||||
@@ -398,8 +393,6 @@ static long vi_channel_ioctl(
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (setup.request_size < sizeof(struct capture_descriptor)) {
|
||||
dev_err(chan->dev,
|
||||
@@ -650,16 +643,10 @@ int vi_channel_drv_register(
|
||||
if (unlikely(chan_drv == NULL))
|
||||
return -ENOMEM;
|
||||
|
||||
if (strstr(ndev->name, "tegra-capture-vi") == NULL) {
|
||||
chan_drv->use_legacy_path = true;
|
||||
chan_drv->dev = &ndev->dev;
|
||||
chan_drv->ndev = ndev;
|
||||
} else {
|
||||
chan_drv->use_legacy_path = false;
|
||||
chan_drv->dev = NULL;
|
||||
chan_drv->ndev = NULL;
|
||||
chan_drv->vi_capture_pdev = ndev;
|
||||
}
|
||||
|
||||
chan_drv->num_channels = max_vi_channels;
|
||||
mutex_init(&chan_drv->lock);
|
||||
|
||||
@@ -676,9 +663,7 @@ int vi_channel_drv_register(
|
||||
for (i = 0; i < chan_drv->num_channels; i++) {
|
||||
dev_t devt = MKDEV(vi_channel_major, i);
|
||||
|
||||
struct device *dev =
|
||||
(chan_drv->use_legacy_path)?chan_drv->dev :
|
||||
&chan_drv->vi_capture_pdev->dev;
|
||||
struct device *dev = &chan_drv->vi_capture_pdev->dev;
|
||||
device_create(vi_channel_class, dev, devt, NULL,
|
||||
"capture-vi-channel%u", i);
|
||||
}
|
||||
@@ -725,7 +710,8 @@ void vi_channel_drv_unregister(
|
||||
mutex_lock(&chdrv_lock);
|
||||
chan_drv = chdrv_;
|
||||
chdrv_ = NULL;
|
||||
WARN_ON(chan_drv->dev != dev);
|
||||
|
||||
WARN_ON(&chan_drv->vi_capture_pdev->dev != dev);
|
||||
mutex_unlock(&chdrv_lock);
|
||||
|
||||
for (i = 0; i < chan_drv->num_channels; i++) {
|
||||
@@ -734,7 +720,7 @@ void vi_channel_drv_unregister(
|
||||
device_destroy(vi_channel_class, devt);
|
||||
}
|
||||
|
||||
devm_kfree(chan_drv->dev, chan_drv);
|
||||
devm_kfree(&chan_drv->vi_capture_pdev->dev, chan_drv);
|
||||
}
|
||||
EXPORT_SYMBOL(vi_channel_drv_unregister);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (c) 2017-2023 NVIDIA Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
/**
|
||||
* @file drivers/media/platform/tegra/camera/fusa-capture/capture-vi.c
|
||||
*
|
||||
* @brief VI channel operations for the T186/T194 Camera RTCPU platform.
|
||||
* @brief VI channel operations for the T234 Camera RTCPU platform.
|
||||
*/
|
||||
|
||||
#include <linux/completion.h>
|
||||
@@ -448,9 +448,6 @@ int vi_capture_init(
|
||||
struct platform_device *rtc_pdev;
|
||||
struct device *dev;
|
||||
|
||||
if (chan->drv->use_legacy_path)
|
||||
dev = chan->dev;
|
||||
else
|
||||
dev = &chan->vi_capture_pdev->dev;
|
||||
|
||||
dev_dbg(dev, "%s++\n", __func__);
|
||||
@@ -595,9 +592,6 @@ int vi_capture_setup(
|
||||
uint32_t vi_inst = 0;
|
||||
struct device *dev;
|
||||
|
||||
if (chan->drv->use_legacy_path)
|
||||
dev = chan->dev;
|
||||
else
|
||||
dev = &chan->vi_capture_pdev->dev;
|
||||
|
||||
if (setup->csi_stream_id >= MAX_NVCSI_STREAM_IDS ||
|
||||
@@ -1702,7 +1696,10 @@ static int capture_vi_remove(struct platform_device *pdev)
|
||||
for (ii = 0; ii < info->num_vi_devices; ii++)
|
||||
put_device(&info->vi_pdevices[ii]->dev);
|
||||
|
||||
vi_channel_drv_unregister(&pdev->dev);
|
||||
tegra_vi_media_controller_cleanup(&info->vi_common.mc_vi);
|
||||
vi_channel_drv_exit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
/*
|
||||
<<<<<<< HEAD (246e62 video: tegra: remove icc request in system resume)
|
||||
* SPDX-FileCopyrightText: Copyright (C) 2017-2023 NVIDIA CORPORATION. All rights reserved.
|
||||
=======
|
||||
* VI5 driver
|
||||
>>>>>>> CHANGE (73a498 video: tegra: Don't use nvhost_get_private_data)
|
||||
*/
|
||||
|
||||
#include <asm/ioctls.h>
|
||||
@@ -309,24 +305,15 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
struct t194_vi5_file_private {
|
||||
struct platform_device *pdev;
|
||||
struct tegra_mc_vi mc_vi;
|
||||
unsigned int vi_bypass_bw;
|
||||
};
|
||||
|
||||
static int vi5_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
|
||||
struct host_vi5 *vi5 = pdata->private_data;
|
||||
|
||||
tegra_camera_device_unregister(vi5);
|
||||
vi_channel_drv_unregister(&pdev->dev);
|
||||
tegra_vi_media_controller_cleanup(&vi5->vi_common.mc_vi);
|
||||
|
||||
vi5_remove_debugfs(vi5);
|
||||
platform_device_put(vi5->vi_thi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2017-2022, NVIDIA Corporation. All rights reserved.
|
||||
*/
|
||||
|
||||
/* SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
|
||||
/**
|
||||
* @file include/media/fusa-capture/capture-vi-channel.h
|
||||
*
|
||||
* @brief VI channel character device driver header for the T186/T194 Camera
|
||||
* @brief VI channel character device driver header for the T234 Camera
|
||||
* RTCPU platform.
|
||||
*/
|
||||
|
||||
@@ -84,8 +81,6 @@ struct vi_channel_drv_ops {
|
||||
struct vi_channel_drv {
|
||||
struct platform_device *vi_capture_pdev;
|
||||
/**< Capture VI driver platform device */
|
||||
bool use_legacy_path;
|
||||
/**< Flag to maintain backward-compatibility for T186 */
|
||||
struct device *dev; /**< VI kernel @em device */
|
||||
struct platform_device *ndev; /**< VI kernel @em platform_device */
|
||||
struct mutex lock; /**< VI channel driver context lock */
|
||||
|
||||
Reference in New Issue
Block a user