From patchwork Wed Sep 26 10:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 147563 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp532793lji; Wed, 26 Sep 2018 03:26:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV63ZuStmBLvk479gHtIVTw/5m/d2l3IDT14r/mksiDqBDlGrp3K3UIIs07Oczup1lYJ+e6DQ X-Received: by 2002:a1c:448a:: with SMTP id r132-v6mr3965267wma.132.1537957577252; Wed, 26 Sep 2018 03:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537957577; cv=none; d=google.com; s=arc-20160816; b=Uo4+iSrPv5NnvYs0mWwdYcxi5SDUqTAPzZh6wiEsZTVyBuLuIxOV1yZJ/GQNlVlY0z NuDvvKEAIYHCzUEqyTnStcJPJr+NdAamMhgWNc6144eQw+FsvQ1kc33daOMQBbWWS/9I 77THxyO8LxYJjT/04RnoUvjtJlLJZ/hf1shEnWSTIVkw/BdPLN9SMuTzgRYMzC3sqEf/ A7BkEbk1GJ/MFt5YCrVHcrc0HM/sVd4WU1/xv4aElFWKkwp9EWjHF17+tJhScdHdl7Tf NNzKx5M7uK/bjnlmkJKCOw22kPShc5IFdeFvirKJpWLji6jNxJNXODp6qfO+3YQGPz6X qMOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=JUk+lYimdTq9Y/QqYt5DhYc8QmZmnfv/4ngeLCJIb6M=; b=SxfvLT85bRiCItEKljnclO7YideJrJwvq/eDdExBdNEbzsKtqewHqG+gg1MALNSmGG uqak1a45uGFnLvCJxqdb5SOPRqCgxHnMjNUHyMKHPJKsxJquebsvmL/MzI2AeNrbtFN8 ATyOpfljhIz8LMYtkVm1YaVslWNpi7GIXhtQZ8oBEMTiiFRs3BM0+GAahQSXIUufbmC8 x42ImhOFll6quKqtwl/60ybvMDt3lWGZkwNSzeu7Jl6g1WEf4PbLLcAopSYDbDlg7II3 BbyP1lxFgHmGfpglAV5Y44FtpABzhSnHZ3CiI9WizQ8ivhbB+edDQma2NRoAEBFYrfar awzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XWqQE2Il; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id j16-v6si4863811wrn.333.2018.09.26.03.26.17; Wed, 26 Sep 2018 03:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XWqQE2Il; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 555D62678D2; Wed, 26 Sep 2018 12:26:05 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3329B2678BD; Wed, 26 Sep 2018 12:26:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by alsa0.perex.cz (Postfix) with ESMTP id 9F5D4267730 for ; Wed, 26 Sep 2018 12:25:58 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id s12-v6so1694395wmc.0 for ; Wed, 26 Sep 2018 03:25:58 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=TN2IJYdHgtT3BemFu8Zp1UT/5yhsLzCn9bEmOt6lOpI=; b=XWqQE2IlUVNjMtveRD6CAvGlRmZ/OpsYOg/IqRzN+4gUlbqaODkme2cXgvvgtNOYIb rl+o44RLqc6nYU44jqWDMUAZiaRLOXpzX92CALCquPVR/MXXkAN9Y15ZL7VSx8tCvFjG e2BwbnieNa3JuEMRFoFkEULU0C+4TENskguac= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=TN2IJYdHgtT3BemFu8Zp1UT/5yhsLzCn9bEmOt6lOpI=; b=MUKpziyE3+4diZ7xVfa2IiLrS9r3NDCI0T4ALFhAkqWTMLcCItu42+GwFBG/PqqiAF rK6OAacydjf0S2y1q34CXrKu0Dki59PVSuO6vULVAJtkuDQd43cVKQwDdcXEv9GpK1Oc gFPWhn5Rpq215kfahCr5l9AF7i+Nx3qCQE3xARxy5gZFLQDYLMreaBinblSSWZRLPIGy 5wOW9BC4jAu9E32EcgAiUMB74OFzqjIY0dvpXB27OLz0k0RlOhmQGh61iPOaylpegMKX 7O282fL8Vo9XXMFkGQXlv18ynVp1hhFhAcLGTJCyGU9emBO5Hf3p3cosfonkzkAfHnlN PL9A== X-Gm-Message-State: ABuFfojZsOqRElEqxt69r1KgOiydsibtGu0TYL8MHG0USzSvHtAdOtR/ pkEsHR5/13aywZL2HiXgPWwQ6g== X-Received: by 2002:a1c:c145:: with SMTP id r66-v6mr3813360wmf.131.1537957558038; Wed, 26 Sep 2018 03:25:58 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id b12sm4442648wrx.11.2018.09.26.03.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Sep 2018 03:25:57 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org Date: Wed, 26 Sep 2018 11:23:46 +0100 Message-Id: <20180926102349.23481-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180926102349.23481-1-srinivas.kandagatla@linaro.org> References: <20180926102349.23481-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, bgoswami@codeaurora.org, lgirdwood@gmail.com, tiwai@suse.com, linux-kernel@vger.kernel.org, vkoul@kernel.org, rohitkr@codeaurora.org, Srinivas Kandagatla Subject: [alsa-devel] [PATCH v2 2/5] ALSA: compress: make use of runtime buffer for copy X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org Default copy function uses kmalloc to allocate buffers, lets check if the runtime buffers are setup before making this allocations. This can be useful if the buffers are dma buffers. Signed-off-by: Srinivas Kandagatla --- sound/core/compress_offload.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) -- 2.19.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 26b5e245b074..a5b09e75e787 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -171,7 +171,8 @@ static int snd_compr_free(struct inode *inode, struct file *f) } data->stream.ops->free(&data->stream); - kfree(data->stream.runtime->buffer); + if (!data->stream.runtime->dma_buffer_p) + kfree(data->stream.runtime->buffer); kfree(data->stream.runtime); kfree(data); return 0; @@ -505,7 +506,7 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, struct snd_compr_params *params) { unsigned int buffer_size; - void *buffer; + void *buffer = NULL; buffer_size = params->buffer.fragment_size * params->buffer.fragments; if (stream->ops->copy) { @@ -514,7 +515,18 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, * the data from core */ } else { - buffer = kmalloc(buffer_size, GFP_KERNEL); + if (stream->runtime->dma_buffer_p) { + + if (buffer_size > stream->runtime->dma_buffer_p->bytes) + dev_err(&stream->device->dev, + "Not enough DMA buffer"); + else + buffer = stream->runtime->dma_buffer_p->area; + + } else { + buffer = kmalloc(buffer_size, GFP_KERNEL); + } + if (!buffer) return -ENOMEM; }