All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: codecs: Fix error handling in power domain init and exit handlers
@ 2022-03-22 16:18 ` Srinivasa Rao Mandadapu
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-03-22 16:18 UTC (permalink / raw)
  To: agross, bjorn.andersson, lgirdwood, broonie, robh+dt, quic_plai,
	bgoswami, perex, tiwai, srinivas.kandagatla, rohitkr,
	linux-arm-msm, alsa-devel, devicetree, linux-kernel, swboyd,
	judyhsiao
  Cc: Srinivasa Rao Mandadapu, Venkata Prasad Potturu

Update error handling in power domain init and exit handlers, as existing handling
may cause issues in device remove function.
Use appropriate pm core api for power domain get and sync to avoid redundant code.

Fixes: 9e3d83c52844 ("ASoC: codecs: Add power domains support in digital macro codecs")

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Co-developed-by: Venkata Prasad Potturu <quic_potturu@quicinc.com>
Signed-off-by: Venkata Prasad Potturu <quic_potturu@quicinc.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/codecs/lpass-macro-common.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/sound/soc/codecs/lpass-macro-common.c b/sound/soc/codecs/lpass-macro-common.c
index 6cede75..3c661fd 100644
--- a/sound/soc/codecs/lpass-macro-common.c
+++ b/sound/soc/codecs/lpass-macro-common.c
@@ -24,42 +24,45 @@ struct lpass_macro *lpass_macro_pds_init(struct device *dev)
 		return ERR_PTR(-ENOMEM);
 
 	l_pds->macro_pd = dev_pm_domain_attach_by_name(dev, "macro");
-	if (IS_ERR_OR_NULL(l_pds->macro_pd))
-		return NULL;
-
-	ret = pm_runtime_get_sync(l_pds->macro_pd);
-	if (ret < 0) {
-		pm_runtime_put_noidle(l_pds->macro_pd);
+	if (IS_ERR_OR_NULL(l_pds->macro_pd)) {
+		ret = PTR_ERR(l_pds->macro_pd);
 		goto macro_err;
 	}
 
+	ret = pm_runtime_resume_and_get(l_pds->macro_pd);
+	if (ret < 0)
+		goto macro_sync_err;
+
 	l_pds->dcodec_pd = dev_pm_domain_attach_by_name(dev, "dcodec");
-	if (IS_ERR_OR_NULL(l_pds->dcodec_pd))
+	if (IS_ERR_OR_NULL(l_pds->dcodec_pd)) {
+		ret = PTR_ERR(l_pds->dcodec_pd);
 		goto dcodec_err;
+	}
 
-	ret = pm_runtime_get_sync(l_pds->dcodec_pd);
-	if (ret < 0) {
-		pm_runtime_put_noidle(l_pds->dcodec_pd);
+	ret = pm_runtime_resume_and_get(l_pds->dcodec_pd);
+	if (ret < 0)
 		goto dcodec_sync_err;
-	}
 	return l_pds;
 
 dcodec_sync_err:
 	dev_pm_domain_detach(l_pds->dcodec_pd, false);
 dcodec_err:
 	pm_runtime_put(l_pds->macro_pd);
-macro_err:
+macro_sync_err:
 	dev_pm_domain_detach(l_pds->macro_pd, false);
+macro_err:
 	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(lpass_macro_pds_init);
 
 void lpass_macro_pds_exit(struct lpass_macro *pds)
 {
-	pm_runtime_put(pds->macro_pd);
-	dev_pm_domain_detach(pds->macro_pd, false);
-	pm_runtime_put(pds->dcodec_pd);
-	dev_pm_domain_detach(pds->dcodec_pd, false);
+	if (pds) {
+		pm_runtime_put(pds->macro_pd);
+		dev_pm_domain_detach(pds->macro_pd, false);
+		pm_runtime_put(pds->dcodec_pd);
+		dev_pm_domain_detach(pds->dcodec_pd, false);
+	}
 }
 EXPORT_SYMBOL_GPL(lpass_macro_pds_exit);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] ASoC: codecs: Fix error handling in power domain init and exit handlers
@ 2022-03-22 16:18 ` Srinivasa Rao Mandadapu
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-03-22 16:18 UTC (permalink / raw)
  To: agross, bjorn.andersson, lgirdwood, broonie, robh+dt, quic_plai,
	bgoswami, perex, tiwai, srinivas.kandagatla, rohitkr,
	linux-arm-msm, alsa-devel, devicetree, linux-kernel, swboyd,
	judyhsiao
  Cc: Venkata Prasad Potturu, Srinivasa Rao Mandadapu

Update error handling in power domain init and exit handlers, as existing handling
may cause issues in device remove function.
Use appropriate pm core api for power domain get and sync to avoid redundant code.

Fixes: 9e3d83c52844 ("ASoC: codecs: Add power domains support in digital macro codecs")

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Co-developed-by: Venkata Prasad Potturu <quic_potturu@quicinc.com>
Signed-off-by: Venkata Prasad Potturu <quic_potturu@quicinc.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/codecs/lpass-macro-common.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/sound/soc/codecs/lpass-macro-common.c b/sound/soc/codecs/lpass-macro-common.c
index 6cede75..3c661fd 100644
--- a/sound/soc/codecs/lpass-macro-common.c
+++ b/sound/soc/codecs/lpass-macro-common.c
@@ -24,42 +24,45 @@ struct lpass_macro *lpass_macro_pds_init(struct device *dev)
 		return ERR_PTR(-ENOMEM);
 
 	l_pds->macro_pd = dev_pm_domain_attach_by_name(dev, "macro");
-	if (IS_ERR_OR_NULL(l_pds->macro_pd))
-		return NULL;
-
-	ret = pm_runtime_get_sync(l_pds->macro_pd);
-	if (ret < 0) {
-		pm_runtime_put_noidle(l_pds->macro_pd);
+	if (IS_ERR_OR_NULL(l_pds->macro_pd)) {
+		ret = PTR_ERR(l_pds->macro_pd);
 		goto macro_err;
 	}
 
+	ret = pm_runtime_resume_and_get(l_pds->macro_pd);
+	if (ret < 0)
+		goto macro_sync_err;
+
 	l_pds->dcodec_pd = dev_pm_domain_attach_by_name(dev, "dcodec");
-	if (IS_ERR_OR_NULL(l_pds->dcodec_pd))
+	if (IS_ERR_OR_NULL(l_pds->dcodec_pd)) {
+		ret = PTR_ERR(l_pds->dcodec_pd);
 		goto dcodec_err;
+	}
 
-	ret = pm_runtime_get_sync(l_pds->dcodec_pd);
-	if (ret < 0) {
-		pm_runtime_put_noidle(l_pds->dcodec_pd);
+	ret = pm_runtime_resume_and_get(l_pds->dcodec_pd);
+	if (ret < 0)
 		goto dcodec_sync_err;
-	}
 	return l_pds;
 
 dcodec_sync_err:
 	dev_pm_domain_detach(l_pds->dcodec_pd, false);
 dcodec_err:
 	pm_runtime_put(l_pds->macro_pd);
-macro_err:
+macro_sync_err:
 	dev_pm_domain_detach(l_pds->macro_pd, false);
+macro_err:
 	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(lpass_macro_pds_init);
 
 void lpass_macro_pds_exit(struct lpass_macro *pds)
 {
-	pm_runtime_put(pds->macro_pd);
-	dev_pm_domain_detach(pds->macro_pd, false);
-	pm_runtime_put(pds->dcodec_pd);
-	dev_pm_domain_detach(pds->dcodec_pd, false);
+	if (pds) {
+		pm_runtime_put(pds->macro_pd);
+		dev_pm_domain_detach(pds->macro_pd, false);
+		pm_runtime_put(pds->dcodec_pd);
+		dev_pm_domain_detach(pds->dcodec_pd, false);
+	}
 }
 EXPORT_SYMBOL_GPL(lpass_macro_pds_exit);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: codecs: Fix error handling in power domain init and exit handlers
  2022-03-22 16:18 ` Srinivasa Rao Mandadapu
  (?)
@ 2022-04-05  9:30 ` Mark Brown
  -1 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-04-05  9:30 UTC (permalink / raw)
  To: quic_plai, srinivas.kandagatla, agross, judyhsiao, linux-kernel,
	lgirdwood, quic_srivasam, robh+dt, swboyd, tiwai,
	bjorn.andersson, alsa-devel, perex, linux-arm-msm, devicetree
  Cc: quic_potturu

On Tue, 22 Mar 2022 21:48:57 +0530, Srinivasa Rao Mandadapu wrote:
> Update error handling in power domain init and exit handlers, as existing handling
> may cause issues in device remove function.
> Use appropriate pm core api for power domain get and sync to avoid redundant code.
> 
> Fixes: 9e3d83c52844 ("ASoC: codecs: Add power domains support in digital macro codecs")
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: codecs: Fix error handling in power domain init and exit handlers
      commit: 1a8ee4cf84187bce17c76886eb6dd9389c3b99a8

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: codecs: Fix error handling in power domain init and exit handlers
@ 2022-03-23  4:07 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-03-23  4:07 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 5864 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <1647965937-32203-1-git-send-email-quic_srivasam@quicinc.com>
References: <1647965937-32203-1-git-send-email-quic_srivasam@quicinc.com>
TO: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
TO: agross(a)kernel.org
TO: bjorn.andersson(a)linaro.org
TO: lgirdwood(a)gmail.com
TO: broonie(a)kernel.org
TO: robh+dt(a)kernel.org
TO: quic_plai(a)quicinc.com
TO: bgoswami(a)codeaurora.org
TO: perex(a)perex.cz
TO: tiwai(a)suse.com
TO: srinivas.kandagatla(a)linaro.org
TO: rohitkr(a)codeaurora.org
TO: linux-arm-msm(a)vger.kernel.org
TO: alsa-devel(a)alsa-project.org
TO: devicetree(a)vger.kernel.org
TO: linux-kernel(a)vger.kernel.org
TO: swboyd(a)chromium.org
TO: judyhsiao(a)chromium.org
CC: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
CC: Venkata Prasad Potturu <quic_potturu@quicinc.com>

Hi Srinivasa,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on next-20220322]
[cannot apply to v5.17]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Srinivasa-Rao-Mandadapu/ASoC-codecs-Fix-error-handling-in-power-domain-init-and-exit-handlers/20220323-001954
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
config: i386-randconfig-m021-20220321 (https://download.01.org/0day-ci/archive/20220323/202203231218.XywussKw-lkp(a)intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
sound/soc/codecs/lpass-macro-common.c:28 lpass_macro_pds_init() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
sound/soc/codecs/lpass-macro-common.c:38 lpass_macro_pds_init() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +28 sound/soc/codecs/lpass-macro-common.c

9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  13  
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  14  struct lpass_macro *lpass_macro_pds_init(struct device *dev)
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  15  {
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  16  	struct lpass_macro *l_pds;
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  17  	int ret;
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  18  
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  19  	if (!of_find_property(dev->of_node, "power-domains", NULL))
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  20  		return NULL;
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  21  
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  22  	l_pds = devm_kzalloc(dev, sizeof(*l_pds), GFP_KERNEL);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  23  	if (!l_pds)
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  24  		return ERR_PTR(-ENOMEM);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  25  
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  26  	l_pds->macro_pd = dev_pm_domain_attach_by_name(dev, "macro");
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  27  	if (IS_ERR_OR_NULL(l_pds->macro_pd)) {
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22 @28  		ret = PTR_ERR(l_pds->macro_pd);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  29  		goto macro_err;
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  30  	}
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  31  
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  32  	ret = pm_runtime_resume_and_get(l_pds->macro_pd);
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  33  	if (ret < 0)
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  34  		goto macro_sync_err;
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  35  
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  36  	l_pds->dcodec_pd = dev_pm_domain_attach_by_name(dev, "dcodec");
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  37  	if (IS_ERR_OR_NULL(l_pds->dcodec_pd)) {
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  38  		ret = PTR_ERR(l_pds->dcodec_pd);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  39  		goto dcodec_err;
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  40  	}
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  41  
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  42  	ret = pm_runtime_resume_and_get(l_pds->dcodec_pd);
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  43  	if (ret < 0)
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  44  		goto dcodec_sync_err;
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  45  	return l_pds;
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  46  
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  47  dcodec_sync_err:
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  48  	dev_pm_domain_detach(l_pds->dcodec_pd, false);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  49  dcodec_err:
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  50  	pm_runtime_put(l_pds->macro_pd);
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  51  macro_sync_err:
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  52  	dev_pm_domain_detach(l_pds->macro_pd, false);
3761a4daab359c Srinivasa Rao Mandadapu 2022-03-22  53  macro_err:
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  54  	return ERR_PTR(ret);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  55  }
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  56  EXPORT_SYMBOL_GPL(lpass_macro_pds_init);
9e3d83c52844f9 Srinivasa Rao Mandadapu 2022-02-26  57  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-05 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 16:18 [PATCH] ASoC: codecs: Fix error handling in power domain init and exit handlers Srinivasa Rao Mandadapu
2022-03-22 16:18 ` Srinivasa Rao Mandadapu
2022-04-05  9:30 ` Mark Brown
2022-03-23  4:07 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.