linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [linux-next:master 9708/11791] sound/virtio/virtio_pcm.c:33:42: sparse: sparse: incorrect type in initializer (different base types)
@ 2021-02-19 12:02 kernel test robot
  2021-02-21 11:50 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2021-02-19 12:02 UTC (permalink / raw)
  To: Anton Yakovlev
  Cc: kbuild-all, Linux Memory Management List, Michael S. Tsirkin

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   ff90dfd2579b2c7bc1f0baa0cb99c918c6c1ec64
commit: 55ab6828ef9338c3c5aa99472db713cd1e3b4858 [9708/11791] ALSA: virtio: build PCM devices and substream hardware descriptors
config: microblaze-randconfig-s031-20210219 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-229-g60c1f270-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=55ab6828ef9338c3c5aa99472db713cd1e3b4858
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout 55ab6828ef9338c3c5aa99472db713cd1e3b4858
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=microblaze 

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


"sparse warnings: (new ones prefixed by >>)"
>> sound/virtio/virtio_pcm.c:33:42: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:33:42: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:33:42: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:34:39: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:34:39: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:34:39: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:35:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:35:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:35:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:36:35: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:36:35: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:36:35: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:37:35: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:37:35: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:37:35: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:38:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:38:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:38:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:39:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:39:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:39:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:40:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:40:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:40:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:41:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:41:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:41:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:42:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:42:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:42:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:43:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:43:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:43:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:44:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:44:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:44:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:45:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:45:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:45:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:46:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:46:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:46:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:47:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:47:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:47:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:48:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:48:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:48:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:49:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:49:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:49:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:50:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:50:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:50:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:51:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:51:36: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:51:36: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:52:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:52:38: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:52:38: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:53:40: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:53:40: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:53:40: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:54:39: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:54:39: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:54:39: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:55:40: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:55:40: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:55:40: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:56:40: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:56:40: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:56:40: sparse:     got restricted snd_pcm_format_t [usertype]
   sound/virtio/virtio_pcm.c:58:17: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
   sound/virtio/virtio_pcm.c:58:17: sparse:     expected unsigned int
   sound/virtio/virtio_pcm.c:58:17: sparse:     got restricted snd_pcm_format_t [usertype]
>> sound/virtio/virtio_pcm.c:131:67: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected restricted snd_pcm_format_t [usertype] format @@     got unsigned int alsa_fmt @@
   sound/virtio/virtio_pcm.c:131:67: sparse:     expected restricted snd_pcm_format_t [usertype] format
   sound/virtio/virtio_pcm.c:131:67: sparse:     got unsigned int alsa_fmt
>> sound/virtio/virtio_pcm.c:316:9: sparse: sparse: no generic selection for 'restricted __le32 virtio_cread_v'
>> sound/virtio/virtio_pcm.c:316:9: sparse: sparse: incompatible types in comparison expression (different base types):
>> sound/virtio/virtio_pcm.c:316:9: sparse:    bad type *
>> sound/virtio/virtio_pcm.c:316:9: sparse:    unsigned int *
>> sound/virtio/virtio_pcm.c:316:9: sparse: sparse: no generic selection for 'restricted __le32 [addressable] virtio_cread_v'

vim +33 sound/virtio/virtio_pcm.c

    30	
    31	/* Map for converting VirtIO format to ALSA format. */
    32	static const unsigned int g_v2a_format_map[] = {
  > 33		[VIRTIO_SND_PCM_FMT_IMA_ADPCM] = SNDRV_PCM_FORMAT_IMA_ADPCM,
    34		[VIRTIO_SND_PCM_FMT_MU_LAW] = SNDRV_PCM_FORMAT_MU_LAW,
    35		[VIRTIO_SND_PCM_FMT_A_LAW] = SNDRV_PCM_FORMAT_A_LAW,
    36		[VIRTIO_SND_PCM_FMT_S8] = SNDRV_PCM_FORMAT_S8,
    37		[VIRTIO_SND_PCM_FMT_U8] = SNDRV_PCM_FORMAT_U8,
    38		[VIRTIO_SND_PCM_FMT_S16] = SNDRV_PCM_FORMAT_S16_LE,
    39		[VIRTIO_SND_PCM_FMT_U16] = SNDRV_PCM_FORMAT_U16_LE,
    40		[VIRTIO_SND_PCM_FMT_S18_3] = SNDRV_PCM_FORMAT_S18_3LE,
    41		[VIRTIO_SND_PCM_FMT_U18_3] = SNDRV_PCM_FORMAT_U18_3LE,
    42		[VIRTIO_SND_PCM_FMT_S20_3] = SNDRV_PCM_FORMAT_S20_3LE,
    43		[VIRTIO_SND_PCM_FMT_U20_3] = SNDRV_PCM_FORMAT_U20_3LE,
    44		[VIRTIO_SND_PCM_FMT_S24_3] = SNDRV_PCM_FORMAT_S24_3LE,
    45		[VIRTIO_SND_PCM_FMT_U24_3] = SNDRV_PCM_FORMAT_U24_3LE,
    46		[VIRTIO_SND_PCM_FMT_S20] = SNDRV_PCM_FORMAT_S20_LE,
    47		[VIRTIO_SND_PCM_FMT_U20] = SNDRV_PCM_FORMAT_U20_LE,
    48		[VIRTIO_SND_PCM_FMT_S24] = SNDRV_PCM_FORMAT_S24_LE,
    49		[VIRTIO_SND_PCM_FMT_U24] = SNDRV_PCM_FORMAT_U24_LE,
    50		[VIRTIO_SND_PCM_FMT_S32] = SNDRV_PCM_FORMAT_S32_LE,
    51		[VIRTIO_SND_PCM_FMT_U32] = SNDRV_PCM_FORMAT_U32_LE,
    52		[VIRTIO_SND_PCM_FMT_FLOAT] = SNDRV_PCM_FORMAT_FLOAT_LE,
    53		[VIRTIO_SND_PCM_FMT_FLOAT64] = SNDRV_PCM_FORMAT_FLOAT64_LE,
    54		[VIRTIO_SND_PCM_FMT_DSD_U8] = SNDRV_PCM_FORMAT_DSD_U8,
    55		[VIRTIO_SND_PCM_FMT_DSD_U16] = SNDRV_PCM_FORMAT_DSD_U16_LE,
    56		[VIRTIO_SND_PCM_FMT_DSD_U32] = SNDRV_PCM_FORMAT_DSD_U32_LE,
    57		[VIRTIO_SND_PCM_FMT_IEC958_SUBFRAME] =
    58			SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
    59	};
    60	
    61	/* Map for converting VirtIO frame rate to ALSA frame rate. */
    62	struct virtsnd_v2a_rate {
    63		unsigned int alsa_bit;
    64		unsigned int rate;
    65	};
    66	
    67	static const struct virtsnd_v2a_rate g_v2a_rate_map[] = {
    68		[VIRTIO_SND_PCM_RATE_5512] = { SNDRV_PCM_RATE_5512, 5512 },
    69		[VIRTIO_SND_PCM_RATE_8000] = { SNDRV_PCM_RATE_8000, 8000 },
    70		[VIRTIO_SND_PCM_RATE_11025] = { SNDRV_PCM_RATE_11025, 11025 },
    71		[VIRTIO_SND_PCM_RATE_16000] = { SNDRV_PCM_RATE_16000, 16000 },
    72		[VIRTIO_SND_PCM_RATE_22050] = { SNDRV_PCM_RATE_22050, 22050 },
    73		[VIRTIO_SND_PCM_RATE_32000] = { SNDRV_PCM_RATE_32000, 32000 },
    74		[VIRTIO_SND_PCM_RATE_44100] = { SNDRV_PCM_RATE_44100, 44100 },
    75		[VIRTIO_SND_PCM_RATE_48000] = { SNDRV_PCM_RATE_48000, 48000 },
    76		[VIRTIO_SND_PCM_RATE_64000] = { SNDRV_PCM_RATE_64000, 64000 },
    77		[VIRTIO_SND_PCM_RATE_88200] = { SNDRV_PCM_RATE_88200, 88200 },
    78		[VIRTIO_SND_PCM_RATE_96000] = { SNDRV_PCM_RATE_96000, 96000 },
    79		[VIRTIO_SND_PCM_RATE_176400] = { SNDRV_PCM_RATE_176400, 176400 },
    80		[VIRTIO_SND_PCM_RATE_192000] = { SNDRV_PCM_RATE_192000, 192000 }
    81	};
    82	
    83	/**
    84	 * virtsnd_pcm_build_hw() - Parse substream config and build HW descriptor.
    85	 * @vss: VirtIO substream.
    86	 * @info: VirtIO substream information entry.
    87	 *
    88	 * Context: Any context.
    89	 * Return: 0 on success, -EINVAL if configuration is invalid.
    90	 */
    91	static int virtsnd_pcm_build_hw(struct virtio_pcm_substream *vss,
    92					struct virtio_snd_pcm_info *info)
    93	{
    94		struct virtio_device *vdev = vss->snd->vdev;
    95		unsigned int i;
    96		u64 values;
    97		size_t sample_max = 0;
    98		size_t sample_min = 0;
    99	
   100		vss->features = le32_to_cpu(info->features);
   101	
   102		/*
   103		 * TODO: set SNDRV_PCM_INFO_{BATCH,BLOCK_TRANSFER} if device supports
   104		 * only message-based transport.
   105		 */
   106		vss->hw.info =
   107			SNDRV_PCM_INFO_MMAP |
   108			SNDRV_PCM_INFO_MMAP_VALID |
   109			SNDRV_PCM_INFO_BATCH |
   110			SNDRV_PCM_INFO_BLOCK_TRANSFER |
   111			SNDRV_PCM_INFO_INTERLEAVED |
   112			SNDRV_PCM_INFO_PAUSE;
   113	
   114		if (!info->channels_min || info->channels_min > info->channels_max) {
   115			dev_err(&vdev->dev,
   116				"SID %u: invalid channel range [%u %u]\n",
   117				vss->sid, info->channels_min, info->channels_max);
   118			return -EINVAL;
   119		}
   120	
   121		vss->hw.channels_min = info->channels_min;
   122		vss->hw.channels_max = info->channels_max;
   123	
   124		values = le64_to_cpu(info->formats);
   125	
   126		vss->hw.formats = 0;
   127	
   128		for (i = 0; i < ARRAY_SIZE(g_v2a_format_map); ++i)
   129			if (values & (1ULL << i)) {
   130				unsigned int alsa_fmt = g_v2a_format_map[i];
 > 131				int bytes = snd_pcm_format_physical_width(alsa_fmt) / 8;
   132	
   133				if (!sample_min || sample_min > bytes)
   134					sample_min = bytes;
   135	
   136				if (sample_max < bytes)
   137					sample_max = bytes;
   138	
   139				vss->hw.formats |= (1ULL << alsa_fmt);
   140			}
   141	
   142		if (!vss->hw.formats) {
   143			dev_err(&vdev->dev,
   144				"SID %u: no supported PCM sample formats found\n",
   145				vss->sid);
   146			return -EINVAL;
   147		}
   148	
   149		values = le64_to_cpu(info->rates);
   150	
   151		vss->hw.rates = 0;
   152	
   153		for (i = 0; i < ARRAY_SIZE(g_v2a_rate_map); ++i)
   154			if (values & (1ULL << i)) {
   155				if (!vss->hw.rate_min ||
   156				    vss->hw.rate_min > g_v2a_rate_map[i].rate)
   157					vss->hw.rate_min = g_v2a_rate_map[i].rate;
   158	
   159				if (vss->hw.rate_max < g_v2a_rate_map[i].rate)
   160					vss->hw.rate_max = g_v2a_rate_map[i].rate;
   161	
   162				vss->hw.rates |= g_v2a_rate_map[i].alsa_bit;
   163			}
   164	
   165		if (!vss->hw.rates) {
   166			dev_err(&vdev->dev,
   167				"SID %u: no supported PCM frame rates found\n",
   168				vss->sid);
   169			return -EINVAL;
   170		}
   171	
   172		vss->hw.periods_min = pcm_periods_min;
   173		vss->hw.periods_max = pcm_periods_max;
   174	
   175		/*
   176		 * We must ensure that there is enough space in the buffer to store
   177		 * pcm_buffer_ms ms for the combination (Cmax, Smax, Rmax), where:
   178		 *   Cmax = maximum supported number of channels,
   179		 *   Smax = maximum supported sample size in bytes,
   180		 *   Rmax = maximum supported frame rate.
   181		 */
   182		vss->hw.buffer_bytes_max =
   183			sample_max * vss->hw.channels_max * pcm_buffer_ms *
   184			(vss->hw.rate_max / MSEC_PER_SEC);
   185	
   186		/* Align the buffer size to the page size */
   187		vss->hw.buffer_bytes_max =
   188			(vss->hw.buffer_bytes_max + PAGE_SIZE - 1) & -PAGE_SIZE;
   189	
   190		/*
   191		 * We must ensure that the minimum period size is enough to store
   192		 * pcm_period_ms_min ms for the combination (Cmin, Smin, Rmin), where:
   193		 *   Cmin = minimum supported number of channels,
   194		 *   Smin = minimum supported sample size in bytes,
   195		 *   Rmin = minimum supported frame rate.
   196		 */
   197		vss->hw.period_bytes_min =
   198			sample_min * vss->hw.channels_min * pcm_period_ms_min *
   199			(vss->hw.rate_min / MSEC_PER_SEC);
   200	
   201		/*
   202		 * We must ensure that the maximum period size is enough to store
   203		 * pcm_period_ms_max ms for the combination (Cmax, Smax, Rmax).
   204		 */
   205		vss->hw.period_bytes_max =
   206			sample_max * vss->hw.channels_max * pcm_period_ms_max *
   207			(vss->hw.rate_max / MSEC_PER_SEC);
   208	
   209		return 0;
   210	}
   211	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30463 bytes --]

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

* Re: [linux-next:master 9708/11791] sound/virtio/virtio_pcm.c:33:42: sparse: sparse: incorrect type in initializer (different base types)
  2021-02-19 12:02 [linux-next:master 9708/11791] sound/virtio/virtio_pcm.c:33:42: sparse: sparse: incorrect type in initializer (different base types) kernel test robot
@ 2021-02-21 11:50 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2021-02-21 11:50 UTC (permalink / raw)
  To: kernel test robot
  Cc: Anton Yakovlev, kbuild-all, Linux Memory Management List

On Fri, Feb 19, 2021 at 08:02:01PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   ff90dfd2579b2c7bc1f0baa0cb99c918c6c1ec64
> commit: 55ab6828ef9338c3c5aa99472db713cd1e3b4858 [9708/11791] ALSA: virtio: build PCM devices and substream hardware descriptors
> config: microblaze-randconfig-s031-20210219 (attached as .config)
> compiler: microblaze-linux-gcc (GCC) 9.3.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # apt-get install sparse
>         # sparse version: v0.6.3-229-g60c1f270-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=55ab6828ef9338c3c5aa99472db713cd1e3b4858
>         git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>         git fetch --no-tags linux-next master
>         git checkout 55ab6828ef9338c3c5aa99472db713cd1e3b4858
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=microblaze 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>


Anton can you comment please? I'm holding back the pull request for now
but I can't merge a driver that triggers sparse warnings, sparse is
too useful a tool.


> 
> "sparse warnings: (new ones prefixed by >>)"
> >> sound/virtio/virtio_pcm.c:33:42: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:33:42: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:33:42: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:34:39: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:34:39: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:34:39: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:35:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:35:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:35:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:36:35: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:36:35: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:36:35: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:37:35: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:37:35: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:37:35: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:38:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:38:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:38:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:39:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:39:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:39:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:40:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:40:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:40:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:41:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:41:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:41:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:42:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:42:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:42:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:43:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:43:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:43:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:44:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:44:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:44:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:45:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:45:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:45:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:46:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:46:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:46:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:47:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:47:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:47:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:48:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:48:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:48:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:49:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:49:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:49:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:50:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:50:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:50:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:51:36: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:51:36: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:51:36: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:52:38: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:52:38: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:52:38: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:53:40: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:53:40: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:53:40: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:54:39: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:54:39: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:54:39: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:55:40: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:55:40: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:55:40: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:56:40: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:56:40: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:56:40: sparse:     got restricted snd_pcm_format_t [usertype]
>    sound/virtio/virtio_pcm.c:58:17: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned int @@     got restricted snd_pcm_format_t [usertype] @@
>    sound/virtio/virtio_pcm.c:58:17: sparse:     expected unsigned int
>    sound/virtio/virtio_pcm.c:58:17: sparse:     got restricted snd_pcm_format_t [usertype]
> >> sound/virtio/virtio_pcm.c:131:67: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected restricted snd_pcm_format_t [usertype] format @@     got unsigned int alsa_fmt @@
>    sound/virtio/virtio_pcm.c:131:67: sparse:     expected restricted snd_pcm_format_t [usertype] format
>    sound/virtio/virtio_pcm.c:131:67: sparse:     got unsigned int alsa_fmt
> >> sound/virtio/virtio_pcm.c:316:9: sparse: sparse: no generic selection for 'restricted __le32 virtio_cread_v'
> >> sound/virtio/virtio_pcm.c:316:9: sparse: sparse: incompatible types in comparison expression (different base types):
> >> sound/virtio/virtio_pcm.c:316:9: sparse:    bad type *
> >> sound/virtio/virtio_pcm.c:316:9: sparse:    unsigned int *
> >> sound/virtio/virtio_pcm.c:316:9: sparse: sparse: no generic selection for 'restricted __le32 [addressable] virtio_cread_v'
> 
> vim +33 sound/virtio/virtio_pcm.c
> 
>     30	
>     31	/* Map for converting VirtIO format to ALSA format. */
>     32	static const unsigned int g_v2a_format_map[] = {
>   > 33		[VIRTIO_SND_PCM_FMT_IMA_ADPCM] = SNDRV_PCM_FORMAT_IMA_ADPCM,
>     34		[VIRTIO_SND_PCM_FMT_MU_LAW] = SNDRV_PCM_FORMAT_MU_LAW,
>     35		[VIRTIO_SND_PCM_FMT_A_LAW] = SNDRV_PCM_FORMAT_A_LAW,
>     36		[VIRTIO_SND_PCM_FMT_S8] = SNDRV_PCM_FORMAT_S8,
>     37		[VIRTIO_SND_PCM_FMT_U8] = SNDRV_PCM_FORMAT_U8,
>     38		[VIRTIO_SND_PCM_FMT_S16] = SNDRV_PCM_FORMAT_S16_LE,
>     39		[VIRTIO_SND_PCM_FMT_U16] = SNDRV_PCM_FORMAT_U16_LE,
>     40		[VIRTIO_SND_PCM_FMT_S18_3] = SNDRV_PCM_FORMAT_S18_3LE,
>     41		[VIRTIO_SND_PCM_FMT_U18_3] = SNDRV_PCM_FORMAT_U18_3LE,
>     42		[VIRTIO_SND_PCM_FMT_S20_3] = SNDRV_PCM_FORMAT_S20_3LE,
>     43		[VIRTIO_SND_PCM_FMT_U20_3] = SNDRV_PCM_FORMAT_U20_3LE,
>     44		[VIRTIO_SND_PCM_FMT_S24_3] = SNDRV_PCM_FORMAT_S24_3LE,
>     45		[VIRTIO_SND_PCM_FMT_U24_3] = SNDRV_PCM_FORMAT_U24_3LE,
>     46		[VIRTIO_SND_PCM_FMT_S20] = SNDRV_PCM_FORMAT_S20_LE,
>     47		[VIRTIO_SND_PCM_FMT_U20] = SNDRV_PCM_FORMAT_U20_LE,
>     48		[VIRTIO_SND_PCM_FMT_S24] = SNDRV_PCM_FORMAT_S24_LE,
>     49		[VIRTIO_SND_PCM_FMT_U24] = SNDRV_PCM_FORMAT_U24_LE,
>     50		[VIRTIO_SND_PCM_FMT_S32] = SNDRV_PCM_FORMAT_S32_LE,
>     51		[VIRTIO_SND_PCM_FMT_U32] = SNDRV_PCM_FORMAT_U32_LE,
>     52		[VIRTIO_SND_PCM_FMT_FLOAT] = SNDRV_PCM_FORMAT_FLOAT_LE,
>     53		[VIRTIO_SND_PCM_FMT_FLOAT64] = SNDRV_PCM_FORMAT_FLOAT64_LE,
>     54		[VIRTIO_SND_PCM_FMT_DSD_U8] = SNDRV_PCM_FORMAT_DSD_U8,
>     55		[VIRTIO_SND_PCM_FMT_DSD_U16] = SNDRV_PCM_FORMAT_DSD_U16_LE,
>     56		[VIRTIO_SND_PCM_FMT_DSD_U32] = SNDRV_PCM_FORMAT_DSD_U32_LE,
>     57		[VIRTIO_SND_PCM_FMT_IEC958_SUBFRAME] =
>     58			SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
>     59	};
>     60	
>     61	/* Map for converting VirtIO frame rate to ALSA frame rate. */
>     62	struct virtsnd_v2a_rate {
>     63		unsigned int alsa_bit;
>     64		unsigned int rate;
>     65	};
>     66	
>     67	static const struct virtsnd_v2a_rate g_v2a_rate_map[] = {
>     68		[VIRTIO_SND_PCM_RATE_5512] = { SNDRV_PCM_RATE_5512, 5512 },
>     69		[VIRTIO_SND_PCM_RATE_8000] = { SNDRV_PCM_RATE_8000, 8000 },
>     70		[VIRTIO_SND_PCM_RATE_11025] = { SNDRV_PCM_RATE_11025, 11025 },
>     71		[VIRTIO_SND_PCM_RATE_16000] = { SNDRV_PCM_RATE_16000, 16000 },
>     72		[VIRTIO_SND_PCM_RATE_22050] = { SNDRV_PCM_RATE_22050, 22050 },
>     73		[VIRTIO_SND_PCM_RATE_32000] = { SNDRV_PCM_RATE_32000, 32000 },
>     74		[VIRTIO_SND_PCM_RATE_44100] = { SNDRV_PCM_RATE_44100, 44100 },
>     75		[VIRTIO_SND_PCM_RATE_48000] = { SNDRV_PCM_RATE_48000, 48000 },
>     76		[VIRTIO_SND_PCM_RATE_64000] = { SNDRV_PCM_RATE_64000, 64000 },
>     77		[VIRTIO_SND_PCM_RATE_88200] = { SNDRV_PCM_RATE_88200, 88200 },
>     78		[VIRTIO_SND_PCM_RATE_96000] = { SNDRV_PCM_RATE_96000, 96000 },
>     79		[VIRTIO_SND_PCM_RATE_176400] = { SNDRV_PCM_RATE_176400, 176400 },
>     80		[VIRTIO_SND_PCM_RATE_192000] = { SNDRV_PCM_RATE_192000, 192000 }
>     81	};
>     82	
>     83	/**
>     84	 * virtsnd_pcm_build_hw() - Parse substream config and build HW descriptor.
>     85	 * @vss: VirtIO substream.
>     86	 * @info: VirtIO substream information entry.
>     87	 *
>     88	 * Context: Any context.
>     89	 * Return: 0 on success, -EINVAL if configuration is invalid.
>     90	 */
>     91	static int virtsnd_pcm_build_hw(struct virtio_pcm_substream *vss,
>     92					struct virtio_snd_pcm_info *info)
>     93	{
>     94		struct virtio_device *vdev = vss->snd->vdev;
>     95		unsigned int i;
>     96		u64 values;
>     97		size_t sample_max = 0;
>     98		size_t sample_min = 0;
>     99	
>    100		vss->features = le32_to_cpu(info->features);
>    101	
>    102		/*
>    103		 * TODO: set SNDRV_PCM_INFO_{BATCH,BLOCK_TRANSFER} if device supports
>    104		 * only message-based transport.
>    105		 */
>    106		vss->hw.info =
>    107			SNDRV_PCM_INFO_MMAP |
>    108			SNDRV_PCM_INFO_MMAP_VALID |
>    109			SNDRV_PCM_INFO_BATCH |
>    110			SNDRV_PCM_INFO_BLOCK_TRANSFER |
>    111			SNDRV_PCM_INFO_INTERLEAVED |
>    112			SNDRV_PCM_INFO_PAUSE;
>    113	
>    114		if (!info->channels_min || info->channels_min > info->channels_max) {
>    115			dev_err(&vdev->dev,
>    116				"SID %u: invalid channel range [%u %u]\n",
>    117				vss->sid, info->channels_min, info->channels_max);
>    118			return -EINVAL;
>    119		}
>    120	
>    121		vss->hw.channels_min = info->channels_min;
>    122		vss->hw.channels_max = info->channels_max;
>    123	
>    124		values = le64_to_cpu(info->formats);
>    125	
>    126		vss->hw.formats = 0;
>    127	
>    128		for (i = 0; i < ARRAY_SIZE(g_v2a_format_map); ++i)
>    129			if (values & (1ULL << i)) {
>    130				unsigned int alsa_fmt = g_v2a_format_map[i];
>  > 131				int bytes = snd_pcm_format_physical_width(alsa_fmt) / 8;
>    132	
>    133				if (!sample_min || sample_min > bytes)
>    134					sample_min = bytes;
>    135	
>    136				if (sample_max < bytes)
>    137					sample_max = bytes;
>    138	
>    139				vss->hw.formats |= (1ULL << alsa_fmt);
>    140			}
>    141	
>    142		if (!vss->hw.formats) {
>    143			dev_err(&vdev->dev,
>    144				"SID %u: no supported PCM sample formats found\n",
>    145				vss->sid);
>    146			return -EINVAL;
>    147		}
>    148	
>    149		values = le64_to_cpu(info->rates);
>    150	
>    151		vss->hw.rates = 0;
>    152	
>    153		for (i = 0; i < ARRAY_SIZE(g_v2a_rate_map); ++i)
>    154			if (values & (1ULL << i)) {
>    155				if (!vss->hw.rate_min ||
>    156				    vss->hw.rate_min > g_v2a_rate_map[i].rate)
>    157					vss->hw.rate_min = g_v2a_rate_map[i].rate;
>    158	
>    159				if (vss->hw.rate_max < g_v2a_rate_map[i].rate)
>    160					vss->hw.rate_max = g_v2a_rate_map[i].rate;
>    161	
>    162				vss->hw.rates |= g_v2a_rate_map[i].alsa_bit;
>    163			}
>    164	
>    165		if (!vss->hw.rates) {
>    166			dev_err(&vdev->dev,
>    167				"SID %u: no supported PCM frame rates found\n",
>    168				vss->sid);
>    169			return -EINVAL;
>    170		}
>    171	
>    172		vss->hw.periods_min = pcm_periods_min;
>    173		vss->hw.periods_max = pcm_periods_max;
>    174	
>    175		/*
>    176		 * We must ensure that there is enough space in the buffer to store
>    177		 * pcm_buffer_ms ms for the combination (Cmax, Smax, Rmax), where:
>    178		 *   Cmax = maximum supported number of channels,
>    179		 *   Smax = maximum supported sample size in bytes,
>    180		 *   Rmax = maximum supported frame rate.
>    181		 */
>    182		vss->hw.buffer_bytes_max =
>    183			sample_max * vss->hw.channels_max * pcm_buffer_ms *
>    184			(vss->hw.rate_max / MSEC_PER_SEC);
>    185	
>    186		/* Align the buffer size to the page size */
>    187		vss->hw.buffer_bytes_max =
>    188			(vss->hw.buffer_bytes_max + PAGE_SIZE - 1) & -PAGE_SIZE;
>    189	
>    190		/*
>    191		 * We must ensure that the minimum period size is enough to store
>    192		 * pcm_period_ms_min ms for the combination (Cmin, Smin, Rmin), where:
>    193		 *   Cmin = minimum supported number of channels,
>    194		 *   Smin = minimum supported sample size in bytes,
>    195		 *   Rmin = minimum supported frame rate.
>    196		 */
>    197		vss->hw.period_bytes_min =
>    198			sample_min * vss->hw.channels_min * pcm_period_ms_min *
>    199			(vss->hw.rate_min / MSEC_PER_SEC);
>    200	
>    201		/*
>    202		 * We must ensure that the maximum period size is enough to store
>    203		 * pcm_period_ms_max ms for the combination (Cmax, Smax, Rmax).
>    204		 */
>    205		vss->hw.period_bytes_max =
>    206			sample_max * vss->hw.channels_max * pcm_period_ms_max *
>    207			(vss->hw.rate_max / MSEC_PER_SEC);
>    208	
>    209		return 0;
>    210	}
>    211	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org




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

end of thread, other threads:[~2021-02-21 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 12:02 [linux-next:master 9708/11791] sound/virtio/virtio_pcm.c:33:42: sparse: sparse: incorrect type in initializer (different base types) kernel test robot
2021-02-21 11:50 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).