From patchwork Mon Apr 16 11:59:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 133456 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp3481167ljb; Mon, 16 Apr 2018 04:59:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/xQZGeIvKUOq3mY4JtncEaHrG3cZd9PJZSb9SPBOFNgJf3BB66vVUK1UWgYNU3aN829Dbn X-Received: by 10.28.235.3 with SMTP id j3mr10614335wmh.146.1523879988531; Mon, 16 Apr 2018 04:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523879988; cv=none; d=google.com; s=arc-20160816; b=f+xxCU9jHK3PlWlrV6NDFsB55QRALr87xyCrXhBpaQIuEY4kzQZmpyaAOhfn9Yh9pJ 3s9LMrJ8UbCivkcciQmReA9JusBpUK4yhAnfcDeQCi1uiKbtauVYN77V7vY0xcacHO1h u1+2ZzQbNB+CU9PLB+GVpdWSDIHY6wkFLXW6vKGu7IfQ2s6Ni821iyz5vcMPC5ooOeKc Xx77XHZYk9uhR+t3rH25fEJqQRusQY1LDue42XSGQzOzG2N5v+9tmWYIB3EnQUPW0CGM faXchZqw9aGbV0oL1Er4MyDuAepHcwG+vN1zAyeARt7l2FGyk1Trv7r0T/UiiTYFxcAT 9+rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=LNNpSsDh7KEV53Dcd5SHwnw129M80Qymjd5VIbbckJE=; b=dP3FcRn58sHQKparyk+JKZ/ZemXYSqukObemiH8z95PZ4vcgaITvpp346QnOVtrDoz fPCvg9Fk5pwkFCES1Ybf3ovzqekGbOOsq1o3BwTTAKETGqM6UQ/sLTg8TqgBTSqL4s17 X6bUSxZQSMkG8MEtY6YRZ8HDUud+FI3zNFQ8j84S5HeffNCBcJT6t5UftKDmDVuP2/D0 lwZqcXjpNa5fIHXCL6wVtwumrcjqOHfyaEFDYOUrbEMmYmIJ9WLsYuSkOnnKjSwpiqcp oP1Tp/A6IFyAVXzr5aOWkair6dujKahXHLnJ+xhGCM2bCLBA9fkOmCE5KN9PpxGZkw+N Vzpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=HAq22JHl; 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 Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id c82si5419038wmc.0.2018.04.16.04.59.48; Mon, 16 Apr 2018 04:59:48 -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=@sirena.org.uk header.s=20170815-heliosphere header.b=HAq22JHl; 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 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B61FA2673ED; Mon, 16 Apr 2018 13:59:46 +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 766BC2673F4; Mon, 16 Apr 2018 13:59:44 +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.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id E316E2673C7 for ; Mon, 16 Apr 2018 13:59:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=CosklEwr78wa2qniBw3/IkI459cSZAVlxmtbdOngTuU=; b=HAq22JHl1HPA CyLgl77RQwQHolO763ny//NsOz31l2l+wtmBSkiPCixSgvUsXxX3BpRim9t/DhYWryorXPXQaOmwQ 3Atq2YBHm+VNFd6vlXmNvM3LyhUBDTzSMAgRxvxAx6g+Zy/nVD5IsCjd5pKHBJ8K3Gxx9BXDK169/ rflwo=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1f82nM-0005eU-3B; Mon, 16 Apr 2018 11:59:40 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1f82nL-00005S-Kz; Mon, 16 Apr 2018 12:59:39 +0100 From: Mark Brown To: Kuninori Morimoto In-Reply-To: <87fu3vd9ct.wl%kuninori.morimoto.gx@renesas.com> Message-Id: Date: Mon, 16 Apr 2018 12:59:39 +0100 Cc: alsa-devel@alsa-project.org, Mark Brown , Hiroyuki Yokoyama Subject: [alsa-devel] Applied "ASoC: rsnd: Enable IPMMU v2" to the asoc tree 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: rsnd: Enable IPMMU v2 has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 5423d77253ac5bcb2d3de61cf0811c0f2a62c0af Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 16 Apr 2018 05:14:01 +0000 Subject: [PATCH] ASoC: rsnd: Enable IPMMU v2 commit 4821d914fe747 ("ASoC: rsnd: use dma_sync_single_for_xxx() for IOMMU") (= v1) which have been already reverted had supported IPMMU support on rsnd driver. Because memory allocating timing and DMAEngine access timing were different, it used continuous memory and called dma map function by itself. OTOH, it is using DMA descriptor mode (= DMA cyclic mode), thus, there was timing conflict between DMA sync/unsync and DMA transfer starting, and it maked sound noise. This patch supports IPMMU with coherent memory, and, it uses Audio DMAC dev for allocating memory by snd_pcm_lib_preallocate_pages_for_all() to indicate memory area to IPMMU. One note is that Playback/Capture need each paired Audio DMAC dev. Because of this, we need to keep each paired Audio DMAC dev when probing, and use it when allocating each memory for IPMMU. Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 47 +++++++++++++++++++++++++++++++++++----- sound/soc/sh/rcar/dma.c | 7 ++++++ sound/soc/sh/rcar/rsnd.h | 1 + 3 files changed, 50 insertions(+), 5 deletions(-) -- 2.17.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 47a55d6bfd80..f9ac086d8e05 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1352,6 +1352,37 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, #define PREALLOC_BUFFER (32 * 1024) #define PREALLOC_BUFFER_MAX (32 * 1024) +static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd, + struct rsnd_dai_stream *io, + int stream) +{ + struct rsnd_priv *priv = rsnd_io_to_priv(io); + struct device *dev = rsnd_priv_to_dev(priv); + struct snd_pcm_substream *substream; + int err; + + /* + * use Audio-DMAC dev if we can use IPMMU + * see + * rsnd_dmaen_attach() + */ + if (io->dmac_dev) + dev = io->dmac_dev; + + for (substream = rtd->pcm->streams[stream].substream; + substream; + substream = substream->next) { + err = snd_pcm_lib_preallocate_pages(substream, + SNDRV_DMA_TYPE_DEV, + dev, + PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); + if (err < 0) + return err; + } + + return 0; +} + static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->cpu_dai; @@ -1366,11 +1397,17 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - return snd_pcm_lib_preallocate_pages_for_all( - rtd->pcm, - SNDRV_DMA_TYPE_DEV, - rtd->card->snd_card->dev, - PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); + ret = rsnd_preallocate_pages(rtd, &rdai->playback, + SNDRV_PCM_STREAM_PLAYBACK); + if (ret) + return ret; + + ret = rsnd_preallocate_pages(rtd, &rdai->capture, + SNDRV_PCM_STREAM_CAPTURE); + if (ret) + return ret; + + return 0; } static const struct snd_soc_component_driver rsnd_soc_component = { diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 32ac97be26f1..ef82b94d038b 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c @@ -253,6 +253,13 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io, return -EAGAIN; } + /* + * use it for IPMMU if needed + * see + * rsnd_preallocate_pages() + */ + io->dmac_dev = chan->device->dev; + dma_release_channel(chan); dmac->dmaen_num++; diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index b1896f1eb214..6d7280d2d9be 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -435,6 +435,7 @@ struct rsnd_dai_stream { struct snd_pcm_substream *substream; struct rsnd_mod *mod[RSND_MOD_MAX]; struct rsnd_dai *rdai; + struct device *dmac_dev; /* for IPMMU */ u32 parent_ssi_status; }; #define rsnd_io_to_mod(io, i) ((i) < RSND_MOD_MAX ? (io)->mod[(i)] : NULL)