Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp899660imm; Sat, 26 May 2018 14:34:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqPMGm+GfW54LePL3qX+A+3v+6ljQBdlPsLslVJAfEUW/lXRyqUOEKLksUqAADF+T08ZBHg X-Received: by 2002:a62:d751:: with SMTP id v17-v6mr7706436pfl.39.1527370494124; Sat, 26 May 2018 14:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527370494; cv=none; d=google.com; s=arc-20160816; b=fHGTbkt1FMWeqeXSZRqOPgiuu83qg5t14qu0iznbU1GUiM1B9Lr4e/h6kTCssKu7/m gXYuJ/GYZV4UufAjEp5Y01bmlcppjkBruGpClViZyDN4TFcPZXXAEVoN42rsBPt4YY0b RPdJDYpUidrHN9H1aZNC/SC1t3eTpa9uK/myUeqeO5k6o1QXRxu6GLD+yf+ialBcTQ3V Pd6EfMrq7f3+k5BYjo63KZaw9OmF5EnFkEaxEfgyzX8USZqJ/p3TzBXvfYmLPgK7zCyq tAJxb+xN6eSpKAukf3yrJDdMBp7s5bWxClwtEIxqnLE62Snf7QJ9Fem7OjCtW7ZWNolQ 5+EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=4HAo3++BZ8miXdW4sZhOgQ1GNrcinPFSRT+bmpN7pKo=; b=OkLU5kK6IxgS/DVerMwpLhPRhFeh8504oje7vlPQ4NPmRzXiJUOgNp/kXcSu3Y2sQa StsB40PR9u4byrBFUtbs1OS3UyzFWnXJpav1hgjmT/K6lt6lfZnAYJv/5fQ5dCuu9bc4 SSS8O4DwGiciawLq/4F3leTfh077i3U/Popfe2Ls8VM6gUjErXqqUEgl5CYdXlVUkuJW Ie9BIGdPvBmSBAyQVN2OfMGj/jp2FadGQMZPi68cBk8kX/o/2tSrkik29M7RdkT3AdTr V3ulH7x1BxckoKUVsVqBpNkr/9QV/qORDRz2sZjw/XZIotvYPSjkDu/0QYtk5Sb1qRPn ujKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nD5XCQJN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11-v6si8177549plt.9.2018.05.26.14.34.25; Sat, 26 May 2018 14:34:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nD5XCQJN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032455AbeEZVeQ (ORCPT + 99 others); Sat, 26 May 2018 17:34:16 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:38853 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032388AbeEZVeP (ORCPT ); Sat, 26 May 2018 17:34:15 -0400 Received: by mail-vk0-f66.google.com with SMTP id u8-v6so5107699vku.5 for ; Sat, 26 May 2018 14:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4HAo3++BZ8miXdW4sZhOgQ1GNrcinPFSRT+bmpN7pKo=; b=nD5XCQJNJMuP5eGzCuDwIy2zHzsuQ4n+vhIX7tCwtp+xMa3KbtqOOGJY5sUnJ5SJWH MVu1atOOAtyX7UxvjrpcZVFKUa8EA1jb0MYm2ernjP2Vnd/QUPZqwd4KDNcyAR767N4Z 8UxeTLTyQ/IHOqn2vt7N70K4eakRnxX6m2Y4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4HAo3++BZ8miXdW4sZhOgQ1GNrcinPFSRT+bmpN7pKo=; b=MIAxQFFFAiDbHmAeXTISijHABEYZPA7NrmOAqkShOdVtlR9uYLJQ1wsnK1ppd7m5it nRPsemQND9mmeeJf8e88erOPi86jrxnDfW57Qcv/q61fTmwbbgEvp8nHEwUqVCKspwCA 0Rfh+7Bzei99fopIXqGK2BZHSZq9O/wdEzeVZ4+BeeVJ3LtGte/fb0dkaFUZ1KPpkvaP skOBPJCdUEJWwhOOWakM0MW9CjbR5IcYEzAmwyO9G/2WANGeWzRAxD8wrJppBEStFlD9 MJne0z96dVoL7Njau9qgBJwZ4WOtWwT89crAGX3ntmCfZXqclyIyKJStO7zzzItJG8Xg sG3A== X-Gm-Message-State: ALKqPwdCCrjSC3DvT2JezcSqzxFIVvToSUixgMeSGst4J5vA3H2aSeNW D0AAhDU2fBlsq8nCvs+6Tn9kSGsLDk6Uv6o0o/1Y2w== X-Received: by 2002:a1f:954:: with SMTP id 81-v6mr60103vkj.46.1527370454163; Sat, 26 May 2018 14:34:14 -0700 (PDT) MIME-Version: 1.0 References: <1527240163-9804-1-git-send-email-akshu.agrawal@amd.com> In-Reply-To: <1527240163-9804-1-git-send-email-akshu.agrawal@amd.com> From: Daniel Kurtz Date: Sat, 26 May 2018 15:34:02 -0600 Message-ID: Subject: Re: [PATCH] ASoC: AMD: make channel 1 dma as circular To: Akshu Agrawal Cc: Alexander.Deucher@amd.com, Liam Girdwood , Mark Brown , perex@perex.cz, tiwai@suse.com, Vijendar.Mukunda@amd.com, Guenter Roeck , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 25, 2018 at 3:23 AM Akshu Agrawal wrote: > channel 1: SYSMEM<->ACP > channel 2: ACP<->I2S > Instead of waiting on period interrupt of ch 2 and then starting > dma on ch1, we make ch1 dma as circular. > This removes dependency of period granularity on hw pointer. > Signed-off-by: Akshu Agrawal Reviewed-by: Daniel Kurtz Tested-by: Daniel Kurtz > --- > sound/soc/amd/acp-pcm-dma.c | 72 +++++++-------------------------------------- > 1 file changed, 10 insertions(+), 62 deletions(-) > diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c > index ac32dea..f1d8678 100644 > --- a/sound/soc/amd/acp-pcm-dma.c > +++ b/sound/soc/amd/acp-pcm-dma.c > @@ -337,8 +337,7 @@ static void config_acp_dma(void __iomem *acp_mmio, > } > /* Start a given DMA channel transfer */ > -static void acp_dma_start(void __iomem *acp_mmio, > - u16 ch_num, bool is_circular) > +static void acp_dma_start(void __iomem *acp_mmio, u16 ch_num) > { > u32 dma_ctrl; > @@ -369,11 +368,8 @@ static void acp_dma_start(void __iomem *acp_mmio, > break; > } > - /* enable for ACP SRAM to/from I2S DMA channel */ > - if (is_circular == true) > - dma_ctrl |= ACP_DMA_CNTL_0__Circular_DMA_En_MASK; > - else > - dma_ctrl &= ~ACP_DMA_CNTL_0__Circular_DMA_En_MASK; > + /* circular for both DMA channel */ > + dma_ctrl |= ACP_DMA_CNTL_0__Circular_DMA_En_MASK; > acp_reg_write(dma_ctrl, acp_mmio, mmACP_DMA_CNTL_0 + ch_num); > } > @@ -617,7 +613,6 @@ static int acp_deinit(void __iomem *acp_mmio) > /* ACP DMA irq handler routine for playback, capture usecases */ > static irqreturn_t dma_irq_handler(int irq, void *arg) > { > - u16 dscr_idx; > u32 intr_flag, ext_intr_status; > struct audio_drv_data *irq_data; > void __iomem *acp_mmio; > @@ -634,33 +629,13 @@ static irqreturn_t dma_irq_handler(int irq, void *arg) > if ((intr_flag & BIT(ACP_TO_I2S_DMA_CH_NUM)) != 0) { > valid_irq = true; > - if (acp_reg_read(acp_mmio, mmACP_DMA_CUR_DSCR_13) == > - PLAYBACK_START_DMA_DESCR_CH13) > - dscr_idx = PLAYBACK_END_DMA_DESCR_CH12; > - else > - dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; > - config_acp_dma_channel(acp_mmio, SYSRAM_TO_ACP_CH_NUM, dscr_idx, > - 1, 0); > - acp_dma_start(acp_mmio, SYSRAM_TO_ACP_CH_NUM, false); > - > snd_pcm_period_elapsed(irq_data->play_i2ssp_stream); > - > acp_reg_write((intr_flag & BIT(ACP_TO_I2S_DMA_CH_NUM)) << 16, > acp_mmio, mmACP_EXTERNAL_INTR_STAT); > } > if ((intr_flag & BIT(ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM)) != 0) { > valid_irq = true; > - if (acp_reg_read(acp_mmio, mmACP_DMA_CUR_DSCR_9) == > - PLAYBACK_START_DMA_DESCR_CH9) > - dscr_idx = PLAYBACK_END_DMA_DESCR_CH8; > - else > - dscr_idx = PLAYBACK_START_DMA_DESCR_CH8; > - config_acp_dma_channel(acp_mmio, > - SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM, > - dscr_idx, 1, 0); > - acp_dma_start(acp_mmio, SYSRAM_TO_ACP_BT_INSTANCE_CH_NUM, > - false); > snd_pcm_period_elapsed(irq_data->play_i2sbt_stream); > acp_reg_write((intr_flag & > BIT(ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM)) << 16, > @@ -669,38 +644,20 @@ static irqreturn_t dma_irq_handler(int irq, void *arg) > if ((intr_flag & BIT(I2S_TO_ACP_DMA_CH_NUM)) != 0) { > valid_irq = true; > - if (acp_reg_read(acp_mmio, mmACP_DMA_CUR_DSCR_15) == > - CAPTURE_START_DMA_DESCR_CH15) > - dscr_idx = CAPTURE_END_DMA_DESCR_CH14; > - else > - dscr_idx = CAPTURE_START_DMA_DESCR_CH14; > - config_acp_dma_channel(acp_mmio, ACP_TO_SYSRAM_CH_NUM, dscr_idx, > - 1, 0); > - acp_dma_start(acp_mmio, ACP_TO_SYSRAM_CH_NUM, false); > - > + snd_pcm_period_elapsed(irq_data->capture_i2ssp_stream); > acp_reg_write((intr_flag & BIT(I2S_TO_ACP_DMA_CH_NUM)) << 16, > acp_mmio, mmACP_EXTERNAL_INTR_STAT); > } > if ((intr_flag & BIT(ACP_TO_SYSRAM_CH_NUM)) != 0) { > valid_irq = true; > - snd_pcm_period_elapsed(irq_data->capture_i2ssp_stream); > acp_reg_write((intr_flag & BIT(ACP_TO_SYSRAM_CH_NUM)) << 16, > acp_mmio, mmACP_EXTERNAL_INTR_STAT); > } > if ((intr_flag & BIT(I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM)) != 0) { > valid_irq = true; > - if (acp_reg_read(acp_mmio, mmACP_DMA_CUR_DSCR_11) == > - CAPTURE_START_DMA_DESCR_CH11) > - dscr_idx = CAPTURE_END_DMA_DESCR_CH10; > - else > - dscr_idx = CAPTURE_START_DMA_DESCR_CH10; > - config_acp_dma_channel(acp_mmio, > - ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM, > - dscr_idx, 1, 0); > - acp_dma_start(acp_mmio, ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM, > - false); > + snd_pcm_period_elapsed(irq_data->capture_i2sbt_stream); > acp_reg_write((intr_flag & > BIT(I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM)) << 16, > acp_mmio, mmACP_EXTERNAL_INTR_STAT); > @@ -708,7 +665,6 @@ static irqreturn_t dma_irq_handler(int irq, void *arg) > if ((intr_flag & BIT(ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM)) != 0) { > valid_irq = true; > - snd_pcm_period_elapsed(irq_data->capture_i2sbt_stream); > acp_reg_write((intr_flag & > BIT(ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM)) << 16, > acp_mmio, mmACP_EXTERNAL_INTR_STAT); > @@ -1015,11 +971,9 @@ static int acp_dma_prepare(struct snd_pcm_substream *substream) > static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) > { > int ret; > - u32 loops = 4000; > u64 bytescount = 0; > struct snd_pcm_runtime *runtime = substream->runtime; > - struct snd_soc_pcm_runtime *prtd = substream->private_data; > struct audio_substream_data *rtd = runtime->private_data; > struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); > @@ -1034,18 +988,12 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) > if (rtd->bytescount == 0) > rtd->bytescount = bytescount; > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > - acp_dma_start(rtd->acp_mmio, rtd->ch1, false); > - while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & > - BIT(rtd->ch1)) { > - if (!loops--) { > - dev_err(component->dev, > - "acp dma start timeout\n"); > - return -ETIMEDOUT; > - } > - cpu_relax(); > - } > + acp_dma_start(rtd->acp_mmio, rtd->ch1); > + acp_dma_start(rtd->acp_mmio, rtd->ch2); > + } else { > + acp_dma_start(rtd->acp_mmio, rtd->ch2); > + acp_dma_start(rtd->acp_mmio, rtd->ch1); > } > - acp_dma_start(rtd->acp_mmio, rtd->ch2, true); > ret = 0; > break; > case SNDRV_PCM_TRIGGER_STOP: > -- > 1.9.1