From patchwork Tue Nov 5 07:55:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 11227111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F36C1390 for ; Tue, 5 Nov 2019 07:56:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6552920717 for ; Tue, 5 Nov 2019 07:56:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="T3xJSi3O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6552920717 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1D9EF16F7; Tue, 5 Nov 2019 08:55:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1D9EF16F7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1572940578; bh=Kq89P5Q5wukqg1KDntuIaKk6j9in7lYPwc5gdwokTDA=; h=Date:From:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=T3xJSi3O+WdxeLkFfKgRDvtQ1rjsm5oe5T7aJUyUFjeDClSH4E83+Myavee9wWlHp XJQ7Xofvg70vwZeghmJyR0iYVwyBdesdxXfpu6uf5OAIWa0muJNDB0sM/SNww6WAk2 wbzfjn5zNsl7KCzobVAC/ViktDdKEAP1ORU8+wzo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A9CEDF80446; Tue, 5 Nov 2019 08:55:27 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 35465F8049B; Tue, 5 Nov 2019 08:55:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A179CF800F3 for ; Tue, 5 Nov 2019 08:55:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A179CF800F3 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7555AABBD; Tue, 5 Nov 2019 07:55:22 +0000 (UTC) Date: Tue, 05 Nov 2019 08:55:21 +0100 Message-ID: From: Takashi Iwai To: Andrzej Hajda , Neil Armstrong User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?utf-8?b?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: Jernej Skrabec , alsa-devel@alsa-project.org, Laurent Pinchart , dri-devel@lists.freedesktop.org, Jonas Karlman Subject: [alsa-devel] Incorrect buffer handling in dw-hdmi bridge audio X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi, while recently working on the ALSA memory allocator API cleanup, I noticed that dw-hdmi bridge driver seems doing weird about the buffer management. It pre-allocates the usual device buffers fully at the probe time, while each stream allocates the buffer via the vmalloc helpers and replaces with it at each open. I guess it's no expected behavior? It's basically a full waste of resources, and the vmalloc buffer isn't guaranteed to work well for mmap on every architecture. Below is the patch to address it. Can anyone check whether this still works? Since I have a cleanup series and this is involved, I'd like to take the fix through my tree once after it's confirmed (and get ACK if possible). Thanks! Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] drm/bridge: dw-hdmi: Fix the incorrect buffer allocations The driver sets up the buffer preallocation with SNDRV_DMA_TYPE_DEV, while it re-allocates and releases vmalloc pages. This is not only a lot of waste resources but also causes the mmap malfunction. Change / drop the vmalloc-related code and use the standard buffer allocation / release code instead. Signed-off-by: Takashi Iwai Signed-off-by: Takashi Iwai Signed-off-by: Takashi Iwai --- drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c | 6 ++---- 1 file changed, 2 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 2b7539701b42..8fe7a6e8ff94 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c @@ -384,15 +384,14 @@ 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); + return snd_pcm_lib_free_pages(substream); } static int dw_hdmi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { /* Allocate the PCM runtime buffer, which is exposed to userspace. */ - return snd_pcm_lib_alloc_vmalloc_buffer(substream, - params_buffer_bytes(params)); + return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); } static int dw_hdmi_prepare(struct snd_pcm_substream *substream) @@ -511,7 +510,6 @@ 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, }; static int snd_dw_hdmi_probe(struct platform_device *pdev)