[linux-next:master 9709/11791] sound/virtio/virtio_pcm_msg.c:224:37: sparse: sparse: incorrect type in assignment (different base types)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   ff90dfd2579b2c7bc1f0baa0cb99c918c6c1ec64
commit: 6caf033d0888967d4ce3b759fba75a56089856d1 [9709/11791] ALSA: virtio: handling control and I/O messages for the PCM device
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=6caf033d0888967d4ce3b759fba75a56089856d1
        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 6caf033d0888967d4ce3b759fba75a56089856d1
        # 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@xxxxxxxxx>


"sparse warnings: (new ones prefixed by >>)"
>> sound/virtio/virtio_pcm_msg.c:224:37: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le32 [usertype] stream_id @@     got restricted __virtio32 @@
   sound/virtio/virtio_pcm_msg.c:224:37: sparse:     expected restricted __le32 [usertype] stream_id
   sound/virtio/virtio_pcm_msg.c:224:37: sparse:     got restricted __virtio32
>> sound/virtio/virtio_pcm_msg.c:388:31: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le32 [usertype] code @@     got restricted __virtio32 @@
   sound/virtio/virtio_pcm_msg.c:388:31: sparse:     expected restricted __le32 [usertype] code
   sound/virtio/virtio_pcm_msg.c:388:31: sparse:     got restricted __virtio32
   sound/virtio/virtio_pcm_msg.c:389:32: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __le32 [usertype] stream_id @@     got restricted __virtio32 @@
   sound/virtio/virtio_pcm_msg.c:389:32: sparse:     expected restricted __le32 [usertype] stream_id
   sound/virtio/virtio_pcm_msg.c:389:32: sparse:     got restricted __virtio32

vim +224 sound/virtio/virtio_pcm_msg.c

   186	
   187	/**
   188	 * virtsnd_pcm_msg_send() - Send asynchronous I/O messages.
   189	 * @vss: VirtIO PCM substream.
   190	 *
   191	 * All messages are organized in an ordered circular list. Each time the
   192	 * function is called, all currently non-enqueued messages are added to the
   193	 * virtqueue. For this, the function keeps track of two values:
   194	 *
   195	 *   msg_last_enqueued = index of the last enqueued message,
   196	 *   msg_count = # of pending messages in the virtqueue.
   197	 *
   198	 * Context: Any context. Expects the tx/rx queue and the VirtIO substream
   199	 *          spinlocks to be held by caller.
   200	 * Return: 0 on success, -errno on failure.
   201	 */
   202	int virtsnd_pcm_msg_send(struct virtio_pcm_substream *vss)
   203	{
   204		struct snd_pcm_runtime *runtime = vss->substream->runtime;
   205		struct virtio_snd *snd = vss->snd;
   206		struct virtio_device *vdev = snd->vdev;
   207		struct virtqueue *vqueue = virtsnd_pcm_queue(vss)->vqueue;
   208		int i;
   209		int n;
   210		bool notify = false;
   211	
   212		i = (vss->msg_last_enqueued + 1) % runtime->periods;
   213		n = runtime->periods - vss->msg_count;
   214	
   215		for (; n; --n, i = (i + 1) % runtime->periods) {
   216			struct virtio_pcm_msg *msg = vss->msgs[i];
   217			struct scatterlist *psgs[] = {
   218				&msg->sgs[PCM_MSG_SG_XFER],
   219				&msg->sgs[PCM_MSG_SG_DATA],
   220				&msg->sgs[PCM_MSG_SG_STATUS]
   221			};
   222			int rc;
   223	
 > 224			msg->xfer.stream_id = cpu_to_virtio32(vdev, vss->sid);
   225			memset(&msg->status, 0, sizeof(msg->status));
   226	
   227			if (vss->direction == SNDRV_PCM_STREAM_PLAYBACK)
   228				rc = virtqueue_add_sgs(vqueue, psgs, 2, 1, msg,
   229						       GFP_ATOMIC);
   230			else
   231				rc = virtqueue_add_sgs(vqueue, psgs, 1, 2, msg,
   232						       GFP_ATOMIC);
   233	
   234			if (rc) {
   235				dev_err(&vdev->dev,
   236					"SID %u: failed to send I/O message\n",
   237					vss->sid);
   238				return rc;
   239			}
   240	
   241			vss->msg_last_enqueued = i;
   242			vss->msg_count++;
   243		}
   244	
   245		if (!(vss->features & (1U << VIRTIO_SND_PCM_F_MSG_POLLING)))
   246			notify = virtqueue_kick_prepare(vqueue);
   247	
   248		if (notify)
   249			virtqueue_notify(vqueue);
   250	
   251		return 0;
   252	}
   253	
   254	/**
   255	 * virtsnd_pcm_msg_complete() - Complete an I/O message.
   256	 * @msg: I/O message.
   257	 * @size: Number of bytes written.
   258	 *
   259	 * Completion of the message means the elapsed period.
   260	 *
   261	 * Context: Interrupt context. Takes and releases the VirtIO substream spinlock.
   262	 */
   263	static void virtsnd_pcm_msg_complete(struct virtio_pcm_msg *msg, size_t size)
   264	{
   265		struct virtio_pcm_substream *vss = msg->substream;
   266	
   267		/*
   268		 * hw_ptr always indicates the buffer position of the first I/O message
   269		 * in the virtqueue. Therefore, on each completion of an I/O message,
   270		 * the hw_ptr value is unconditionally advanced.
   271		 */
   272		spin_lock(&vss->lock);
   273		/*
   274		 * If the capture substream returned an incorrect status, then just
   275		 * increase the hw_ptr by the period size.
   276		 */
   277		if (vss->direction == SNDRV_PCM_STREAM_PLAYBACK ||
   278		    size <= sizeof(msg->status)) {
   279			vss->hw_ptr += vss->period_size;
   280		} else {
   281			size -= sizeof(msg->status);
   282			vss->hw_ptr += size / vss->frame_bytes;
   283		}
   284	
   285		vss->hw_ptr %= vss->buffer_size;
   286		vss->xfer_xrun = false;
   287		vss->msg_count--;
   288	
   289		if (vss->xfer_enabled) {
   290			struct snd_pcm_runtime *runtime = vss->substream->runtime;
   291	
   292			runtime->delay =
   293				bytes_to_frames(runtime,
   294						le32_to_cpu(msg->status.latency_bytes));
   295	
   296			spin_unlock(&vss->lock);
   297			snd_pcm_period_elapsed(vss->substream);
   298			spin_lock(&vss->lock);
   299	
   300			virtsnd_pcm_msg_send(vss);
   301		} else if (!vss->msg_count) {
   302			wake_up_all(&vss->msg_empty);
   303		}
   304		spin_unlock(&vss->lock);
   305	}
   306	
   307	/**
   308	 * virtsnd_pcm_notify_cb() - Process all completed I/O messages.
   309	 * @queue: Underlying tx/rx virtqueue.
   310	 *
   311	 * If transmission is allowed, then each completed message is immediately placed
   312	 * back at the end of the queue.
   313	 *
   314	 * Context: Interrupt context. Takes and releases the tx/rx queue spinlock.
   315	 */
   316	static inline void virtsnd_pcm_notify_cb(struct virtio_snd_queue *queue)
   317	{
   318		struct virtio_pcm_msg *msg;
   319		u32 length;
   320		unsigned long flags;
   321	
   322		spin_lock_irqsave(&queue->lock, flags);
   323		do {
   324			virtqueue_disable_cb(queue->vqueue);
   325			while ((msg = virtqueue_get_buf(queue->vqueue, &length)))
   326				virtsnd_pcm_msg_complete(msg, length);
   327			if (unlikely(virtqueue_is_broken(queue->vqueue)))
   328				break;
   329		} while (!virtqueue_enable_cb(queue->vqueue));
   330		spin_unlock_irqrestore(&queue->lock, flags);
   331	}
   332	
   333	/**
   334	 * virtsnd_pcm_tx_notify_cb() - Process all completed TX messages.
   335	 * @vqueue: Underlying tx virtqueue.
   336	 *
   337	 * Context: Interrupt context.
   338	 */
   339	void virtsnd_pcm_tx_notify_cb(struct virtqueue *vqueue)
   340	{
   341		struct virtio_snd *snd = vqueue->vdev->priv;
   342	
   343		virtsnd_pcm_notify_cb(virtsnd_tx_queue(snd));
   344	}
   345	
   346	/**
   347	 * virtsnd_pcm_rx_notify_cb() - Process all completed RX messages.
   348	 * @vqueue: Underlying rx virtqueue.
   349	 *
   350	 * Context: Interrupt context.
   351	 */
   352	void virtsnd_pcm_rx_notify_cb(struct virtqueue *vqueue)
   353	{
   354		struct virtio_snd *snd = vqueue->vdev->priv;
   355	
   356		virtsnd_pcm_notify_cb(virtsnd_rx_queue(snd));
   357	}
   358	
   359	/**
   360	 * virtsnd_pcm_ctl_msg_alloc() - Allocate and initialize the PCM device control
   361	 *                               message for the specified substream.
   362	 * @vss: VirtIO PCM substream.
   363	 * @command: Control request code (VIRTIO_SND_R_PCM_XXX).
   364	 * @gfp: Kernel flags for memory allocation.
   365	 *
   366	 * Context: Any context. May sleep if @gfp flags permit.
   367	 * Return: Allocated message on success, NULL on failure.
   368	 */
   369	struct virtio_snd_msg *
   370	virtsnd_pcm_ctl_msg_alloc(struct virtio_pcm_substream *vss,
   371				  unsigned int command, gfp_t gfp)
   372	{
   373		struct virtio_device *vdev = vss->snd->vdev;
   374		size_t request_size = sizeof(struct virtio_snd_pcm_hdr);
   375		size_t response_size = sizeof(struct virtio_snd_hdr);
   376		struct virtio_snd_msg *msg;
   377	
   378		switch (command) {
   379		case VIRTIO_SND_R_PCM_SET_PARAMS:
   380			request_size = sizeof(struct virtio_snd_pcm_set_params);
   381			break;
   382		}
   383	
   384		msg = virtsnd_ctl_msg_alloc(request_size, response_size, gfp);
   385		if (msg) {
   386			struct virtio_snd_pcm_hdr *hdr = virtsnd_ctl_msg_request(msg);
   387	
 > 388			hdr->hdr.code = cpu_to_virtio32(vdev, command);

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux