From 4a686896100a5016b5a6bf2a5b298e8a35f9bb95 Mon Sep 17 00:00:00 2001 From: spatki Date: Wed, 30 Jul 2025 12:05:03 +0000 Subject: [PATCH] tsec: add support for s2idle state TSEC from t26x onwards is booted by PSC. Since s2idle PSC never resets tsec, there is no need to handle streamid programming form KMD side. Moreover this change also fixes a bug wherein tsec KMD would poweroff the clocks of TSEC in suspend case. Bug 5407465 Change-Id: Idb648e2f0e7226bb779bd1a801796fa28c415419 Signed-off-by: spatki Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3420250 Reviewed-by: Mayuresh Kulkarni Reviewed-by: Bharat Nihalani Reviewed-by: svcacv GVS: buildbot_gerritrpt --- drivers/video/tegra/tsec/tsec.c | 19 ++++++++++++++++++- drivers/video/tegra/tsec/tsec_linux.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/video/tegra/tsec/tsec.c b/drivers/video/tegra/tsec/tsec.c index c104a901..488370c9 100644 --- a/drivers/video/tegra/tsec/tsec.c +++ b/drivers/video/tegra/tsec/tsec.c @@ -338,7 +338,18 @@ int tsec_poweroff(struct device *dev) static int tsec_module_suspend(struct device *dev) { - return tsec_poweroff(dev); + struct tsec_device_data *pdata = dev_get_drvdata(dev); + + switch (pdata->soc) { + case TSEC_ON_T26x: + /* + * If TSEC is on T26x, we don't need to power off TSEC. + */ + return 0; + default: + return tsec_poweroff(dev); + } + } static int tsec_module_resume(struct device *dev) @@ -346,6 +357,12 @@ static int tsec_module_resume(struct device *dev) struct tsec_device_data *pdata = dev_get_drvdata(dev); switch (pdata->soc) { case TSEC_ON_T26x: + /* + * If the system resumed from suspend to idle, we don't need to resume TSEC. + * This is because TSEC is already powered on and running. + */ + if (pm_suspend_target_state == PM_SUSPEND_TO_IDLE) + return 0; return tsec_t264_init(to_platform_device(dev)); default: return tsec_poweron(dev); diff --git a/drivers/video/tegra/tsec/tsec_linux.h b/drivers/video/tegra/tsec/tsec_linux.h index 6e6abdb4..f2056e2e 100644 --- a/drivers/video/tegra/tsec/tsec_linux.h +++ b/drivers/video/tegra/tsec/tsec_linux.h @@ -34,5 +34,6 @@ #endif #include /* for SZ_* size macros */ #include /* for BIT(x) macro */ +#include /* for suspend APIs */ #endif /* TSEC_LINUX_H */