From patchwork Thu Jan 24 08:56:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Borleis X-Patchwork-Id: 2030031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 895EFDF264 for ; Thu, 24 Jan 2013 09:00:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TyIcq-0004GS-1e; Thu, 24 Jan 2013 08:57:36 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TyIcm-0004G9-UO for linux-arm-kernel@lists.infradead.org; Thu, 24 Jan 2013 08:57:33 +0000 Received: from isonoe.hi.pengutronix.de ([10.1.0.76]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1TyIck-0003fQ-VG; Thu, 24 Jan 2013 09:57:30 +0100 From: Juergen Beisert Organization: Pengutronix - Linux Solutions for Science and Industry Subject: Sound/ARM/i.MX/SSI: fix SDMA starvation Date: Thu, 24 Jan 2013 09:56:30 +0100 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Disposition: inline To: linux-sound@vger.kernel.org Message-Id: <201301240956.30641.jbe@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.76 X-SA-Exim-Mail-From: jbe@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-20130124_035733_352020_7A80EC76 X-CRM114-Status: GOOD ( 18.92 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In cases when capturing is already running and someone enables also playback, the SDMA unit of the i.MX SoC does not see an edge on its TX DMA request line. This is due to the TX FIFOs are empty, and this request line is active all the time, when the CCSR_SSI_SIER_TDMAE bit is set. In this case also the TX FIFO underrun interrupt will flood the system forever. To ensure the first edge happens after enabling the TX side of the SSI unit and to trigger the SDMA unit successfully enable the CCSR_SSI_SIER_TDMAE on demand only. To be sure, this patch does the same for the CCSR_SSI_SIER_RDMAE (RX side) bit. Signed-off-by: Juergen Beisert Acked-by: Shawn Guo --- sound/soc/fsl/fsl_ssi.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) Index: linux.git/sound/soc/fsl/fsl_ssi.c =================================================================== --- linux.git.orig/sound/soc/fsl/fsl_ssi.c +++ linux.git/sound/soc/fsl/fsl_ssi.c @@ -86,10 +86,9 @@ static inline void write_ssi_mask(u32 __ #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 | \ +#define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TIE | \ + CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TUE1_EN | \ + CCSR_SSI_SIER_RFRC_EN | CCSR_SSI_SIER_RIE | \ CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN) /** @@ -489,6 +488,9 @@ static int fsl_ssi_hw_params(struct snd_ * * The DMA channel is in external master start and pause mode, which * means the SSI completely controls the flow of data. + * + * To use the i.MX's SDMA unit it is important to create an edge on the + * corresponding request line. Otherwise the request will be ignored! */ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) @@ -500,20 +502,26 @@ static int fsl_ssi_trigger(struct snd_pc switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); - else + write_ssi_mask(&ssi->sier, 0, CCSR_SSI_SIER_TDMAE); + } else { write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); + write_ssi_mask(&ssi->sier, 0, CCSR_SSI_SIER_RDMAE); + } break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0); - else + write_ssi_mask(&ssi->sier, CCSR_SSI_SIER_TDMAE, 0); + } else { write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); + write_ssi_mask(&ssi->sier, CCSR_SSI_SIER_RDMAE, 0); + } break; default: