From: Keyon Jie <yang.jie@linux.intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [alsa-devel] [PATCH] ALSA: pcm: fix buffer_bytes max constrained by preallocated bytes issue
Date: Thu, 16 Jan 2020 17:50:33 +0800 [thread overview]
Message-ID: <97bbe88d1a6b63fe8e9b02bf0c5ce4a80553c48d.camel@linux.intel.com> (raw)
In-Reply-To: <s5hd0bjq3cu.wl-tiwai@suse.de>
On Thu, 2020-01-16 at 08:15 +0100, Takashi Iwai wrote:
> On Thu, 16 Jan 2020 05:53:18 +0100,
> Keyon Jie wrote:
> > With today's code, we preallocate DMA buffer for substreams at
> > pcm_new()
> > stage, and the substream->buffer_bytes_max and substream->dma_max
> > will
> > save as the actually preallocated buffer size and maximum size that
> > the
> > dma buffer can be expanded by at hw_params() state,
> > correspondingly.
>
> No, it's other way round: the former, buffer_bytes_max, is the max
> size defined by the driver (i.e. passed in snd_pcm_hardware) and the
> latter, dma_max, is the max preallocation size (passed to
> preallocation helper).
Hi Takashi, thanks for your comment.
First of all, have you ever hit issue I mentioned in the commit message
that we can't set buffer_bytes larger than the preallocated dma bytes?
I found this issue in kinds of platforms, not only on SOF/SoC ones, but
also on legacy HDA ones.
Secondly, I am not clear about the design intention of the substream-
>buffer_bytes_max and substream->dma_max, if it is as you commented
above, can you help answer my questions below inline the code?
void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
int type, struct device *data,
size_t size, size_t max)
static void preallocate_pages(struct snd_pcm_substream *substream,
int type, struct device *data,
size_t size, size_t max, bool managed)
{
...
if (substream->dma_buffer.bytes > 0)
substream->buffer_bytes_max = substream-
>dma_buffer.bytes;//Keyon: this is the actual allocated buffer bytes,
what is the intention here and why it is assigned to buffer_bytes_max
which will be used to constrain on the _HW_PARAM_BUFFER_BYTES later?
substream->dma_max = max; //Keyon: looks here it is where the
*max* param used only if we don't define SND_VERBOSE_PROCFS? what
relationship can we have with the preallocation itself?
...
}
>
> > At pcm_open() stage, the maximum constraint of
> > HW_PARAM_BUFFER_BYTES is
> > set to substream->buffer_bytes_max and returned to user space as
> > the max
> > interval of the HW_PARAM_BUFFER_BYTES, this will lead to issue that
> > user
> > can't choose any buffer-bytes larger than the preallocated buffer
> > size,
> > and the buffer reallocation will never happen actually.
> >
> > Here change to use substream->dma_max as the maximum constraint of
> > the
> > HW_PARAM_BUFFER_BYTES and fix the issue mentioned above.
>
> I don't think the logic in the current code you're changing is wrong.
> If there is any, it must be something else.
>
> This might be rather the FIXME code found in
> snd_pcm_hw_constraints_complete()?
I just tried removing the FIXME part code and it doesn't help, the rule
snd_pcm_hw_rule_buffer_bytes_max here limit the max of the
SNDRV_PCM_HW_PARAM_BUFFER_BYTES and this will returned to user space
like aplay for the subsequent hw_params(), is this intentional?
int snd_pcm_hw_constraints_complete(struct snd_pcm_substream
*substream)
{
...
err = snd_pcm_hw_rule_add(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
snd_pcm_hw_rule_buffer_bytes_max,
substream,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1);
if (err < 0)
return err;
/* FIXME: remove */
if (runtime->dma_bytes) {
err = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes);
if (err < 0)
return err;
}
...
return 0;
}
Thanks,
~Keyon
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2020-01-16 9:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 4:53 [alsa-devel] [PATCH] ALSA: pcm: fix buffer_bytes max constrained by preallocated bytes issue Keyon Jie
2020-01-16 7:15 ` Takashi Iwai
2020-01-16 9:50 ` Keyon Jie [this message]
2020-01-16 10:27 ` Takashi Iwai
2020-01-16 11:25 ` Keyon Jie
2020-01-16 11:50 ` Takashi Iwai
2020-01-16 14:14 ` Jie, Yang
2020-01-16 15:31 ` Jie, Yang
2020-01-16 16:07 ` Takashi Iwai
2020-01-16 16:39 ` Pierre-Louis Bossart
2020-01-16 17:25 ` Rajwa, Marcin
2020-01-16 17:40 ` Pierre-Louis Bossart
2020-01-16 20:37 ` Takashi Iwai
2020-01-17 5:30 ` Keyon Jie
2020-01-17 7:57 ` Takashi Iwai
2020-01-17 10:13 ` Keyon Jie
2020-01-17 10:30 ` Takashi Iwai
2020-01-17 10:56 ` Keyon Jie
2020-01-17 11:15 ` Takashi Iwai
2020-01-17 5:37 ` Keyon Jie
2020-01-17 8:00 ` Takashi Iwai
2020-01-17 10:43 ` Keyon Jie
2020-01-17 11:12 ` Takashi Iwai
2020-01-19 3:52 ` Keyon Jie
2020-01-19 7:09 ` Takashi Iwai
2020-01-19 8:11 ` Keyon Jie
2020-01-19 9:04 ` Takashi Iwai
2020-01-19 10:14 ` Keyon Jie
2020-01-19 10:43 ` Takashi Iwai
2020-01-20 2:23 ` Keyon Jie
2020-01-16 15:45 ` Takashi Iwai
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=97bbe88d1a6b63fe8e9b02bf0c5ce4a80553c48d.camel@linux.intel.com \
--to=yang.jie@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/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 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).