All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mukunda, Vijendar" <Vijendar.Mukunda@amd.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Alex Deucher <alexdeucher@gmail.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"tiwai@suse.de" <tiwai@suse.de>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>
Subject: RE: [PATCH v2 08/14] ASoC: amd: add ACP PDM DMA driver dai ops
Date: Tue, 12 May 2020 16:15:03 +0000	[thread overview]
Message-ID: <DM6PR12MB26338B02D772799482F1A01997BE0@DM6PR12MB2633.namprd12.prod.outlook.com> (raw)
In-Reply-To: <3c1a08a0-31e8-dc0c-a903-190861b7fa11@linux.intel.com>



> -----Original Message-----
> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Sent: Tuesday, May 12, 2020 3:42 AM
> To: Alex Deucher <alexdeucher@gmail.com>; alsa-devel@alsa-project.org;
> broonie@kernel.org; Mukunda, Vijendar <Vijendar.Mukunda@amd.com>;
> tiwai@suse.de
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>
> Subject: Re: [PATCH v2 08/14] ASoC: amd: add ACP PDM DMA driver dai ops
> 
> 
> 
> 
> > +static int start_pdm_dma(void __iomem *acp_base)
> > +{
> > +	u32 pdm_enable;
> > +	u32 pdm_dma_enable;
> > +	int timeout;
> > +
> > +	pdm_enable = 0x01;
> > +	pdm_dma_enable  = 0x01;
> > +
> > +	enable_pdm_clock(acp_base);
> > +	rn_writel(pdm_enable, acp_base + ACP_WOV_PDM_ENABLE);
> > +	rn_writel(pdm_dma_enable, acp_base +
> ACP_WOV_PDM_DMA_ENABLE);
> > +	pdm_dma_enable = 0x00;
> > +	timeout = 0;
> > +	while (++timeout < ACP_COUNTER) {
> > +		pdm_dma_enable = rn_readl(acp_base +
> ACP_WOV_PDM_DMA_ENABLE);
> > +		if ((pdm_dma_enable & 0x02) ==
> ACP_PDM_DMA_EN_STATUS)
> > +			return 0;
> > +		udelay(DELAY_US);
> > +	}
> > +	return -ETIMEDOUT;
> > +}
> > +
> > +static int stop_pdm_dma(void __iomem *acp_base)
> > +{
> > +	u32 pdm_enable, pdm_dma_enable, pdm_fifo_flush;
> > +	int timeout;
> > +
> > +	pdm_enable = 0x00;
> > +	pdm_dma_enable  = 0x00;
> > +	pdm_fifo_flush = 0x00;
> > +
> > +	pdm_enable = rn_readl(acp_base + ACP_WOV_PDM_ENABLE);
> > +	pdm_dma_enable = rn_readl(acp_base +
> ACP_WOV_PDM_DMA_ENABLE);
> > +	if (pdm_dma_enable & 0x01) {
> > +		pdm_dma_enable = 0x02;
> > +		rn_writel(pdm_dma_enable, acp_base +
> ACP_WOV_PDM_DMA_ENABLE);
> > +		pdm_dma_enable = 0x00;
> > +		timeout = 0;
> > +		while (++timeout < ACP_COUNTER) {
> > +			pdm_dma_enable = rn_readl(acp_base +
> > +
> ACP_WOV_PDM_DMA_ENABLE);
> > +			if ((pdm_dma_enable & 0x02) == 0x00)
> > +				break;
> > +			udelay(DELAY_US);
> > +		}
> > +		if (timeout == ACP_COUNTER)
> 
> if you reach this point, timeout is by construction equal to ACP_COUNTER
> so this test is useless

Here we are checking current dma status. 
If DMA enable status bit is set to zero , it will exit the while loop.
It will continue rest of the registers programming to disable PDM
decoder and flushing fifo.

When  this condition "if ((pdm_dma_enable & 0x02) == 0x00)" is true,
"timeout" counter won't be exhausted i.e it won't cross ACP_COUNTER
value.

We have to return time out error only when DMA enable status bit is 
not cleared and timeout reached max value i.e ACP_COUNTER. i.e 
This check " if (timeout == ACP_COUNTER) " required to know the while 
loop exit condition.

> 
> You could also use a helper where you check if the value is
> ACP_PDM_DMA_EN_STATUS or zero so that you don't copy the same logic
> twice.

I believe it's only a single register check, still its hold to be good.



  reply	other threads:[~2020-05-12 16:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 21:20 [PATCH v2 00/14] Add Renoir ACP driver Alex Deucher
2020-05-11 21:20 ` [PATCH v2 01/14] ASoC: amd: add Renoir ACP3x IP register header Alex Deucher
2020-05-11 21:20 ` [PATCH v2 02/14] ASoC: amd: add Renoir ACP PCI driver Alex Deucher
2020-05-11 21:20 ` [PATCH v2 03/14] ASoC: amd: add acp init/de-init functions Alex Deucher
2020-05-11 21:20 ` [PATCH v2 04/14] ASoC: amd: create acp3x pdm platform device Alex Deucher
2020-05-11 21:20 ` [PATCH v2 05/14] ASoC: amd: add ACP3x PDM platform driver Alex Deucher
2020-05-11 21:20 ` [PATCH v2 06/14] ASoC: amd: irq handler changes for ACP3x PDM dma driver Alex Deucher
2020-05-11 21:20 ` [PATCH v2 07/14] ASoC: amd: add acp3x pdm driver dma ops Alex Deucher
2020-05-11 21:20 ` [PATCH v2 08/14] ASoC: amd: add ACP PDM DMA driver dai ops Alex Deucher
2020-05-11 22:12   ` Pierre-Louis Bossart
2020-05-12 16:15     ` Mukunda, Vijendar [this message]
2020-05-11 21:20 ` [PATCH v2 09/14] ASoC: amd: add Renoir ACP PCI driver PM ops Alex Deucher
2020-05-11 22:28   ` Pierre-Louis Bossart
2020-05-12 13:46     ` Alex Deucher
2020-05-12 15:16       ` Pierre-Louis Bossart
2020-05-12 19:54         ` Mukunda, Vijendar
2020-05-12 20:36           ` Pierre-Louis Bossart
2020-05-13 17:44             ` Mukunda, Vijendar
2020-05-11 21:20 ` [PATCH v2 10/14] ASoC: amd: add ACP PDM DMA driver pm ops Alex Deucher
2020-05-11 21:20 ` [PATCH v2 11/14] ASoC: amd: enable Renoir acp3x drivers build Alex Deucher
2020-05-11 21:20 ` [PATCH v2 12/14] ASoC: amd: create platform devices for Renoir Alex Deucher
2020-05-11 21:20 ` [PATCH v2 13/14] ASoC: amd: RN machine driver using dmic Alex Deucher
2020-05-11 22:37   ` Pierre-Louis Bossart
2020-05-12 14:22     ` Mukunda, Vijendar
2020-05-11 21:20 ` [PATCH v2 14/14] ASoC: amd: enable build for RN machine driver Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR12MB26338B02D772799482F1A01997BE0@DM6PR12MB2633.namprd12.prod.outlook.com \
    --to=vijendar.mukunda@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=alexdeucher@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.