Fix Sparse warnings on sound/soc/intel
Subsystems (3)
cover Fix Sparse warnings on sound/soc/intel
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(-)
Signature · 1 line
2.14.1
PATCH 1/6 ASoC: Intel: boards: cleanup snd_mask_set usage
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.csound/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] valsound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: got restricted snd_pcm_format_t [usertype] <noident>
--- 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(-)
sound/soc/intel/boards/bdw-rt5677.c +1 -1
@@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,/* set SSP0 to 16 bit */ snd_mask_set (¶ms->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 ; }
sound/soc/intel/boards/bxt_da7219_max98357a.c +1 -1
@@ -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 ; }
sound/soc/intel/boards/bxt_rt298.c +1 -1
@@ -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 ; }
sound/soc/intel/boards/glk_rt5682_max98357a.c +1 -1
@@ -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 ; }
sound/soc/intel/boards/kbl_da7219_max98357a.c +1 -1
@@ -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 ; }
sound/soc/intel/boards/kbl_rt5663_max98927.c +4 -2
@@ -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 ; }
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +4 -2
@@ -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 ; }
sound/soc/intel/boards/skl_nau88l25_max98357a.c +1 -1
@@ -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 ; }
sound/soc/intel/boards/skl_nau88l25_ssm4567.c +1 -1
@@ -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 ; }
sound/soc/intel/boards/skl_rt286.c +1 -1
@@ -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 ; }
Signature · 1 line
2.14.1
Re: [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage
Quoted 30 lines · Pierre-Louis Bossart
Sparse reports a ton of warnings when
snd_mask_setis used (see e.g. below). Fix by adding the right typecast with the__forceattribute. 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.csound/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] valsound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: got restrictedsnd_pcm_format_t[usertype] <noident>Signed-off-by Pierre-Louis Bossart <[email protected]>--- 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(-)sound/soc/intel/boards/bdw-rt5677.c +0
-0
sound/soc/intel/boards/bdw-rt5677.c static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, · line 159
Quoted 5 lines
sound/soc/intel/boards/bdw-rt5677.c +1
-1@@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,/* set SSP0 to 16 bit */ snd_mask_set (¶ms->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
Re: [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage
Quoted 27 lines · Takashi Iwai
Quoted 25 lines · Pierre-Louis Bossart
Sparse reports a ton of warnings when
snd_mask_setis used (see e.g. below). Fix by adding the right typecast with the__forceattribute. 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.csound/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] valsound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: got restrictedsnd_pcm_format_t[usertype] <noident>Signed-off-by Pierre-Louis Bossart <[email protected]>--- 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(-)
Quoted 14 lines
sound/soc/intel/boards/bdw-rt5677.c static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, · line 159
Quoted 10 lines
sound/soc/intel/boards/bdw-rt5677.c +1
-1@@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,/* set SSP0 to 16 bit */ snd_mask_set (¶ms->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.
Quoted 12 lines
Will cook up the patch later.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 2/6 ASoC: Intel: Haswell: fix endianness handling
In reply to Pierre-Louis BossartMake all Sparse warnings go away by using le16/32_to_cpu.
--- sound/soc/intel/haswell/sst-haswell-dsp.c | 53 +++++++++++++++++-------------- 1 file changed, 29 insertions(+), 24 deletions(-)
sound/soc/intel/haswell/sst-haswell-dsp.c +29 -24
@@ -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 ;
Signature · 1 line
2.14.1
Mark Brown
maintainerApplied "ASoC: Intel: Haswell: fix endianness handling" to the asoc tree
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
Quoted 1 line
From
92beb0a26975c6459794d885d27f48357c1aefd0Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <[email protected]>
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.
--- sound/soc/intel/haswell/sst-haswell-dsp.c | 53 +++++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-)
sound/soc/intel/haswell/sst-haswell-dsp.c +29 -24
@@ -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 ;
Signature · 1 line
2.18.0
PATCH 3/6 ASoC: Intel: Skylake: BDL definitions should be __le32
In reply to Pierre-Louis BossartMake sure definitions are consistent with usage.
Detected with Sparse.
--- 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(-)
sound/soc/intel/skylake/skl-sst-cldma.c +4 -4
@@ -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,
sound/soc/intel/skylake/skl-sst-cldma.h +1 -1
@@ -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);
Signature · 1 line
2.14.1
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: BDL definitions should be __le32" to the asoc tree
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
Quoted 1 line
From
86efd35ec1e34094914494dacb83077e5df2d1b8Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <[email protected]>
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.
--- 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(-)
sound/soc/intel/skylake/skl-sst-cldma.c +4 -4
@@ -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,
sound/soc/intel/skylake/skl-sst-cldma.h +1 -1
@@ -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);
Signature · 1 line
2.18.0
PATCH 4/6 ASoC: Intel: common: make sst_dma functions static
In reply to Pierre-Louis Bossartsst_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.
--- sound/soc/intel/common/sst-firmware.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/intel/common/sst-firmware.c +2 -4
@@ -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,
Signature · 1 line
2.14.1
Mark Brown
maintainerApplied "ASoC: Intel: common: make sst_dma functions static" to the asoc tree
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
Quoted 1 line
From
ef3cb7423358ff0cadacb76f26e3e1f4da8be4ceMon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <[email protected]>
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.
--- sound/soc/intel/common/sst-firmware.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/intel/common/sst-firmware.c +2 -4
@@ -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,
Signature · 1 line
2.18.0
PATCH 5/6 ASoC: Intel: Atom: simplify iomem address and casts
In reply to Pierre-Louis BossartSimplify code and add relevant casts to make Sparse warnings go away
--- sound/soc/intel/atom/sst/sst_drv_interface.c | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
sound/soc/intel/atom/sst/sst_drv_interface.c +15 -14
@@ -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); }
Signature · 1 line
2.14.1
Mark Brown
maintainerApplied "ASoC: Intel: Atom: simplify iomem address and casts" to the asoc tree
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
Quoted 1 line
From
ce1cfe295abaa7436f9049bcb2562c843089abfcMon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <[email protected]>
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
--- sound/soc/intel/atom/sst/sst_drv_interface.c | 29 ++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-)
sound/soc/intel/atom/sst/sst_drv_interface.c +15 -14
@@ -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); }
Signature · 1 line
2.18.0
PATCH 6/6 ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32
In reply to Pierre-Louis BossartThis 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.
--- sound/soc/intel/atom/sst/sst_loader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/atom/sst/sst_loader.c +3 -3
@@ -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 ); }/**
Signature · 1 line
2.14.1
Mark Brown
maintainerApplied "ASoC: Intel: Atom: fix inversion between __iowrite32 and __ioread32" to the asoc tree
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
Quoted 1 line
From
9a0daaab31e9e39047ced79409313c34dae4635aMon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <[email protected]>
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.
--- sound/soc/intel/atom/sst/sst_loader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/atom/sst/sst_loader.c +3 -3
@@ -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 ); }/**
Signature · 1 line
2.18.0