2020-10-22 15:29:41

by kernel test robot

[permalink] [raw]
Subject: sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f804b3159482eedbb4250b1e9248c308fb63b805
commit: 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1 ASoC: Intel: Select catpt and deprecate haswell
date: 3 weeks ago
config: i386-randconfig-s002-20201022 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


"sparse warnings: (new ones prefixed by >>)"
>> sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer
sound/soc/intel/catpt/dsp.c:372:9: sparse: sparse: restricted pci_power_t degrades to integer
sound/soc/intel/catpt/dsp.c:423:9: sparse: sparse: restricted pci_power_t degrades to integer
sound/soc/intel/catpt/dsp.c:447:9: sparse: sparse: restricted pci_power_t degrades to integer

vim +359 sound/soc/intel/catpt/dsp.c

ba202a7bc3da05 Cezary Rojewski 2020-09-29 343
ba202a7bc3da05 Cezary Rojewski 2020-09-29 344 int lpt_dsp_power_down(struct catpt_dev *cdev)
ba202a7bc3da05 Cezary Rojewski 2020-09-29 345 {
ba202a7bc3da05 Cezary Rojewski 2020-09-29 346 catpt_dsp_reset(cdev, true);
ba202a7bc3da05 Cezary Rojewski 2020-09-29 347
ba202a7bc3da05 Cezary Rojewski 2020-09-29 348 /* set 24Mhz clock for both SSPs */
ba202a7bc3da05 Cezary Rojewski 2020-09-29 349 catpt_updatel_shim(cdev, CS1, CATPT_CS_SBCS(0) | CATPT_CS_SBCS(1),
ba202a7bc3da05 Cezary Rojewski 2020-09-29 350 CATPT_CS_SBCS(0) | CATPT_CS_SBCS(1));
ba202a7bc3da05 Cezary Rojewski 2020-09-29 351 catpt_dsp_select_lpclock(cdev, true, false);
ba202a7bc3da05 Cezary Rojewski 2020-09-29 352
ba202a7bc3da05 Cezary Rojewski 2020-09-29 353 /* DRAM power gating all */
ba202a7bc3da05 Cezary Rojewski 2020-09-29 354 catpt_dsp_set_srampge(cdev, &cdev->dram, cdev->spec->dram_mask,
ba202a7bc3da05 Cezary Rojewski 2020-09-29 355 cdev->spec->dram_mask);
ba202a7bc3da05 Cezary Rojewski 2020-09-29 356 catpt_dsp_set_srampge(cdev, &cdev->iram, cdev->spec->iram_mask,
ba202a7bc3da05 Cezary Rojewski 2020-09-29 357 cdev->spec->iram_mask);
ba202a7bc3da05 Cezary Rojewski 2020-09-29 358
ba202a7bc3da05 Cezary Rojewski 2020-09-29 @359 catpt_updatel_pci(cdev, PMCS, PCI_PM_CTRL_STATE_MASK, PCI_D3hot);
ba202a7bc3da05 Cezary Rojewski 2020-09-29 360 /* give hw time to drop off */
ba202a7bc3da05 Cezary Rojewski 2020-09-29 361 udelay(50);
ba202a7bc3da05 Cezary Rojewski 2020-09-29 362
ba202a7bc3da05 Cezary Rojewski 2020-09-29 363 return 0;
ba202a7bc3da05 Cezary Rojewski 2020-09-29 364 }
ba202a7bc3da05 Cezary Rojewski 2020-09-29 365

:::::: The code at line 359 was first introduced by commit
:::::: ba202a7bc3da05ca4548c7247f9be769b4e8c9fa ASoC: Intel: catpt: Define DSP operations

:::::: TO: Cezary Rojewski <[email protected]>
:::::: CC: Mark Brown <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (3.55 kB)
.config.gz (35.44 kB)
Download all attachments

2020-10-22 17:31:33

by Andy Shevchenko

[permalink] [raw]
Subject: Re: sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer

+Cc: Bjorn

On Thu, Oct 22, 2020 at 03:25:49PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: f804b3159482eedbb4250b1e9248c308fb63b805
> commit: 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1 ASoC: Intel: Select catpt and deprecate haswell
> date: 3 weeks ago
> config: i386-randconfig-s002-20201022 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.3-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
>
> "sparse warnings: (new ones prefixed by >>)"
> >> sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer
> sound/soc/intel/catpt/dsp.c:372:9: sparse: sparse: restricted pci_power_t degrades to integer
> sound/soc/intel/catpt/dsp.c:423:9: sparse: sparse: restricted pci_power_t degrades to integer
> sound/soc/intel/catpt/dsp.c:447:9: sparse: sparse: restricted pci_power_t degrades to integer

I dunno who and why created that specific bitwise type. I met not the first
time the same Sparse complain.

In some places I have fixed that by forcing the lvalue type, i.e.

(__force int)PCI_D3hot

or so.

Also there are two other approaches
- leave as is (ignore this warning)
- create a helper that will convert PCI power type to an integer, like

switch (pci_pwr) {
default:
return -EINVAL;
case PCI_D3hot:
return 3;
...
}

But I consider the second one is a bit silly. Dunno if PCI core has this already.

--
With Best Regards,
Andy Shevchenko


2020-10-22 17:42:40

by Cezary Rojewski

[permalink] [raw]
Subject: RE: sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer

On 2020-10-22 4:09 PM, Bjorn Helgaas wrote:
> On Thu, Oct 22, 2020 at 04:52:29PM +0300, Andy Shevchenko wrote:
>> +Cc: Bjorn
>>
>> On Thu, Oct 22, 2020 at 03:25:49PM +0800, kernel test robot wrote:
>>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>>> head: f804b3159482eedbb4250b1e9248c308fb63b805
>>> commit: 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1 ASoC: Intel: Select catpt and deprecate haswell
>>> date: 3 weeks ago
>>> config: i386-randconfig-s002-20201022 (attached as .config)
>>> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
>>> reproduce:
>>> # apt-get install sparse
>>> # sparse version: v0.6.3-dirty
>>> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
>>> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>> git fetch --no-tags linus master
>>> git checkout 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
>>> # save the attached .config to linux build tree
>>> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
>>>
>>> If you fix the issue, kindly add following tag as appropriate
>>> Reported-by: kernel test robot <[email protected]>
>>>
>>>
>>> "sparse warnings: (new ones prefixed by >>)"
>>>>> sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer
>>> sound/soc/intel/catpt/dsp.c:372:9: sparse: sparse: restricted pci_power_t degrades to integer
>>> sound/soc/intel/catpt/dsp.c:423:9: sparse: sparse: restricted pci_power_t degrades to integer
>>> sound/soc/intel/catpt/dsp.c:447:9: sparse: sparse: restricted pci_power_t degrades to integer
>>
>> I dunno who and why created that specific bitwise type. I met not the first
>> time the same Sparse complain.
>
> Thanks for the cc. Yeah, I hate that too. It's one of the few
> remaining warnings in drivers/pci/. It's my goal to eradicate it for
> v5.11.
>

I've ignored that warning when upstreaming catpt ASoC driver as I
believe code is more readable when constants are not prepended with
explicit cast in this very case.

Should the warning be ignored (leave code as is) -or- do you want me to
prepend all PCI_Dx usages with explicit cast regardless of my initial
intentions?

Regards,
Czarek

2020-10-22 22:28:57

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer

On Thu, Oct 22, 2020 at 04:52:29PM +0300, Andy Shevchenko wrote:
> +Cc: Bjorn
>
> On Thu, Oct 22, 2020 at 03:25:49PM +0800, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: f804b3159482eedbb4250b1e9248c308fb63b805
> > commit: 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1 ASoC: Intel: Select catpt and deprecate haswell
> > date: 3 weeks ago
> > config: i386-randconfig-s002-20201022 (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> > reproduce:
> > # apt-get install sparse
> > # sparse version: v0.6.3-dirty
> > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
> > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > git fetch --no-tags linus master
> > git checkout 6cbfa11d2694b8a1e46d6834fb9705d5589e3ef1
> > # save the attached .config to linux build tree
> > make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <[email protected]>
> >
> >
> > "sparse warnings: (new ones prefixed by >>)"
> > >> sound/soc/intel/catpt/dsp.c:359:9: sparse: sparse: restricted pci_power_t degrades to integer
> > sound/soc/intel/catpt/dsp.c:372:9: sparse: sparse: restricted pci_power_t degrades to integer
> > sound/soc/intel/catpt/dsp.c:423:9: sparse: sparse: restricted pci_power_t degrades to integer
> > sound/soc/intel/catpt/dsp.c:447:9: sparse: sparse: restricted pci_power_t degrades to integer
>
> I dunno who and why created that specific bitwise type. I met not the first
> time the same Sparse complain.

Thanks for the cc. Yeah, I hate that too. It's one of the few
remaining warnings in drivers/pci/. It's my goal to eradicate it for
v5.11.