All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Cc: anton.yakovlev@opensynergy.com, mst@redhat.com, perex@perex.cz,
	tiwai@suse.com, virtualization@lists.linux-foundation.org,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	pbonzini@redhat.com, stefanha@redhat.com, sgarzare@redhat.com,
	manos.pitsidianakis@linaro.org, mripard@redhat.com
Subject: Re: [PATCH v3] ALSA: virtio: use ack callback
Date: Mon, 23 Oct 2023 17:50:00 +0200	[thread overview]
Message-ID: <87edhlwd7b.wl-tiwai@suse.de> (raw)
In-Reply-To: <ZTaMEUZUTrRRUD6y@fedora>

On Mon, 23 Oct 2023 17:06:57 +0200,
Matias Ezequiel Vara Larsen wrote:
> 
> +static int virtsnd_pcm_ack(struct snd_pcm_substream *substream)
> +{
> +	struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream);
> +	struct virtio_snd_queue *queue = virtsnd_pcm_queue(vss);
> +	unsigned long flags;
> +	struct snd_pcm_runtime *runtime = vss->substream->runtime;
> +	ssize_t appl_pos = frames_to_bytes(runtime, runtime->control->appl_ptr);
> +	ssize_t buf_size = frames_to_bytes(runtime, runtime->buffer_size);
> +	int rc;
> +
> +	spin_lock_irqsave(&queue->lock, flags);
> +	spin_lock(&vss->lock);
> +
> +	ssize_t bytes = (appl_pos - vss->appl_ptr) % buf_size;

The variable declaration should be moved to the beginning of the
function.

Also, there can be a overlap beyond runtime->boundary (which easily
happens for 32bit apps), so the calculation can be a bit more complex
with conditional.


thanks,

Takashi

  reply	other threads:[~2023-10-23 15:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 15:06 [PATCH v3] ALSA: virtio: use ack callback Matias Ezequiel Vara Larsen
2023-10-23 15:06 ` Matias Ezequiel Vara Larsen
2023-10-23 15:50 ` Takashi Iwai [this message]
2023-10-24 11:12   ` Matias Ezequiel Vara Larsen
2023-10-24 11:12     ` Matias Ezequiel Vara Larsen
2023-10-24 12:33     ` Takashi Iwai
2023-10-24  0:11 ` Anton Yakovlev
2023-10-24  0:11   ` Anton Yakovlev via Virtualization
2023-10-24 11:14   ` Matias Ezequiel Vara Larsen
2023-10-24 11:14     ` Matias Ezequiel Vara Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edhlwd7b.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=anton.yakovlev@opensynergy.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=mripard@redhat.com \
    --cc=mst@redhat.com \
    --cc=mvaralar@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=perex@perex.cz \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=tiwai@suse.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.