From 0b4dd54af468cc6a74f042c6ea93a2f4c9864a4e Mon Sep 17 00:00:00 2001 From: Uday Gupta Date: Sun, 12 Sep 2021 16:45:19 +0530 Subject: nvadsp: Add more error logs and fix crash - Change adds more error logs in case of APP init failure. - Also potentially fixes the crash issue Bug 3374437 Bug 3498407 Change-Id: If6baf6e2e11250815cff4a6b8a2abe553e893e34 Signed-off-by: Uday Gupta Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2593021 (cherry picked from commit b051fae2faffafbffed99b94914bbd9bc370240f) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2658565 Reviewed-by: Dipesh Gandhi Reviewed-by: Phoenix Jung GVS: Gerrit_Virtual_Submit --- drivers/platform/tegra/nvadsp/adsp_lpthread.c | 4 ++-- drivers/platform/tegra/nvadsp/adspff.c | 4 ++-- drivers/platform/tegra/nvadsp/app.c | 15 +++++++++++---- drivers/platform/tegra/nvadsp/mailbox.c | 8 ++++++-- sound/soc/tegra-virt-alt/tegra210_adsp_virt_alt.c | 12 ++++++++++-- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/platform/tegra/nvadsp/adsp_lpthread.c b/drivers/platform/tegra/nvadsp/adsp_lpthread.c index 8a827a298..e42ad7684 100644 --- a/drivers/platform/tegra/nvadsp/adsp_lpthread.c +++ b/drivers/platform/tegra/nvadsp/adsp_lpthread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -69,7 +69,7 @@ int adsp_lpthread_init(bool is_adsp_suspended) return -1; app_info = nvadsp_app_init(handle, NULL); - if (!app_info) { + if (IS_ERR_OR_NULL(app_info)) { pr_err("unable to init app adsp_lpthread\n"); return -1; } diff --git a/drivers/platform/tegra/nvadsp/adspff.c b/drivers/platform/tegra/nvadsp/adspff.c index fc1ec5baf..64597c2a8 100644 --- a/drivers/platform/tegra/nvadsp/adspff.c +++ b/drivers/platform/tegra/nvadsp/adspff.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -650,7 +650,7 @@ int adspff_init(struct platform_device *pdev) return -1; app_info = nvadsp_app_init(handle, NULL); - if (!app_info) { + if (IS_ERR_OR_NULL(app_info)) { pr_err("unable to init app adspff\n"); return -1; } diff --git a/drivers/platform/tegra/nvadsp/app.c b/drivers/platform/tegra/nvadsp/app.c index 6fafdb80a..582ce14b5 100644 --- a/drivers/platform/tegra/nvadsp/app.c +++ b/drivers/platform/tegra/nvadsp/app.c @@ -3,7 +3,7 @@ * * ADSP OS App management * - * Copyright (C) 2014-2018, NVIDIA Corporation. All rights reserved. + * Copyright (C) 2014-2022, NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -625,15 +625,21 @@ nvadsp_app_info_t __must_check *nvadsp_app_init(nvadsp_app_handle_t handle, drv_data = platform_get_drvdata(priv.pdev); - if (!drv_data->adsp_os_running) + if (!drv_data->adsp_os_running) { + pr_err("ADSP is not running\n"); goto err; + } - if (IS_ERR_OR_NULL(handle)) + if (IS_ERR_OR_NULL(handle)) { + pr_err("ADSP APP handle is NULL\n"); goto err; + } message = kzalloc(sizeof(*message), GFP_KERNEL); - if (!message) + if (!message) { + pr_err("Failed to allocate memory for ADSP msg\n"); goto err; + } shared_mem = drv_data->shared_adsp_os_data; msg_pool = &shared_mem->app_shared_msg_pool; @@ -642,6 +648,7 @@ nvadsp_app_info_t __must_check *nvadsp_app_init(nvadsp_app_handle_t handle, app = create_app_instance(handle, args, &data->app_init, NULL, 0); if (IS_ERR_OR_NULL(app)) { + pr_err("Failed to create APP instance\n"); kfree(message); goto err; } diff --git a/drivers/platform/tegra/nvadsp/mailbox.c b/drivers/platform/tegra/nvadsp/mailbox.c index 3b197a6e1..94afbd43e 100644 --- a/drivers/platform/tegra/nvadsp/mailbox.c +++ b/drivers/platform/tegra/nvadsp/mailbox.c @@ -1,7 +1,7 @@ /* * ADSP mailbox manager * - * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2022, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -219,11 +219,13 @@ status_t nvadsp_mbox_send(struct nvadsp_mbox *mbox, uint32_t data, int ret = 0; if (!nvadsp_drv_data) { + pr_err("ADSP drv_data is NULL\n"); ret = -ENOSYS; goto out; } if (!mbox) { + pr_err("ADSP MBOX is NULL\n"); ret = -EINVAL; goto out; } @@ -239,9 +241,11 @@ status_t nvadsp_mbox_send(struct nvadsp_mbox *mbox, uint32_t data, &nvadsp_drv_data->hwmbox_send_queue.comp, msecs_to_jiffies(timeout)); if (ret) { + pr_warn("ADSP HWMBOX send retry\n"); block = false; goto retry; } else { + pr_err("ADSP wait for completion timed out\n"); ret = -ETIME; goto out; } @@ -250,7 +254,7 @@ status_t nvadsp_mbox_send(struct nvadsp_mbox *mbox, uint32_t data, data, ret); } } else if (ret) { - pr_debug("Failed to enqueue data 0x%x. ret: %d\n", data, ret); + pr_warn("Failed to enqueue data 0x%x. ret: %d\n", data, ret); goto out; } out: diff --git a/sound/soc/tegra-virt-alt/tegra210_adsp_virt_alt.c b/sound/soc/tegra-virt-alt/tegra210_adsp_virt_alt.c index eda9176a3..560cbf55b 100644 --- a/sound/soc/tegra-virt-alt/tegra210_adsp_virt_alt.c +++ b/sound/soc/tegra-virt-alt/tegra210_adsp_virt_alt.c @@ -2,7 +2,7 @@ * tegra210_adsp_virt_alt.c - Tegra ADSP audio driver * * Author: Sumit Bhattacharya - * Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2022, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -622,6 +622,12 @@ static int tegra210_adsp_send_connect_msg(struct tegra210_adsp_app *src, { apm_msg_t apm_msg; + if ((src == NULL) || (dst == NULL)) { + pr_err("%s: SRC = %p or DST = %p is NULL\n", + __func__, src, dst); + return -1; + } + apm_msg.msgq_msg.size = MSGQ_MSG_WSIZE(apm_fx_connect_params_t); apm_msg.msg.call_params.size = sizeof(apm_fx_connect_params_t); apm_msg.msg.call_params.method = nvfx_apm_method_fx_connect; @@ -3195,8 +3201,10 @@ static int tegra210_adsp_mux_put(struct snd_kcontrol *kcontrol, uint32_t cur_val = 0; int ret = 0; - if (!adsp->init_done) + if (!adsp->init_done) { + dev_err(adsp->dev, "%s ADSP not initialized\n", __func__); return -ENODEV; + } if (e->reg >= TEGRA210_ADSP_VIRT_REG_MAX) return -EINVAL; -- cgit v1.2.2