mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: mediatek: Enable irq before the spi registration
Date: Sun, 25 Dec 2022 14:06:59 +0000	[thread overview]
Message-ID: <Y6hZA19rWuDkGJa2@makrotopia.org> (raw)
In-Reply-To: <20221225-mtk-spi-fixes-v1-0-bb6c14c232f8@chromium.org>

On Sun, Dec 25, 2022 at 09:37:12AM +0100, Ricardo Ribalda wrote:
> If the irq is enabled after the spi si registered, there can be a race
> with the initialization of the devices on the spi bus.
> 
> Eg:
> mtk-spi 1100a000.spi: spi-mem transfer timeout
> spi-nor: probe of spi0.0 failed with error -110
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000010
> ...
> Call trace:
>  mtk_spi_can_dma+0x0/0x2c
> 
> Fixes: c6f7874687f7 ("spi: mediatek: Enable irq when pdata is ready")
> Reported-by: Daniel Golle <daniel@makrotopia.org>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> spi: mediatek: Fix init order (again)
> 
> Hi Mark
> 
> Here is a fixup of the previous patch. Daniel, can you confirm that it
> works on your hardware? 

Yes, this fixes the issue and SPI now works fine on MT7986 with the
patch applied.

Tested-by: Daniel Golle <daniel@makrotopia.org>

> 
> Thanks and sorry for annoyance. 
> 
> To: Mark Brown <broonie@kernel.org>
> To: Matthias Brugger <matthias.bgg@gmail.com>
> To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: linux-spi@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: Daniel Golle <daniel@makrotopia.org>
> ---
>  drivers/spi/spi-mt65xx.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
> index 6de8360e5c2a..9eab6c20dbc5 100644
> --- a/drivers/spi/spi-mt65xx.c
> +++ b/drivers/spi/spi-mt65xx.c
> @@ -1253,6 +1253,11 @@ static int mtk_spi_probe(struct platform_device *pdev)
>  		dev_notice(dev, "SPI dma_set_mask(%d) failed, ret:%d\n",
>  			   addr_bits, ret);
>  
> +	ret = devm_request_irq(dev, irq, mtk_spi_interrupt,
> +			       IRQF_TRIGGER_NONE, dev_name(dev), master);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to register irq\n");
> +
>  	pm_runtime_enable(dev);
>  
>  	ret = devm_spi_register_master(dev, master);
> @@ -1261,13 +1266,6 @@ static int mtk_spi_probe(struct platform_device *pdev)
>  		return dev_err_probe(dev, ret, "failed to register master\n");
>  	}
>  
> -	ret = devm_request_irq(dev, irq, mtk_spi_interrupt,
> -			       IRQF_TRIGGER_NONE, dev_name(dev), master);
> -	if (ret) {
> -		pm_runtime_disable(dev);
> -		return dev_err_probe(dev, ret, "failed to register irq\n");
> -	}
> -
>  	return 0;
>  }
>  
> 
> ---
> base-commit: 45b3cd900bf8d1a3cd7cf48361df8c09ae5b4009
> change-id: 20221225-mtk-spi-fixes-99c863a6fdf1
> 
> Best regards,
> -- 
> Ricardo Ribalda <ribalda@chromium.org>

  reply	other threads:[~2022-12-25 14:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-25  8:37 Ricardo Ribalda
2022-12-25 14:06 ` Daniel Golle [this message]
2022-12-27 11:57 ` Mark Brown
2022-12-27 13:43 ` Mark Brown
2023-01-04 14:08   ` Thorsten Leemhuis
2023-01-04 14:35     ` Mark Brown

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=Y6hZA19rWuDkGJa2@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=ribalda@chromium.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®