From patchwork Fri Apr 12 06:40:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10897301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83A6913B5 for ; Fri, 12 Apr 2019 06:41:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A15628B09 for ; Fri, 12 Apr 2019 06:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D72C28E53; Fri, 12 Apr 2019 06:41:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A6D028B09 for ; Fri, 12 Apr 2019 06:41:32 +0000 (UTC) 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 DAE3D822; Fri, 12 Apr 2019 08:40:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DAE3D822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555051289; bh=23OXNnLQdr5mSwWcY6gr0rHHW4oGNZclO7gyeSMsc3I=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=YqZ2veS5ql0GXdTGp8tqV9ksQGCYh/TGTRrWQ+caDOjCAubnBD0wiyTnQIvDgvoCV UJtHLkZ4Bw2dYmkuSUfYS3n9XOP841RQicHy9f736B992yiToRcWnz4vb/pjGEcb6d qYOwzV9+mdfbsyDvBkdGvA6trE3cvLCzSH72WBXU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 03FB7F89616; Fri, 12 Apr 2019 08:40:39 +0200 (CEST) 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 B6398F896DB; Fri, 12 Apr 2019 08:40:33 +0200 (CEST) Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (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 D7C2DF89616 for ; Fri, 12 Apr 2019 08:40:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D7C2DF89616 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="S/EzBrKj" Received: by mail-pl1-x641.google.com with SMTP id bf11so4593661plb.12 for ; Thu, 11 Apr 2019 23:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=y+bMKdHi3SWeYs4dZvhMtk+AUKH/ZBVC2n8ty7LnNMw=; b=S/EzBrKjJJKgsluKYBFxQPiOpxxW782zUguX1a5Zvg0lojmCS9Tfce6kjL47U0FH8k zRO4WK5f7Bn/3J2Glth5uD5LRQemRVU5B19z9+s2U8GdF9xtmbp0WlF2KUBWVopieMkp 0t2yz1wMI6jyS/x1Ol+9doChihWKwI+PS9Tdl3sBGlsFXtA2GDjkmL1l9XHue6WF/LQX EMd04VChvZbzYs2hUr6KQYaZyZXLgNcoIUuZvgsmTokc/kpKNjSYXCzzRKKJEVIomSpM EOIfD1x65D9iyLpoRqu9bvMPxZ0q388GXgFFRyHnll5H2NAgJFuexZGHYy2aeNHZdPlI 9ALQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=y+bMKdHi3SWeYs4dZvhMtk+AUKH/ZBVC2n8ty7LnNMw=; b=ZRhClVCJeJxO3W8nXksjXKTfcvhusOb2/H3pmAWLRGCTAcx8pHN+W5wh6pGHpXthvi 8TFjOzXNuDsy34mi7TwA/RPb6DucvgK2dFdOFr7rUWc7wR6NPnaD46pUMiTGlINUs/I4 gldw3xDRYbvAgy47sYTObIAqmyWo3VAmPaFUAm0xNLuYFi0Np1xlgCR8mNGrm299W2hZ BxSk/Vh7u7fpes+HCOaYmSu9nJDSD+5J/ULV1J6+sNGX3twKilXnVeZa9Fxzd2nskTYx 5fmZgymgb0dNrQPTctglp6tJAHYrPcHfMumNYIVrqULV1rnRIYdyySMujGW/19cowENR 2rAQ== X-Gm-Message-State: APjAAAVRkBlQbbEHa5OBC+D4qX5cBd2Qf9eDQGIqwTC2SWgwLm4yS1kx 8gmf1JynY5z1HbSCfirjV9mTug== X-Google-Smtp-Source: APXvYqz7yEcQCcV2YqsuxzHQvEks2ZE/l/OOZgMrg0Wz6mqHYeR2PgroLF9cUQOlbXrypOEq4yA/5g== X-Received: by 2002:a17:902:b089:: with SMTP id p9mr30161989plr.185.1555051226410; Thu, 11 Apr 2019 23:40:26 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h65sm100553081pfd.108.2019.04.11.23.40.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Apr 2019 23:40:25 -0700 (PDT) From: Baolin Wang To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Date: Fri, 12 Apr 2019 14:40:17 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Cc: orsonzhai@gmail.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, zhang.lyra@gmail.com, baolin.wang@linaro.org Subject: [alsa-devel] [PATCH] ASoC: sprd: Add reserved DMA memory support 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP For Spreadtrum audio platform driver, it need allocate a larger DMA buffer dynamically to copy audio data between userspace and kernel space, but that will increase the risk of memory allocation failure especially the system is under heavy load situation. To make sure the audio can work in this scenario, we usually reserve one region of memory to be used as a shared pool of DMA buffers for the platform component. So add of_reserved_mem_device_init_by_idx() function to initialize the shared pool of DMA buffers to be used by the platform component. Signed-off-by: Baolin Wang --- sound/soc/sprd/sprd-pcm-dma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/sprd/sprd-pcm-dma.c b/sound/soc/sprd/sprd-pcm-dma.c index 9be6d4b..d38ebbb 100644 --- a/sound/soc/sprd/sprd-pcm-dma.c +++ b/sound/soc/sprd/sprd-pcm-dma.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -530,8 +531,14 @@ static void sprd_pcm_free(struct snd_pcm *pcm) static int sprd_soc_platform_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; int ret; + ret = of_reserved_mem_device_init_by_idx(&pdev->dev, np, 0); + if (ret) + dev_warn(&pdev->dev, + "no reserved DMA memory for audio platform device\n"); + ret = devm_snd_soc_register_component(&pdev->dev, &sprd_soc_component, NULL, 0); if (ret)