From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Oleksij Rempel <linux@rempel-privat.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Gao Pan <b54642@freescale.com>,
Fugang Duan <B38611@freescale.com>, Wolfram Sang <wsa@kernel.org>,
linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] i2c: imx: Fix external abort on early interrupt
Date: Fri, 12 Jun 2020 07:51:14 +0200 [thread overview]
Message-ID: <20200612055114.alhm2uakoze6epvf@pengutronix.de> (raw)
In-Reply-To: <1591796802-23504-1-git-send-email-krzk@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 4525 bytes --]
Hi Krzysztof,
thank you for your patch.
On Wed, Jun 10, 2020 at 03:46:42PM +0200, Krzysztof Kozlowski wrote:
> If interrupt comes early (could be triggered with CONFIG_DEBUG_SHIRQ),
> the i2c_imx_isr() will access registers before the I2C hardware is
> initialized. This leads to external abort on non-linefetch on Toradex
> Colibri VF50 module (with Vybrid VF5xx):
>
> Unhandled fault: external abort on non-linefetch (0x1008) at 0x8882d003
> Internal error: : 1008 [#1] ARM
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper Not tainted 5.7.0 #607
> Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree)
> (i2c_imx_isr) from [<8017009c>] (free_irq+0x25c/0x3b0)
> (free_irq) from [<805844ec>] (release_nodes+0x178/0x284)
> (release_nodes) from [<80580030>] (really_probe+0x10c/0x348)
> (really_probe) from [<80580380>] (driver_probe_device+0x60/0x170)
> (driver_probe_device) from [<80580630>] (device_driver_attach+0x58/0x60)
> (device_driver_attach) from [<805806bc>] (__driver_attach+0x84/0xc0)
> (__driver_attach) from [<8057e228>] (bus_for_each_dev+0x68/0xb4)
> (bus_for_each_dev) from [<8057f3ec>] (bus_add_driver+0x144/0x1ec)
> (bus_add_driver) from [<80581320>] (driver_register+0x78/0x110)
> (driver_register) from [<8010213c>] (do_one_initcall+0xa8/0x2f4)
> (do_one_initcall) from [<80c0100c>] (kernel_init_freeable+0x178/0x1dc)
> (kernel_init_freeable) from [<80807048>] (kernel_init+0x8/0x110)
> (kernel_init) from [<80100114>] (ret_from_fork+0x14/0x20)
>
> Additionally, the i2c_imx_isr() could wake up the wait queue
> (imx_i2c_struct->queue) before its initialization happens.
>
> Fixes: 1c4b6c3bcf30 ("i2c: imx: implement bus recovery")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
I assume register access is aborted, because the IP core clock is not
enabled. In this case we have bigger problem then just probe.
Since this driver support runtime power management, the clock will be
disabled as soon as transfer is done. It means, on shared interrupt, we
will get in trouble even if there is no active transfer.
So, probably the only way to fix it, is to check in i2c_imx_isr() if the
HW is expected to be active and register access should be save.
Regards,
Oleksij
> ---
> drivers/i2c/busses/i2c-imx.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 0ab5381aa012..e28a39f4840f 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1171,14 +1171,6 @@ static int i2c_imx_probe(struct platform_device *pdev)
> return ret;
> }
>
> - /* Request IRQ */
> - ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, IRQF_SHARED,
> - pdev->name, i2c_imx);
> - if (ret) {
> - dev_err(&pdev->dev, "can't claim irq %d\n", irq);
> - goto clk_disable;
> - }
> -
> /* Init queue */
> init_waitqueue_head(&i2c_imx->queue);
>
> @@ -1223,6 +1215,14 @@ static int i2c_imx_probe(struct platform_device *pdev)
> if (ret < 0)
> goto clk_notifier_unregister;
>
> + /* Request IRQ */
> + ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, IRQF_SHARED,
> + pdev->name, i2c_imx);
> + if (ret) {
> + dev_err(&pdev->dev, "can't claim irq %d\n", irq);
> + goto i2c_del_adapter;
> + }
> +
> pm_runtime_mark_last_busy(&pdev->dev);
> pm_runtime_put_autosuspend(&pdev->dev);
>
> @@ -1237,6 +1237,8 @@ static int i2c_imx_probe(struct platform_device *pdev)
>
> return 0; /* Return OK */
>
> +i2c_del_adapter:
> + i2c_del_adapter(&i2c_imx->adapter);
> clk_notifier_unregister:
> clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
> rpm_disable:
> @@ -1244,8 +1246,6 @@ static int i2c_imx_probe(struct platform_device *pdev)
> pm_runtime_disable(&pdev->dev);
> pm_runtime_set_suspended(&pdev->dev);
> pm_runtime_dont_use_autosuspend(&pdev->dev);
> -
> -clk_disable:
> clk_disable_unprepare(i2c_imx->clk);
> return ret;
> }
> --
> 2.7.4
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-06-12 5:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 13:46 [PATCH] i2c: imx: Fix external abort on early interrupt Krzysztof Kozlowski
2020-06-12 5:51 ` Oleksij Rempel [this message]
2020-06-12 7:38 ` Krzysztof Kozlowski
2020-06-12 8:02 ` Oleksij Rempel
2020-06-12 8:23 ` Krzysztof Kozlowski
2020-06-12 9:05 ` Wolfram Sang
2020-06-12 9:29 ` Krzysztof Kozlowski
2020-06-12 9:56 ` Wolfram Sang
2020-06-12 10:21 ` Krzysztof Kozlowski
2020-06-12 10:31 ` Oleksij Rempel
2020-06-12 10:34 ` Marc Kleine-Budde
2020-06-12 10:44 ` Krzysztof Kozlowski
2020-06-12 10:50 ` Marc Kleine-Budde
2020-06-12 10:39 ` Krzysztof Kozlowski
2020-06-12 11:51 ` Wolfram Sang
2020-06-12 12:18 ` Marc Kleine-Budde
2020-06-12 13:00 ` Wolfram Sang
2020-06-12 13:09 ` Krzysztof Kozlowski
2020-06-15 7:37 ` Aisheng Dong
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=20200612055114.alhm2uakoze6epvf@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=B38611@freescale.com \
--cc=b54642@freescale.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rempel-privat.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=wsa@kernel.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;
as well as URLs for NNTP newsgroup(s).