All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure
@ 2017-08-22 11:15 Subhransu S. Prusty
  2017-08-22 11:15 ` [PATCH 1/4] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure Subhransu S. Prusty
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Subhransu S. Prusty @ 2017-08-22 11:15 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, patches.audio, broonie, Subhransu S. Prusty, lgirdwood

Some resources are not freed for ipc and dsp init failures. This results in
random failures in a stress test environment. So fixed to free the required
resources and also fixed the DSP core reference counting for firmware load
failure.

Subhransu S. Prusty (4):
  ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure
  ASoC: Intel: Skylake: Fix to free resources for dsp_init failure
  ASoC: Intel: Skylake: Fix to free correct dev id in free_irq
  ASoC: Intel: Skylake: Fix DSP core ref count for init failure

 sound/soc/intel/skylake/bxt-sst.c      |  4 +++-
 sound/soc/intel/skylake/cnl-sst.c      |  4 +++-
 sound/soc/intel/skylake/skl-messages.c | 26 +++++++++++++++++++-------
 sound/soc/intel/skylake/skl-sst-dsp.c  |  4 ++--
 sound/soc/intel/skylake/skl-sst.c      |  4 +++-
 sound/soc/intel/skylake/skl.c          |  2 +-
 6 files changed, 31 insertions(+), 13 deletions(-)

-- 
1.9.1

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

* [PATCH 1/4] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure
  2017-08-22 11:15 [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Subhransu S. Prusty
@ 2017-08-22 11:15 ` Subhransu S. Prusty
  2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure" to the asoc tree Mark Brown
  2017-08-22 11:15 ` [PATCH 2/4] ASoC: Intel: Skylake: Fix to free resources for dsp_init failure Subhransu S. Prusty
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Subhransu S. Prusty @ 2017-08-22 11:15 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, patches.audio, broonie, Subhransu S. Prusty, lgirdwood

For some dsp init error path, irq and few more resources are not freed.
This results in oops. So, fix it by freeing up the resources on ipc_init
failure.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
---
 sound/soc/intel/skylake/bxt-sst.c | 4 +++-
 sound/soc/intel/skylake/cnl-sst.c | 4 +++-
 sound/soc/intel/skylake/skl-sst.c | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c
index 71042aceb25f..88b8de342f31 100644
--- a/sound/soc/intel/skylake/bxt-sst.c
+++ b/sound/soc/intel/skylake/bxt-sst.c
@@ -582,8 +582,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 			SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
 	ret = skl_ipc_init(dev, skl);
-	if (ret)
+	if (ret) {
+		skl_dsp_free(sst);
 		return ret;
+	}
 
 	/* set the D0i3 check */
 	skl->ipc.ops.check_dsp_lp_on = skl_ipc_check_D0i0;
diff --git a/sound/soc/intel/skylake/cnl-sst.c b/sound/soc/intel/skylake/cnl-sst.c
index 7dcfe66a20e2..76ef1e40a50e 100644
--- a/sound/soc/intel/skylake/cnl-sst.c
+++ b/sound/soc/intel/skylake/cnl-sst.c
@@ -450,8 +450,10 @@ int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 			     CNL_ADSP_W1_SZ);
 
 	ret = cnl_ipc_init(dev, cnl);
-	if (ret)
+	if (ret) {
+		skl_dsp_free(sst);
 		return ret;
+	}
 
 	cnl->boot_complete = false;
 	init_waitqueue_head(&cnl->boot_wait);
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 6cc586d3f03b..a6bcc0e6788f 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -562,8 +562,10 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 			SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
 	ret = skl_ipc_init(dev, skl);
-	if (ret)
+	if (ret) {
+		skl_dsp_free(sst);
 		return ret;
+	}
 
 	sst->fw_ops = skl_fw_ops;
 
-- 
1.9.1

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

* [PATCH 2/4] ASoC: Intel: Skylake: Fix to free resources for dsp_init failure
  2017-08-22 11:15 [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Subhransu S. Prusty
  2017-08-22 11:15 ` [PATCH 1/4] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure Subhransu S. Prusty
@ 2017-08-22 11:15 ` Subhransu S. Prusty
  2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix to free resources for dsp_init failure" to the asoc tree Mark Brown
  2017-08-22 11:15 ` [PATCH 3/4] ASoC: Intel: Skylake: Fix to free correct dev id in free_irq Subhransu S. Prusty
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Subhransu S. Prusty @ 2017-08-22 11:15 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, patches.audio, broonie, Subhransu S. Prusty, lgirdwood

unmap mmio and free memory resources if dsp_init fails.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
---
 sound/soc/intel/skylake/skl-messages.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index bfb3332a77ca..f0f11f597b21 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -277,8 +277,10 @@ int skl_init_dsp(struct skl *skl)
 	}
 
 	ops = skl_get_dsp_ops(skl->pci->device);
-	if (!ops)
-		return -EIO;
+	if (!ops) {
+		goto unmap_mmio;
+		ret = -EIO;
+	}
 
 	loader_ops = ops->loader_ops();
 	ret = ops->init(bus->dev, mmio_base, irq,
@@ -286,25 +288,35 @@ int skl_init_dsp(struct skl *skl)
 				&skl->skl_sst);
 
 	if (ret < 0)
-		return ret;
+		goto unmap_mmio;
 
 	skl->skl_sst->dsp_ops = ops;
 	cores = &skl->skl_sst->cores;
 	cores->count = ops->num_cores;
 
 	cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL);
-	if (!cores->state)
-		return -ENOMEM;
+	if (!cores->state) {
+		ret = -ENOMEM;
+		goto unmap_mmio;
+	}
 
 	cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count),
 				     GFP_KERNEL);
 	if (!cores->usage_count) {
-		kfree(cores->state);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto free_core_state;
 	}
 
 	dev_dbg(bus->dev, "dsp registration status=%d\n", ret);
 
+	return 0;
+
+free_core_state:
+	kfree(cores->state);
+
+unmap_mmio:
+	iounmap(mmio_base);
+
 	return ret;
 }
 
-- 
1.9.1

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

* [PATCH 3/4] ASoC: Intel: Skylake: Fix to free correct dev id in free_irq
  2017-08-22 11:15 [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Subhransu S. Prusty
  2017-08-22 11:15 ` [PATCH 1/4] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure Subhransu S. Prusty
  2017-08-22 11:15 ` [PATCH 2/4] ASoC: Intel: Skylake: Fix to free resources for dsp_init failure Subhransu S. Prusty
@ 2017-08-22 11:15 ` Subhransu S. Prusty
  2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix to free correct dev id in free_irq" to the asoc tree Mark Brown
  2017-08-22 11:15 ` [PATCH 4/4] ASoC: Intel: Skylake: Fix DSP core ref count for init failure Subhransu S. Prusty
  2017-08-23  1:11 ` [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Vinod Koul
  4 siblings, 1 reply; 10+ messages in thread
From: Subhransu S. Prusty @ 2017-08-22 11:15 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, patches.audio, broonie, Subhransu S. Prusty, lgirdwood

The dev_id passed by the driver in request_threaded_irq is an ebus pointer,
whereas to free_irq it is hdac_bus. Fix by passing correct dev_id to
free_irq.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
---
 sound/soc/intel/skylake/skl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index e25e5ed464dc..f94b484abb99 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -415,7 +415,7 @@ static int skl_free(struct hdac_ext_bus *ebus)
 	snd_hdac_ext_stop_streams(ebus);
 
 	if (bus->irq >= 0)
-		free_irq(bus->irq, (void *)bus);
+		free_irq(bus->irq, (void *)ebus);
 	snd_hdac_bus_free_stream_pages(bus);
 	snd_hdac_stream_free_all(ebus);
 	snd_hdac_link_free_all(ebus);
-- 
1.9.1

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

* [PATCH 4/4] ASoC: Intel: Skylake: Fix DSP core ref count for init failure
  2017-08-22 11:15 [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Subhransu S. Prusty
                   ` (2 preceding siblings ...)
  2017-08-22 11:15 ` [PATCH 3/4] ASoC: Intel: Skylake: Fix to free correct dev id in free_irq Subhransu S. Prusty
@ 2017-08-22 11:15 ` Subhransu S. Prusty
  2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix DSP core ref count for init failure" to the asoc tree Mark Brown
  2017-08-23  1:11 ` [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Vinod Koul
  4 siblings, 1 reply; 10+ messages in thread
From: Subhransu S. Prusty @ 2017-08-22 11:15 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, patches.audio, broonie, Subhransu S. Prusty, lgirdwood

During dsp init failure, the ref count is not incremented and dsp is
powered down. But as the skl driver calls put_core for the init failure it
decrements the dsp core ref count and ref count becomes unbalanced.

This results in dsp core powered up in further runtime suspend/resume
cycles and never powered down.

So increment the ref count before dsp core powerup and for any failure,
decrement in put_core will be balanced.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
---
 sound/soc/intel/skylake/skl-sst-dsp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c
index c2ba5ff1632c..19ee1d4f3bdf 100644
--- a/sound/soc/intel/skylake/skl-sst-dsp.c
+++ b/sound/soc/intel/skylake/skl-sst-dsp.c
@@ -351,6 +351,8 @@ int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id)
 		return -EINVAL;
 	}
 
+	skl->cores.usage_count[core_id]++;
+
 	if (skl->cores.state[core_id] == SKL_DSP_RESET) {
 		ret = ctx->fw_ops.set_state_D0(ctx, core_id);
 		if (ret < 0) {
@@ -359,8 +361,6 @@ int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id)
 		}
 	}
 
-	skl->cores.usage_count[core_id]++;
-
 out:
 	dev_dbg(ctx->dev, "core id %d state %d usage_count %d\n",
 			core_id, skl->cores.state[core_id],
-- 
1.9.1

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

* Re: [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure
  2017-08-22 11:15 [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Subhransu S. Prusty
                   ` (3 preceding siblings ...)
  2017-08-22 11:15 ` [PATCH 4/4] ASoC: Intel: Skylake: Fix DSP core ref count for init failure Subhransu S. Prusty
@ 2017-08-23  1:11 ` Vinod Koul
  4 siblings, 0 replies; 10+ messages in thread
From: Vinod Koul @ 2017-08-23  1:11 UTC (permalink / raw)
  To: Subhransu S. Prusty; +Cc: tiwai, patches.audio, alsa-devel, broonie, lgirdwood

On Tue, Aug 22, 2017 at 04:45:49PM +0530, Subhransu S. Prusty wrote:
> Some resources are not freed for ipc and dsp init failures. This results in
> random failures in a stress test environment. So fixed to free the required
> resources and also fixed the DSP core reference counting for firmware load
> failure.

Acked-By: Vinod Koul <vinod.koul@intel.com>

> Subhransu S. Prusty (4):
>   ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure
>   ASoC: Intel: Skylake: Fix to free resources for dsp_init failure
>   ASoC: Intel: Skylake: Fix to free correct dev id in free_irq
>   ASoC: Intel: Skylake: Fix DSP core ref count for init failure
> 
>  sound/soc/intel/skylake/bxt-sst.c      |  4 +++-
>  sound/soc/intel/skylake/cnl-sst.c      |  4 +++-
>  sound/soc/intel/skylake/skl-messages.c | 26 +++++++++++++++++++-------
>  sound/soc/intel/skylake/skl-sst-dsp.c  |  4 ++--
>  sound/soc/intel/skylake/skl-sst.c      |  4 +++-
>  sound/soc/intel/skylake/skl.c          |  2 +-
>  6 files changed, 31 insertions(+), 13 deletions(-)
> 
> -- 
> 1.9.1
> 

-- 
~Vinod

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

* Applied "ASoC: Intel: Skylake: Fix DSP core ref count for init failure" to the asoc tree
  2017-08-22 11:15 ` [PATCH 4/4] ASoC: Intel: Skylake: Fix DSP core ref count for init failure Subhransu S. Prusty
@ 2017-08-23 11:24   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-08-23 11:24 UTC (permalink / raw)
  Cc: alsa-devel, tiwai, lgirdwood, patches.audio, broonie,
	Subhransu S. Prusty

The patch

   ASoC: Intel: Skylake: Fix DSP core ref count for init failure

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From 7b992c24de78a206b3abd07192686d2d5db5012c Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 22 Aug 2017 16:45:53 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix DSP core ref count for init failure

During dsp init failure, the ref count is not incremented and dsp is
powered down. But as the skl driver calls put_core for the init failure it
decrements the dsp core ref count and ref count becomes unbalanced.

This results in dsp core powered up in further runtime suspend/resume
cycles and never powered down.

So increment the ref count before dsp core powerup and for any failure,
decrement in put_core will be balanced.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-sst-dsp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c
index c2ba5ff1632c..19ee1d4f3bdf 100644
--- a/sound/soc/intel/skylake/skl-sst-dsp.c
+++ b/sound/soc/intel/skylake/skl-sst-dsp.c
@@ -351,6 +351,8 @@ int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id)
 		return -EINVAL;
 	}
 
+	skl->cores.usage_count[core_id]++;
+
 	if (skl->cores.state[core_id] == SKL_DSP_RESET) {
 		ret = ctx->fw_ops.set_state_D0(ctx, core_id);
 		if (ret < 0) {
@@ -359,8 +361,6 @@ int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id)
 		}
 	}
 
-	skl->cores.usage_count[core_id]++;
-
 out:
 	dev_dbg(ctx->dev, "core id %d state %d usage_count %d\n",
 			core_id, skl->cores.state[core_id],
-- 
2.14.1

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

* Applied "ASoC: Intel: Skylake: Fix to free correct dev id in free_irq" to the asoc tree
  2017-08-22 11:15 ` [PATCH 3/4] ASoC: Intel: Skylake: Fix to free correct dev id in free_irq Subhransu S. Prusty
@ 2017-08-23 11:24   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-08-23 11:24 UTC (permalink / raw)
  Cc: alsa-devel, tiwai, lgirdwood, patches.audio, broonie,
	Subhransu S. Prusty

The patch

   ASoC: Intel: Skylake: Fix to free correct dev id in free_irq

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From c360e0c3ab8ef8d0fd6b5501a407b9a2be4f204d Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 22 Aug 2017 16:45:52 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix to free correct dev id in free_irq

The dev_id passed by the driver in request_threaded_irq is an ebus pointer,
whereas to free_irq it is hdac_bus. Fix by passing correct dev_id to
free_irq.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index e612a4097275..d62ffbc93d54 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -415,7 +415,7 @@ static int skl_free(struct hdac_ext_bus *ebus)
 	snd_hdac_ext_stop_streams(ebus);
 
 	if (bus->irq >= 0)
-		free_irq(bus->irq, (void *)bus);
+		free_irq(bus->irq, (void *)ebus);
 	snd_hdac_bus_free_stream_pages(bus);
 	snd_hdac_stream_free_all(ebus);
 	snd_hdac_link_free_all(ebus);
-- 
2.14.1

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

* Applied "ASoC: Intel: Skylake: Fix to free resources for dsp_init failure" to the asoc tree
  2017-08-22 11:15 ` [PATCH 2/4] ASoC: Intel: Skylake: Fix to free resources for dsp_init failure Subhransu S. Prusty
@ 2017-08-23 11:24   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-08-23 11:24 UTC (permalink / raw)
  Cc: alsa-devel, tiwai, lgirdwood, patches.audio, broonie,
	Subhransu S. Prusty

The patch

   ASoC: Intel: Skylake: Fix to free resources for dsp_init failure

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From f77d443c4c299aff5ad9c74811dd063f4d8bebcf Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 22 Aug 2017 16:45:51 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix to free resources for dsp_init
 failure

unmap mmio and free memory resources if dsp_init fails.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-messages.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index bfb3332a77ca..f0f11f597b21 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -277,8 +277,10 @@ int skl_init_dsp(struct skl *skl)
 	}
 
 	ops = skl_get_dsp_ops(skl->pci->device);
-	if (!ops)
-		return -EIO;
+	if (!ops) {
+		goto unmap_mmio;
+		ret = -EIO;
+	}
 
 	loader_ops = ops->loader_ops();
 	ret = ops->init(bus->dev, mmio_base, irq,
@@ -286,25 +288,35 @@ int skl_init_dsp(struct skl *skl)
 				&skl->skl_sst);
 
 	if (ret < 0)
-		return ret;
+		goto unmap_mmio;
 
 	skl->skl_sst->dsp_ops = ops;
 	cores = &skl->skl_sst->cores;
 	cores->count = ops->num_cores;
 
 	cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL);
-	if (!cores->state)
-		return -ENOMEM;
+	if (!cores->state) {
+		ret = -ENOMEM;
+		goto unmap_mmio;
+	}
 
 	cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count),
 				     GFP_KERNEL);
 	if (!cores->usage_count) {
-		kfree(cores->state);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto free_core_state;
 	}
 
 	dev_dbg(bus->dev, "dsp registration status=%d\n", ret);
 
+	return 0;
+
+free_core_state:
+	kfree(cores->state);
+
+unmap_mmio:
+	iounmap(mmio_base);
+
 	return ret;
 }
 
-- 
2.14.1

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

* Applied "ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure" to the asoc tree
  2017-08-22 11:15 ` [PATCH 1/4] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure Subhransu S. Prusty
@ 2017-08-23 11:24   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-08-23 11:24 UTC (permalink / raw)
  Cc: alsa-devel, tiwai, lgirdwood, patches.audio, broonie,
	Subhransu S. Prusty

The patch

   ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From 3b3011adada3bba47c56c205634e1b32512e0c7c Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 22 Aug 2017 16:45:50 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init
 failure

For some dsp init error path, irq and few more resources are not freed.
This results in oops. So, fix it by freeing up the resources on ipc_init
failure.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/bxt-sst.c | 4 +++-
 sound/soc/intel/skylake/cnl-sst.c | 4 +++-
 sound/soc/intel/skylake/skl-sst.c | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c
index 5e1ac99ffa8b..4524211960e4 100644
--- a/sound/soc/intel/skylake/bxt-sst.c
+++ b/sound/soc/intel/skylake/bxt-sst.c
@@ -582,8 +582,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 			SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
 	ret = skl_ipc_init(dev, skl);
-	if (ret)
+	if (ret) {
+		skl_dsp_free(sst);
 		return ret;
+	}
 
 	/* set the D0i3 check */
 	skl->ipc.ops.check_dsp_lp_on = skl_ipc_check_D0i0;
diff --git a/sound/soc/intel/skylake/cnl-sst.c b/sound/soc/intel/skylake/cnl-sst.c
index 48ef04d5da89..387de388ce29 100644
--- a/sound/soc/intel/skylake/cnl-sst.c
+++ b/sound/soc/intel/skylake/cnl-sst.c
@@ -450,8 +450,10 @@ int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 			     CNL_ADSP_W1_SZ);
 
 	ret = cnl_ipc_init(dev, cnl);
-	if (ret)
+	if (ret) {
+		skl_dsp_free(sst);
 		return ret;
+	}
 
 	cnl->boot_complete = false;
 	init_waitqueue_head(&cnl->boot_wait);
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index a7ad734f591d..a436abf2fe3f 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -562,8 +562,10 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 			SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ);
 
 	ret = skl_ipc_init(dev, skl);
-	if (ret)
+	if (ret) {
+		skl_dsp_free(sst);
 		return ret;
+	}
 
 	sst->fw_ops = skl_fw_ops;
 
-- 
2.14.1

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

end of thread, other threads:[~2017-08-23 11:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-22 11:15 [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Subhransu S. Prusty
2017-08-22 11:15 ` [PATCH 1/4] ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure Subhransu S. Prusty
2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure" to the asoc tree Mark Brown
2017-08-22 11:15 ` [PATCH 2/4] ASoC: Intel: Skylake: Fix to free resources for dsp_init failure Subhransu S. Prusty
2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix to free resources for dsp_init failure" to the asoc tree Mark Brown
2017-08-22 11:15 ` [PATCH 3/4] ASoC: Intel: Skylake: Fix to free correct dev id in free_irq Subhransu S. Prusty
2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix to free correct dev id in free_irq" to the asoc tree Mark Brown
2017-08-22 11:15 ` [PATCH 4/4] ASoC: Intel: Skylake: Fix DSP core ref count for init failure Subhransu S. Prusty
2017-08-23 11:24   ` Applied "ASoC: Intel: Skylake: Fix DSP core ref count for init failure" to the asoc tree Mark Brown
2017-08-23  1:11 ` [PATCH 0/4] ASoC: Intel: Skylake: Fixes to free resources on init failure Vinod Koul

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.