From 0081a6e97c11d862507584c9e708d721d68ae3c1 Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Fri, 21 Jul 2017 17:23:18 +0530 Subject: [PATCH] platform: nvadsp: dfs: add os status checks Add checks for adsp os running state in adsp_override_freq() and update_freq(). If adsp os is not running state then communication with ADSP for freq update will not work. This could result in failure in updating ADSP CPU frequency. Bug 200295526 Bug 200322504 Change-Id: Iea25f542b080ac22faf562f35e82ceede43bbc83 Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/1526340 (cherry picked from commit 2aea120c7c1385e14f36e5fa707594e3ab6e2294) Reviewed-on: https://git-master.nvidia.com/r/1527565 Reviewed-on: https://git-master.nvidia.com/r/1537337 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit --- drivers/platform/tegra/nvadsp/adsp_dfs.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/platform/tegra/nvadsp/adsp_dfs.c b/drivers/platform/tegra/nvadsp/adsp_dfs.c index c97f598a..9e3974ce 100644 --- a/drivers/platform/tegra/nvadsp/adsp_dfs.c +++ b/drivers/platform/tegra/nvadsp/adsp_dfs.c @@ -115,8 +115,14 @@ static DEFINE_MUTEX(policy_mutex); static bool is_os_running(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct nvadsp_drv_data *drv_data = platform_get_drvdata(pdev); + struct platform_device *pdev; + struct nvadsp_drv_data *drv_data; + + if (!dev) + return false; + + pdev = to_platform_device(dev); + drv_data = platform_get_drvdata(pdev); if (!drv_data->adsp_os_running) { dev_dbg(&pdev->dev, "%s: adsp os is not loaded\n", __func__); @@ -324,9 +330,14 @@ static unsigned long update_freq(unsigned long freq_khz) int index; int ret; + if (!is_os_running(device)) { + dev_err(device, "adsp os is not running\n"); + return 0; + } + tfreq_hz = adsp_get_target_freq(freq_khz * 1000, &index); if (!tfreq_hz) { - dev_info(device, "unable get the target freq\n"); + dev_err(device, "unable get the target freq\n"); return 0; } @@ -714,6 +725,11 @@ unsigned long adsp_override_freq(unsigned long req_freq_khz) unsigned long ret_freq = 0, freq; int index; + if (!is_os_running(device)) { + pr_err("%s: adsp os is not in running state.\n", __func__); + return 0; + } + mutex_lock(&policy_mutex); freq = req_freq_khz;