Skip to content

Commit e8c220f

Browse files
fabioestevamWolfram Sang
authored and
Wolfram Sang
committed
Revert "i2c: imx: improve the error handling in i2c_imx_dma_request()"
Since commit e1ab9a4 ("i2c: imx: improve the error handling in i2c_imx_dma_request()") when booting with the DMA driver as module (such as CONFIG_FSL_EDMA=m) the following endless clk warnings are seen: [ 153.077831] ------------[ cut here ]------------ [ 153.082528] WARNING: CPU: 0 PID: 15 at drivers/clk/clk.c:924 clk_core_disable_lock+0x18/0x24 [ 153.093077] i2c0 already disabled [ 153.096416] Modules linked in: [ 153.099521] CPU: 0 PID: 15 Comm: kworker/0:1 Tainted: G W 5.2.0+ hardkernel#321 [ 153.107290] Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree) [ 153.113772] Workqueue: events deferred_probe_work_func [ 153.118979] [<c0019560>] (unwind_backtrace) from [<c0014734>] (show_stack+0x10/0x14) [ 153.126778] [<c0014734>] (show_stack) from [<c083f8dc>] (dump_stack+0x9c/0xd4) [ 153.134051] [<c083f8dc>] (dump_stack) from [<c0031154>] (__warn+0xf8/0x124) [ 153.141056] [<c0031154>] (__warn) from [<c0031248>] (warn_slowpath_fmt+0x38/0x48) [ 153.148580] [<c0031248>] (warn_slowpath_fmt) from [<c040fde0>] (clk_core_disable_lock+0x18/0x24) [ 153.157413] [<c040fde0>] (clk_core_disable_lock) from [<c058f520>] (i2c_imx_probe+0x554/0x6ec) [ 153.166076] [<c058f520>] (i2c_imx_probe) from [<c04b9178>] (platform_drv_probe+0x48/0x98) [ 153.174297] [<c04b9178>] (platform_drv_probe) from [<c04b7298>] (really_probe+0x1d8/0x2c0) [ 153.182605] [<c04b7298>] (really_probe) from [<c04b7554>] (driver_probe_device+0x5c/0x174) [ 153.190909] [<c04b7554>] (driver_probe_device) from [<c04b58c8>] (bus_for_each_drv+0x44/0x8c) [ 153.199480] [<c04b58c8>] (bus_for_each_drv) from [<c04b746c>] (__device_attach+0xa0/0x108) [ 153.207782] [<c04b746c>] (__device_attach) from [<c04b65a4>] (bus_probe_device+0x88/0x90) [ 153.215999] [<c04b65a4>] (bus_probe_device) from [<c04b6a04>] (deferred_probe_work_func+0x60/0x90) [ 153.225003] [<c04b6a04>] (deferred_probe_work_func) from [<c004f190>] (process_one_work+0x204/0x634) [ 153.234178] [<c004f190>] (process_one_work) from [<c004f618>] (worker_thread+0x20/0x484) [ 153.242315] [<c004f618>] (worker_thread) from [<c0055c2c>] (kthread+0x118/0x150) [ 153.249758] [<c0055c2c>] (kthread) from [<c00090b4>] (ret_from_fork+0x14/0x20) [ 153.257006] Exception stack(0xdde43fb0 to 0xdde43ff8) [ 153.262095] 3fa0: 00000000 00000000 00000000 00000000 [ 153.270306] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 153.278520] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 153.285159] irq event stamp: 3323022 [ 153.288787] hardirqs last enabled at (3323021): [<c0861c4c>] _raw_spin_unlock_irq+0x24/0x2c [ 153.297261] hardirqs last disabled at (3323022): [<c040d7a0>] clk_enable_lock+0x10/0x124 [ 153.305392] softirqs last enabled at (3322092): [<c000a504>] __do_softirq+0x344/0x540 [ 153.313352] softirqs last disabled at (3322081): [<c00385c0>] irq_exit+0x10c/0x128 [ 153.320946] ---[ end trace a506731ccd9bd703 ]--- This endless clk warnings behaviour is well explained by Andrey Smirnov: "Allocating DMA after registering I2C adapter can lead to infinite probing loop, for example, consider the following scenario: 1. i2c_imx_probe() is called and successfully registers an I2C adapter via i2c_add_numbered_adapter() 2. As a part of i2c_add_numbered_adapter() new I2C slave devices are added from DT which results in a call to driver_deferred_probe_trigger() 3. i2c_imx_probe() continues and calls i2c_imx_dma_request() which due to lack of proper DMA driver returns -EPROBE_DEFER 4. i2c_imx_probe() fails, removes I2C adapter and returns -EPROBE_DEFER, which places it into deferred probe list 5. Deferred probe work triggered in #2 above kicks in and calls i2c_imx_probe() again thus bringing us to step #1" So revert commit e1ab9a4 ("i2c: imx: improve the error handling in i2c_imx_dma_request()") and restore the old behaviour, in order to avoid regressions on existing setups. Cc: <[email protected]> Reported-by: Andrey Smirnov <[email protected]> Reported-by: Russell King <[email protected]> Fixes: e1ab9a4 ("i2c: imx: improve the error handling in i2c_imx_dma_request()") Signed-off-by: Fabio Estevam <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent d45331b commit e8c220f

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ static inline unsigned char imx_i2c_read_reg(struct imx_i2c_struct *i2c_imx,
273273
}
274274

275275
/* Functions for DMA support */
276-
static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
277-
dma_addr_t phy_addr)
276+
static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
277+
dma_addr_t phy_addr)
278278
{
279279
struct imx_i2c_dma *dma;
280280
struct dma_slave_config dma_sconfig;
@@ -283,7 +283,7 @@ static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
283283

284284
dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
285285
if (!dma)
286-
return -ENOMEM;
286+
return;
287287

288288
dma->chan_tx = dma_request_chan(dev, "tx");
289289
if (IS_ERR(dma->chan_tx)) {
@@ -328,16 +328,14 @@ static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
328328
dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n",
329329
dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
330330

331-
return 0;
331+
return;
332332

333333
fail_rx:
334334
dma_release_channel(dma->chan_rx);
335335
fail_tx:
336336
dma_release_channel(dma->chan_tx);
337337
fail_al:
338338
devm_kfree(dev, dma);
339-
/* return successfully if there is no dma support */
340-
return ret == -ENODEV ? 0 : ret;
341339
}
342340

343341
static void i2c_imx_dma_callback(void *arg)
@@ -1165,17 +1163,13 @@ static int i2c_imx_probe(struct platform_device *pdev)
11651163
dev_dbg(&i2c_imx->adapter.dev, "device resources: %pR\n", res);
11661164
dev_dbg(&i2c_imx->adapter.dev, "adapter name: \"%s\"\n",
11671165
i2c_imx->adapter.name);
1166+
dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
11681167

11691168
/* Init DMA config if supported */
1170-
ret = i2c_imx_dma_request(i2c_imx, phy_addr);
1171-
if (ret < 0)
1172-
goto del_adapter;
1169+
i2c_imx_dma_request(i2c_imx, phy_addr);
11731170

1174-
dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
11751171
return 0; /* Return OK */
11761172

1177-
del_adapter:
1178-
i2c_del_adapter(&i2c_imx->adapter);
11791173
clk_notifier_unregister:
11801174
clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
11811175
rpm_disable:

0 commit comments

Comments
 (0)