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
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
// Copyright (c) 2017-2023 NVIDIA Corporation. All rights reserved.
|
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file drivers/media/platform/tegra/camera/fusa-capture/capture-vi-channel.c
|
* @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.
|
* platform.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -204,11 +204,7 @@ struct tegra_vi_channel *vi_channel_open_ex(
|
|||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
chan->drv = chan_drv;
|
chan->drv = chan_drv;
|
||||||
if (chan_drv->use_legacy_path) {
|
chan->vi_capture_pdev = chan_drv->vi_capture_pdev;
|
||||||
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;
|
chan->ops = chan_drv->ops;
|
||||||
|
|
||||||
@@ -390,17 +386,14 @@ static long vi_channel_ioctl(
|
|||||||
if (copy_from_user(&setup, ptr, sizeof(setup)))
|
if (copy_from_user(&setup, ptr, sizeof(setup)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (chan->drv->use_legacy_path == false) {
|
vi_get_nvhost_device(chan, &setup);
|
||||||
vi_get_nvhost_device(chan, &setup);
|
if (chan->dev == NULL) {
|
||||||
if (chan->dev == NULL) {
|
dev_err(&chan->vi_capture_pdev->dev,
|
||||||
dev_err(&chan->vi_capture_pdev->dev,
|
"%s: channel device is NULL",
|
||||||
"%s: channel device is NULL",
|
__func__);
|
||||||
__func__);
|
return -EINVAL;
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (setup.request_size < sizeof(struct capture_descriptor)) {
|
if (setup.request_size < sizeof(struct capture_descriptor)) {
|
||||||
dev_err(chan->dev,
|
dev_err(chan->dev,
|
||||||
"request size is too small to fit capture descriptor\n");
|
"request size is too small to fit capture descriptor\n");
|
||||||
@@ -650,16 +643,10 @@ int vi_channel_drv_register(
|
|||||||
if (unlikely(chan_drv == NULL))
|
if (unlikely(chan_drv == NULL))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (strstr(ndev->name, "tegra-capture-vi") == NULL) {
|
chan_drv->dev = NULL;
|
||||||
chan_drv->use_legacy_path = true;
|
chan_drv->ndev = NULL;
|
||||||
chan_drv->dev = &ndev->dev;
|
chan_drv->vi_capture_pdev = ndev;
|
||||||
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;
|
chan_drv->num_channels = max_vi_channels;
|
||||||
mutex_init(&chan_drv->lock);
|
mutex_init(&chan_drv->lock);
|
||||||
|
|
||||||
@@ -676,9 +663,7 @@ int vi_channel_drv_register(
|
|||||||
for (i = 0; i < chan_drv->num_channels; i++) {
|
for (i = 0; i < chan_drv->num_channels; i++) {
|
||||||
dev_t devt = MKDEV(vi_channel_major, i);
|
dev_t devt = MKDEV(vi_channel_major, i);
|
||||||
|
|
||||||
struct device *dev =
|
struct device *dev = &chan_drv->vi_capture_pdev->dev;
|
||||||
(chan_drv->use_legacy_path)?chan_drv->dev :
|
|
||||||
&chan_drv->vi_capture_pdev->dev;
|
|
||||||
device_create(vi_channel_class, dev, devt, NULL,
|
device_create(vi_channel_class, dev, devt, NULL,
|
||||||
"capture-vi-channel%u", i);
|
"capture-vi-channel%u", i);
|
||||||
}
|
}
|
||||||
@@ -725,7 +710,8 @@ void vi_channel_drv_unregister(
|
|||||||
mutex_lock(&chdrv_lock);
|
mutex_lock(&chdrv_lock);
|
||||||
chan_drv = chdrv_;
|
chan_drv = chdrv_;
|
||||||
chdrv_ = NULL;
|
chdrv_ = NULL;
|
||||||
WARN_ON(chan_drv->dev != dev);
|
|
||||||
|
WARN_ON(&chan_drv->vi_capture_pdev->dev != dev);
|
||||||
mutex_unlock(&chdrv_lock);
|
mutex_unlock(&chdrv_lock);
|
||||||
|
|
||||||
for (i = 0; i < chan_drv->num_channels; i++) {
|
for (i = 0; i < chan_drv->num_channels; i++) {
|
||||||
@@ -734,7 +720,7 @@ void vi_channel_drv_unregister(
|
|||||||
device_destroy(vi_channel_class, devt);
|
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);
|
EXPORT_SYMBOL(vi_channel_drv_unregister);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
// Copyright (c) 2017-2023 NVIDIA Corporation. All rights reserved.
|
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file drivers/media/platform/tegra/camera/fusa-capture/capture-vi.c
|
* @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>
|
#include <linux/completion.h>
|
||||||
@@ -448,10 +448,7 @@ int vi_capture_init(
|
|||||||
struct platform_device *rtc_pdev;
|
struct platform_device *rtc_pdev;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
if (chan->drv->use_legacy_path)
|
dev = &chan->vi_capture_pdev->dev;
|
||||||
dev = chan->dev;
|
|
||||||
else
|
|
||||||
dev = &chan->vi_capture_pdev->dev;
|
|
||||||
|
|
||||||
dev_dbg(dev, "%s++\n", __func__);
|
dev_dbg(dev, "%s++\n", __func__);
|
||||||
dn = of_find_node_by_path("tegra-camera-rtcpu");
|
dn = of_find_node_by_path("tegra-camera-rtcpu");
|
||||||
@@ -595,10 +592,7 @@ int vi_capture_setup(
|
|||||||
uint32_t vi_inst = 0;
|
uint32_t vi_inst = 0;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
if (chan->drv->use_legacy_path)
|
dev = &chan->vi_capture_pdev->dev;
|
||||||
dev = chan->dev;
|
|
||||||
else
|
|
||||||
dev = &chan->vi_capture_pdev->dev;
|
|
||||||
|
|
||||||
if (setup->csi_stream_id >= MAX_NVCSI_STREAM_IDS ||
|
if (setup->csi_stream_id >= MAX_NVCSI_STREAM_IDS ||
|
||||||
setup->virtual_channel_id >= MAX_VIRTUAL_CHANNEL_PER_STREAM) {
|
setup->virtual_channel_id >= MAX_VIRTUAL_CHANNEL_PER_STREAM) {
|
||||||
@@ -1664,7 +1658,7 @@ static int capture_vi_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
err = vi_channel_drv_register(pdev, info->max_vi_channels);
|
err = vi_channel_drv_register(pdev, info->max_vi_channels);
|
||||||
if (err) {
|
if (err) {
|
||||||
vi_channel_drv_exit();
|
vi_channel_drv_exit();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1702,7 +1696,10 @@ static int capture_vi_remove(struct platform_device *pdev)
|
|||||||
for (ii = 0; ii < info->num_vi_devices; ii++)
|
for (ii = 0; ii < info->num_vi_devices; ii++)
|
||||||
put_device(&info->vi_pdevices[ii]->dev);
|
put_device(&info->vi_pdevices[ii]->dev);
|
||||||
|
|
||||||
vi_channel_drv_exit();
|
vi_channel_drv_unregister(&pdev->dev);
|
||||||
|
tegra_vi_media_controller_cleanup(&info->vi_common.mc_vi);
|
||||||
|
vi_channel_drv_exit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
// 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
|
* VI5 driver
|
||||||
>>>>>>> CHANGE (73a498 video: tegra: Don't use nvhost_get_private_data)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <asm/ioctls.h>
|
#include <asm/ioctls.h>
|
||||||
@@ -309,24 +305,15 @@ error:
|
|||||||
return err;
|
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)
|
static int vi5_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
|
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
|
||||||
struct host_vi5 *vi5 = pdata->private_data;
|
struct host_vi5 *vi5 = pdata->private_data;
|
||||||
|
|
||||||
tegra_camera_device_unregister(vi5);
|
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);
|
vi5_remove_debugfs(vi5);
|
||||||
platform_device_put(vi5->vi_thi);
|
platform_device_put(vi5->vi_thi);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/*
|
/* SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
|
||||||
* Copyright (c) 2017-2022, NVIDIA Corporation. All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file include/media/fusa-capture/capture-vi-channel.h
|
* @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.
|
* RTCPU platform.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -84,8 +81,6 @@ struct vi_channel_drv_ops {
|
|||||||
struct vi_channel_drv {
|
struct vi_channel_drv {
|
||||||
struct platform_device *vi_capture_pdev;
|
struct platform_device *vi_capture_pdev;
|
||||||
/**< Capture VI driver platform device */
|
/**< Capture VI driver platform device */
|
||||||
bool use_legacy_path;
|
|
||||||
/**< Flag to maintain backward-compatibility for T186 */
|
|
||||||
struct device *dev; /**< VI kernel @em device */
|
struct device *dev; /**< VI kernel @em device */
|
||||||
struct platform_device *ndev; /**< VI kernel @em platform_device */
|
struct platform_device *ndev; /**< VI kernel @em platform_device */
|
||||||
struct mutex lock; /**< VI channel driver context lock */
|
struct mutex lock; /**< VI channel driver context lock */
|
||||||
|
|||||||
Reference in New Issue
Block a user