From patchwork Wed Nov 13 13:12:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 3178121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0F8A39F39E for ; Wed, 13 Nov 2013 13:13:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 566EF205E4 for ; Wed, 13 Nov 2013 13:13:36 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F7D92011F for ; Wed, 13 Nov 2013 13:13:31 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgaG7-0005bB-Ni; Wed, 13 Nov 2013 13:13:27 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgaG5-0007kJ-FN; Wed, 13 Nov 2013 13:13:25 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VgaG2-0007j0-8c for linux-arm-kernel@lists.infradead.org; Wed, 13 Nov 2013 13:13:23 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1VgaFQ-0003ub-7j; Wed, 13 Nov 2013 14:12:44 +0100 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1VgaFN-00017v-TT; Wed, 13 Nov 2013 14:12:41 +0100 From: Markus Pargmann To: Timur Tabi , Mark Brown , Liam Girdwood Subject: [PATCH] ASoC: fsl-ssi: Fix interrupt enable/disable Date: Wed, 13 Nov 2013 14:12:10 +0100 Message-Id: <1384348330-23117-1-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 1.8.4.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131113_081322_713607_E4C5A214 X-CRM114-Status: GOOD ( 16.60 ) X-Spam-Score: -1.9 (-) Cc: Markus Pargmann , alsa-devel@alsa-project.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fsl_ssi_trigger function enables all interrupts (for RX and TX) when a stream is started. The enabled interrupts are never cleared. We don't need all interrupts enabled for one active stream, e.g. RX interrupts are not necessary for playback. Next to the interrupts, the DMA enable bits are set at the same time. This can lead to lost DMA requests and SDMA starvation. This patch seperates the SIER flags into DMA_TX and DMA_RX flags to seperatly enable/disable the TX/RX channels. Based on Jürgen Beisert's patch 'ASoC: fsl-ssi: fix SDMA starvation'. Cc: Jürgen Beisert Signed-off-by: Markus Pargmann --- sound/soc/fsl/fsl_ssi.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 6b81d0c..905b8db 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -107,11 +107,18 @@ static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set) #endif /* SIER bitflag of interrupts to enable */ -#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \ - CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \ - CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \ - CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ - CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN) +#define FSLSSI_TX_SIER_FLAGS (CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN) +#define FSLSSI_RX_SIER_FLAGS (CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN) + +#define FSLSSI_DMA_TX_SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | \ + CCSR_SSI_SIER_TDMAE | CCSR_SSI_SIER_TIE | \ + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TUE1_EN) +#define FSLSSI_DMA_RX_SIER_FLAGS (CCSR_SSI_SIER_RFRC_EN | \ + CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \ + CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN) + +#define FSLSSI_SISR_MASK (FSLSSI_TX_SIER_FLAGS | FSLSSI_RX_SIER_FLAGS | \ + FSLSSI_DMA_TX_SIER_FLAGS | FSLSSI_DMA_RX_SIER_FLAGS) /** * fsl_ssi_private: per-SSI private data @@ -201,7 +208,7 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) were interrupted for. We mask it with the Interrupt Enable register so that we only check for events that we're interested in. */ - sisr = read_ssi(&ssi->sisr) & SIER_FLAGS; + sisr = read_ssi(&ssi->sisr) & FSLSSI_SISR_MASK; if (sisr & CCSR_SSI_SISR_RFRC) { ssi_private->stats.rfrc++; @@ -567,19 +574,20 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (ssi_private->use_dma) - sier_bits = SIER_FLAGS; + sier_bits = FSLSSI_DMA_TX_SIER_FLAGS; else - sier_bits = CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN; + sier_bits = FSLSSI_TX_SIER_FLAGS; } else { if (ssi_private->use_dma) - sier_bits = SIER_FLAGS; + sier_bits = FSLSSI_DMA_RX_SIER_FLAGS; else - sier_bits = CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN; + sier_bits = FSLSSI_RX_SIER_FLAGS; } switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + write_ssi_mask(&ssi->sier, 0, sier_bits); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); @@ -590,6 +598,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + write_ssi_mask(&ssi->sier, sier_bits, 0); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0); else @@ -604,8 +613,6 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, return -EINVAL; } - write_ssi(sier_bits, &ssi->sier); - return 0; } @@ -801,7 +808,7 @@ static struct snd_ac97_bus_ops fsl_ssi_ac97_ops = { */ #define SIER_SHOW(flag, name) \ do { \ - if (SIER_FLAGS & CCSR_SSI_SIER_##flag) \ + if (FSLSSI_SISR_MASK & CCSR_SSI_SIER_##flag) \ length += sprintf(buf + length, #name "=%u\n", \ ssi_private->stats.name); \ } while (0)