Commit 19cfcafd authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Wolfram Sang

i2c: davinci: fix the cpufreq transition

i2c_davinci_cpufreq_transition() is implemented in a way that will
block if it ever gets called while no transfer is in progress.

Not only that, but reinit_completion() is never called for xfr_complete.

Use the fact that cpufreq uses an srcu_notifier (running in process
context) for transitions and that the bus_lock is taken during the call
to master_xfer() and simplify the code by removing the transfer
completion entirely and protecting i2c_davinci_cpufreq_transition()
with i2c_lock/unlock_adapter().
Reported-by: default avatarDavid Lechner <david@lechnology.com>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: default avatarSekhar Nori <nsekhar@ti.com>
Tested-by: default avatarDavid Lechner <david@lechnology.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 5bacb56b
...@@ -139,7 +139,6 @@ struct davinci_i2c_dev { ...@@ -139,7 +139,6 @@ struct davinci_i2c_dev {
u8 terminate; u8 terminate;
struct i2c_adapter adapter; struct i2c_adapter adapter;
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
struct completion xfr_complete;
struct notifier_block freq_transition; struct notifier_block freq_transition;
#endif #endif
struct davinci_i2c_platform_data *pdata; struct davinci_i2c_platform_data *pdata;
...@@ -567,9 +566,6 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) ...@@ -567,9 +566,6 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
} }
ret = num; ret = num;
#ifdef CONFIG_CPU_FREQ
complete(&dev->xfr_complete);
#endif
out: out:
pm_runtime_mark_last_busy(dev->dev); pm_runtime_mark_last_busy(dev->dev);
...@@ -717,13 +713,15 @@ static int i2c_davinci_cpufreq_transition(struct notifier_block *nb, ...@@ -717,13 +713,15 @@ static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
struct davinci_i2c_dev *dev; struct davinci_i2c_dev *dev;
dev = container_of(nb, struct davinci_i2c_dev, freq_transition); dev = container_of(nb, struct davinci_i2c_dev, freq_transition);
i2c_lock_adapter(&dev->adapter);
if (val == CPUFREQ_PRECHANGE) { if (val == CPUFREQ_PRECHANGE) {
wait_for_completion(&dev->xfr_complete);
davinci_i2c_reset_ctrl(dev, 0); davinci_i2c_reset_ctrl(dev, 0);
} else if (val == CPUFREQ_POSTCHANGE) { } else if (val == CPUFREQ_POSTCHANGE) {
i2c_davinci_calc_clk_dividers(dev); i2c_davinci_calc_clk_dividers(dev);
davinci_i2c_reset_ctrl(dev, 1); davinci_i2c_reset_ctrl(dev, 1);
} }
i2c_unlock_adapter(&dev->adapter);
return 0; return 0;
} }
...@@ -790,9 +788,7 @@ static int davinci_i2c_probe(struct platform_device *pdev) ...@@ -790,9 +788,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
} }
init_completion(&dev->cmd_complete); init_completion(&dev->cmd_complete);
#ifdef CONFIG_CPU_FREQ
init_completion(&dev->xfr_complete);
#endif
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->irq = irq; dev->irq = irq;
dev->pdata = dev_get_platdata(&pdev->dev); dev->pdata = dev_get_platdata(&pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment