mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-23 09:42:19 +03:00
tegra: nvadsp: disable suspend when adsp usage log
Prevents adsp os from getting suspended when adsp_usage is being logged Checks whether usage app is running and skips suspend accordingly Bug 1727014 Change-Id: Iafd800d3d18d6292bee5d3376cec59dbb4557f2e Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com> Reviewed-on: http://git-master/r/1142669 (cherry picked from commit 04660b149f1455f1e5e77f75aeb652a9dceae55f) Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1564184 Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Nitin Pai <npai@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Laxman Dewangan
parent
f9f361c265
commit
d593fa42f0
@@ -41,10 +41,9 @@ enum adsp_lpthread_mbx_cmd {
|
|||||||
struct adsp_lpthread {
|
struct adsp_lpthread {
|
||||||
bool lpthread_initialized;
|
bool lpthread_initialized;
|
||||||
bool adsp_os_suspended;
|
bool adsp_os_suspended;
|
||||||
bool lpthread_to_be_paused;
|
bool lpthread_paused;
|
||||||
bool lpthread_to_be_resumed;
|
bool lpthread_resumed;
|
||||||
bool lpthread_to_be_closed;
|
bool lpthread_closed;
|
||||||
bool lpthread_init_and_closed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct adsp_lpthread lpthread_obj;
|
static struct adsp_lpthread lpthread_obj;
|
||||||
@@ -101,6 +100,7 @@ int adsp_lpthread_init(bool is_adsp_suspended)
|
|||||||
int adsp_lpthread_resume(void)
|
int adsp_lpthread_resume(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
||||||
pr_info("ADSP_LPTHREAD_RESUME()\n");
|
pr_info("ADSP_LPTHREAD_RESUME()\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -113,6 +113,7 @@ int adsp_lpthread_resume(void)
|
|||||||
int adsp_lpthread_pause(void)
|
int adsp_lpthread_pause(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
||||||
pr_info("ADSP_LPTHREAD_PAUSE()\n");
|
pr_info("ADSP_LPTHREAD_PAUSE()\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -125,6 +126,7 @@ int adsp_lpthread_pause(void)
|
|||||||
int adsp_lpthread_exit(void)
|
int adsp_lpthread_exit(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
||||||
pr_info("ADSP_LPTHREAD_EXIT()\n");
|
pr_info("ADSP_LPTHREAD_EXIT()\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -140,84 +142,54 @@ static int adsp_usage_set(void *data, u64 val)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 1:
|
case 1:
|
||||||
|
if (lpthread->lpthread_initialized && lpthread->lpthread_resumed) {
|
||||||
|
pr_info("App already running\n");
|
||||||
|
pr_info("echo 2 > adsp_usage to pause\n");
|
||||||
|
pr_info("echo 0 > adsp_usage to stop\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (lpthread->adsp_os_suspended && !lpthread->lpthread_initialized) {
|
if (lpthread->adsp_os_suspended && !lpthread->lpthread_initialized) {
|
||||||
if (lpthread->lpthread_init_and_closed) {
|
pr_info("Starting ADSP OS\n");
|
||||||
lpthread->lpthread_init_and_closed = false;
|
|
||||||
lpthread->lpthread_initialized = true;
|
|
||||||
lpthread->lpthread_to_be_resumed = true;
|
|
||||||
pr_info("App already initialized\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
|
||||||
pr_info("Starting os\n");
|
|
||||||
#endif
|
|
||||||
if (nvadsp_os_start()) {
|
if (nvadsp_os_start()) {
|
||||||
pr_info("Unable to restart os\n");
|
pr_info("Unable to start OS\n");
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = adsp_lpthread_init(true);
|
|
||||||
lpthread->lpthread_initialized = true;
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
|
||||||
pr_info("Initialized lpthread. Suspending OS\n");
|
|
||||||
#endif
|
|
||||||
if (nvadsp_os_suspend()) {
|
|
||||||
pr_info("Unable to restart os\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lpthread->lpthread_to_be_resumed = true;
|
|
||||||
} else if (!lpthread->lpthread_initialized) {
|
|
||||||
if (lpthread->lpthread_init_and_closed) {
|
|
||||||
lpthread->lpthread_init_and_closed = false;
|
|
||||||
lpthread->lpthread_initialized = true;
|
|
||||||
lpthread->lpthread_to_be_resumed = true;
|
|
||||||
pr_info("App already initialized\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
lpthread->adsp_os_suspended = false;
|
||||||
ret = adsp_lpthread_init(lpthread->adsp_os_suspended);
|
ret = adsp_lpthread_init(lpthread->adsp_os_suspended);
|
||||||
|
pr_info("Initializing lpthread\n");
|
||||||
|
lpthread->lpthread_initialized = true;
|
||||||
|
} else if (!lpthread->lpthread_initialized) {
|
||||||
|
ret = adsp_lpthread_init(lpthread->adsp_os_suspended);
|
||||||
|
pr_info("Initializing lpthread\n");
|
||||||
lpthread->lpthread_initialized = true;
|
lpthread->lpthread_initialized = true;
|
||||||
} else if (lpthread->adsp_os_suspended) {
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
|
||||||
pr_info("App to be resumed\n");
|
|
||||||
#endif
|
|
||||||
lpthread->lpthread_to_be_resumed = true;
|
|
||||||
lpthread->lpthread_to_be_paused = false;
|
|
||||||
ret = 0;
|
|
||||||
} else {
|
} else {
|
||||||
ret = adsp_lpthread_resume();
|
ret = adsp_lpthread_resume();
|
||||||
|
pr_info("Resuming lpthread\n");
|
||||||
}
|
}
|
||||||
|
lpthread->lpthread_resumed = true;
|
||||||
|
lpthread->lpthread_paused = false;
|
||||||
|
lpthread->lpthread_closed = false;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (lpthread->adsp_os_suspended && lpthread->lpthread_initialized) {
|
if (!lpthread->lpthread_initialized) {
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
|
||||||
pr_info("App to be paused\n");
|
|
||||||
#endif
|
|
||||||
lpthread->lpthread_to_be_resumed = false;
|
|
||||||
lpthread->lpthread_to_be_paused = true;
|
|
||||||
ret = 0;
|
|
||||||
} else if (lpthread->lpthread_initialized) {
|
|
||||||
ret = adsp_lpthread_pause();
|
|
||||||
} else {
|
|
||||||
pr_info("App not initialized. echo 1 > adsp_usage to init\n");
|
pr_info("App not initialized. echo 1 > adsp_usage to init\n");
|
||||||
ret = 0;
|
break;
|
||||||
}
|
}
|
||||||
|
ret = adsp_lpthread_pause();
|
||||||
|
lpthread->lpthread_resumed = false;
|
||||||
|
lpthread->lpthread_paused = true;
|
||||||
|
lpthread->lpthread_closed = false;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
if (lpthread->adsp_os_suspended && lpthread->lpthread_initialized) {
|
if (!lpthread->lpthread_initialized) {
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
|
||||||
pr_info("App to be closed\n");
|
|
||||||
#endif
|
|
||||||
lpthread->lpthread_to_be_closed = true;
|
|
||||||
lpthread->lpthread_init_and_closed = true;
|
|
||||||
lpthread->lpthread_initialized = false;
|
|
||||||
lpthread->lpthread_to_be_resumed = false;
|
|
||||||
ret = 0;
|
|
||||||
} else if (lpthread->lpthread_initialized) {
|
|
||||||
ret = adsp_lpthread_exit();
|
|
||||||
lpthread->lpthread_initialized = false;
|
|
||||||
} else {
|
|
||||||
pr_info("App not initialized. echo 1 > adsp_usage to init\n");
|
pr_info("App not initialized. echo 1 > adsp_usage to init\n");
|
||||||
ret = 0;
|
break;
|
||||||
}
|
}
|
||||||
|
ret = adsp_lpthread_exit();
|
||||||
|
lpthread->lpthread_resumed = false;
|
||||||
|
lpthread->lpthread_paused = false;
|
||||||
|
lpthread->lpthread_closed = true;
|
||||||
|
lpthread->lpthread_initialized = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_info("Invalid input\n");
|
pr_info("Invalid input\n");
|
||||||
@@ -231,7 +203,12 @@ static int adsp_usage_set(void *data, u64 val)
|
|||||||
|
|
||||||
static int adsp_usage_get(void *data, u64 *val)
|
static int adsp_usage_get(void *data, u64 *val)
|
||||||
{
|
{
|
||||||
return 0;
|
if (lpthread->lpthread_initialized && lpthread->lpthread_resumed)
|
||||||
|
return 1;
|
||||||
|
else if (lpthread->lpthread_initialized && lpthread->lpthread_paused)
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_SIMPLE_ATTRIBUTE(adsp_usage_fops, adsp_usage_get, adsp_usage_set, "%llu\n");
|
DEFINE_SIMPLE_ATTRIBUTE(adsp_usage_fops, adsp_usage_get, adsp_usage_set, "%llu\n");
|
||||||
@@ -293,35 +270,10 @@ int adsp_lpthread_debugfs_set_suspend(bool is_suspended)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int adsp_lpthread_debugfs_callback(void)
|
int adsp_lpthread_get_state(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
if (lpthread->lpthread_initialized && lpthread->lpthread_resumed)
|
||||||
|
return 1;
|
||||||
if (lpthread->lpthread_initialized) {
|
else
|
||||||
if (lpthread->lpthread_to_be_resumed) {
|
return 0;
|
||||||
lpthread->lpthread_to_be_resumed = false;
|
|
||||||
ret = adsp_lpthread_resume();
|
|
||||||
} else if (lpthread->lpthread_to_be_paused) {
|
|
||||||
lpthread->lpthread_to_be_paused = false;
|
|
||||||
ret = adsp_lpthread_pause();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lpthread->lpthread_to_be_closed) {
|
|
||||||
lpthread->lpthread_to_be_closed = false;
|
|
||||||
lpthread->lpthread_init_and_closed = false;
|
|
||||||
ret = adsp_lpthread_exit();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef VERBOSE_OUTPUT_LPTHREAD
|
|
||||||
pr_info("to_be_paused = %d\n", (int)lpthread->lpthread_to_be_paused);
|
|
||||||
pr_info("to_be_resumed = %d\n", (int)lpthread->lpthread_to_be_resumed);
|
|
||||||
pr_info("to_be_closed = %d\n", (int)lpthread->lpthread_to_be_closed);
|
|
||||||
pr_info("init_and_closed = %d\n", (int)lpthread->lpthread_init_and_closed);
|
|
||||||
pr_info("initialized = %d\n", (int)lpthread->lpthread_initialized);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,11 +279,11 @@ int adsp_lpthread_init(bool is_adsp_suspended);
|
|||||||
int adsp_lpthread_resume(void);
|
int adsp_lpthread_resume(void);
|
||||||
int adsp_lpthread_pause(void);
|
int adsp_lpthread_pause(void);
|
||||||
int adsp_lpthread_exit(void);
|
int adsp_lpthread_exit(void);
|
||||||
|
int adsp_lpthread_get_state(void);
|
||||||
|
|
||||||
int adsp_lpthread_debugfs_init(struct platform_device *pdev);
|
int adsp_lpthread_debugfs_init(struct platform_device *pdev);
|
||||||
int adsp_lpthread_debugfs_exit(struct platform_device *pdev);
|
int adsp_lpthread_debugfs_exit(struct platform_device *pdev);
|
||||||
int adsp_lpthread_debugfs_set_suspend(bool is_suspended);
|
int adsp_lpthread_debugfs_set_suspend(bool is_suspended);
|
||||||
int adsp_lpthread_debugfs_callback(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __TEGRA_NVADSP_DEV_H */
|
#endif /* __TEGRA_NVADSP_DEV_H */
|
||||||
|
|||||||
@@ -1507,7 +1507,6 @@ int nvadsp_os_start(void)
|
|||||||
|
|
||||||
#ifdef CONFIG_TEGRA_ADSP_LPTHREAD
|
#ifdef CONFIG_TEGRA_ADSP_LPTHREAD
|
||||||
adsp_lpthread_debugfs_set_suspend(drv_data->adsp_os_suspended);
|
adsp_lpthread_debugfs_set_suspend(drv_data->adsp_os_suspended);
|
||||||
adsp_lpthread_debugfs_callback();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
@@ -1685,6 +1684,14 @@ int nvadsp_os_suspend(void)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_TEGRA_ADSP_LPTHREAD
|
||||||
|
if (adsp_lpthread_get_state()) {
|
||||||
|
dev_err(&priv.pdev->dev, "Adsp usage being calculated. Not suspending adsp\n");
|
||||||
|
ret = 0;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
drv_data = platform_get_drvdata(priv.pdev);
|
drv_data = platform_get_drvdata(priv.pdev);
|
||||||
|
|
||||||
mutex_lock(&priv.os_run_lock);
|
mutex_lock(&priv.os_run_lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user