diff mbox series

spi: spi-fsl-lpspi: Use IRQF_NO_AUTOEN flag in request_irq()

Message ID 20240906022828.891812-1-ruanjinjie@huawei.com
State New
Headers show
Series spi: spi-fsl-lpspi: Use IRQF_NO_AUTOEN flag in request_irq() | expand

Commit Message

Jinjie Ruan Sept. 6, 2024, 2:28 a.m. UTC
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable when request IRQ.

Fixes: 9728fb3ce117 ("spi: lpspi: disable lpspi module irq in DMA mode")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/spi/spi-fsl-lpspi.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Mark Brown Sept. 19, 2024, 10:47 a.m. UTC | #1
On Fri, Sep 06, 2024 at 10:28:28AM +0800, Jinjie Ruan wrote:
> disable_irq() after request_irq() still has a time gap in which
> interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
> disable IRQ auto-enable when request IRQ.

> @@ -948,14 +948,10 @@ 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)
> +	if (ret < 0) {
>  		dev_warn(&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);
> +		enable_irq(irq);
> +	}

This now enabled the interrupt in the case where we previously would've
disabled it - I would have expected the condition on the if statement to
be reversed?
Jinjie Ruan Sept. 19, 2024, 11:18 a.m. UTC | #2
On 2024/9/19 18:47, Mark Brown wrote:
> On Fri, Sep 06, 2024 at 10:28:28AM +0800, Jinjie Ruan wrote:
>> disable_irq() after request_irq() still has a time gap in which
>> interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
>> disable IRQ auto-enable when request IRQ.
> 
>> @@ -948,14 +948,10 @@ 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)
>> +	if (ret < 0) {
>>  		dev_warn(&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);
>> +		enable_irq(irq);
>> +	}
> 
> This now enabled the interrupt in the case where we previously would've
> disabled it - I would have expected the condition on the if statement to
> be reversed?

It enabled the if statement rather than the else because the else
statement has been removed.

Use IRQF_NO_AUTOEN, the irq will not be enabled in devm_request_irq(),
so if (ret < 0), we should enable it, otherwise it is same with
disable_irq(irq) if we do nothing now, the main difference is that the
irq is not enabled when return before calling enable_irq().
Mark Brown Sept. 19, 2024, 12:26 p.m. UTC | #3
On Thu, Sep 19, 2024 at 07:18:45PM +0800, Jinjie Ruan wrote:
> On 2024/9/19 18:47, Mark Brown wrote:

> > This now enabled the interrupt in the case where we previously would've
> > disabled it - I would have expected the condition on the if statement to
> > be reversed?

> It enabled the if statement rather than the else because the else
> statement has been removed.

Ah, yes - I'd missed the else there.
Mark Brown Sept. 30, 2024, 9:41 p.m. UTC | #4
On Fri, 06 Sep 2024 10:28:28 +0800, Jinjie Ruan wrote:
> disable_irq() after request_irq() still has a time gap in which
> interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
> disable IRQ auto-enable when request IRQ.
> 
> 

Applied to

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

Thanks!

[1/1] spi: spi-fsl-lpspi: Use IRQF_NO_AUTOEN flag in request_irq()
      commit: 003c7e01916c5e2af95add9b0cbda2e6163873e8

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
diff mbox series

Patch

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 8f8496578d6b..7ab251e911a8 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -891,7 +891,7 @@  static int fsl_lpspi_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0,
+	ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, IRQF_NO_AUTOEN,
 			       dev_name(&pdev->dev), fsl_lpspi);
 	if (ret) {
 		dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret);
@@ -948,14 +948,10 @@  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)
+	if (ret < 0) {
 		dev_warn(&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);
+		enable_irq(irq);
+	}
 
 	ret = devm_spi_register_controller(&pdev->dev, controller);
 	if (ret < 0) {