From: Neil Armstrong <neil.armstrong@linaro.org>
To: Takashi Iwai <tiwai@suse.de>,
linux-sound@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: [PATCH 1/2] drm/bridge: dw-hdmi: Move vmalloc PCM buffer management into the driver
Date: Fri, 13 Sep 2024 09:55:27 +0200 [thread overview]
Message-ID: <d9fe0fd3-c494-4c93-8f86-98dbb6fea4f3@linaro.org> (raw)
In-Reply-To: <20240807152725.18948-2-tiwai@suse.de>
On 07/08/2024 17:27, Takashi Iwai wrote:
> The dw-hdmi drm bridge driver is the only one who still uses the ALSA
> vmalloc helper API functions. A previous attempt to change the way of
> buffer management wasn't taken for this legacy stuff, as we had little
> chance for test and some risk of major breaking.
> Instead, this patch moves the vmalloc buffer stuff into the dw-hdmi
> driver code itself, so that we can drop them from ALSA core code
> afterwards.
>
> There should be no functional changes.
>
> Link: https://lore.kernel.org/20191210154536.29819-1-tiwai@suse.de
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> .../drm/bridge/synopsys/dw-hdmi-ahb-audio.c | 30 ++++++++++++++++---
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
> index 67b8d17a722a..221e9a4edb40 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
> @@ -8,6 +8,7 @@
> #include <linux/interrupt.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> +#include <linux/vmalloc.h>
> #include <drm/bridge/dw_hdmi.h>
> #include <drm/drm_edid.h>
>
> @@ -388,15 +389,36 @@ static int dw_hdmi_close(struct snd_pcm_substream *substream)
>
> static int dw_hdmi_hw_free(struct snd_pcm_substream *substream)
> {
> - return snd_pcm_lib_free_vmalloc_buffer(substream);
> + struct snd_pcm_runtime *runtime = substream->runtime;
> +
> + vfree(runtime->dma_area);
> + runtime->dma_area = NULL;
> + return 0;
> }
>
> static int dw_hdmi_hw_params(struct snd_pcm_substream *substream,
> struct snd_pcm_hw_params *params)
> {
> + struct snd_pcm_runtime *runtime = substream->runtime;
> + size_t size = params_buffer_bytes(params);
> +
> /* Allocate the PCM runtime buffer, which is exposed to userspace. */
> - return snd_pcm_lib_alloc_vmalloc_buffer(substream,
> - params_buffer_bytes(params));
> + if (runtime->dma_area) {
> + if (runtime->dma_bytes >= size)
> + return 0; /* already large enough */
> + vfree(runtime->dma_area);
> + }
> + runtime->dma_area = vzalloc(size);
> + if (!runtime->dma_area)
> + return -ENOMEM;
> + runtime->dma_bytes = size;
> + return 1;
> +}
> +
> +static struct page *dw_hdmi_get_page(struct snd_pcm_substream *substream,
> + unsigned long offset)
> +{
> + return vmalloc_to_page(substream->runtime->dma_area + offset);
> }
>
> static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
> @@ -515,7 +537,7 @@ static const struct snd_pcm_ops snd_dw_hdmi_ops = {
> .prepare = dw_hdmi_prepare,
> .trigger = dw_hdmi_trigger,
> .pointer = dw_hdmi_pointer,
> - .page = snd_pcm_lib_get_vmalloc_page,
> + .page = dw_hdmi_get_page,
> };
>
> static int snd_dw_hdmi_probe(struct platform_device *pdev)
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
next prev parent reply other threads:[~2024-09-13 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 15:27 [PATCH 0/2] ALSA/DRM: vmalloc PCM buffer helper cleanup Takashi Iwai
2024-08-07 15:27 ` [PATCH 1/2] drm/bridge: dw-hdmi: Move vmalloc PCM buffer management into the driver Takashi Iwai
2024-09-13 7:55 ` Neil Armstrong [this message]
2024-08-07 15:27 ` [PATCH 2/2] ALSA: pcm: Drop PCM vmalloc buffer helpers Takashi Iwai
2024-08-15 8:03 ` [PATCH 0/2] ALSA/DRM: vmalloc PCM buffer helper cleanup Takashi Iwai
2024-08-27 6:47 ` 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=d9fe0fd3-c494-4c93-8f86-98dbb6fea4f3@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-sound@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=rfoss@kernel.org \
--cc=tiwai@suse.de \
--cc=tzimmermann@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