camera:kmd replace WARN/WARN_ON usage

Replace use of WARN or WARN_ON kernel with dev_warn to improve logging
behavior. This change ensures that error conditions are reported with
clear informative messages rather than kernel stack traces that can
flood logs.

Additional information:
- The files `drivers/platform/tegra/rtcpu/debug.c` and
  `drivers/platform/tegra/rtcpu/hsp-combo.c` present in the original
  codebase were deleted as part of unrelated refactoring in the
  target repository; hence, changes related to these files in the
  patch were not applied.
- Additional changes are done to replace WARN_ON at other places.

Bug 4719119

Change-Id: Id12f1b4de77f8b007b557de140257a3bd7478b52
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/3308911
Signed-off-by: Mohit Ingale <mohiti@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3352892
Reviewed-by: Jagadeesh Kinni <jkinni@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Vincent Chung <vincentc@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
This commit is contained in:
Mohit Ingale
2025-05-01 03:58:41 +00:00
committed by Jon Hunter
parent 15b054f417
commit a8bff2c6e5
10 changed files with 168 additions and 103 deletions

View File

@@ -298,7 +298,7 @@ init_err:
* It performs the following operations: * It performs the following operations:
* - Calls @ref isp_capture_shutdown() to shut down the ISP capture process. * - Calls @ref isp_capture_shutdown() to shut down the ISP capture process.
* - Acquires the channel driver's lock by invoking @ref mutex_lock(). * - Acquires the channel driver's lock by invoking @ref mutex_lock().
* - Verifies that the channel being released matches the registered channel using @ref WARN_ON(). * - Verifies that the channel being released matches the registered channel.
* - Removes the channel from the driver's channel array by setting the corresponding entry to NULL. * - Removes the channel from the driver's channel array by setting the corresponding entry to NULL.
* - Releases the channel driver's lock by calling @ref mutex_unlock(). * - Releases the channel driver's lock by calling @ref mutex_unlock().
* - Frees the memory allocated for the channel using @ref kfree(). * - Frees the memory allocated for the channel using @ref kfree().
@@ -322,7 +322,9 @@ static int isp_channel_release(
mutex_lock(&chan_drv->lock); mutex_lock(&chan_drv->lock);
WARN_ON(chan_drv->channels[channel] != chan); if (chan_drv->channels[channel] != chan)
dev_warn(chan_drv->dev, "%s: dev does not match!\n", __func__);
chan_drv->channels[channel] = NULL; chan_drv->channels[channel] = NULL;
mutex_unlock(&chan_drv->lock); mutex_unlock(&chan_drv->lock);
@@ -611,7 +613,7 @@ static int isp_channel_major = -1;
* device TO @a ndev and the maximum number of channels to @a max_isp_channels. * device TO @a ndev and the maximum number of channels to @a max_isp_channels.
* - Initializes the driver mutex lock using @ref mutex_init(). * - Initializes the driver mutex lock using @ref mutex_init().
* - Acquires the global channel driver lock by invoking @ref mutex_lock(). * - Acquires the global channel driver lock by invoking @ref mutex_lock().
* - Checks if a channel driver is already registered using @ref WARN_ON(). * - Checks if a channel driver is already registered.
* If a driver is already registered, it releases the lock and frees the allocated * If a driver is already registered, it releases the lock and frees the allocated
* memory with @ref kfree(). * memory with @ref kfree().
* - Sets the global channel driver reference to the newly allocated driver and * - Sets the global channel driver reference to the newly allocated driver and
@@ -629,8 +631,7 @@ static int isp_channel_major = -1;
* @retval 0 Successfully registered and initialized the ISP channel driver. * @retval 0 Successfully registered and initialized the ISP channel driver.
* @retval -ENOMEM If memory allocation for the driver structure fails, * @retval -ENOMEM If memory allocation for the driver structure fails,
* as indicated by @ref kzalloc(). * as indicated by @ref kzalloc().
* @retval -EBUSY If an ISP channel driver is already registered, detected via * @retval -EBUSY If an ISP channel driver is already registered.
* @ref WARN_ON().
* @retval -EINVAL If the ISP channel major number is invalid, as checked before * @retval -EINVAL If the ISP channel major number is invalid, as checked before
* device creation. * device creation.
*/ */
@@ -653,7 +654,8 @@ int isp_channel_drv_register(
mutex_init(&chan_drv->lock); mutex_init(&chan_drv->lock);
mutex_lock(&chdrv_lock); mutex_lock(&chdrv_lock);
if (WARN_ON(chdrv_ != NULL)) { if (chdrv_ != NULL) {
dev_warn(chan_drv->dev, "%s: dev is busy\n", __func__);
mutex_unlock(&chdrv_lock); mutex_unlock(&chdrv_lock);
kfree(chan_drv); kfree(chan_drv);
return -EBUSY; return -EBUSY;
@@ -731,7 +733,7 @@ EXPORT_SYMBOL(isp_channel_drv_fops_register);
* - Acquires the global channel driver lock using @ref mutex_lock(). * - Acquires the global channel driver lock using @ref mutex_lock().
* - Retrieves the current ISP channel driver instance from the global reference. * - Retrieves the current ISP channel driver instance from the global reference.
* - Clears the global channel driver reference to indicate that it is no longer registered. * - Clears the global channel driver reference to indicate that it is no longer registered.
* - Validates that the provided device matches the driver's device using @ref WARN_ON(). * - Validates that the provided device matches the driver's device.
* - Releases the global channel driver lock using @ref mutex_unlock(). * - Releases the global channel driver lock using @ref mutex_unlock().
* - Checks if the ISP channel major number is valid. If invalid, logs an error using * - Checks if the ISP channel major number is valid. If invalid, logs an error using
* @ref pr_err() and exits. * @ref pr_err() and exits.
@@ -751,7 +753,10 @@ void isp_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);
if (chan_drv->dev != dev)
dev_warn(chan_drv->dev, "%s: dev does not match\n", __func__);
mutex_unlock(&chdrv_lock); mutex_unlock(&chdrv_lock);
if (isp_channel_major < 0) { if (isp_channel_major < 0) {

View File

@@ -2148,7 +2148,7 @@ int isp_capture_release(
if (err < 0) { if (err < 0) {
dev_err(chan->isp_dev, dev_err(chan->isp_dev,
"%s: release channel IVC failed\n", __func__); "%s: release channel IVC failed\n", __func__);
WARN_ON("RTCPU is in a bad state. Reboot to recover"); pr_warn("RTCPU is in a bad state. Reboot to recover");
tegra_camrtc_reboot(capture->rtcpu_dev); tegra_camrtc_reboot(capture->rtcpu_dev);
@@ -3482,7 +3482,7 @@ static int capture_isp_probe(struct platform_device *pdev)
of_node_put(node); of_node_put(node);
if (ispdev == NULL) { if (ispdev == NULL) {
dev_WARN(dev, "isp node %u has no device\n", i); dev_warn(dev, "isp node %u has no device\n", i);
err = -ENODEV; err = -ENODEV;
goto cleanup; goto cleanup;
} }

View File

@@ -324,7 +324,9 @@ int vi_channel_close_ex(
mutex_lock(&chan_drv->lock); mutex_lock(&chan_drv->lock);
WARN_ON(rcu_access_pointer(chan_drv->channels[channel]) != chan); if (rcu_access_pointer(chan_drv->channels[channel]) != chan)
dev_warn(chan_drv->dev, "%s: dev does not match\n", __func__);
RCU_INIT_POINTER(chan_drv->channels[channel], NULL); RCU_INIT_POINTER(chan_drv->channels[channel], NULL);
mutex_unlock(&chan_drv->lock); mutex_unlock(&chan_drv->lock);
@@ -894,7 +896,7 @@ int vi_channel_drv_register(
mutex_lock(&chdrv_lock); mutex_lock(&chdrv_lock);
if (chdrv_ != NULL) { if (chdrv_ != NULL) {
mutex_unlock(&chdrv_lock); mutex_unlock(&chdrv_lock);
WARN_ON(1); dev_warn(chdrv_->dev, "%s: chdrv is busy\n", __func__);
err = -EBUSY; err = -EBUSY;
goto error; goto error;
} }
@@ -985,8 +987,8 @@ void vi_channel_drv_unregister(
mutex_lock(&chdrv_lock); mutex_lock(&chdrv_lock);
chan_drv = chdrv_; chan_drv = chdrv_;
chdrv_ = NULL; chdrv_ = NULL;
if (chan_drv->dev != dev)
WARN_ON(&chan_drv->vi_capture_pdev->dev != dev); dev_warn(chan_drv->dev, "%s: dev does not match\n", __func__);
mutex_unlock(&chdrv_lock); mutex_unlock(&chdrv_lock);
if (vi_channel_major < 0) { if (vi_channel_major < 0) {

View File

@@ -928,16 +928,16 @@ int vi_capture_setup(
dev_dbg(chan->dev, "vi unit id %u\n", vi_inst); dev_dbg(chan->dev, "vi unit id %u\n", vi_inst);
dev_dbg(chan->dev, "vi2 chan mask %llx\n", setup->vi2_channel_mask); dev_dbg(chan->dev, "vi2 chan mask %llx\n", setup->vi2_channel_mask);
if (WARN_ON(vi_inst == VI_UNIT_VI && if ((vi_inst == VI_UNIT_VI &&
setup->vi_channel_mask == CAPTURE_CHANNEL_INVALID_MASK) || setup->vi_channel_mask == CAPTURE_CHANNEL_INVALID_MASK) ||
WARN_ON(vi_inst == VI_UNIT_VI2 && (vi_inst == VI_UNIT_VI2 &&
setup->vi2_channel_mask == CAPTURE_CHANNEL_INVALID_MASK) || setup->vi2_channel_mask == CAPTURE_CHANNEL_INVALID_MASK) ||
WARN_ON(setup->channel_flags == 0) || setup->channel_flags == 0 ||
WARN_ON(setup->queue_depth == 0) || setup->queue_depth == 0 ||
WARN_ON(setup->request_size == 0) || setup->request_size == 0 ||
WARN_ON(setup->csi_stream_id == NVCSI_STREAM_INVALID_ID)) { setup->csi_stream_id == NVCSI_STREAM_INVALID_ID) {
dev_err(chan->dev, "%s: invalid setup parameters\n", __func__); dev_warn(chan->dev, "%s: invalid setup parameters\n", __func__);
return -EINVAL; return -EINVAL;
} }
@@ -978,7 +978,8 @@ int vi_capture_setup(
goto memoryinfo_alloc_fail; goto memoryinfo_alloc_fail;
} }
WARN_ON(capture->unpins_list != NULL); if (capture->unpins_list != NULL)
dev_warn(chan->dev, "%s: unpins_list is not NULL\n", __func__);
capture->unpins_list = capture->unpins_list =
vzalloc(setup->queue_depth * sizeof(*capture->unpins_list)); vzalloc(setup->queue_depth * sizeof(*capture->unpins_list));
@@ -1288,10 +1289,8 @@ int vi_capture_release(
err = vi_capture_ivc_send_control(chan, &control_desc, err = vi_capture_ivc_send_control(chan, &control_desc,
sizeof(control_desc), CAPTURE_CHANNEL_RELEASE_RESP); sizeof(control_desc), CAPTURE_CHANNEL_RELEASE_RESP);
if (err < 0) { if (err < 0) {
dev_err(chan->dev, dev_warn(chan->dev,
"%s: release channel IVC failed\n", __func__); "%s: release channel IVC failed, reboot RTCPU to recover\n", __func__);
WARN_ON("RTCPU is in a bad state. Reboot to recover");
tegra_camrtc_reboot(chan->rtcpu_dev); tegra_camrtc_reboot(chan->rtcpu_dev);
err = -EIO; err = -EIO;
@@ -2327,7 +2326,7 @@ static int capture_vi_probe(struct platform_device *pdev)
of_node_put(np); of_node_put(np);
if (pvidev == NULL) { if (pvidev == NULL) {
dev_WARN(dev, "vi node %d has no device\n", ii); dev_warn(dev, "vi node %d has no device\n", ii);
err = -ENODEV; err = -ENODEV;
goto cleanup; goto cleanup;
} }

View File

@@ -206,8 +206,10 @@ static ssize_t tegra_camchar_read(struct file *fp, char __user *buffer, size_t l
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
ssize_t ret; ssize_t ret;
if (WARN_ON(!ch->is_ready)) if (!ch->is_ready) {
dev_warn(&ch->dev, "%s: dev is not ready!\n", __func__);
return -EIO; return -EIO;
}
len = min_t(size_t, len, ch->ivc.frame_size); len = min_t(size_t, len, ch->ivc.frame_size);
if (len == 0) if (len == 0)
@@ -246,7 +248,7 @@ static ssize_t tegra_camchar_read(struct file *fp, char __user *buffer, size_t l
* - Obtains the device-specific data by calling * - Obtains the device-specific data by calling
* @ref tegra_ivc_channel_get_drvdata(). * @ref tegra_ivc_channel_get_drvdata().
* - Defines a wait queue using @ref DEFINE_WAIT(). * - Defines a wait queue using @ref DEFINE_WAIT().
* - Checks if the channel is ready using @ref WARN_ON(). * - Checks if the channel is ready.
* - Limits the write length to the minimum of the requested length and the * - Limits the write length to the minimum of the requested length and the
* channel's frame size using @ref min_t(). * channel's frame size using @ref min_t().
* - If the adjusted length is zero, returns 0 indicating no data to write. * - If the adjusted length is zero, returns 0 indicating no data to write.
@@ -277,8 +279,7 @@ static ssize_t tegra_camchar_read(struct file *fp, char __user *buffer, size_t l
* @param[in, out] offset File position offset. * @param[in, out] offset File position offset.
* Valid Value: non-NULL. * Valid Value: non-NULL.
* *
* @retval -EIO If the channel is not ready, as determined by * @retval -EIO If the channel is not ready.
* @ref WARN_ON().
* @retval 0 If the adjusted write length is zero. * @retval 0 If the adjusted write length is zero.
* @retval -EINTR If the write operation was interrupted by a signal, * @retval -EINTR If the write operation was interrupted by a signal,
* as determined by @ref mutex_lock_interruptible() * as determined by @ref mutex_lock_interruptible()
@@ -298,8 +299,10 @@ static ssize_t tegra_camchar_write(struct file *fp, const char __user *buffer,
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
ssize_t ret; ssize_t ret;
if (WARN_ON(!ch->is_ready)) if (!ch->is_ready) {
dev_warn(&ch->dev, "%s: dev is not ready!\n", __func__);
return -EIO; return -EIO;
}
len = min_t(size_t, len, ch->ivc.frame_size); len = min_t(size_t, len, ch->ivc.frame_size);
if (len == 0) if (len == 0)

View File

@@ -54,8 +54,11 @@ static int tegra_capture_ivc_tx_(struct tegra_capture_ivc *civc,
int ret; int ret;
chan = civc->chan; chan = civc->chan;
if (chan == NULL || WARN_ON(!chan->is_ready)) if (chan == NULL || !chan->is_ready) {
if (chan != NULL)
dev_warn(&chan->dev, "%s: dev is not ready!\n", __func__);
return -EIO; return -EIO;
}
ret = mutex_lock_interruptible(&civc->ivc_wr_lock); ret = mutex_lock_interruptible(&civc->ivc_wr_lock);
if (unlikely(ret == -EINTR)) if (unlikely(ret == -EINTR))
@@ -143,8 +146,10 @@ static int tegra_capture_ivc_tx(struct tegra_capture_ivc *civc,
*/ */
int tegra_capture_ivc_control_submit(const void *control_desc, size_t len) int tegra_capture_ivc_control_submit(const void *control_desc, size_t len)
{ {
if (WARN_ON(__scivc_control == NULL)) if (__scivc_control == NULL) {
pr_warn("%s: __scivc_control is NULL!\n", __func__);
return -ENODEV; return -ENODEV;
}
return tegra_capture_ivc_tx(__scivc_control, control_desc, len); return tegra_capture_ivc_tx(__scivc_control, control_desc, len);
} }
@@ -167,8 +172,10 @@ EXPORT_SYMBOL(tegra_capture_ivc_control_submit);
*/ */
int tegra_capture_ivc_capture_submit(const void *capture_desc, size_t len) int tegra_capture_ivc_capture_submit(const void *capture_desc, size_t len)
{ {
if (WARN_ON(__scivc_capture == NULL)) if (__scivc_capture == NULL) {
pr_warn("%s: __scivc_capture is NULL!\n", __func__);
return -ENODEV; return -ENODEV;
}
return tegra_capture_ivc_tx(__scivc_capture, capture_desc, len); return tegra_capture_ivc_tx(__scivc_capture, capture_desc, len);
} }
@@ -218,12 +225,20 @@ int tegra_capture_ivc_register_control_cb(
int ret; int ret;
/* Check if inputs are valid */ /* Check if inputs are valid */
if (WARN(control_resp_cb == NULL, "callback function is NULL")) if (control_resp_cb == NULL) {
pr_warn("%s: callback function is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
if (WARN(trans_id == NULL, "return value trans_id is NULL")) }
if (trans_id == NULL) {
pr_warn("%s: return value trans_id is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
if (WARN_ON(!__scivc_control)) }
if (!__scivc_control) {
pr_warn("%s: invalid __scivc_control\n", __func__);
return -ENODEV; return -ENODEV;
}
civc = __scivc_control; civc = __scivc_control;
@@ -247,16 +262,16 @@ int tegra_capture_ivc_register_control_cb(
ctx_id = cb_ctx - &civc->cb_ctx[0]; ctx_id = cb_ctx - &civc->cb_ctx[0];
if (WARN(ctx_id < TRANS_ID_START_IDX || if (ctx_id < TRANS_ID_START_IDX ||
ctx_id >= ARRAY_SIZE(civc->cb_ctx), ctx_id >= ARRAY_SIZE(civc->cb_ctx)) {
"invalid cb_ctx %zu", ctx_id)) {
ret = -EIO; ret = -EIO;
goto fail; goto fail;
} }
mutex_lock(&civc->cb_ctx_lock); mutex_lock(&civc->cb_ctx_lock);
if (WARN(cb_ctx->cb_func != NULL, "cb_ctx is busy")) { if (cb_ctx->cb_func != NULL) {
pr_warn("%s: cb_ctx is not NULL\n", __func__);
ret = -EIO; ret = -EIO;
goto locked_fail; goto locked_fail;
} }
@@ -312,13 +327,21 @@ int tegra_capture_ivc_notify_chan_id(uint32_t chan_id, uint32_t trans_id)
{ {
struct tegra_capture_ivc *civc; struct tegra_capture_ivc *civc;
if (WARN(chan_id >= NUM_CAPTURE_CHANNELS, "invalid chan_id")) if (chan_id >= NUM_CAPTURE_CHANNELS) {
pr_warn("%s: invalid chan_id\n", __func__);
return -EINVAL; return -EINVAL;
if (WARN(trans_id < TRANS_ID_START_IDX || }
trans_id >= TOTAL_CHANNELS, "invalid trans_id"))
if (trans_id < TRANS_ID_START_IDX ||
trans_id >= TOTAL_CHANNELS) {
pr_warn("%s: invalid trans_id\n", __func__);
return -EINVAL; return -EINVAL;
if (WARN_ON(!__scivc_control)) }
if (!__scivc_control) {
pr_warn("%s: invalid __scivc_control\n", __func__);
return -ENODEV; return -ENODEV;
}
chan_id = array_index_nospec(chan_id, NUM_CAPTURE_CHANNELS); chan_id = array_index_nospec(chan_id, NUM_CAPTURE_CHANNELS);
trans_id = array_index_nospec(trans_id, TOTAL_CHANNELS); trans_id = array_index_nospec(trans_id, TOTAL_CHANNELS);
@@ -327,14 +350,14 @@ int tegra_capture_ivc_notify_chan_id(uint32_t chan_id, uint32_t trans_id)
mutex_lock(&civc->cb_ctx_lock); mutex_lock(&civc->cb_ctx_lock);
if (WARN(civc->cb_ctx[trans_id].cb_func == NULL, if (civc->cb_ctx[trans_id].cb_func == NULL) {
"transaction context at %u is idle", trans_id)) { pr_warn("%s: transaction context at %u is idle\n", __func__, trans_id);
mutex_unlock(&civc->cb_ctx_lock); mutex_unlock(&civc->cb_ctx_lock);
return -EBADF; return -EBADF;
} }
if (WARN(civc->cb_ctx[chan_id].cb_func != NULL, if (civc->cb_ctx[chan_id].cb_func != NULL) {
"channel context at %u is busy", chan_id)) { pr_warn("%s: channel context at %u is busy\n", __func__, chan_id);
mutex_unlock(&civc->cb_ctx_lock); mutex_unlock(&civc->cb_ctx_lock);
return -EBUSY; return -EBUSY;
} }
@@ -393,12 +416,15 @@ int tegra_capture_ivc_register_capture_cb(
struct tegra_capture_ivc *civc; struct tegra_capture_ivc *civc;
int ret; int ret;
if (WARN(capture_status_ind_cb == NULL, "callback function is NULL")) if (capture_status_ind_cb == NULL) {
pr_warn("%s: callback function is NULL\n", __func__);
return -EINVAL; return -EINVAL;
}
if (WARN(chan_id >= NUM_CAPTURE_CHANNELS, if (chan_id >= NUM_CAPTURE_CHANNELS) {
"invalid channel id %u", chan_id)) pr_warn("%s: invalid channel id %u\n", __func__, chan_id);
return -EINVAL; return -EINVAL;
}
chan_id = array_index_nospec(chan_id, NUM_CAPTURE_CHANNELS); chan_id = array_index_nospec(chan_id, NUM_CAPTURE_CHANNELS);
if (!__scivc_capture) if (!__scivc_capture)
@@ -412,8 +438,8 @@ int tegra_capture_ivc_register_capture_cb(
mutex_lock(&civc->cb_ctx_lock); mutex_lock(&civc->cb_ctx_lock);
if (WARN(civc->cb_ctx[chan_id].cb_func != NULL, if (civc->cb_ctx[chan_id].cb_func != NULL) {
"capture channel %u is busy", chan_id)) { pr_warn("%s: capture channel %u is busy\n", __func__, chan_id);
ret = -EBUSY; ret = -EBUSY;
goto fail; goto fail;
} }
@@ -460,10 +486,14 @@ int tegra_capture_ivc_unregister_control_cb(uint32_t id)
struct tegra_capture_ivc *civc; struct tegra_capture_ivc *civc;
/* id could be temporary trans_id or rtcpu-allocated chan_id */ /* id could be temporary trans_id or rtcpu-allocated chan_id */
if (WARN(id >= TOTAL_CHANNELS, "invalid id %u", id)) if (id >= TOTAL_CHANNELS) {
pr_warn("%s: invalid id %u\n", __func__, id);
return -EINVAL; return -EINVAL;
if (WARN_ON(!__scivc_control)) }
if (!__scivc_control) {
pr_warn("%s: __scivc_control is not exist!\n", __func__);
return -ENODEV; return -ENODEV;
}
id = array_index_nospec(id, TOTAL_CHANNELS); id = array_index_nospec(id, TOTAL_CHANNELS);
@@ -471,8 +501,8 @@ int tegra_capture_ivc_unregister_control_cb(uint32_t id)
mutex_lock(&civc->cb_ctx_lock); mutex_lock(&civc->cb_ctx_lock);
if (WARN(civc->cb_ctx[id].cb_func == NULL, if (civc->cb_ctx[id].cb_func == NULL) {
"control channel %u is idle", id)) { pr_warn("%s: control channel %u is idle\n", __func__, id);
mutex_unlock(&civc->cb_ctx_lock); mutex_unlock(&civc->cb_ctx_lock);
return -EBADF; return -EBADF;
} }
@@ -535,8 +565,8 @@ int tegra_capture_ivc_unregister_capture_cb(uint32_t chan_id)
mutex_lock(&civc->cb_ctx_lock); mutex_lock(&civc->cb_ctx_lock);
if (WARN(civc->cb_ctx[chan_id].cb_func == NULL, if (civc->cb_ctx[chan_id].cb_func == NULL) {
"capture channel %u is idle", chan_id)) { pr_warn("%s: capture channel %u is idle\n", __func__, chan_id);
mutex_unlock(&civc->cb_ctx_lock); mutex_unlock(&civc->cb_ctx_lock);
return -EBADF; return -EBADF;
} }
@@ -632,7 +662,7 @@ static inline void tegra_capture_ivc_recv(struct tegra_capture_ivc *civc)
id = array_index_nospec(id, TOTAL_CHANNELS); id = array_index_nospec(id, TOTAL_CHANNELS);
tegra_capture_ivc_recv_msg(civc, id, msg); tegra_capture_ivc_recv_msg(civc, id, msg);
} else { } else {
dev_WARN(dev, "Invalid rtcpu channel id %u", id); dev_warn(dev, "Invalid rtcpu channel id %u", id);
} }
tegra_ivc_read_advance(ivc); tegra_ivc_read_advance(ivc);
@@ -646,7 +676,7 @@ static inline void tegra_capture_ivc_recv(struct tegra_capture_ivc *civc)
* - Retrieves the capture IVC context from the work structure using @ref container_of() * - Retrieves the capture IVC context from the work structure using @ref container_of()
* - Acquires a runtime PM reference to prevent suspended operation using * - Acquires a runtime PM reference to prevent suspended operation using
* @ref pm_runtime_get_if_in_use() * @ref pm_runtime_get_if_in_use()
* - If channel is not ready, logs a warning using @ref WARN_ON() * - If channel is not ready, logs a warning.
* - Verifies that the channel is ready using @ref chan->is_ready * - Verifies that the channel is ready using @ref chan->is_ready
* - Calls @ref tegra_capture_ivc_recv() to process all pending messages * - Calls @ref tegra_capture_ivc_recv() to process all pending messages
* - Releases the runtime PM reference using @ref pm_runtime_put() * - Releases the runtime PM reference using @ref pm_runtime_put()
@@ -668,7 +698,9 @@ static void tegra_capture_ivc_worker(struct kthread_work *work)
* notify when RCE resumes and IVC bus gets set up. * notify when RCE resumes and IVC bus gets set up.
*/ */
if (pm_runtime_get_if_in_use(&chan->dev) > 0) { if (pm_runtime_get_if_in_use(&chan->dev) > 0) {
WARN_ON(!chan->is_ready); if (!chan->is_ready) {
dev_warn(&chan->dev, "channel not ready\n");
}
tegra_capture_ivc_recv(civc); tegra_capture_ivc_recv(civc);
@@ -726,10 +758,10 @@ static void tegra_capture_ivc_notify(struct tegra_ivc_channel *chan)
* - Unlocks the callback context lock using @ref mutex_unlock() * - Unlocks the callback context lock using @ref mutex_unlock()
* - Associates the context with the IVC channel using @ref tegra_ivc_channel_set_drvdata() * - Associates the context with the IVC channel using @ref tegra_ivc_channel_set_drvdata()
* - Checks if the service type is "capture-control" using @ref strcmp() * - Checks if the service type is "capture-control" using @ref strcmp()
* - Verifies that no control channel already exists using @ref WARN_ON() * - Verifies that no control channel already exists
* - Registers the context as a control service by setting @ref __scivc_control * - Registers the context as a control service by setting @ref __scivc_control
* - If not control, checks if service type is "capture" using @ref strcmp() * - If not control, checks if service type is "capture" using @ref strcmp()
* - Verifies that no capture channel already exists using @ref WARN_ON() * - Verifies that no capture channel already exists
* - Registers the context as a capture service by setting @ref __scivc_capture * - Registers the context as a capture service by setting @ref __scivc_capture
* - Returns error if service type is neither control nor capture * - Returns error if service type is neither control nor capture
* - Stops the worker thread using @ref kthread_stop() if an error occurs * - Stops the worker thread using @ref kthread_stop() if an error occurs
@@ -798,13 +830,15 @@ static int tegra_capture_ivc_probe(struct tegra_ivc_channel *chan)
tegra_ivc_channel_set_drvdata(chan, civc); tegra_ivc_channel_set_drvdata(chan, civc);
if (!strcmp("capture-control", service)) { if (!strcmp("capture-control", service)) {
if (WARN_ON(__scivc_control != NULL)) { if (__scivc_control != NULL) {
dev_warn(&chan->dev, "%s: __scivc_control already exists!\n", __func__);
ret = -EEXIST; ret = -EEXIST;
goto err_service; goto err_service;
} }
__scivc_control = civc; __scivc_control = civc;
} else if (!strcmp("capture", service)) { } else if (!strcmp("capture", service)) {
if (WARN_ON(__scivc_capture != NULL)) { if (__scivc_capture != NULL) {
dev_warn(&chan->dev, "%s: __scivc_capture already exists!\n", __func__);
ret = -EEXIST; ret = -EEXIST;
goto err_service; goto err_service;
} }

View File

@@ -174,7 +174,7 @@ static int camrtc_hsp_sendrecv(struct camrtc_hsp *camhsp,
* It processes the received message and performs the appropriate action: * It processes the received message and performs the appropriate action:
* - Retrieves the HSP context using @ref dev_get_drvdata() * - Retrieves the HSP context using @ref dev_get_drvdata()
* - Extracts status and group information from the message * - Extracts status and group information from the message
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context
* - Handles unknown messages using @ref dev_dbg() * - Handles unknown messages using @ref dev_dbg()
* - Calls the group notification callback if a group notification is received * - Calls the group notification callback if a group notification is received
* - For response messages, sets the response and wakes up waiters using @ref atomic_set() and @ref wake_up() * - For response messages, sets the response and wakes up waiters using @ref atomic_set() and @ref wake_up()
@@ -194,8 +194,10 @@ static void camrtc_hsp_rx_full_notify(mbox_client *cl, void *data)
status >>= CAMRTC_HSP_SS_FW_SHIFT; status >>= CAMRTC_HSP_SS_FW_SHIFT;
group = status & CAMRTC_HSP_SS_IVC_MASK; group = status & CAMRTC_HSP_SS_IVC_MASK;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
dev_warn(cl->dev, "%s: camhsp is NULL!\n", __func__);
return; return;
}
if (CAMRTC_HSP_MSG_ID(msg) == CAMRTC_HSP_UNKNOWN) if (CAMRTC_HSP_MSG_ID(msg) == CAMRTC_HSP_UNKNOWN)
dev_dbg(&camhsp->dev, "request message unknown 0x%08x\n", msg); dev_dbg(&camhsp->dev, "request message unknown 0x%08x\n", msg);
@@ -392,7 +394,7 @@ static int camrtc_hsp_vm_sendrecv(struct camrtc_hsp *camhsp,
* *
* This function reads and processes boot log messages from the RTCPU during * This function reads and processes boot log messages from the RTCPU during
* the initialization process. It performs the following operations: * the initialization process. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Uses @ref camrtc_hsp_recv() to wait for and receive boot log messages * - Uses @ref camrtc_hsp_recv() to wait for and receive boot log messages
* - Processes different types of boot messages (complete, stage, error) * - Processes different types of boot messages (complete, stage, error)
* - Logs messages at appropriate log levels using @ref dev_info(), @ref dev_dbg(), and @ref dev_err() * - Logs messages at appropriate log levels using @ref dev_info(), @ref dev_dbg(), and @ref dev_err()
@@ -409,8 +411,10 @@ static int camrtc_hsp_vm_read_boot_log(struct camrtc_hsp *camhsp)
uint32_t boot_log; uint32_t boot_log;
long msg_timeout; long msg_timeout;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
msg_timeout = camhsp->timeout; msg_timeout = camhsp->timeout;
@@ -839,7 +843,7 @@ fail:
* *
* This function rings a group doorbell by calling the group_ring operation * This function rings a group doorbell by calling the group_ring operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Calls the group_ring operation on the HSP context using @ref group_ring() * - Calls the group_ring operation on the HSP context using @ref group_ring()
* *
* @param[in] camhsp Pointer to the camera HSP context * @param[in] camhsp Pointer to the camera HSP context
@@ -850,7 +854,9 @@ fail:
void camrtc_hsp_group_ring(struct camrtc_hsp *camhsp, void camrtc_hsp_group_ring(struct camrtc_hsp *camhsp,
u16 group) u16 group)
{ {
if (!WARN_ON(camhsp == NULL)) if (camhsp == NULL)
pr_warn("%s: camhsp is NULL!\n", __func__);
else
camhsp->op->group_ring(camhsp, group); camhsp->op->group_ring(camhsp, group);
} }
EXPORT_SYMBOL(camrtc_hsp_group_ring); EXPORT_SYMBOL(camrtc_hsp_group_ring);
@@ -860,7 +866,7 @@ EXPORT_SYMBOL(camrtc_hsp_group_ring);
* *
* This function synchronizes the HSP by calling the sync operation * This function synchronizes the HSP by calling the sync operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the sync operation on the HSP context using @ref sync() * - Calls the sync operation on the HSP context using @ref sync()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -876,8 +882,10 @@ int camrtc_hsp_sync(struct camrtc_hsp *camhsp)
long timeout; long timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
timeout = camhsp->timeout; timeout = camhsp->timeout;
mutex_lock(&camhsp->mutex); mutex_lock(&camhsp->mutex);
@@ -893,7 +901,7 @@ EXPORT_SYMBOL(camrtc_hsp_sync);
* *
* This function resumes the HSP by calling the resume operation * This function resumes the HSP by calling the resume operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the resume operation on the HSP context using @ref resume() * - Calls the resume operation on the HSP context using @ref resume()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -909,8 +917,10 @@ int camrtc_hsp_resume(struct camrtc_hsp *camhsp)
long timeout; long timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
timeout = camhsp->timeout; timeout = camhsp->timeout;
mutex_lock(&camhsp->mutex); mutex_lock(&camhsp->mutex);
@@ -926,7 +936,7 @@ EXPORT_SYMBOL(camrtc_hsp_resume);
* *
* This function suspends the HSP by calling the suspend operation * This function suspends the HSP by calling the suspend operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the suspend operation on the HSP context using @ref suspend() * - Calls the suspend operation on the HSP context using @ref suspend()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -943,8 +953,10 @@ int camrtc_hsp_suspend(struct camrtc_hsp *camhsp)
long timeout; long timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
timeout = camhsp->timeout; timeout = camhsp->timeout;
mutex_lock(&camhsp->mutex); mutex_lock(&camhsp->mutex);
@@ -964,7 +976,7 @@ EXPORT_SYMBOL(camrtc_hsp_suspend);
* *
* This function sets the operating point for the HSP by calling the set_operating_point * This function sets the operating point for the HSP by calling the set_operating_point
* operation on the HSP context. It performs the following operations: * operation on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the set_operating_point operation on the HSP context using @ref set_operating_point() * - Calls the set_operating_point operation on the HSP context using @ref set_operating_point()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -983,8 +995,10 @@ int camrtc_hsp_set_operating_point(struct camrtc_hsp *camhsp, uint32_t operating
long timeout; long timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
timeout = camhsp->timeout; timeout = camhsp->timeout;
mutex_lock(&camhsp->mutex); mutex_lock(&camhsp->mutex);
@@ -1004,7 +1018,7 @@ EXPORT_SYMBOL(camrtc_hsp_set_operating_point);
* *
* This function sends a BYE message to the HSP by calling the bye operation * This function sends a BYE message to the HSP by calling the bye operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the bye operation on the HSP context using @ref bye() * - Calls the bye operation on the HSP context using @ref bye()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -1020,8 +1034,10 @@ int camrtc_hsp_bye(struct camrtc_hsp *camhsp)
long timeout; long timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
timeout = camhsp->timeout; timeout = camhsp->timeout;
mutex_lock(&camhsp->mutex); mutex_lock(&camhsp->mutex);
@@ -1040,7 +1056,7 @@ EXPORT_SYMBOL(camrtc_hsp_bye);
* *
* This function sets up the HSP channel by calling the ch_setup operation * This function sets up the HSP channel by calling the ch_setup operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the ch_setup operation on the HSP context using @ref ch_setup() * - Calls the ch_setup operation on the HSP context using @ref ch_setup()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -1058,8 +1074,10 @@ int camrtc_hsp_ch_setup(struct camrtc_hsp *camhsp, dma_addr_t iova)
long timeout; long timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
pr_warn("%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
if (iova >= BIT_ULL(32) || (iova & 0xffU) != 0) { if (iova >= BIT_ULL(32) || (iova & 0xffU) != 0) {
dev_warn(&camhsp->dev, dev_warn(&camhsp->dev,
@@ -1084,7 +1102,7 @@ EXPORT_SYMBOL(camrtc_hsp_ch_setup);
* *
* This function pings the HSP by calling the ping operation * This function pings the HSP by calling the ping operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the ping operation on the HSP context using @ref ping() * - Calls the ping operation on the HSP context using @ref ping()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -1104,8 +1122,10 @@ int camrtc_hsp_ping(struct camrtc_hsp *camhsp, u32 data, long timeout)
long left = timeout; long left = timeout;
int response; int response;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
dev_warn(&camhsp->dev, "%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
if (left == 0L) if (left == 0L)
left = camhsp->timeout; left = camhsp->timeout;
@@ -1123,7 +1143,7 @@ EXPORT_SYMBOL(camrtc_hsp_ping);
* *
* This function gets the firmware hash for the HSP by calling the get_fw_hash operation * This function gets the firmware hash for the HSP by calling the get_fw_hash operation
* on the HSP context. It performs the following operations: * on the HSP context. It performs the following operations:
* - Validates the HSP context using @ref WARN_ON() * - Validates the HSP context is non-NULL
* - Locks the mutex using @ref mutex_lock() * - Locks the mutex using @ref mutex_lock()
* - Calls the get_fw_hash operation on the HSP context using @ref get_fw_hash() * - Calls the get_fw_hash operation on the HSP context using @ref get_fw_hash()
* - Unlocks the mutex using @ref mutex_unlock() * - Unlocks the mutex using @ref mutex_unlock()
@@ -1147,8 +1167,10 @@ int camrtc_hsp_get_fw_hash(struct camrtc_hsp *camhsp,
int ret = 0; int ret = 0;
long timeout; long timeout;
if (WARN_ON(camhsp == NULL)) if (camhsp == NULL) {
dev_warn(&camhsp->dev, "%s: camhsp is NULL!\n", __func__);
return -EINVAL; return -EINVAL;
}
memset(hash, 0, hash_size); memset(hash, 0, hash_size);
timeout = camhsp->timeout; timeout = camhsp->timeout;

View File

@@ -706,7 +706,8 @@ static void tegra_ivc_bus_remove(struct device *dev)
struct tegra_ivc_channel *chan = to_tegra_ivc_channel(dev); struct tegra_ivc_channel *chan = to_tegra_ivc_channel(dev);
const struct tegra_ivc_channel_ops *ops = drv->ops.channel; const struct tegra_ivc_channel_ops *ops = drv->ops.channel;
WARN_ON(rcu_access_pointer(chan->ops) != ops); if (rcu_access_pointer(chan->ops) != ops)
dev_warn(dev, "dev ops does not match!\n");
RCU_INIT_POINTER(chan->ops, NULL); RCU_INIT_POINTER(chan->ops, NULL);
synchronize_rcu(); synchronize_rcu();

View File

@@ -1247,8 +1247,10 @@ static int camrtc_test_run_and_show_result(struct seq_file *file,
const char *nul; const char *nul;
(void)__builtin_usubl_overflow(resp_size, data_offset, &result_size); (void)__builtin_usubl_overflow(resp_size, data_offset, &result_size);
if (WARN_ON(test_case_size > camrtc_dbgfs_get_max_test_size(ch))) if (test_case_size > camrtc_dbgfs_get_max_test_size(ch)) {
dev_warn(&ch->dev, "%s: test_case_size > camrtc_dbgfs_get_max_test_size(ch)\n", __func__);
test_case_size = camrtc_dbgfs_get_max_test_size(ch); test_case_size = camrtc_dbgfs_get_max_test_size(ch);
}
memcpy((char *)req + data_offset, test_case, test_case_size); memcpy((char *)req + data_offset, test_case, test_case_size);
@@ -1633,7 +1635,9 @@ static int camrtc_run_mem_test(struct seq_file *file,
continue; continue;
testmem = &resp->data.run_mem_test_data.mem[i]; testmem = &resp->data.run_mem_test_data.mem[i];
if (!WARN_ON(testmem->size > mem->size)) if (testmem->size > mem->size)
dev_warn(mem_dev, "%s: testmem->size > mem->size\n", __func__);
else
mem->used = testmem->size; mem->used = testmem->size;
if (_camdbg_rmem.enabled) { if (_camdbg_rmem.enabled) {

View File

@@ -488,7 +488,6 @@ static inline void rtcpu_trace_exceptions(struct tegra_rtcpu_trace *tracer)
return; return;
if (new_next >= tracer->exception_entries) { if (new_next >= tracer->exception_entries) {
WARN_ON_ONCE(new_next >= tracer->exception_entries);
dev_warn_ratelimited(tracer->dev, dev_warn_ratelimited(tracer->dev,
"exception entry %u outside range 0..%u\n", "exception entry %u outside range 0..%u\n",
new_next, tracer->exception_entries - 1); new_next, tracer->exception_entries - 1);
@@ -1837,7 +1836,6 @@ static inline void rtcpu_trace_events(struct tegra_rtcpu_trace *tracer)
struct camrtc_event_struct *event, *last_event; struct camrtc_event_struct *event, *last_event;
if (new_next >= tracer->event_entries) { if (new_next >= tracer->event_entries) {
WARN_ON_ONCE(new_next >= tracer->event_entries);
dev_warn_ratelimited(tracer->dev, dev_warn_ratelimited(tracer->dev,
"trace entry %u outside range 0..%u\n", "trace entry %u outside range 0..%u\n",
new_next, tracer->event_entries - 1); new_next, tracer->event_entries - 1);
@@ -1985,12 +1983,9 @@ static int32_t raw_trace_read_impl(
int64_t mul_value = 0; int64_t mul_value = 0;
if (new_next >= tracer->event_entries) { if (new_next >= tracer->event_entries) {
WARN_ON_ONCE(new_next >= tracer->event_entries); dev_warn_ratelimited(tracer->dev,
dev_warn_ratelimited(
tracer->dev,
"trace entry %u outside range 0..%u\n", "trace entry %u outside range 0..%u\n",
new_next, new_next, tracer->event_entries - 1);
tracer->event_entries - 1);
return -EIO; return -EIO;
} }