Skip to content

Commit b484f3c

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Some driver bugfixes and an old API removal now that all users are gone" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: tegra: Synchronize DMA before termination i2c: tegra: Better handle case where CPU0 is busy for a long time i2c: remove i2c_new_probed_device API i2c: altera: use proper variable to hold errno i2c: designware: platdrv: Remove DPM_FLAG_SMART_SUSPEND flag on BYT and CHT
2 parents fecca68 + 8814044 commit b484f3c

File tree

5 files changed

+38
-40
lines changed

5 files changed

+38
-40
lines changed

drivers/i2c/busses/i2c-altera.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ static int altr_i2c_probe(struct platform_device *pdev)
384384
struct altr_i2c_dev *idev = NULL;
385385
struct resource *res;
386386
int irq, ret;
387-
u32 val;
388387

389388
idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
390389
if (!idev)
@@ -411,17 +410,17 @@ static int altr_i2c_probe(struct platform_device *pdev)
411410
init_completion(&idev->msg_complete);
412411
spin_lock_init(&idev->lock);
413412

414-
val = device_property_read_u32(idev->dev, "fifo-size",
413+
ret = device_property_read_u32(idev->dev, "fifo-size",
415414
&idev->fifo_size);
416-
if (val) {
415+
if (ret) {
417416
dev_err(&pdev->dev, "FIFO size set to default of %d\n",
418417
ALTR_I2C_DFLT_FIFO_SZ);
419418
idev->fifo_size = ALTR_I2C_DFLT_FIFO_SZ;
420419
}
421420

422-
val = device_property_read_u32(idev->dev, "clock-frequency",
421+
ret = device_property_read_u32(idev->dev, "clock-frequency",
423422
&idev->bus_clk_rate);
424-
if (val) {
423+
if (ret) {
425424
dev_err(&pdev->dev, "Default to 100kHz\n");
426425
idev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; /* default clock rate */
427426
}

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,16 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
354354
adap->dev.of_node = pdev->dev.of_node;
355355
adap->nr = -1;
356356

357-
dev_pm_set_driver_flags(&pdev->dev,
358-
DPM_FLAG_SMART_PREPARE |
359-
DPM_FLAG_SMART_SUSPEND |
360-
DPM_FLAG_LEAVE_SUSPENDED);
357+
if (dev->flags & ACCESS_NO_IRQ_SUSPEND) {
358+
dev_pm_set_driver_flags(&pdev->dev,
359+
DPM_FLAG_SMART_PREPARE |
360+
DPM_FLAG_LEAVE_SUSPENDED);
361+
} else {
362+
dev_pm_set_driver_flags(&pdev->dev,
363+
DPM_FLAG_SMART_PREPARE |
364+
DPM_FLAG_SMART_SUSPEND |
365+
DPM_FLAG_LEAVE_SUSPENDED);
366+
}
361367

362368
/* The code below assumes runtime PM to be disabled. */
363369
WARN_ON(pm_runtime_enabled(&pdev->dev));

drivers/i2c/busses/i2c-tegra.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -996,14 +996,13 @@ tegra_i2c_poll_completion_timeout(struct tegra_i2c_dev *i2c_dev,
996996
do {
997997
u32 status = i2c_readl(i2c_dev, I2C_INT_STATUS);
998998

999-
if (status) {
999+
if (status)
10001000
tegra_i2c_isr(i2c_dev->irq, i2c_dev);
10011001

1002-
if (completion_done(complete)) {
1003-
s64 delta = ktime_ms_delta(ktimeout, ktime);
1002+
if (completion_done(complete)) {
1003+
s64 delta = ktime_ms_delta(ktimeout, ktime);
10041004

1005-
return msecs_to_jiffies(delta) ?: 1;
1006-
}
1005+
return msecs_to_jiffies(delta) ?: 1;
10071006
}
10081007

10091008
ktime = ktime_get();
@@ -1030,14 +1029,18 @@ tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev,
10301029
disable_irq(i2c_dev->irq);
10311030

10321031
/*
1033-
* There is a chance that completion may happen after IRQ
1034-
* synchronization, which is done by disable_irq().
1032+
* Under some rare circumstances (like running KASAN +
1033+
* NFS root) CPU, which handles interrupt, may stuck in
1034+
* uninterruptible state for a significant time. In this
1035+
* case we will get timeout if I2C transfer is running on
1036+
* a sibling CPU, despite of IRQ being raised.
1037+
*
1038+
* In order to handle this rare condition, the IRQ status
1039+
* needs to be checked after timeout.
10351040
*/
1036-
if (ret == 0 && completion_done(complete)) {
1037-
dev_warn(i2c_dev->dev,
1038-
"completion done after timeout\n");
1039-
ret = 1;
1040-
}
1041+
if (ret == 0)
1042+
ret = tegra_i2c_poll_completion_timeout(i2c_dev,
1043+
complete, 0);
10411044
}
10421045

10431046
return ret;
@@ -1216,6 +1219,15 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
12161219
time_left = tegra_i2c_wait_completion_timeout(
12171220
i2c_dev, &i2c_dev->dma_complete, xfer_time);
12181221

1222+
/*
1223+
* Synchronize DMA first, since dmaengine_terminate_sync()
1224+
* performs synchronization after the transfer's termination
1225+
* and we want to get a completion if transfer succeeded.
1226+
*/
1227+
dmaengine_synchronize(i2c_dev->msg_read ?
1228+
i2c_dev->rx_dma_chan :
1229+
i2c_dev->tx_dma_chan);
1230+
12191231
dmaengine_terminate_sync(i2c_dev->msg_read ?
12201232
i2c_dev->rx_dma_chan :
12211233
i2c_dev->tx_dma_chan);

drivers/i2c/i2c-core-base.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,19 +2273,6 @@ i2c_new_scanned_device(struct i2c_adapter *adap,
22732273
}
22742274
EXPORT_SYMBOL_GPL(i2c_new_scanned_device);
22752275

2276-
struct i2c_client *
2277-
i2c_new_probed_device(struct i2c_adapter *adap,
2278-
struct i2c_board_info *info,
2279-
unsigned short const *addr_list,
2280-
int (*probe)(struct i2c_adapter *adap, unsigned short addr))
2281-
{
2282-
struct i2c_client *client;
2283-
2284-
client = i2c_new_scanned_device(adap, info, addr_list, probe);
2285-
return IS_ERR(client) ? NULL : client;
2286-
}
2287-
EXPORT_SYMBOL_GPL(i2c_new_probed_device);
2288-
22892276
struct i2c_adapter *i2c_get_adapter(int nr)
22902277
{
22912278
struct i2c_adapter *adapter;

include/linux/i2c.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,6 @@ i2c_new_scanned_device(struct i2c_adapter *adap,
461461
unsigned short const *addr_list,
462462
int (*probe)(struct i2c_adapter *adap, unsigned short addr));
463463

464-
struct i2c_client *
465-
i2c_new_probed_device(struct i2c_adapter *adap,
466-
struct i2c_board_info *info,
467-
unsigned short const *addr_list,
468-
int (*probe)(struct i2c_adapter *adap, unsigned short addr));
469-
470464
/* Common custom probe functions */
471465
int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr);
472466

0 commit comments

Comments
 (0)