Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp653514ybi; Wed, 3 Jul 2019 02:33:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzewWFqxfbdTBQLXkPW5/aBceyZVzObDCl2auf5AJR48ZZYYwQ0roeIpnP77Yf1NRXhXIA X-Received: by 2002:a63:4518:: with SMTP id s24mr36755087pga.123.1562146381051; Wed, 03 Jul 2019 02:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562146381; cv=none; d=google.com; s=arc-20160816; b=xEm+0341tONNkbM1W428qJV+hVaLpGOR22YPonoKhWqs8P9K1gZFcqtqoC7H3jrfcV Zu75ZFFzVUVnNBFehU2X1Sh7iHDbaeaMAk0yOf9IY6QGJ72VL9oU+VukaPvKuD6HEUPx xc8puFdlteZ9DQ7OcuMlL8K8T8AtgpzCpHgB757jaesJNaXF/AoAptsCU1EucoLAFubu yIYVp6UPh6YHFQGWEMj1QLFL98GlkaSIKN2IPCawebNxT+oNNPXcTG9NXm4WtWKSiJT0 vhZf7VfphIUhf3+oHcYMbFwDl6J/ckZ3BCsMKwnPGt9ACkZJm8xxvYdl0+AyRTDkeNmv CudQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/0Sf7T61uUKW8C8wXwdWCRDXeImdhIeyIR/3laF3HyM=; b=VMpoFQ5Wq/hLaRMh4vH0leiWgJq3SqrXAJfcCAaxfIpebefPiADsmLSVkqmymeKZDK k9oFAphlrMxhzwlbZ1Whdd5JyyS5vvgdZVDkAbACcDPNOrcta/sb1uiBudZTD7Um2sDw shI1Im/kVsH2qYlhNOpa/goGTUQuWRiQ1sxK8AQxEU3ZDCiOENBkeVUY0N1bdLOftGOP Jd/CsYBqEz9zmnnUx12o8/kd0QCYEndrocx0mWiBxKqD12+AEObeGbBuDISZL56q8pB6 5vtuvMMPmAraogueHNMc75jJI2+tALUE8TiqQeKV1uk1He7fD/CNMzcc5zG2lKDf6rFZ 50qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mEzXQP7R; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si1777090pgb.107.2019.07.03.02.32.45; Wed, 03 Jul 2019 02:33:01 -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=@gmail.com header.s=20161025 header.b=mEzXQP7R; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbfGCJcU (ORCPT + 99 others); Wed, 3 Jul 2019 05:32:20 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39694 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbfGCJcT (ORCPT ); Wed, 3 Jul 2019 05:32:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id j2so966793pfe.6 for ; Wed, 03 Jul 2019 02:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/0Sf7T61uUKW8C8wXwdWCRDXeImdhIeyIR/3laF3HyM=; b=mEzXQP7R1V8XIbe8Lr0s+G/4kNC5xNjBNZzmeTIBTzqFw5xaqVNElsXEEOYrMq1Eni V689Dl9KTZ6Hwpmn83oe5KBFfg7l/UtnBW5mqkwD3Elx30bWLTsHJM+fhDLK6XcJgG0K LmWi9ed8LgLEYQ9jKpZ44X3z6fM/VSLiRcfAjJslpRWN/YZ4ly0HSbA/AA6MoBM41MsB Zzeg9cgwhS8XLGxOjG52x/uWYE+TOSegRwu6eJ01dy0Z9yzGY9VuROJIgUFFXgr8j4/2 v/AXHf1AO+csh1CN22EISwqC7PLlEn7z5y4615Fo7pVFDGx+no3x62CVNajF3F1xLEXy iQNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/0Sf7T61uUKW8C8wXwdWCRDXeImdhIeyIR/3laF3HyM=; b=OsJvEJ6BeNmHA4m8VSn5rmtA4YmEzQ0DcXiqkJEI67OLPZ88ypUMHNA9jfwLZNK8fU uerywXjsdV5W4haXQwrnB+jE79RKdzPvM2K2GpMMsPkDxNK5BrpPBvY0nEg3iYz16j9m zYGxXZMpHZ8XGSePkjlFjaRDmaW58ofLhxcVQVpjjVYAZfMCs9GMKn/tY/zZKV/SG5du t+fyV/mA0lkMdJipTSNEM9V7svok5AI7fFu354R/Efr/8nVcdzpPeMb519ktbO663xJ4 A/ljksmNFni+bIdSz1J7zaFochXYae8FKT+NER2bLpUOjdZ9mTBuASjO3dDAHfUY26bc etyQ== X-Gm-Message-State: APjAAAU4zyJD92nzy7qYr5om1flqkYo0bdTRIjTrgNKRHZNCJPY2abgj yAQGxNc7Kb/eNQMly0yeUnOEKy4x+dA= X-Received: by 2002:a17:90a:9f08:: with SMTP id n8mr11713529pjp.102.1562146338970; Wed, 03 Jul 2019 02:32:18 -0700 (PDT) Received: from Asurada (c-98-248-47-108.hsd1.ca.comcast.net. [98.248.47.108]) by smtp.gmail.com with ESMTPSA id a3sm2234049pfi.63.2019.07.03.02.32.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2019 02:32:18 -0700 (PDT) Date: Wed, 3 Jul 2019 02:32:10 -0700 From: Nicolin Chen To: shengjiu.wang@nxp.com Cc: timur@kernel.org, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 2/2] ASoC: fsl_esai: recover the channel swap after xrun Message-ID: <20190703093209.GB8764@Asurada> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 03, 2019 at 02:42:05PM +0800, shengjiu.wang@nxp.com wrote: > From: Shengjiu Wang > > There is chip errata ERR008000, the reference doc is > (https://www.nxp.com/docs/en/errata/IMX6DQCE.pdf), > > The issue is "While using ESAI transmit or receive and > an underrun/overrun happens, channel swap may occur. > The only recovery mechanism is to reset the ESAI." > > This issue exist in imx3/imx5/imx6(partial) series. > > In this commit add a tasklet to handle reset of ESAI > after xrun happens to recover the channel swap. > > Signed-off-by: Shengjiu Wang > --- > sound/soc/fsl/fsl_esai.c | 76 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 76 insertions(+) > > diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c > index 20039ae9893b..8c92e49ad6d8 100644 > --- a/sound/soc/fsl/fsl_esai.c > +++ b/sound/soc/fsl/fsl_esai.c > +static void fsl_esai_reset(unsigned long arg) Similarly fsl_esai_hw_reset? This one isn't really that bad though, yet it feels better to have function naming in a similar style. > +{ > + struct fsl_esai *esai_priv = (struct fsl_esai *)arg; > + u32 saisr, tfcr, rfcr; > + > + /* save the registers */ > + regmap_read(esai_priv->regmap, REG_ESAI_TFCR, &tfcr); > + regmap_read(esai_priv->regmap, REG_ESAI_RFCR, &rfcr); Instead of having this implicit comments, we could have: + bool tx = true, rx = false, enabled[2]; + + regmap_read(esai_priv->regmap, REG_ESAI_TFCR, &tfcr); + regmap_read(esai_priv->regmap, REG_ESAI_RFCR, &rfcr); + enabled[tx] = tfcr & ESAI_xFCR_xFEN; + enabled[rx] = rfcr & ESAI_xFCR_xFEN; > + > + /* stop the tx & rx */ > + fsl_esai_trigger_stop(esai_priv, 1); > + fsl_esai_trigger_stop(esai_priv, 0); And we could reuse the boolean 'tx' and 'rx' here. > + > + /* reset the esai, and restore the registers */ > + fsl_esai_init(esai_priv); > + [...] > + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, > + ESAI_xCR_xPR_MASK, > + ESAI_xCR_xPR); > + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR, > + ESAI_xCR_xPR_MASK, > + ESAI_xCR_xPR); Mask and value might fit into one line? > + > + /* restore registers by regcache_sync */ > + fsl_esai_register_restore(esai_priv); > + > + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, > + ESAI_xCR_xPR_MASK, 0); > + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR, > + ESAI_xCR_xPR_MASK, 0); And just for curious, can (or shall) we stuff this personal reset to the reset() function? I found this one is a part of the reset routine being mentioned in the RM -- it was done after ESAI reset is done via ECR register. [...] > + regmap_update_bits(esai_priv->regmap, REG_ESAI_PRRC, > + ESAI_PRRC_PDC_MASK, > + ESAI_PRRC_PDC(ESAI_GPIO)); > + regmap_update_bits(esai_priv->regmap, REG_ESAI_PCRC, > + ESAI_PCRC_PC_MASK, > + ESAI_PCRC_PC(ESAI_GPIO)); Mask and value might fit into one line?