All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Fix Sparse warnings on sound/soc/intel
@ 2018-07-24 21:12 Pierre-Louis Bossart
  2018-07-24 21:12 ` [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage Pierre-Louis Bossart
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

Since we found quite a few issues when checking the SOF code with
Sparse, I figured I'd run a quick check on the rest of the Intel audio
drivers. Some of the issues are trivial but in the end there are a
couple of improvements identified by reducing the volume of warnings,
so it's worth it overall.

If there are concerns about the code readability, I would still
recommend merging the last 3-4 patches that are really the interesting
ones exposed by Sparse checks.

Pierre-Louis Bossart (6):
  ASoC: Intel: boards: cleanup snd_mask_set usage
  ASoC: Intel: Haswell: fix endianness handling
  ASoC: Intel: Skylake: BDL definitions should be __le32
  ASoC: Intel: common: make sst_dma functions static
  ASoC: Intel: Atom: simplify iomem address and casts
  ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32

 sound/soc/intel/atom/sst/sst_drv_interface.c       | 29 ++++++------
 sound/soc/intel/atom/sst/sst_loader.c              |  6 +--
 sound/soc/intel/boards/bdw-rt5677.c                |  2 +-
 sound/soc/intel/boards/bxt_da7219_max98357a.c      |  2 +-
 sound/soc/intel/boards/bxt_rt298.c                 |  2 +-
 sound/soc/intel/boards/glk_rt5682_max98357a.c      |  2 +-
 sound/soc/intel/boards/kbl_da7219_max98357a.c      |  2 +-
 sound/soc/intel/boards/kbl_rt5663_max98927.c       |  6 ++-
 .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c  |  6 ++-
 sound/soc/intel/boards/skl_nau88l25_max98357a.c    |  2 +-
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c      |  2 +-
 sound/soc/intel/boards/skl_rt286.c                 |  2 +-
 sound/soc/intel/common/sst-firmware.c              |  6 +--
 sound/soc/intel/haswell/sst-haswell-dsp.c          | 53 ++++++++++++----------
 sound/soc/intel/skylake/skl-sst-cldma.c            |  8 ++--
 sound/soc/intel/skylake/skl-sst-cldma.h            |  2 +-
 16 files changed, 70 insertions(+), 62 deletions(-)

-- 
2.14.1

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

* [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage
  2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
@ 2018-07-24 21:12 ` Pierre-Louis Bossart
  2018-07-25  5:34   ` Takashi Iwai
  2018-07-24 21:12 ` [PATCH 2/6] ASoC: Intel: Haswell: fix endianness handling Pierre-Louis Bossart
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

Sparse reports a ton of warnings when snd_mask_set is used (see
e.g. below). Fix by adding the right typecast with the __force
attribute. The code is less readable but with fewer warnings it's
easier to track the real issues and improve the rest of the code.

 CHECK   sound/soc/intel/boards/skl_nau88l25_max98357a.c
sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: warning: incorrect type in argument 2 (different base types)
sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    expected unsigned int [unsigned] val
sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    got restricted snd_pcm_format_t [usertype] <noident>

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/bdw-rt5677.c                 | 2 +-
 sound/soc/intel/boards/bxt_da7219_max98357a.c       | 2 +-
 sound/soc/intel/boards/bxt_rt298.c                  | 2 +-
 sound/soc/intel/boards/glk_rt5682_max98357a.c       | 2 +-
 sound/soc/intel/boards/kbl_da7219_max98357a.c       | 2 +-
 sound/soc/intel/boards/kbl_rt5663_max98927.c        | 6 ++++--
 sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 6 ++++--
 sound/soc/intel/boards/skl_nau88l25_max98357a.c     | 2 +-
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c       | 2 +-
 sound/soc/intel/boards/skl_rt286.c                  | 2 +-
 10 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
index 6ea360f33575..17037892c16b 100644
--- a/sound/soc/intel/boards/bdw-rt5677.c
+++ b/sound/soc/intel/boards/bdw-rt5677.c
@@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 	/* set SSP0 to 16 bit */
 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S16_LE);
+				(__force unsigned int)SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index 3aba5bcf806a..726412599b7a 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -160,7 +160,7 @@ static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c
index b68c289558a8..0bef1922bdce 100644
--- a/sound/soc/intel/boards/bxt_rt298.c
+++ b/sound/soc/intel/boards/bxt_rt298.c
@@ -221,7 +221,7 @@ static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP5 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c
index c4b94e2617c5..fc4eb2fa773f 100644
--- a/sound/soc/intel/boards/glk_rt5682_max98357a.c
+++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c
@@ -164,7 +164,7 @@ static int geminilake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c
index 7961f1fd18bd..0f315b0e9724 100644
--- a/sound/soc/intel/boards/kbl_da7219_max98357a.c
+++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c
@@ -152,7 +152,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c
index 3a61252fe450..8c7a81fef220 100644
--- a/sound/soc/intel/boards/kbl_rt5663_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c
@@ -434,14 +434,16 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 		rate->min = rate->max = 48000;
 		channels->min = channels->max = 2;
 		snd_mask_none(fmt);
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+		snd_mask_set(fmt,
+			     (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 	}
 	/*
 	 * The speaker on the SSP0 supports S16_LE and not S24_LE.
 	 * thus changing the mask here
 	 */
 	if (!strcmp(be_dai_link->name, "SSP0-Codec"))
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
+		snd_mask_set(fmt,
+			     (__force unsigned int)SNDRV_PCM_FORMAT_S16_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 92f5fb2ae0a3..155e0dc00401 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -307,7 +307,8 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 		rate->min = rate->max = 48000;
 		channels->min = channels->max = 2;
 		snd_mask_none(fmt);
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+		snd_mask_set(fmt,
+			     (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 	} else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
 		if (params_channels(params) == 2 ||
 				DMIC_CH(dmic_constraints) == 2)
@@ -320,7 +321,8 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 	 * thus changing the mask here
 	 */
 	if (!strcmp(be_dai_link->name, "SSP0-Codec"))
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
+		snd_mask_set(fmt,
+			     (__force unsigned int)SNDRV_PCM_FORMAT_S16_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 3ff6646cfa21..2558e494231b 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -157,7 +157,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index b0610bba3cfa..3e59437784d8 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -346,7 +346,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c
index 38a1495c29cf..807ab0c57c14 100644
--- a/sound/soc/intel/boards/skl_rt286.c
+++ b/sound/soc/intel/boards/skl_rt286.c
@@ -229,7 +229,7 @@ static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set(fmt, (__force unsigned int)SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
-- 
2.14.1

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

* [PATCH 2/6] ASoC: Intel: Haswell: fix endianness handling
  2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
  2018-07-24 21:12 ` [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage Pierre-Louis Bossart
@ 2018-07-24 21:12 ` Pierre-Louis Bossart
  2018-07-25 16:40   ` Applied "ASoC: Intel: Haswell: fix endianness handling" to the asoc tree Mark Brown
  2018-07-24 21:12 ` [PATCH 3/6] ASoC: Intel: Skylake: BDL definitions should be __le32 Pierre-Louis Bossart
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

Make all Sparse warnings go away by using le16/32_to_cpu.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/haswell/sst-haswell-dsp.c | 53 +++++++++++++++++--------------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/sound/soc/intel/haswell/sst-haswell-dsp.c b/sound/soc/intel/haswell/sst-haswell-dsp.c
index b2bec36d074c..a28220e67cdf 100644
--- a/sound/soc/intel/haswell/sst-haswell-dsp.c
+++ b/sound/soc/intel/haswell/sst-haswell-dsp.c
@@ -93,29 +93,31 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 	struct sst_module_template template;
 	int count, ret;
 	void __iomem *ram;
+	int type = le16_to_cpu(module->type);
+	int entry_point = le32_to_cpu(module->entry_point);
 
 	/* TODO: allowed module types need to be configurable */
-	if (module->type != SST_HSW_MODULE_BASE_FW
-		&& module->type != SST_HSW_MODULE_PCM_SYSTEM
-		&& module->type != SST_HSW_MODULE_PCM
-		&& module->type != SST_HSW_MODULE_PCM_REFERENCE
-		&& module->type != SST_HSW_MODULE_PCM_CAPTURE
-		&& module->type != SST_HSW_MODULE_WAVES
-		&& module->type != SST_HSW_MODULE_LPAL)
+	if (type != SST_HSW_MODULE_BASE_FW &&
+	    type != SST_HSW_MODULE_PCM_SYSTEM &&
+	    type != SST_HSW_MODULE_PCM &&
+	    type != SST_HSW_MODULE_PCM_REFERENCE &&
+	    type != SST_HSW_MODULE_PCM_CAPTURE &&
+	    type != SST_HSW_MODULE_WAVES &&
+	    type != SST_HSW_MODULE_LPAL)
 		return 0;
 
 	dev_dbg(dsp->dev, "new module sign 0x%s size 0x%x blocks 0x%x type 0x%x\n",
 		module->signature, module->mod_size,
-		module->blocks, module->type);
-	dev_dbg(dsp->dev, " entrypoint 0x%x\n", module->entry_point);
+		module->blocks, type);
+	dev_dbg(dsp->dev, " entrypoint 0x%x\n", entry_point);
 	dev_dbg(dsp->dev, " persistent 0x%x scratch 0x%x\n",
 		module->info.persistent_size, module->info.scratch_size);
 
 	memset(&template, 0, sizeof(template));
-	template.id = module->type;
-	template.entry = module->entry_point - 4;
-	template.persistent_size = module->info.persistent_size;
-	template.scratch_size = module->info.scratch_size;
+	template.id = type;
+	template.entry = entry_point - 4;
+	template.persistent_size = le32_to_cpu(module->info.persistent_size);
+	template.scratch_size = le32_to_cpu(module->info.scratch_size);
 
 	mod = sst_module_new(fw, &template, NULL);
 	if (mod == NULL)
@@ -123,26 +125,26 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 
 	block = (void *)module + sizeof(*module);
 
-	for (count = 0; count < module->blocks; count++) {
+	for (count = 0; count < le32_to_cpu(module->blocks); count++) {
 
-		if (block->size <= 0) {
+		if (le32_to_cpu(block->size) <= 0) {
 			dev_err(dsp->dev,
 				"error: block %d size invalid\n", count);
 			sst_module_free(mod);
 			return -EINVAL;
 		}
 
-		switch (block->type) {
+		switch (le32_to_cpu(block->type)) {
 		case SST_HSW_IRAM:
 			ram = dsp->addr.lpe;
-			mod->offset =
-				block->ram_offset + dsp->addr.iram_offset;
+			mod->offset = le32_to_cpu(block->ram_offset) +
+				dsp->addr.iram_offset;
 			mod->type = SST_MEM_IRAM;
 			break;
 		case SST_HSW_DRAM:
 		case SST_HSW_REGS:
 			ram = dsp->addr.lpe;
-			mod->offset = block->ram_offset;
+			mod->offset = le32_to_cpu(block->ram_offset);
 			mod->type = SST_MEM_DRAM;
 			break;
 		default:
@@ -152,7 +154,7 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 			return -EINVAL;
 		}
 
-		mod->size = block->size;
+		mod->size = le32_to_cpu(block->size);
 		mod->data = (void *)block + sizeof(*block);
 		mod->data_offset = mod->data - fw->dma_buf;
 
@@ -169,7 +171,8 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 			return ret;
 		}
 
-		block = (void *)block + sizeof(*block) + block->size;
+		block = (void *)block + sizeof(*block) +
+			le32_to_cpu(block->size);
 	}
 	mod->state = SST_MODULE_STATE_LOADED;
 
@@ -188,7 +191,8 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 
 	/* verify FW */
 	if ((strncmp(header->signature, SST_HSW_FW_SIGN, 4) != 0) ||
-		(sst_fw->size != header->file_size + sizeof(*header))) {
+	    (sst_fw->size !=
+	     le32_to_cpu(header->file_size) + sizeof(*header))) {
 		dev_err(dsp->dev, "error: invalid fw sign/filesize mismatch\n");
 		return -EINVAL;
 	}
@@ -199,7 +203,7 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 
 	/* parse each module */
 	module = (void *)sst_fw->dma_buf + sizeof(*header);
-	for (count = 0; count < header->modules; count++) {
+	for (count = 0; count < le32_to_cpu(header->modules); count++) {
 
 		/* module */
 		ret = hsw_parse_module(dsp, sst_fw, module);
@@ -207,7 +211,8 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 			dev_err(dsp->dev, "error: invalid module %d\n", count);
 			return ret;
 		}
-		module = (void *)module + sizeof(*module) + module->mod_size;
+		module = (void *)module + sizeof(*module) +
+			le32_to_cpu(module->mod_size);
 	}
 
 	return 0;
-- 
2.14.1

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

* [PATCH 3/6] ASoC: Intel: Skylake: BDL definitions should be __le32
  2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
  2018-07-24 21:12 ` [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage Pierre-Louis Bossart
  2018-07-24 21:12 ` [PATCH 2/6] ASoC: Intel: Haswell: fix endianness handling Pierre-Louis Bossart
@ 2018-07-24 21:12 ` Pierre-Louis Bossart
  2018-07-25 16:40   ` Applied "ASoC: Intel: Skylake: BDL definitions should be __le32" to the asoc tree Mark Brown
  2018-07-24 21:12 ` [PATCH 4/6] ASoC: Intel: common: make sst_dma functions static Pierre-Louis Bossart
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

Make sure definitions are consistent with usage.
Detected with Sparse.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/skylake/skl-sst-cldma.c | 8 ++++----
 sound/soc/intel/skylake/skl-sst-cldma.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-sst-cldma.c b/sound/soc/intel/skylake/skl-sst-cldma.c
index d2b1d60fec02..5bc0d38da7e3 100644
--- a/sound/soc/intel/skylake/skl-sst-cldma.c
+++ b/sound/soc/intel/skylake/skl-sst-cldma.c
@@ -83,9 +83,9 @@ static void skl_cldma_stream_clear(struct sst_dsp  *ctx)
 /* Code loader helper APIs */
 static void skl_cldma_setup_bdle(struct sst_dsp *ctx,
 		struct snd_dma_buffer *dmab_data,
-		u32 **bdlp, int size, int with_ioc)
+		__le32 **bdlp, int size, int with_ioc)
 {
-	u32 *bdl = *bdlp;
+	__le32 *bdl = *bdlp;
 
 	ctx->cl_dev.frags = 0;
 	while (size > 0) {
@@ -330,7 +330,7 @@ void skl_cldma_process_intr(struct sst_dsp *ctx)
 int skl_cldma_prepare(struct sst_dsp *ctx)
 {
 	int ret;
-	u32 *bdl;
+	__le32 *bdl;
 
 	ctx->cl_dev.bufsize = SKL_MAX_BUFFER_SIZE;
 
@@ -359,7 +359,7 @@ int skl_cldma_prepare(struct sst_dsp *ctx)
 		ctx->dsp_ops.free_dma_buf(ctx->dev, &ctx->cl_dev.dmab_data);
 		return ret;
 	}
-	bdl = (u32 *)ctx->cl_dev.dmab_bdl.area;
+	bdl = (__le32 *)ctx->cl_dev.dmab_bdl.area;
 
 	/* Allocate BDLs */
 	ctx->cl_dev.ops.cl_setup_bdle(ctx, &ctx->cl_dev.dmab_data,
diff --git a/sound/soc/intel/skylake/skl-sst-cldma.h b/sound/soc/intel/skylake/skl-sst-cldma.h
index 5b730a1a0ae4..ec736921a083 100644
--- a/sound/soc/intel/skylake/skl-sst-cldma.h
+++ b/sound/soc/intel/skylake/skl-sst-cldma.h
@@ -203,7 +203,7 @@ struct sst_dsp;
 struct skl_cl_dev_ops {
 	void (*cl_setup_bdle)(struct sst_dsp *ctx,
 			struct snd_dma_buffer *dmab_data,
-			u32 **bdlp, int size, int with_ioc);
+			__le32 **bdlp, int size, int with_ioc);
 	void (*cl_setup_controller)(struct sst_dsp *ctx,
 			struct snd_dma_buffer *dmab_bdl,
 			unsigned int max_size, u32 page_count);
-- 
2.14.1

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

* [PATCH 4/6] ASoC: Intel: common: make sst_dma functions static
  2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
                   ` (2 preceding siblings ...)
  2018-07-24 21:12 ` [PATCH 3/6] ASoC: Intel: Skylake: BDL definitions should be __le32 Pierre-Louis Bossart
@ 2018-07-24 21:12 ` Pierre-Louis Bossart
  2018-07-25 16:40   ` Applied "ASoC: Intel: common: make sst_dma functions static" to the asoc tree Mark Brown
  2018-07-24 21:12 ` [PATCH 5/6] ASoC: Intel: Atom: simplify iomem address and casts Pierre-Louis Bossart
  2018-07-24 21:12 ` [PATCH 6/6] ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32 Pierre-Louis Bossart
  5 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

sst_dma_new and sst_dma_free are not used in any other file and don't
have a prototype. Move to static functions and remove
EXPORT_SYMBOL_GPL statement.

Reported by sparse warnings.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/common/sst-firmware.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index 657afc02f1c4..11041aedea31 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -270,7 +270,7 @@ void sst_dsp_dma_put_channel(struct sst_dsp *dsp)
 }
 EXPORT_SYMBOL_GPL(sst_dsp_dma_put_channel);
 
-int sst_dma_new(struct sst_dsp *sst)
+static int sst_dma_new(struct sst_dsp *sst)
 {
 	struct sst_pdata *sst_pdata = sst->pdata;
 	struct sst_dma *dma;
@@ -320,9 +320,8 @@ int sst_dma_new(struct sst_dsp *sst)
 	devm_kfree(sst->dev, dma);
 	return ret;
 }
-EXPORT_SYMBOL(sst_dma_new);
 
-void sst_dma_free(struct sst_dma *dma)
+static void sst_dma_free(struct sst_dma *dma)
 {
 
 	if (dma == NULL)
@@ -335,7 +334,6 @@ void sst_dma_free(struct sst_dma *dma)
 		dw_remove(dma->chip);
 
 }
-EXPORT_SYMBOL(sst_dma_free);
 
 /* create new generic firmware object */
 struct sst_fw *sst_fw_new(struct sst_dsp *dsp, 
-- 
2.14.1

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

* [PATCH 5/6] ASoC: Intel: Atom: simplify iomem address and casts
  2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
                   ` (3 preceding siblings ...)
  2018-07-24 21:12 ` [PATCH 4/6] ASoC: Intel: common: make sst_dma functions static Pierre-Louis Bossart
@ 2018-07-24 21:12 ` Pierre-Louis Bossart
  2018-07-25 16:40   ` Applied "ASoC: Intel: Atom: simplify iomem address and casts" to the asoc tree Mark Brown
  2018-07-24 21:12 ` [PATCH 6/6] ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32 Pierre-Louis Bossart
  5 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

Simplify code and add relevant casts to make Sparse warnings go away

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/atom/sst/sst_drv_interface.c | 29 ++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
index 6a8b253c58d2..5455d6e0ab53 100644
--- a/sound/soc/intel/atom/sst/sst_drv_interface.c
+++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
@@ -266,17 +266,15 @@ static int sst_cdev_ack(struct device *dev, unsigned int str_id,
 	stream->cumm_bytes += bytes;
 	dev_dbg(dev, "bytes copied %d inc by %ld\n", stream->cumm_bytes, bytes);
 
-	memcpy_fromio(&fw_tstamp,
-		((void *)(ctx->mailbox + ctx->tstamp)
-		+(str_id * sizeof(fw_tstamp))),
-		sizeof(fw_tstamp));
+	addr =  ((void __iomem *)(ctx->mailbox + ctx->tstamp)) +
+		(str_id * sizeof(fw_tstamp));
+
+	memcpy_fromio(&fw_tstamp, addr, sizeof(fw_tstamp));
 
 	fw_tstamp.bytes_copied = stream->cumm_bytes;
 	dev_dbg(dev, "bytes sent to fw %llu inc by %ld\n",
 			fw_tstamp.bytes_copied, bytes);
 
-	addr =  ((void *)(ctx->mailbox + ctx->tstamp)) +
-			(str_id * sizeof(fw_tstamp));
 	offset =  offsetof(struct snd_sst_tstamp, bytes_copied);
 	sst_shim_write(addr, offset, fw_tstamp.bytes_copied);
 	return 0;
@@ -360,11 +358,12 @@ static int sst_cdev_tstamp(struct device *dev, unsigned int str_id,
 	struct snd_sst_tstamp fw_tstamp = {0,};
 	struct stream_info *stream;
 	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	void __iomem *addr;
+
+	addr = (void __iomem *)(ctx->mailbox + ctx->tstamp) +
+		(str_id * sizeof(fw_tstamp));
 
-	memcpy_fromio(&fw_tstamp,
-		((void *)(ctx->mailbox + ctx->tstamp)
-		+(str_id * sizeof(fw_tstamp))),
-		sizeof(fw_tstamp));
+	memcpy_fromio(&fw_tstamp, addr, sizeof(fw_tstamp));
 
 	stream = get_stream_info(ctx, str_id);
 	if (!stream)
@@ -530,6 +529,7 @@ static int sst_read_timestamp(struct device *dev, struct pcm_stream_info *info)
 	struct snd_sst_tstamp fw_tstamp;
 	unsigned int str_id;
 	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	void __iomem *addr;
 
 	str_id = info->str_id;
 	stream = get_stream_info(ctx, str_id);
@@ -540,10 +540,11 @@ static int sst_read_timestamp(struct device *dev, struct pcm_stream_info *info)
 		return -EINVAL;
 	substream = stream->pcm_substream;
 
-	memcpy_fromio(&fw_tstamp,
-		((void *)(ctx->mailbox + ctx->tstamp)
-			+ (str_id * sizeof(fw_tstamp))),
-		sizeof(fw_tstamp));
+	addr = (void __iomem *)(ctx->mailbox + ctx->tstamp) +
+		(str_id * sizeof(fw_tstamp));
+
+	memcpy_fromio(&fw_tstamp, addr, sizeof(fw_tstamp));
+
 	return sst_calc_tstamp(ctx, info, substream, &fw_tstamp);
 }
 
-- 
2.14.1

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

* [PATCH 6/6] ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32
  2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
                   ` (4 preceding siblings ...)
  2018-07-24 21:12 ` [PATCH 5/6] ASoC: Intel: Atom: simplify iomem address and casts Pierre-Louis Bossart
@ 2018-07-24 21:12 ` Pierre-Louis Bossart
  2018-07-25 16:40   ` Applied "ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32" to the asoc tree Mark Brown
  5 siblings, 1 reply; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-24 21:12 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, liam.r.girdwood, vkoul, broonie, Pierre-Louis Bossart

This looks like a copy/paste issue, but clearly there is an inversion
that is obvious when checking the arguments.

Detected with Sparse - now that we have fewer warnings this one was
easy to find.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/atom/sst/sst_loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
index a686eef2cf7f..27413ebae956 100644
--- a/sound/soc/intel/atom/sst/sst_loader.c
+++ b/sound/soc/intel/atom/sst/sst_loader.c
@@ -44,15 +44,15 @@ void memcpy32_toio(void __iomem *dst, const void *src, int count)
 	/* __iowrite32_copy uses 32-bit count values so divide by 4 for
 	 * right count in words
 	 */
-	__iowrite32_copy(dst, src, count/4);
+	__iowrite32_copy(dst, src, count / 4);
 }
 
 void memcpy32_fromio(void *dst, const void __iomem *src, int count)
 {
-	/* __iowrite32_copy uses 32-bit count values so divide by 4 for
+	/* __ioread32_copy uses 32-bit count values so divide by 4 for
 	 * right count in words
 	 */
-	__iowrite32_copy(dst, src, count/4);
+	__ioread32_copy(dst, src, count / 4);
 }
 
 /**
-- 
2.14.1

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

* Re: [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage
  2018-07-24 21:12 ` [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage Pierre-Louis Bossart
@ 2018-07-25  5:34   ` Takashi Iwai
  2018-07-25 13:54     ` Pierre-Louis Bossart
  0 siblings, 1 reply; 14+ messages in thread
From: Takashi Iwai @ 2018-07-25  5:34 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: liam.r.girdwood, alsa-devel, broonie, vkoul

On Tue, 24 Jul 2018 23:12:43 +0200,
Pierre-Louis Bossart wrote:
> 
> Sparse reports a ton of warnings when snd_mask_set is used (see
> e.g. below). Fix by adding the right typecast with the __force
> attribute. The code is less readable but with fewer warnings it's
> easier to track the real issues and improve the rest of the code.
> 
>  CHECK   sound/soc/intel/boards/skl_nau88l25_max98357a.c
> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: warning: incorrect type in argument 2 (different base types)
> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    expected unsigned int [unsigned] val
> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    got restricted snd_pcm_format_t [usertype] <noident>
> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>  sound/soc/intel/boards/bdw-rt5677.c                 | 2 +-
>  sound/soc/intel/boards/bxt_da7219_max98357a.c       | 2 +-
>  sound/soc/intel/boards/bxt_rt298.c                  | 2 +-
>  sound/soc/intel/boards/glk_rt5682_max98357a.c       | 2 +-
>  sound/soc/intel/boards/kbl_da7219_max98357a.c       | 2 +-
>  sound/soc/intel/boards/kbl_rt5663_max98927.c        | 6 ++++--
>  sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 6 ++++--
>  sound/soc/intel/boards/skl_nau88l25_max98357a.c     | 2 +-
>  sound/soc/intel/boards/skl_nau88l25_ssm4567.c       | 2 +-
>  sound/soc/intel/boards/skl_rt286.c                  | 2 +-
>  10 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
> index 6ea360f33575..17037892c16b 100644
> --- a/sound/soc/intel/boards/bdw-rt5677.c
> +++ b/sound/soc/intel/boards/bdw-rt5677.c
> @@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
>  	/* set SSP0 to 16 bit */
>  	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
>  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> -				    SNDRV_PCM_FORMAT_S16_LE);
> +				(__force unsigned int)SNDRV_PCM_FORMAT_S16_LE);

I believe we should provide a specific type of snd_mask_set(), e.g.
snd_mask_set_format(), snd_mask_set_access(), etc, which receives the
right type as the argument, instead of this kind of ugly cast.

Will cook up the patch later.


thanks,

Takashi

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

* Re: [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage
  2018-07-25  5:34   ` Takashi Iwai
@ 2018-07-25 13:54     ` Pierre-Louis Bossart
  0 siblings, 0 replies; 14+ messages in thread
From: Pierre-Louis Bossart @ 2018-07-25 13:54 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: liam.r.girdwood, alsa-devel, broonie, vkoul

On 7/25/18 12:34 AM, Takashi Iwai wrote:
> On Tue, 24 Jul 2018 23:12:43 +0200,
> Pierre-Louis Bossart wrote:
>>
>> Sparse reports a ton of warnings when snd_mask_set is used (see
>> e.g. below). Fix by adding the right typecast with the __force
>> attribute. The code is less readable but with fewer warnings it's
>> easier to track the real issues and improve the rest of the code.
>>
>>   CHECK   sound/soc/intel/boards/skl_nau88l25_max98357a.c
>> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: warning: incorrect type in argument 2 (different base types)
>> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    expected unsigned int [unsigned] val
>> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    got restricted snd_pcm_format_t [usertype] <noident>
>>
>> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>> ---
>>   sound/soc/intel/boards/bdw-rt5677.c                 | 2 +-
>>   sound/soc/intel/boards/bxt_da7219_max98357a.c       | 2 +-
>>   sound/soc/intel/boards/bxt_rt298.c                  | 2 +-
>>   sound/soc/intel/boards/glk_rt5682_max98357a.c       | 2 +-
>>   sound/soc/intel/boards/kbl_da7219_max98357a.c       | 2 +-
>>   sound/soc/intel/boards/kbl_rt5663_max98927.c        | 6 ++++--
>>   sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 6 ++++--
>>   sound/soc/intel/boards/skl_nau88l25_max98357a.c     | 2 +-
>>   sound/soc/intel/boards/skl_nau88l25_ssm4567.c       | 2 +-
>>   sound/soc/intel/boards/skl_rt286.c                  | 2 +-
>>   10 files changed, 16 insertions(+), 12 deletions(-)
>>
>> diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
>> index 6ea360f33575..17037892c16b 100644
>> --- a/sound/soc/intel/boards/bdw-rt5677.c
>> +++ b/sound/soc/intel/boards/bdw-rt5677.c
>> @@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
>>   	/* set SSP0 to 16 bit */
>>   	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
>>   				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
>> -				    SNDRV_PCM_FORMAT_S16_LE);
>> +				(__force unsigned int)SNDRV_PCM_FORMAT_S16_LE);
> 
> I believe we should provide a specific type of snd_mask_set(), e.g.
> snd_mask_set_format(), snd_mask_set_access(), etc, which receives the
> right type as the argument, instead of this kind of ugly cast.

I agree it's ugly, I was indeed hoping we'd fix this in a nicer way.

> 
> Will cook up the patch later.
> 
> 
> thanks,
> 
> Takashi
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

* Applied "ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32" to the asoc tree
  2018-07-24 21:12 ` [PATCH 6/6] ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32 Pierre-Louis Bossart
@ 2018-07-25 16:40   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2018-07-25 16:40 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: tiwai, liam.r.girdwood, alsa-devel, broonie, vkoul

The patch

   ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32

has been applied to the asoc tree at

   https://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 9a0daaab31e9e39047ced79409313c34dae4635a Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Tue, 24 Jul 2018 16:12:48 -0500
Subject: [PATCH] ASoC: Intel: Atom: fix inversion between __iowrite32 and
 __ioread32

This looks like a copy/paste issue, but clearly there is an inversion
that is obvious when checking the arguments.

Detected with Sparse - now that we have fewer warnings this one was
easy to find.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/atom/sst/sst_loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
index a686eef2cf7f..27413ebae956 100644
--- a/sound/soc/intel/atom/sst/sst_loader.c
+++ b/sound/soc/intel/atom/sst/sst_loader.c
@@ -44,15 +44,15 @@ void memcpy32_toio(void __iomem *dst, const void *src, int count)
 	/* __iowrite32_copy uses 32-bit count values so divide by 4 for
 	 * right count in words
 	 */
-	__iowrite32_copy(dst, src, count/4);
+	__iowrite32_copy(dst, src, count / 4);
 }
 
 void memcpy32_fromio(void *dst, const void __iomem *src, int count)
 {
-	/* __iowrite32_copy uses 32-bit count values so divide by 4 for
+	/* __ioread32_copy uses 32-bit count values so divide by 4 for
 	 * right count in words
 	 */
-	__iowrite32_copy(dst, src, count/4);
+	__ioread32_copy(dst, src, count / 4);
 }
 
 /**
-- 
2.18.0

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

* Applied "ASoC: Intel: Atom: simplify iomem address and casts" to the asoc tree
  2018-07-24 21:12 ` [PATCH 5/6] ASoC: Intel: Atom: simplify iomem address and casts Pierre-Louis Bossart
@ 2018-07-25 16:40   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2018-07-25 16:40 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: tiwai, liam.r.girdwood, alsa-devel, broonie, vkoul

The patch

   ASoC: Intel: Atom: simplify iomem address and casts

has been applied to the asoc tree at

   https://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 ce1cfe295abaa7436f9049bcb2562c843089abfc Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Tue, 24 Jul 2018 16:12:47 -0500
Subject: [PATCH] ASoC: Intel: Atom: simplify iomem address and casts

Simplify code and add relevant casts to make Sparse warnings go away

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/atom/sst/sst_drv_interface.c | 29 ++++++++++----------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
index 6a8b253c58d2..5455d6e0ab53 100644
--- a/sound/soc/intel/atom/sst/sst_drv_interface.c
+++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
@@ -266,17 +266,15 @@ static int sst_cdev_ack(struct device *dev, unsigned int str_id,
 	stream->cumm_bytes += bytes;
 	dev_dbg(dev, "bytes copied %d inc by %ld\n", stream->cumm_bytes, bytes);
 
-	memcpy_fromio(&fw_tstamp,
-		((void *)(ctx->mailbox + ctx->tstamp)
-		+(str_id * sizeof(fw_tstamp))),
-		sizeof(fw_tstamp));
+	addr =  ((void __iomem *)(ctx->mailbox + ctx->tstamp)) +
+		(str_id * sizeof(fw_tstamp));
+
+	memcpy_fromio(&fw_tstamp, addr, sizeof(fw_tstamp));
 
 	fw_tstamp.bytes_copied = stream->cumm_bytes;
 	dev_dbg(dev, "bytes sent to fw %llu inc by %ld\n",
 			fw_tstamp.bytes_copied, bytes);
 
-	addr =  ((void *)(ctx->mailbox + ctx->tstamp)) +
-			(str_id * sizeof(fw_tstamp));
 	offset =  offsetof(struct snd_sst_tstamp, bytes_copied);
 	sst_shim_write(addr, offset, fw_tstamp.bytes_copied);
 	return 0;
@@ -360,11 +358,12 @@ static int sst_cdev_tstamp(struct device *dev, unsigned int str_id,
 	struct snd_sst_tstamp fw_tstamp = {0,};
 	struct stream_info *stream;
 	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	void __iomem *addr;
+
+	addr = (void __iomem *)(ctx->mailbox + ctx->tstamp) +
+		(str_id * sizeof(fw_tstamp));
 
-	memcpy_fromio(&fw_tstamp,
-		((void *)(ctx->mailbox + ctx->tstamp)
-		+(str_id * sizeof(fw_tstamp))),
-		sizeof(fw_tstamp));
+	memcpy_fromio(&fw_tstamp, addr, sizeof(fw_tstamp));
 
 	stream = get_stream_info(ctx, str_id);
 	if (!stream)
@@ -530,6 +529,7 @@ static int sst_read_timestamp(struct device *dev, struct pcm_stream_info *info)
 	struct snd_sst_tstamp fw_tstamp;
 	unsigned int str_id;
 	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	void __iomem *addr;
 
 	str_id = info->str_id;
 	stream = get_stream_info(ctx, str_id);
@@ -540,10 +540,11 @@ static int sst_read_timestamp(struct device *dev, struct pcm_stream_info *info)
 		return -EINVAL;
 	substream = stream->pcm_substream;
 
-	memcpy_fromio(&fw_tstamp,
-		((void *)(ctx->mailbox + ctx->tstamp)
-			+ (str_id * sizeof(fw_tstamp))),
-		sizeof(fw_tstamp));
+	addr = (void __iomem *)(ctx->mailbox + ctx->tstamp) +
+		(str_id * sizeof(fw_tstamp));
+
+	memcpy_fromio(&fw_tstamp, addr, sizeof(fw_tstamp));
+
 	return sst_calc_tstamp(ctx, info, substream, &fw_tstamp);
 }
 
-- 
2.18.0

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

* Applied "ASoC: Intel: common: make sst_dma functions static" to the asoc tree
  2018-07-24 21:12 ` [PATCH 4/6] ASoC: Intel: common: make sst_dma functions static Pierre-Louis Bossart
@ 2018-07-25 16:40   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2018-07-25 16:40 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: tiwai, liam.r.girdwood, alsa-devel, broonie, vkoul

The patch

   ASoC: Intel: common: make sst_dma functions static

has been applied to the asoc tree at

   https://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 ef3cb7423358ff0cadacb76f26e3e1f4da8be4ce Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Tue, 24 Jul 2018 16:12:46 -0500
Subject: [PATCH] ASoC: Intel: common: make sst_dma functions static

sst_dma_new and sst_dma_free are not used in any other file and don't
have a prototype. Move to static functions and remove
EXPORT_SYMBOL_GPL statement.

Reported by sparse warnings.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/common/sst-firmware.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index 657afc02f1c4..11041aedea31 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -270,7 +270,7 @@ void sst_dsp_dma_put_channel(struct sst_dsp *dsp)
 }
 EXPORT_SYMBOL_GPL(sst_dsp_dma_put_channel);
 
-int sst_dma_new(struct sst_dsp *sst)
+static int sst_dma_new(struct sst_dsp *sst)
 {
 	struct sst_pdata *sst_pdata = sst->pdata;
 	struct sst_dma *dma;
@@ -320,9 +320,8 @@ int sst_dma_new(struct sst_dsp *sst)
 	devm_kfree(sst->dev, dma);
 	return ret;
 }
-EXPORT_SYMBOL(sst_dma_new);
 
-void sst_dma_free(struct sst_dma *dma)
+static void sst_dma_free(struct sst_dma *dma)
 {
 
 	if (dma == NULL)
@@ -335,7 +334,6 @@ void sst_dma_free(struct sst_dma *dma)
 		dw_remove(dma->chip);
 
 }
-EXPORT_SYMBOL(sst_dma_free);
 
 /* create new generic firmware object */
 struct sst_fw *sst_fw_new(struct sst_dsp *dsp, 
-- 
2.18.0

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

* Applied "ASoC: Intel: Skylake: BDL definitions should be __le32" to the asoc tree
  2018-07-24 21:12 ` [PATCH 3/6] ASoC: Intel: Skylake: BDL definitions should be __le32 Pierre-Louis Bossart
@ 2018-07-25 16:40   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2018-07-25 16:40 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: tiwai, liam.r.girdwood, alsa-devel, broonie, vkoul

The patch

   ASoC: Intel: Skylake: BDL definitions should be __le32

has been applied to the asoc tree at

   https://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 86efd35ec1e34094914494dacb83077e5df2d1b8 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Tue, 24 Jul 2018 16:12:45 -0500
Subject: [PATCH] ASoC: Intel: Skylake: BDL definitions should be __le32

Make sure definitions are consistent with usage.
Detected with Sparse.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-sst-cldma.c | 8 ++++----
 sound/soc/intel/skylake/skl-sst-cldma.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-sst-cldma.c b/sound/soc/intel/skylake/skl-sst-cldma.c
index d2b1d60fec02..5bc0d38da7e3 100644
--- a/sound/soc/intel/skylake/skl-sst-cldma.c
+++ b/sound/soc/intel/skylake/skl-sst-cldma.c
@@ -83,9 +83,9 @@ static void skl_cldma_stream_clear(struct sst_dsp  *ctx)
 /* Code loader helper APIs */
 static void skl_cldma_setup_bdle(struct sst_dsp *ctx,
 		struct snd_dma_buffer *dmab_data,
-		u32 **bdlp, int size, int with_ioc)
+		__le32 **bdlp, int size, int with_ioc)
 {
-	u32 *bdl = *bdlp;
+	__le32 *bdl = *bdlp;
 
 	ctx->cl_dev.frags = 0;
 	while (size > 0) {
@@ -330,7 +330,7 @@ void skl_cldma_process_intr(struct sst_dsp *ctx)
 int skl_cldma_prepare(struct sst_dsp *ctx)
 {
 	int ret;
-	u32 *bdl;
+	__le32 *bdl;
 
 	ctx->cl_dev.bufsize = SKL_MAX_BUFFER_SIZE;
 
@@ -359,7 +359,7 @@ int skl_cldma_prepare(struct sst_dsp *ctx)
 		ctx->dsp_ops.free_dma_buf(ctx->dev, &ctx->cl_dev.dmab_data);
 		return ret;
 	}
-	bdl = (u32 *)ctx->cl_dev.dmab_bdl.area;
+	bdl = (__le32 *)ctx->cl_dev.dmab_bdl.area;
 
 	/* Allocate BDLs */
 	ctx->cl_dev.ops.cl_setup_bdle(ctx, &ctx->cl_dev.dmab_data,
diff --git a/sound/soc/intel/skylake/skl-sst-cldma.h b/sound/soc/intel/skylake/skl-sst-cldma.h
index 5b730a1a0ae4..ec736921a083 100644
--- a/sound/soc/intel/skylake/skl-sst-cldma.h
+++ b/sound/soc/intel/skylake/skl-sst-cldma.h
@@ -203,7 +203,7 @@ struct sst_dsp;
 struct skl_cl_dev_ops {
 	void (*cl_setup_bdle)(struct sst_dsp *ctx,
 			struct snd_dma_buffer *dmab_data,
-			u32 **bdlp, int size, int with_ioc);
+			__le32 **bdlp, int size, int with_ioc);
 	void (*cl_setup_controller)(struct sst_dsp *ctx,
 			struct snd_dma_buffer *dmab_bdl,
 			unsigned int max_size, u32 page_count);
-- 
2.18.0

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

* Applied "ASoC: Intel: Haswell: fix endianness handling" to the asoc tree
  2018-07-24 21:12 ` [PATCH 2/6] ASoC: Intel: Haswell: fix endianness handling Pierre-Louis Bossart
@ 2018-07-25 16:40   ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2018-07-25 16:40 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: tiwai, liam.r.girdwood, alsa-devel, broonie, vkoul

The patch

   ASoC: Intel: Haswell: fix endianness handling

has been applied to the asoc tree at

   https://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 92beb0a26975c6459794d885d27f48357c1aefd0 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Tue, 24 Jul 2018 16:12:44 -0500
Subject: [PATCH] ASoC: Intel: Haswell: fix endianness handling

Make all Sparse warnings go away by using le16/32_to_cpu.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/haswell/sst-haswell-dsp.c | 53 +++++++++++++----------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/sound/soc/intel/haswell/sst-haswell-dsp.c b/sound/soc/intel/haswell/sst-haswell-dsp.c
index b2bec36d074c..a28220e67cdf 100644
--- a/sound/soc/intel/haswell/sst-haswell-dsp.c
+++ b/sound/soc/intel/haswell/sst-haswell-dsp.c
@@ -93,29 +93,31 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 	struct sst_module_template template;
 	int count, ret;
 	void __iomem *ram;
+	int type = le16_to_cpu(module->type);
+	int entry_point = le32_to_cpu(module->entry_point);
 
 	/* TODO: allowed module types need to be configurable */
-	if (module->type != SST_HSW_MODULE_BASE_FW
-		&& module->type != SST_HSW_MODULE_PCM_SYSTEM
-		&& module->type != SST_HSW_MODULE_PCM
-		&& module->type != SST_HSW_MODULE_PCM_REFERENCE
-		&& module->type != SST_HSW_MODULE_PCM_CAPTURE
-		&& module->type != SST_HSW_MODULE_WAVES
-		&& module->type != SST_HSW_MODULE_LPAL)
+	if (type != SST_HSW_MODULE_BASE_FW &&
+	    type != SST_HSW_MODULE_PCM_SYSTEM &&
+	    type != SST_HSW_MODULE_PCM &&
+	    type != SST_HSW_MODULE_PCM_REFERENCE &&
+	    type != SST_HSW_MODULE_PCM_CAPTURE &&
+	    type != SST_HSW_MODULE_WAVES &&
+	    type != SST_HSW_MODULE_LPAL)
 		return 0;
 
 	dev_dbg(dsp->dev, "new module sign 0x%s size 0x%x blocks 0x%x type 0x%x\n",
 		module->signature, module->mod_size,
-		module->blocks, module->type);
-	dev_dbg(dsp->dev, " entrypoint 0x%x\n", module->entry_point);
+		module->blocks, type);
+	dev_dbg(dsp->dev, " entrypoint 0x%x\n", entry_point);
 	dev_dbg(dsp->dev, " persistent 0x%x scratch 0x%x\n",
 		module->info.persistent_size, module->info.scratch_size);
 
 	memset(&template, 0, sizeof(template));
-	template.id = module->type;
-	template.entry = module->entry_point - 4;
-	template.persistent_size = module->info.persistent_size;
-	template.scratch_size = module->info.scratch_size;
+	template.id = type;
+	template.entry = entry_point - 4;
+	template.persistent_size = le32_to_cpu(module->info.persistent_size);
+	template.scratch_size = le32_to_cpu(module->info.scratch_size);
 
 	mod = sst_module_new(fw, &template, NULL);
 	if (mod == NULL)
@@ -123,26 +125,26 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 
 	block = (void *)module + sizeof(*module);
 
-	for (count = 0; count < module->blocks; count++) {
+	for (count = 0; count < le32_to_cpu(module->blocks); count++) {
 
-		if (block->size <= 0) {
+		if (le32_to_cpu(block->size) <= 0) {
 			dev_err(dsp->dev,
 				"error: block %d size invalid\n", count);
 			sst_module_free(mod);
 			return -EINVAL;
 		}
 
-		switch (block->type) {
+		switch (le32_to_cpu(block->type)) {
 		case SST_HSW_IRAM:
 			ram = dsp->addr.lpe;
-			mod->offset =
-				block->ram_offset + dsp->addr.iram_offset;
+			mod->offset = le32_to_cpu(block->ram_offset) +
+				dsp->addr.iram_offset;
 			mod->type = SST_MEM_IRAM;
 			break;
 		case SST_HSW_DRAM:
 		case SST_HSW_REGS:
 			ram = dsp->addr.lpe;
-			mod->offset = block->ram_offset;
+			mod->offset = le32_to_cpu(block->ram_offset);
 			mod->type = SST_MEM_DRAM;
 			break;
 		default:
@@ -152,7 +154,7 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 			return -EINVAL;
 		}
 
-		mod->size = block->size;
+		mod->size = le32_to_cpu(block->size);
 		mod->data = (void *)block + sizeof(*block);
 		mod->data_offset = mod->data - fw->dma_buf;
 
@@ -169,7 +171,8 @@ static int hsw_parse_module(struct sst_dsp *dsp, struct sst_fw *fw,
 			return ret;
 		}
 
-		block = (void *)block + sizeof(*block) + block->size;
+		block = (void *)block + sizeof(*block) +
+			le32_to_cpu(block->size);
 	}
 	mod->state = SST_MODULE_STATE_LOADED;
 
@@ -188,7 +191,8 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 
 	/* verify FW */
 	if ((strncmp(header->signature, SST_HSW_FW_SIGN, 4) != 0) ||
-		(sst_fw->size != header->file_size + sizeof(*header))) {
+	    (sst_fw->size !=
+	     le32_to_cpu(header->file_size) + sizeof(*header))) {
 		dev_err(dsp->dev, "error: invalid fw sign/filesize mismatch\n");
 		return -EINVAL;
 	}
@@ -199,7 +203,7 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 
 	/* parse each module */
 	module = (void *)sst_fw->dma_buf + sizeof(*header);
-	for (count = 0; count < header->modules; count++) {
+	for (count = 0; count < le32_to_cpu(header->modules); count++) {
 
 		/* module */
 		ret = hsw_parse_module(dsp, sst_fw, module);
@@ -207,7 +211,8 @@ static int hsw_parse_fw_image(struct sst_fw *sst_fw)
 			dev_err(dsp->dev, "error: invalid module %d\n", count);
 			return ret;
 		}
-		module = (void *)module + sizeof(*module) + module->mod_size;
+		module = (void *)module + sizeof(*module) +
+			le32_to_cpu(module->mod_size);
 	}
 
 	return 0;
-- 
2.18.0

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

end of thread, other threads:[~2018-07-25 16:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 21:12 [PATCH 0/6] Fix Sparse warnings on sound/soc/intel Pierre-Louis Bossart
2018-07-24 21:12 ` [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage Pierre-Louis Bossart
2018-07-25  5:34   ` Takashi Iwai
2018-07-25 13:54     ` Pierre-Louis Bossart
2018-07-24 21:12 ` [PATCH 2/6] ASoC: Intel: Haswell: fix endianness handling Pierre-Louis Bossart
2018-07-25 16:40   ` Applied "ASoC: Intel: Haswell: fix endianness handling" to the asoc tree Mark Brown
2018-07-24 21:12 ` [PATCH 3/6] ASoC: Intel: Skylake: BDL definitions should be __le32 Pierre-Louis Bossart
2018-07-25 16:40   ` Applied "ASoC: Intel: Skylake: BDL definitions should be __le32" to the asoc tree Mark Brown
2018-07-24 21:12 ` [PATCH 4/6] ASoC: Intel: common: make sst_dma functions static Pierre-Louis Bossart
2018-07-25 16:40   ` Applied "ASoC: Intel: common: make sst_dma functions static" to the asoc tree Mark Brown
2018-07-24 21:12 ` [PATCH 5/6] ASoC: Intel: Atom: simplify iomem address and casts Pierre-Louis Bossart
2018-07-25 16:40   ` Applied "ASoC: Intel: Atom: simplify iomem address and casts" to the asoc tree Mark Brown
2018-07-24 21:12 ` [PATCH 6/6] ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32 Pierre-Louis Bossart
2018-07-25 16:40   ` Applied "ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32" to the asoc tree Mark Brown

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.