linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: lpspi: disable lpspi module irq in DMA mode
@ 2023-05-05  6:35 Clark Wang
  2023-05-05  9:16 ` Dhruva Gole
  2023-05-24 11:04 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Clark Wang @ 2023-05-05  6:35 UTC (permalink / raw)
  To: broonie; +Cc: linux-spi, linux-kernel

When all bits of IER are set to 0, we still can observe the lpspi irq events
when using DMA mode to transfer data.

So disable irq to avoid the too much irq events.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/spi/spi-fsl-lpspi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index f2341ab99556..4b70038ceb6b 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -910,9 +910,14 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
 	ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
 	if (ret == -EPROBE_DEFER)
 		goto out_pm_get;
-
 	if (ret < 0)
 		dev_err(&pdev->dev, "dma setup error %d, use pio\n", ret);
+	else
+		/*
+		 * disable LPSPI module IRQ when enable DMA mode successfully,
+		 * to prevent the unexpected LPSPI module IRQ events.
+		 */
+		disable_irq(irq);
 
 	ret = devm_spi_register_controller(&pdev->dev, controller);
 	if (ret < 0) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi: lpspi: disable lpspi module irq in DMA mode
  2023-05-05  6:35 [PATCH] spi: lpspi: disable lpspi module irq in DMA mode Clark Wang
@ 2023-05-05  9:16 ` Dhruva Gole
  2023-05-05  9:40   ` Clark Wang
  2023-05-24 11:04 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Dhruva Gole @ 2023-05-05  9:16 UTC (permalink / raw)
  To: Clark Wang, broonie; +Cc: linux-spi, linux-kernel



On 05/05/23 12:05, Clark Wang wrote:
> When all bits of IER are set to 0, we still can observe the lpspi irq events
> when using DMA mode to transfer data.
> 
> So disable irq to avoid the too much irq events.
> 
> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
> ---
>   drivers/spi/spi-fsl-lpspi.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> index f2341ab99556..4b70038ceb6b 100644
> --- a/drivers/spi/spi-fsl-lpspi.c
> +++ b/drivers/spi/spi-fsl-lpspi.c
> @@ -910,9 +910,14 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
>   	ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
>   	if (ret == -EPROBE_DEFER)
>   		goto out_pm_get;
> -

Any reason to delete this line?

>   	if (ret < 0)
>   		dev_err(&pdev->dev, "dma setup error %d, use pio\n", ret);
> +	else
> +		/*
> +		 * disable LPSPI module IRQ when enable DMA mode successfully,
> +		 * to prevent the unexpected LPSPI module IRQ events.
> +		 */
> +		disable_irq(irq);

Just wondering, have you actually seen any unexpected LPSPI module IRQ
events? If this was causing issues earlier then maybe add a fixes tag?

>   
>   	ret = devm_spi_register_controller(&pdev->dev, controller);
>   	if (ret < 0) {

-- 
Thanks and Regards,
Dhruva Gole

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] spi: lpspi: disable lpspi module irq in DMA mode
  2023-05-05  9:16 ` Dhruva Gole
@ 2023-05-05  9:40   ` Clark Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Clark Wang @ 2023-05-05  9:40 UTC (permalink / raw)
  To: Dhruva Gole, broonie; +Cc: linux-spi, linux-kernel

Hi Dhruva,

> -----Original Message-----
> From: Dhruva Gole <d-gole@ti.com>
> Sent: 2023年5月5日 17:16
> To: Clark Wang <xiaoning.wang@nxp.com>; broonie@kernel.org
> Cc: linux-spi@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] spi: lpspi: disable lpspi module irq in DMA mode
> 
> 
> 
> On 05/05/23 12:05, Clark Wang wrote:
> > When all bits of IER are set to 0, we still can observe the lpspi irq
> > events when using DMA mode to transfer data.
> >
> > So disable irq to avoid the too much irq events.
> >
> > Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
> > ---
> >   drivers/spi/spi-fsl-lpspi.c | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> > index f2341ab99556..4b70038ceb6b 100644
> > --- a/drivers/spi/spi-fsl-lpspi.c
> > +++ b/drivers/spi/spi-fsl-lpspi.c
> > @@ -910,9 +910,14 @@ static int fsl_lpspi_probe(struct platform_device
> *pdev)
> >   	ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
> >   	if (ret == -EPROBE_DEFER)
> >   		goto out_pm_get;
> > -
> 
> Any reason to delete this line?

Both of the if statements are used to determine the return value of fsl_lpspi_dma_init(), so I remove this line.

> 
> >   	if (ret < 0)
> >   		dev_err(&pdev->dev, "dma setup error %d, use pio\n", ret);
> > +	else
> > +		/*
> > +		 * disable LPSPI module IRQ when enable DMA mode successfully,
> > +		 * to prevent the unexpected LPSPI module IRQ events.
> > +		 */
> > +		disable_irq(irq);
> 
> Just wondering, have you actually seen any unexpected LPSPI module IRQ
> events? If this was causing issues earlier then maybe add a fixes tag?

Yes, I have observed this issue. 
The reason for this problem is that some older platforms are designed to combine LPSPI interrupt and LPSPI DMA channel interrupt into one shared interrupt number because the IRQ interrupt number is not enough.
When the problem occurs, we can observe that if the interrupt comes too many times and too quickly, it will trigger the IRQ in the LPSPI driver while DMA is still processing the previous DMA request(through the shared dma channel interrupt), resulting in data messing.

Best Regards,
Clark Wang
> 
> >
> >   	ret = devm_spi_register_controller(&pdev->dev, controller);
> >   	if (ret < 0) {
> 
> --
> Thanks and Regards,
> Dhruva Gole

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi: lpspi: disable lpspi module irq in DMA mode
  2023-05-05  6:35 [PATCH] spi: lpspi: disable lpspi module irq in DMA mode Clark Wang
  2023-05-05  9:16 ` Dhruva Gole
@ 2023-05-24 11:04 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-05-24 11:04 UTC (permalink / raw)
  To: Clark Wang; +Cc: linux-spi, linux-kernel

On Fri, 05 May 2023 14:35:57 +0800, Clark Wang wrote:
> When all bits of IER are set to 0, we still can observe the lpspi irq events
> when using DMA mode to transfer data.
> 
> So disable irq to avoid the too much irq events.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: lpspi: disable lpspi module irq in DMA mode
      commit: 9728fb3ce11729aa8c276825ddf504edeb00611d

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-24 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05  6:35 [PATCH] spi: lpspi: disable lpspi module irq in DMA mode Clark Wang
2023-05-05  9:16 ` Dhruva Gole
2023-05-05  9:40   ` Clark Wang
2023-05-24 11:04 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).