]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Nov 2020 08:51:59 +0000 (09:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Nov 2020 08:51:59 +0000 (09:51 +0100)
added patches:
i2c-imx-fix-external-abort-on-interrupt-in-exit-paths.patch

queue-4.4/i2c-imx-fix-external-abort-on-interrupt-in-exit-paths.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/i2c-imx-fix-external-abort-on-interrupt-in-exit-paths.patch b/queue-4.4/i2c-imx-fix-external-abort-on-interrupt-in-exit-paths.patch
new file mode 100644 (file)
index 0000000..d65cf7b
--- /dev/null
@@ -0,0 +1,121 @@
+From foo@baz Fri Nov 20 09:48:52 AM CET 2020
+From: Krzysztof Kozlowski <krzk@kernel.org>
+Date: Sun, 20 Sep 2020 23:12:38 +0200
+Subject: i2c: imx: Fix external abort on interrupt in exit paths
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+commit e50e4f0b85be308a01b830c5fbdffc657e1a6dd0 upstream
+
+If interrupt comes late, during probe error path or device remove (could
+be triggered with CONFIG_DEBUG_SHIRQ), the interrupt handler
+i2c_imx_isr() will access registers with the clock being disabled.  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.
+
+The resource-managed framework should not be used for interrupt handling,
+because the resource will be released too late - after disabling clocks.
+The interrupt handler is not prepared for such case.
+
+Fixes: 1c4b6c3bcf30 ("i2c: imx: implement bus recovery")
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
+Signed-off-by: Wolfram Sang <wsa@kernel.org>
+[sudip: manual backport with extra label for goto]
+Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/i2c/busses/i2c-imx.c |   25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+--- a/drivers/i2c/busses/i2c-imx.c
++++ b/drivers/i2c/busses/i2c-imx.c
+@@ -1093,20 +1093,20 @@ static int i2c_imx_probe(struct platform
+               goto clk_disable;
+       }
+-      /* Request IRQ */
+-      ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, 0,
+-                              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);
+       /* Set up adapter data */
+       i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
++      /* Request IRQ */
++      ret = request_threaded_irq(irq, i2c_imx_isr, NULL, 0,
++                                 pdev->name, i2c_imx);
++      if (ret) {
++              dev_err(&pdev->dev, "can't claim irq %d\n", irq);
++              goto clk_disable;
++      }
++
+       /* Set up clock divider */
+       i2c_imx->bitrate = IMX_I2C_BIT_RATE;
+       ret = of_property_read_u32(pdev->dev.of_node,
+@@ -1125,7 +1125,7 @@ static int i2c_imx_probe(struct platform
+       ret = i2c_add_numbered_adapter(&i2c_imx->adapter);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "registration failed\n");
+-              goto clk_disable;
++              goto clk_free_irq;
+       }
+       /* Set up platform driver data */
+@@ -1143,6 +1143,8 @@ static int i2c_imx_probe(struct platform
+       return 0;   /* Return OK */
++clk_free_irq:
++      free_irq(irq, i2c_imx);
+ clk_disable:
+       clk_disable_unprepare(i2c_imx->clk);
+       return ret;
+@@ -1151,6 +1153,7 @@ clk_disable:
+ static int i2c_imx_remove(struct platform_device *pdev)
+ {
+       struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
++      int irq;
+       /* remove adapter */
+       dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
+@@ -1165,6 +1168,10 @@ static int i2c_imx_remove(struct platfor
+       imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR);
+       imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR);
++      irq = platform_get_irq(pdev, 0);
++      if (irq >= 0)
++              free_irq(irq, i2c_imx);
++
+       return 0;
+ }
index 222dc1f107d91b94328714ef190aef4f17a06e26..b40d410f621b1573cbc2052e5da8358ca34b7f07 100644 (file)
@@ -6,3 +6,4 @@ powerpc-implement-user_access_begin-and-friends.patch
 powerpc-fix-__clear_user-with-kuap-enabled.patch
 powerpc-uaccess-evaluate-macro-arguments-once-before-user-access-is-allowed.patch
 powerpc-64s-flush-l1d-after-user-accesses.patch
+i2c-imx-fix-external-abort-on-interrupt-in-exit-paths.patch