From patchwork Mon Aug 2 07:28:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D56DEC4338F for ; Mon, 2 Aug 2021 07:31:47 +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 4B5A060F9F for ; Mon, 2 Aug 2021 07:31:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4B5A060F9F 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-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 CEB3C17EE; Mon, 2 Aug 2021 09:30:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CEB3C17EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889505; bh=rf3J/rPN4vHK92EDAthoNBunfEy6R87dHZQfnFxdn4Y=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RrVOhTG/Pj1BLF1mbxBbUOu/r6chluCgN/PpfEYfQ9dC1PMCiwsnsS9Kx7CWUISUt OhY+5FiZRXwkyoET0hWJfgwEmlFboqOgObinyG6YtVnV0JyqCWY3PBDoS19b9O0CTz He1iGdamcK0lUtqTTs5UWdxp4l4cHiHVC7dAAFkw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 97336F804FD; Mon, 2 Aug 2021 09:28:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9CC8FF804EC; Mon, 2 Aug 2021 09:28:34 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B7409F8026A for ; Mon, 2 Aug 2021 09:28:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B7409F8026A Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Uc9vefOe"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="OJZt1rAS" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 212DD21FDE; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OgJl5d3Ooc6rLhcIDVXe1Xf0JLn2fDZ9mL/uQrwlgyY=; b=Uc9vefOerwJC9ewjAmbCpI39nzsfw52Ewv8jtJ21VaiHhpd+cPfwlYHsiEjnAt7Tl26W7z SQp1it9zPvFsR+TWrHMCVtcwRAmEWlG8IrQfFnorbZhlqmqb5fYEcW5Km8420ZIqpKFNC4 neT/8mQLluElUpiJ8w+j0USZ5RgA/1w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OgJl5d3Ooc6rLhcIDVXe1Xf0JLn2fDZ9mL/uQrwlgyY=; b=OJZt1rASc+s0StoE/6cgoeMJ3r6JF4g3QkpTgOmV8Fy6EC+1icWYK9/rXqHYEu1HLG7zuu Fx/RUyL/P3WLCwDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 0F90BA3B85; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 07/15] ASoC: fsl: imx-pcm-fiq: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:07 +0200 Message-Id: <20210802072815.13551-8-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Nicolin Chen , Shengjiu Wang , Mark Brown , Fabio Estevam , Xiubo Li 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" As the standard buffer allocation helper supports WC pages now, we can convert imx-pcm-fiq driver to use that. This allows us to remove lots of superfluous code. Cc: Nicolin Chen Cc: Xiubo Li Cc: Fabio Estevam Cc: Shengjiu Wang Signed-off-by: Takashi Iwai --- sound/soc/fsl/imx-pcm-fiq.c | 75 ++----------------------------------- 1 file changed, 3 insertions(+), 72 deletions(-) diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index f20d5b1c3848..0d124002678e 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -81,7 +81,6 @@ static int snd_imx_pcm_hw_params(struct snd_soc_component *component, iprtd->offset = 0; iprtd->poll_time_ns = 1000000000 / params_rate(params) * params_period_size(params); - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); return 0; } @@ -213,40 +212,6 @@ static int snd_imx_close(struct snd_soc_component *component, return 0; } -static int snd_imx_pcm_mmap(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int ret; - - ret = dma_mmap_wc(substream->pcm->card->dev, vma, runtime->dma_area, - runtime->dma_addr, runtime->dma_bytes); - - pr_debug("%s: ret: %d %p %pad 0x%08zx\n", __func__, ret, - runtime->dma_area, - &runtime->dma_addr, - runtime->dma_bytes); - return ret; -} - -static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size = IMX_SSI_DMABUF_SIZE; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_wc(pcm->card->dev, size, &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - buf->bytes = size; - - return 0; -} - static int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; @@ -257,21 +222,9 @@ static int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { - ret = imx_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - return ret; - } - - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - ret = imx_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_CAPTURE); - if (ret) - return ret; - } - - return 0; + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_WC, + pcm->card->dev, + IMX_SSI_DMABUF_SIZE); } static int ssi_irq; @@ -307,32 +260,11 @@ static int snd_imx_pcm_new(struct snd_soc_component *component, return 0; } -static void imx_pcm_free(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_wc(pcm->card->dev, buf->bytes, buf->area, buf->addr); - buf->area = NULL; - } -} - static void snd_imx_pcm_free(struct snd_soc_component *component, struct snd_pcm *pcm) { mxc_set_irq_fiq(ssi_irq, 0); release_fiq(&fh); - imx_pcm_free(pcm); } static const struct snd_soc_component_driver imx_soc_component_fiq = { @@ -342,7 +274,6 @@ static const struct snd_soc_component_driver imx_soc_component_fiq = { .prepare = snd_imx_pcm_prepare, .trigger = snd_imx_pcm_trigger, .pointer = snd_imx_pcm_pointer, - .mmap = snd_imx_pcm_mmap, .pcm_construct = snd_imx_pcm_new, .pcm_destruct = snd_imx_pcm_free, }; From patchwork Mon Aug 2 07:28:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED614C4338F for ; Mon, 2 Aug 2021 07:35:43 +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 6A52060F6E for ; Mon, 2 Aug 2021 07:35:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A52060F6E 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-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 0898A16A3; Mon, 2 Aug 2021 09:34:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0898A16A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889742; bh=eswuxo1W0i5PFWZAUUURjJvjkpw1DjGr+M4WxdwxYyQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Nnbf74/tIXVV15b5zo29Dh0BRmJZt6SFzpcsS/7YAiapfTccPlDyXkfKn6MWkI+Ok fz74+ohH+Ej2Knxu3c6p/P35CvbNjtcZq2dVgK34XmgvQ2UOcRlNLmk1Qe9bbLHGl/ YcsdmE1gnLNvtGy04+w73fXebbxBfCOS7F/HVNbI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3EB79F80564; Mon, 2 Aug 2021 09:29:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AFE93F8054A; Mon, 2 Aug 2021 09:29:04 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C7432F804E1 for ; Mon, 2 Aug 2021 09:28:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C7432F804E1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kATXn2br"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="f4W+Jtk+" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 32CF721FDF; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KhGlkJrcDMMTRRbAadaufuaM9yTH4rtTjIKubH+IHQQ=; b=kATXn2bru6zGMh26LRoOLg2wayUIOfa8CHI1xq/MJzUJf7exFW8lt4dTq7wCZflxIXZXC4 1KTo8/hF811oDLg5SuRczDgylehozkVgsKu5/oS8N+LOVHH/0nQlLINAfKp83UG9cJ08rN f6EeCS0O7O5xfuAF5keC2qV/IZy0Bds= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KhGlkJrcDMMTRRbAadaufuaM9yTH4rtTjIKubH+IHQQ=; b=f4W+Jtk+zNGs/JiCTRTFkaSz5E7xQA7NGg31rFJcPiZ00sbxA/uLlajbP1oFra5WyUrGts kHnOyr1FOA4ZjxCw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 20284A3B83; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 08/15] ASoC: fsl: imx-pcm-rpmsg: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:08 +0200 Message-Id: <20210802072815.13551-9-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Nicolin Chen , Shengjiu Wang , Mark Brown , Fabio Estevam , Xiubo Li 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" As the standard buffer allocation helper supports WC pages now, we can convert imx-pcm-rpmsg driver to use that. This allows us to remove lots of superfluous code. Cc: Nicolin Chen Cc: Xiubo Li Cc: Fabio Estevam Cc: Shengjiu Wang Signed-off-by: Takashi Iwai --- sound/soc/fsl/imx-pcm-rpmsg.c | 89 +---------------------------------- 1 file changed, 2 insertions(+), 87 deletions(-) diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c index 6d6c44cf3451..35049043e532 100644 --- a/sound/soc/fsl/imx-pcm-rpmsg.c +++ b/sound/soc/fsl/imx-pcm-rpmsg.c @@ -139,7 +139,6 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_hw_params *params) { struct rpmsg_info *info = dev_get_drvdata(component->dev); - struct snd_pcm_runtime *runtime = substream->runtime; struct rpmsg_msg *msg; int ret = 0; @@ -183,21 +182,11 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component, break; } - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - runtime->dma_bytes = params_buffer_bytes(params); - info->send_message(msg, info); return ret; } -static int imx_rpmsg_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_set_runtime_buffer(substream, NULL); - return 0; -} - static snd_pcm_uframes_t imx_rpmsg_pcm_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -347,18 +336,6 @@ static int imx_rpmsg_pcm_prepare(struct snd_soc_component *component, return 0; } -static int imx_rpmsg_pcm_mmap(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - return dma_mmap_wc(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); -} - static void imx_rpmsg_pcm_dma_complete(void *arg) { struct snd_pcm_substream *substream = arg; @@ -609,47 +586,6 @@ static int imx_rpmsg_pcm_ack(struct snd_soc_component *component, return 0; } -static int imx_rpmsg_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, - int stream, int size) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_wc(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - - buf->bytes = size; - return 0; -} - -static void imx_rpmsg_pcm_free_dma_buffers(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = SNDRV_PCM_STREAM_PLAYBACK; - stream < SNDRV_PCM_STREAM_LAST; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_wc(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} - static int imx_rpmsg_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { @@ -663,40 +599,19 @@ static int imx_rpmsg_pcm_new(struct snd_soc_component *component, if (ret) return ret; - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { - ret = imx_rpmsg_pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK, - rpmsg->buffer_size); - if (ret) - goto out; - } - - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - ret = imx_rpmsg_pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_CAPTURE, - rpmsg->buffer_size); - if (ret) - goto out; - } - imx_rpmsg_pcm_hardware.buffer_bytes_max = rpmsg->buffer_size; -out: - /* free preallocated buffers in case of error */ - if (ret) - imx_rpmsg_pcm_free_dma_buffers(component, pcm); - - return ret; + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_WC, + pcm->card->dev, rpmsg->buffer_size); } static const struct snd_soc_component_driver imx_rpmsg_soc_component = { .name = IMX_PCM_DRV_NAME, .pcm_construct = imx_rpmsg_pcm_new, - .pcm_destruct = imx_rpmsg_pcm_free_dma_buffers, .open = imx_rpmsg_pcm_open, .close = imx_rpmsg_pcm_close, .hw_params = imx_rpmsg_pcm_hw_params, - .hw_free = imx_rpmsg_pcm_hw_free, .trigger = imx_rpmsg_pcm_trigger, .pointer = imx_rpmsg_pcm_pointer, - .mmap = imx_rpmsg_pcm_mmap, .ack = imx_rpmsg_pcm_ack, .prepare = imx_rpmsg_pcm_prepare, }; From patchwork Mon Aug 2 07:28:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DC65C4338F for ; Mon, 2 Aug 2021 07:30:23 +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 29CD260EFF for ; Mon, 2 Aug 2021 07:30:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 29CD260EFF 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-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 46E3F17CE; Mon, 2 Aug 2021 09:29:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 46E3F17CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889420; bh=kUDFfRpgqGweiN7jHoe3QcxyIQW8Vj8+dTEv9QgLV30=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jNEnlGk4rN0DEx2uexHs9tCjXk97jH35gXlWVkjWQSMwv/SHwgseE4JzBEW6Gztqg YNnu7I05r+A9vO6nkmQniAFpB4TFiE3jg3hc7umtUsZ3441QGVb4mkpixiPvEgIJ0v jd4Oz/6LTWygslJwHpMU1I2oSAz5OeUeIv9wbmR0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 28938F802C4; Mon, 2 Aug 2021 09:28:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2D466F804E4; Mon, 2 Aug 2021 09:28:28 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 55E9CF801F7 for ; Mon, 2 Aug 2021 09:28:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 55E9CF801F7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MOSE7eW+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4ftkZB2i" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 432201FF37; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mMa7a2ZIJhTa1n6mMDKX9yZqi+hP2N/DpOoZ8q3npY4=; b=MOSE7eW+sPdJh6yTMXPMbVlriDU7/ZYHE5nHXOevKjNzyIpOJGA0UvfMDK2Dq8kxkvufC7 AVP/VwdF/3nFsrnF9fbazr7EnPSqPatomQm6QgpI/03Dlor14O/MPFJbmFlR7VqV/X4exb tBNRWKtzQ1BYqWEJLjGm/M+qZjtHt1I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mMa7a2ZIJhTa1n6mMDKX9yZqi+hP2N/DpOoZ8q3npY4=; b=4ftkZB2iUFh0LvfyrZw4lqjKroELpGg0hv76iBOoENxoIKdH2YkNUfSf3awFmUWDE0olm/ nel24VCpsG7sFcDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 31D59A3B85; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 09/15] ASoC: tegra: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:09 +0200 Message-Id: <20210802072815.13551-10-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Mark Brown 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" As the standard buffer allocation helper supports WC pages now, we can convert imx-pcm-rpmsg driver to use that. This allows us to remove lots of superfluous code. Signed-off-by: Takashi Iwai --- sound/soc/tegra/tegra210_admaif.c | 6 -- sound/soc/tegra/tegra_pcm.c | 93 +------------------------------ sound/soc/tegra/tegra_pcm.h | 7 --- 3 files changed, 1 insertion(+), 105 deletions(-) diff --git a/sound/soc/tegra/tegra210_admaif.c b/sound/soc/tegra/tegra210_admaif.c index 0f9beef429a2..bcccdf3ddc52 100644 --- a/sound/soc/tegra/tegra210_admaif.c +++ b/sound/soc/tegra/tegra210_admaif.c @@ -612,12 +612,9 @@ static const struct snd_soc_component_driver tegra210_admaif_cmpnt = { .controls = tegra210_admaif_controls, .num_controls = ARRAY_SIZE(tegra210_admaif_controls), .pcm_construct = tegra_pcm_construct, - .pcm_destruct = tegra_pcm_destruct, .open = tegra_pcm_open, .close = tegra_pcm_close, .hw_params = tegra_pcm_hw_params, - .hw_free = tegra_pcm_hw_free, - .mmap = tegra_pcm_mmap, .pointer = tegra_pcm_pointer, }; @@ -625,12 +622,9 @@ static const struct snd_soc_component_driver tegra186_admaif_cmpnt = { .controls = tegra186_admaif_controls, .num_controls = ARRAY_SIZE(tegra186_admaif_controls), .pcm_construct = tegra_pcm_construct, - .pcm_destruct = tegra_pcm_destruct, .open = tegra_pcm_open, .close = tegra_pcm_close, .hw_params = tegra_pcm_hw_params, - .hw_free = tegra_pcm_hw_free, - .mmap = tegra_pcm_mmap, .pointer = tegra_pcm_pointer, }; diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index d3276b4595af..ef1e74d95236 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c @@ -171,41 +171,10 @@ int tegra_pcm_hw_params(struct snd_soc_component *component, return ret; } - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; } EXPORT_SYMBOL_GPL(tegra_pcm_hw_params); -int tegra_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - if (rtd->dai_link->no_pcm) - return 0; - - snd_pcm_set_runtime_buffer(substream, NULL); - - return 0; -} -EXPORT_SYMBOL_GPL(tegra_pcm_hw_free); - -int tegra_pcm_mmap(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; - - if (rtd->dai_link->no_pcm) - return 0; - - return dma_mmap_wc(substream->pcm->card->dev, vma, runtime->dma_area, - runtime->dma_addr, runtime->dma_bytes); -} -EXPORT_SYMBOL_GPL(tegra_pcm_mmap); - snd_pcm_uframes_t tegra_pcm_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -213,41 +182,6 @@ snd_pcm_uframes_t tegra_pcm_pointer(struct snd_soc_component *component, } EXPORT_SYMBOL_GPL(tegra_pcm_pointer); -static int tegra_pcm_preallocate_dma_buffer(struct device *dev, struct snd_pcm *pcm, int stream, - size_t size) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - - buf->area = dma_alloc_wc(dev, size, &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - - buf->private_data = NULL; - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = dev; - buf->bytes = size; - - return 0; -} - -static void tegra_pcm_deallocate_dma_buffer(struct snd_pcm *pcm, int stream) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - - substream = pcm->streams[stream].substream; - if (!substream) - return; - - buf = &substream->dma_buffer; - if (!buf->area) - return; - - dma_free_wc(buf->dev.dev, buf->bytes, buf->area, buf->addr); - buf->area = NULL; -} - static int tegra_pcm_dma_allocate(struct device *dev, struct snd_soc_pcm_runtime *rtd, size_t size) { @@ -258,24 +192,7 @@ static int tegra_pcm_dma_allocate(struct device *dev, struct snd_soc_pcm_runtime if (ret < 0) return ret; - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { - ret = tegra_pcm_preallocate_dma_buffer(dev, pcm, SNDRV_PCM_STREAM_PLAYBACK, size); - if (ret) - goto err; - } - - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - ret = tegra_pcm_preallocate_dma_buffer(dev, pcm, SNDRV_PCM_STREAM_CAPTURE, size); - if (ret) - goto err_free_play; - } - - return 0; - -err_free_play: - tegra_pcm_deallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK); -err: - return ret; + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_WC, dev, size); } int tegra_pcm_construct(struct snd_soc_component *component, @@ -294,14 +211,6 @@ int tegra_pcm_construct(struct snd_soc_component *component, } EXPORT_SYMBOL_GPL(tegra_pcm_construct); -void tegra_pcm_destruct(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - tegra_pcm_deallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_CAPTURE); - tegra_pcm_deallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK); -} -EXPORT_SYMBOL_GPL(tegra_pcm_destruct); - MODULE_AUTHOR("Stephen Warren "); MODULE_DESCRIPTION("Tegra PCM ASoC driver"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h index 4838cdcee20e..d602126c65b7 100644 --- a/sound/soc/tegra/tegra_pcm.h +++ b/sound/soc/tegra/tegra_pcm.h @@ -22,8 +22,6 @@ int tegra_pcm_construct(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd); -void tegra_pcm_destruct(struct snd_soc_component *component, - struct snd_pcm *pcm); int tegra_pcm_open(struct snd_soc_component *component, struct snd_pcm_substream *substream); int tegra_pcm_close(struct snd_soc_component *component, @@ -31,11 +29,6 @@ int tegra_pcm_close(struct snd_soc_component *component, int tegra_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); -int tegra_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream); -int tegra_pcm_mmap(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct vm_area_struct *vma); snd_pcm_uframes_t tegra_pcm_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream); int tegra_pcm_platform_register(struct device *dev); From patchwork Mon Aug 2 07:28:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46784C4338F for ; Mon, 2 Aug 2021 07:32:40 +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 BC61660F5A for ; Mon, 2 Aug 2021 07:32:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BC61660F5A 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-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 40A2F17EC; Mon, 2 Aug 2021 09:31:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 40A2F17EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889558; bh=UxwNLv6NBg8P8h9RfQupZ81k+QAfy2e+THU8qDXjcBs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tb1TNSxp6jTIlFUKeS1dUv9bvum9X2mKjBfCerRhVdI2sjjAvcCgL5F1R/gZbRn3E yBlFfGYt1obXJFchxKJnmi5QgfQ13kNDG+X7yoEKJbfVnpAUzYSpKFpSo1gVdaZG74 Zk81NMRLJnfgeXZm4N990ikAQkn9zkDfRpBTr07s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CA027F8051F; Mon, 2 Aug 2021 09:28:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34F15F80279; Mon, 2 Aug 2021 09:28:39 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BC2F0F802C4 for ; Mon, 2 Aug 2021 09:28:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BC2F0F802C4 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="e8c7s8wV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="5rNNx3Om" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 54C4B1FF38; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pmda/XrSprLClbY/FF5n6lIdWiTtgyzqPauil82aqoQ=; b=e8c7s8wVraiczZQqfr2Ky1oH3HUXuXv3iawCoUFe+2tysm4coY8KiNuN4vNqS8mcCNXrmw gCYfT6l5AH7Hg3VoBd7So2U9dIroNEPG/mobCURSnQAjPOeTu6r8wK1RPV6SE5j5391fUD RfUpS5PGoyBurQ0eRSH4LcBgfldPyWU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pmda/XrSprLClbY/FF5n6lIdWiTtgyzqPauil82aqoQ=; b=5rNNx3OmjWPwDSUfD2Owj1L8CJougnNvLvhSE5zKjZwpL/ScPFeIaQ076q5eFt6bhEeNv3 jfpPCWw1IByCdsBA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 41FAEA3B83; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 10/15] ASoC: fsl_asrc_dma: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:10 +0200 Message-Id: <20210802072815.13551-11-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Nicolin Chen , Shengjiu Wang , Mark Brown , Fabio Estevam , Xiubo Li 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" This patch simplifies the buffer pre-allocation code of fsl_asrc_dma driver with the standard managed buffer helper. It uses the newly introduced fixed-size buffer allocation helper. Cc: Nicolin Chen Cc: Xiubo Li Cc: Fabio Estevam Cc: Shengjiu Wang Signed-off-by: Takashi Iwai --- sound/soc/fsl/fsl_asrc_dma.c | 47 +++--------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index c313a26c8f95..cd9b36ec0ecb 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -284,8 +284,6 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, return ret; } - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; } @@ -297,8 +295,6 @@ static int fsl_asrc_dma_hw_free(struct snd_soc_component *component, struct fsl_asrc_pair *pair = runtime->private_data; u8 dir = tx ? OUT : IN; - snd_pcm_set_runtime_buffer(substream, NULL); - if (pair->dma_chan[!dir]) dma_release_channel(pair->dma_chan[!dir]); @@ -423,9 +419,8 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; - struct snd_pcm_substream *substream; struct snd_pcm *pcm = rtd->pcm; - int ret, i; + int ret; ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); if (ret) { @@ -433,43 +428,8 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component, return ret; } - for_each_pcm_streams(i) { - substream = pcm->streams[i].substream; - if (!substream) - continue; - - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, - FSL_ASRC_DMABUF_SIZE, &substream->dma_buffer); - if (ret) { - dev_err(card->dev, "failed to allocate DMA buffer\n"); - goto err; - } - } - - return 0; - -err: - if (--i == 0 && pcm->streams[i].substream) - snd_dma_free_pages(&pcm->streams[i].substream->dma_buffer); - - return ret; -} - -static void fsl_asrc_dma_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - int i; - - for_each_pcm_streams(i) { - substream = pcm->streams[i].substream; - if (!substream) - continue; - - snd_dma_free_pages(&substream->dma_buffer); - substream->dma_buffer.area = NULL; - substream->dma_buffer.addr = 0; - } + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + card->dev, FSL_ASRC_DMABUF_SIZE); } struct snd_soc_component_driver fsl_asrc_component = { @@ -481,6 +441,5 @@ struct snd_soc_component_driver fsl_asrc_component = { .close = fsl_asrc_dma_shutdown, .pointer = fsl_asrc_dma_pcm_pointer, .pcm_construct = fsl_asrc_dma_pcm_new, - .pcm_destruct = fsl_asrc_dma_pcm_free, }; EXPORT_SYMBOL_GPL(fsl_asrc_component); From patchwork Mon Aug 2 07:28:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06113C4338F for ; Mon, 2 Aug 2021 07:33: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 8051F60F9F for ; Mon, 2 Aug 2021 07:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8051F60F9F 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-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 20CA317C0; Mon, 2 Aug 2021 09:32:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 20CA317C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889599; bh=9Af7SB3PctODiwsqkjtVoJuR6FEIMc3Qihv30zM4gWM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d0r9RyYzu70Eu9wW32LbxtCxO5QE062Ib10iC1vnazdT3gaLN+t41b6xPmNiNrbL1 IzPBrQ1q1307BoI362IAxbwEq3+v9fGENfkFNSvAS6wWCZetvH1ykT24pcMvy1BXgz aTF2HsPGitCbGGiRsE0qJYZ1zihiHp+SBXBh3oxw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9F3B9F80529; Mon, 2 Aug 2021 09:29:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8A0C6F804F2; Mon, 2 Aug 2021 09:28:44 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BA698F80095 for ; Mon, 2 Aug 2021 09:28:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BA698F80095 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="aw71b/7m"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pmHnkkBR" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 744461FF39; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RCxKYjZQPU7IXrU9OgGuwm0/3Bp/fVIfCXKuL4GIT8s=; b=aw71b/7majcpc5nCGbVqk5wmWKR37dy2bUclPcHvLiXyym76ppFnxYzWLr6SoF210kDayZ nKIytObljphJNJRgy9RGN2TdGH5ABEswlNfunRxoUG9/0qSWISIJa+zAVxngFiXFSGaKx1 ozMoJxuVzAWQCrazGb42fijoUP9zPAk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RCxKYjZQPU7IXrU9OgGuwm0/3Bp/fVIfCXKuL4GIT8s=; b=pmHnkkBRmPl1F9TBn4d+GuQpT7CzGC1qoVTriz9xFCrQDIeL1u5+Dw0hX6Y9Q0PYMj7xrE RLVBxzyX+C/aUeBA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 6386BA3B83; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 12/15] ASoC: mpc5200: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:12 +0200 Message-Id: <20210802072815.13551-13-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Mark Brown 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" This patch simplifies the buffer pre-allocation code of fsl mpc5200 driver with the standard managed buffer helper. It uses the newly introduced fixed-size buffer allocation helper. Signed-off-by: Takashi Iwai --- sound/soc/fsl/mpc5200_dma.c | 63 ++----------------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 6c65cd858b0b..901497810020 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -98,13 +98,6 @@ static irqreturn_t psc_dma_bcom_irq(int irq, void *_psc_dma_stream) return IRQ_HANDLED; } -static int psc_dma_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_set_runtime_buffer(substream, NULL); - return 0; -} - /** * psc_dma_trigger: start and stop the DMA transfer. * @@ -285,15 +278,6 @@ psc_dma_pointer(struct snd_soc_component *component, return bytes_to_frames(substream->runtime, count); } -static int psc_dma_hw_params(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - - return 0; -} - static int psc_dma_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { @@ -310,60 +294,17 @@ static int psc_dma_new(struct snd_soc_component *component, if (rc) return rc; - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { - rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, - size, &pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->dma_buffer); - if (rc) - goto playback_alloc_err; - } - - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, - size, &pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->dma_buffer); - if (rc) - goto capture_alloc_err; - } - - return 0; - - capture_alloc_err: - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) - snd_dma_free_pages(&pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->dma_buffer); - - playback_alloc_err: - dev_err(card->dev, "Cannot allocate buffer(s)\n"); - - return -ENOMEM; -} - -static void psc_dma_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - int stream; - - dev_dbg(component->dev, "psc_dma_free(pcm=%p)\n", pcm); - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (substream) { - snd_dma_free_pages(&substream->dma_buffer); - substream->dma_buffer.area = NULL; - substream->dma_buffer.addr = 0; - } - } + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, + size); } static const struct snd_soc_component_driver mpc5200_audio_dma_component = { .name = DRV_NAME, .open = psc_dma_open, .close = psc_dma_close, - .hw_free = psc_dma_hw_free, .pointer = psc_dma_pointer, .trigger = psc_dma_trigger, - .hw_params = psc_dma_hw_params, .pcm_construct = psc_dma_new, - .pcm_destruct = psc_dma_free, }; int mpc5200_audio_dma_create(struct platform_device *op) From patchwork Mon Aug 2 07:28:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB578C4338F for ; Mon, 2 Aug 2021 07:34:53 +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 E78E260FF2 for ; Mon, 2 Aug 2021 07:34:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E78E260FF2 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-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 78D4B17CB; Mon, 2 Aug 2021 09:34:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78D4B17CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889691; bh=3HxRS/pOsp7jb3AaBrZMJE8ZybrJ0G+mNBMJkVZON+Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AXuZiF8xg7jasToh/tYtptgH8MDWnO1uoziBfykqPodCZl0vm890oKYznQxlnNTot cqS6RRmxUTTgkJk11KSwFrmEkdW9yEb13meVo7IIC4VAcc3CmpJl9hFpNoakrLAfRO 1PJ0THTngSM8yowrUzQfMSd4p7FfIZLUjuiFw5y0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DC8C2F80548; Mon, 2 Aug 2021 09:29:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A08D3F80544; Mon, 2 Aug 2021 09:29:03 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CA9D7F804BB for ; Mon, 2 Aug 2021 09:28:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CA9D7F804BB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="EKqjMT6V"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="KNesE0kA" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 786F91FF3B; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nR1sBCV9vZJYsDibr+p+hwpgVADIJo/2b3keeUzfz2c=; b=EKqjMT6V5kQm60MbrQHU3dKUxl9ir6AXFm2wQbn+APPyjQaoaGkgMgni06sUcWudkUqhI7 R1d7N2xiAzpN5R7pooimcZzGmMmryEKyH8TW/DsUe4edC+ndUxguPZI8jKhMc24H82AlCN jRgsix4Sgt+bDoNjN9jnAMdzlBnsysU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nR1sBCV9vZJYsDibr+p+hwpgVADIJo/2b3keeUzfz2c=; b=KNesE0kAWyHCS4P+VYy9ERYKYCTx00DnWspwSDf3sK6diC66JWbHf/+AtbSzVgSJA74hLm XZYhuDKE1E+zzsCw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 72619A3B85; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 13/15] ASoC: qcom: lpass: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:13 +0200 Message-Id: <20210802072815.13551-14-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Banajit Goswami , Mark Brown 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" This patch simplifies the buffer pre-allocation code of qcom lpass driver with the standard managed buffer helper. It uses the newly introduced fixed-size buffer allocation helper. Cc: Srinivas Kandagatla Cc: Banajit Goswami Signed-off-by: Takashi Iwai --- sound/soc/qcom/lpass-platform.c | 60 ++------------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index f9df76d37858..a59e9d20cb46 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -156,8 +156,6 @@ static int lpass_platform_pcmops_open(struct snd_soc_component *component, return -EINVAL; } - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; } @@ -630,16 +628,6 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer( return bytes_to_frames(substream->runtime, curr_addr - base_addr); } -static int lpass_platform_pcmops_mmap(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - return dma_mmap_coherent(component->dev, vma, runtime->dma_area, - runtime->dma_addr, runtime->dma_bytes); -} - static irqreturn_t lpass_dma_interrupt_handler( struct snd_pcm_substream *substream, struct lpass_data *drvdata, @@ -787,52 +775,10 @@ static int lpass_platform_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *soc_runtime) { struct snd_pcm *pcm = soc_runtime->pcm; - struct snd_pcm_substream *psubstream, *csubstream; - int ret; size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; - psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; - if (psubstream) { - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - component->dev, - size, &psubstream->dma_buffer); - if (ret) { - dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); - return ret; - } - } - - csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - if (csubstream) { - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - component->dev, - size, &csubstream->dma_buffer); - if (ret) { - dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); - if (psubstream) - snd_dma_free_pages(&psubstream->dma_buffer); - return ret; - } - - } - - return 0; -} - -static void lpass_platform_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - int i; - - for_each_pcm_streams(i) { - substream = pcm->streams[i].substream; - if (substream) { - snd_dma_free_pages(&substream->dma_buffer); - substream->dma_buffer.area = NULL; - substream->dma_buffer.addr = 0; - } - } + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + component->dev, size); } static int lpass_platform_pcmops_suspend(struct snd_soc_component *component) @@ -877,9 +823,7 @@ static const struct snd_soc_component_driver lpass_component_driver = { .prepare = lpass_platform_pcmops_prepare, .trigger = lpass_platform_pcmops_trigger, .pointer = lpass_platform_pcmops_pointer, - .mmap = lpass_platform_pcmops_mmap, .pcm_construct = lpass_platform_pcm_new, - .pcm_destruct = lpass_platform_pcm_free, .suspend = lpass_platform_pcmops_suspend, .resume = lpass_platform_pcmops_resume, From patchwork Mon Aug 2 07:28:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 490381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65783C4338F for ; Mon, 2 Aug 2021 07:34:00 +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 D558760F5A for ; Mon, 2 Aug 2021 07:33:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D558760F5A 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-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 6603317E0; Mon, 2 Aug 2021 09:33:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6603317E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1627889638; bh=cgFcUs5NC1sTMgVNfIgRnpkmlKgFT6AQUok4Muq7ORo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FwA1mc0rSwQXHqy+gJxxuF20punkxpHMRb/kCVPolba6w/9BtZFbT6bx2vNkTjDai bmpTf5CrsoKf3QgB+vlZv/P74bQkj/DYW9v8xW1umkeIr56SOTl3VqpQpVe3k2vyWX t8jq1/4ip44QxXs44O+5LW5m09oYDZwOEC2k2vyI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D2621F80536; Mon, 2 Aug 2021 09:29:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DEFBEF80515; Mon, 2 Aug 2021 09:28:48 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 02A21F801F7 for ; Mon, 2 Aug 2021 09:28:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 02A21F801F7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="dAVCJzJ8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="k0BTXIDU" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 81D8521FE4; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T/9Ei4GtsCFAyBdbXBde4yyEC4s3IL0aTIPbnSZs+zs=; b=dAVCJzJ8d1B3Zy8J/KlbqxZlhxvLqUc56V5xLEkhMOpbnWX9xUfFvSsYp4C318KZYE6alE cV9Xom5jABo8L1ilwpxeE+xRvmq1IV5ceBHFsrLA8LJv8C+S4lzMyGVnMt2nUHzNZhrFjl jCa6sM8HkuCc27YcCrVcV+dE8PUTVh4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627889298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T/9Ei4GtsCFAyBdbXBde4yyEC4s3IL0aTIPbnSZs+zs=; b=k0BTXIDUEptgOrcA1KD3mrv5Lv/nvC5mUCWJ67dAm74RFjGeR58BS2EJRlsuB8hsSYk7fC Ou20/yuV5X2gWCBQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 7C2EEA3B83; Mon, 2 Aug 2021 07:28:18 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 15/15] ASoC: sprd: Use managed buffer allocation Date: Mon, 2 Aug 2021 09:28:15 +0200 Message-Id: <20210802072815.13551-16-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210802072815.13551-1-tiwai@suse.de> References: <20210802072815.13551-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Mark Brown 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" This patch simplifies the buffer pre-allocation code of sprd driver with the standard managed buffer helper. It uses the newly introduced fixed-size buffer allocation helper. Signed-off-by: Takashi Iwai --- sound/soc/sprd/sprd-pcm-dma.c | 67 ++--------------------------------- 1 file changed, 3 insertions(+), 64 deletions(-) diff --git a/sound/soc/sprd/sprd-pcm-dma.c b/sound/soc/sprd/sprd-pcm-dma.c index 5e3a96d4793c..48d90616b23f 100644 --- a/sound/soc/sprd/sprd-pcm-dma.c +++ b/sound/soc/sprd/sprd-pcm-dma.c @@ -204,8 +204,6 @@ static int sprd_pcm_hw_params(struct snd_soc_component *component, if (!dma_params) { dev_warn(component->dev, "no dma parameters setting\n"); dma_private->params = NULL; - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - runtime->dma_bytes = totsize; return 0; } @@ -217,9 +215,6 @@ static int sprd_pcm_hw_params(struct snd_soc_component *component, return ret; } - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - - runtime->dma_bytes = totsize; sg_num = totsize / period; dma_private->dma_addr_offset = totsize / channels; @@ -310,7 +305,6 @@ static int sprd_pcm_hw_params(struct snd_soc_component *component, static int sprd_pcm_hw_free(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - snd_pcm_set_runtime_buffer(substream, NULL); sprd_pcm_release_dma_channel(substream); return 0; @@ -435,73 +429,20 @@ static snd_pcm_uframes_t sprd_pcm_pointer(struct snd_soc_component *component, return x; } -static int sprd_pcm_mmap(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); - return remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - vma->vm_end - vma->vm_start, - vma->vm_page_prot); -} - static int sprd_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - struct snd_pcm_substream *substream; int ret; ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); if (ret) return ret; - substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; - if (substream) { - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, - sprd_pcm_hardware.buffer_bytes_max, - &substream->dma_buffer); - if (ret) { - dev_err(card->dev, - "can't alloc playback dma buffer: %d\n", ret); - return ret; - } - } - - substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - if (substream) { - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, - sprd_pcm_hardware.buffer_bytes_max, - &substream->dma_buffer); - if (ret) { - dev_err(card->dev, - "can't alloc capture dma buffer: %d\n", ret); - snd_dma_free_pages(&pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->dma_buffer); - return ret; - } - } - - return 0; -} - -static void sprd_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - int i; - - for (i = 0; i < ARRAY_SIZE(pcm->streams); i++) { - substream = pcm->streams[i].substream; - if (substream) { - snd_dma_free_pages(&substream->dma_buffer); - substream->dma_buffer.area = NULL; - substream->dma_buffer.addr = 0; - } - } + return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + card->dev, + sprd_pcm_hardware.buffer_bytes_max); } static const struct snd_soc_component_driver sprd_soc_component = { @@ -512,9 +453,7 @@ static const struct snd_soc_component_driver sprd_soc_component = { .hw_free = sprd_pcm_hw_free, .trigger = sprd_pcm_trigger, .pointer = sprd_pcm_pointer, - .mmap = sprd_pcm_mmap, .pcm_construct = sprd_pcm_new, - .pcm_destruct = sprd_pcm_free, .compress_ops = &sprd_platform_compress_ops, };