Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3481101imm; Tue, 29 May 2018 08:00:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpnCmg8JUu7dOJkD2oZ5omB68Bn3OLKDwp2Ocy/PIp2twNkFFimfUKg/niT2aYUWpWELAJM X-Received: by 2002:a65:4487:: with SMTP id l7-v6mr13847928pgq.194.1527606030071; Tue, 29 May 2018 08:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527606030; cv=none; d=google.com; s=arc-20160816; b=vq3dMApvlPFMm7lX0FhwQEyv1nCm8M2iz5NPTisS027ZlSahw2STA7TF/K4cDKWnp6 qI6QvwA1LXHxrWHNhKFdn1nT3aP/FZDJD3m7D23J5NgrpCvC5OOWIcXtOccpgQ9ey5Zn TasnGvAPI/cu0ORn3V+ARdvqoizvN8GTKpcGyHJkcttGTxTKpSm45yalcHoO7lZW0okZ MPPs4GyDJEvxUCgWMNDOFZAwV7IfcpQUx8yELnr94O/da3/O8fVXA84eVNmjQ4SRvTp5 mddyDmusL+qjxefby3tfRX1ezjISVh/vwMgKgiMsqYrdoxNqSBgYSZX+U9xgocL06vUw YHPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=Svbs6LG+Iy9qxCaYeeD6FMJ9LKnCa8cAufdCqUe65rE=; b=btp6nU0Ew3ukP2IuekLtZKW0NrGfjXYDqe4+5zq717HLjCPpPGiYrFLqfAwovP9a37 sb5Il1pawZ5jGSJW/Z6IPHwk3pmLeCK0E0GKp71VJlI/s+d86mb5uLe8mtnlndT1eIdB 0dI3GwRaCtW8JuZKZuspnUNiVh/xSVDZn7SRu6Cs5UDE2VU+Sriosspy3pwithnH1kmh dO4Y4/jBv6vIPI5c3UjKvA2CL5egg/aN7TrghIHW6e1+RXokbxBYjJuMfUGNiBJdsLft pclv9FKl5DEjJOOXnrjKwXZfgCjC0t/wAT43E+ZjKVoW8qJirPthNHKJCFfSEzuNbb47 iEpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=Z1nJTlMn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4-v6si25879617pgn.403.2018.05.29.08.00.15; Tue, 29 May 2018 08:00:30 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=Z1nJTlMn; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965094AbeE2O7w (ORCPT + 99 others); Tue, 29 May 2018 10:59:52 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:41762 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965048AbeE2O7p (ORCPT ); Tue, 29 May 2018 10:59:45 -0400 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=Svbs6LG+Iy9qxCaYeeD6FMJ9LKnCa8cAufdCqUe65rE=; b=Z1nJTlMnIM1B v0O8QBt9Dfs9b5dhtQkUEzSuCf+gBkCj5WYpfVNSi8yHMQJ4o4JxHJx/rK+kTrUtWwNECNRWE5rjp fJWIvw5qSynx7Ssu3u+2i+ZBqL4mrVKIBId7Ea7RasiR7a5gk2IF5G9K9SE5YOjdm7xVg3A15nl1L HRYNA=; 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 1fNg6B-0005bw-52; Tue, 29 May 2018 14:59:43 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fNg6A-00069N-NV; Tue, 29 May 2018 15:59:42 +0100 From: Mark Brown To: Agrawal@sirena.org.uk, Akshu Cc: Akshu Agrawal , Daniel Kurtz , Mark Brown , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Takashi Iwai , Liam Girdwood , djkurtz@chromium.org, Mark Brown , "Mukunda,, Vijendar" , Alex Deucher , akshu.agrawal@amd.com, Guenter Roeck , alsa-devel@alsa-project.org Subject: Applied "ASoC: AMD: make channel 1 dma as circular" to the asoc tree In-Reply-To: <1527479306-12658-1-git-send-email-akshu.agrawal@amd.com> Message-Id: Date: Tue, 29 May 2018 15:59:42 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch ASoC: AMD: make channel 1 dma as circular 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 6b116dfb4633a7efce7f96355c2d272d8b16f0fb Mon Sep 17 00:00:00 2001 From: "Agrawal, Akshu" Date: Mon, 28 May 2018 11:48:22 +0800 Subject: [PATCH] ASoC: AMD: make channel 1 dma as circular 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 Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 74 +++++-------------------------------- 1 file changed, 10 insertions(+), 64 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index ac32deaa9541..77203841c535 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,14 +971,10 @@ 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); if (!rtd) return -EINVAL; @@ -1034,18 +986,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: -- 2.17.0