* [PATCH] i2c: designware: remove redundant lock
@ 2016-01-12 13:16 Baruch Siach
2016-01-13 7:25 ` Mika Westerberg
2016-02-12 18:52 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Baruch Siach @ 2016-01-12 13:16 UTC (permalink / raw)
To: Andy Shevchenko, Jarkko Nikula, Mika Westerberg
Cc: linux-i2c, Rongrong Zou, Baruch Siach
The per adapter bus_lock already projects from concurrent calls to the
master_xfer callback. No need to add a driver internal lock.
Also, rephrase a comment to drop mention of this lock.
Reported-by: Rongrong Zou <zourongrong@gmail.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
Based on i2c/for-next.
Build tested only.
---
drivers/i2c/busses/i2c-designware-core.c | 14 ++++++--------
drivers/i2c/busses/i2c-designware-core.h | 2 --
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index ba9732c236c5..99bc950f5d9d 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -634,7 +634,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num);
- mutex_lock(&dev->lock);
pm_runtime_get_sync(dev->dev);
reinit_completion(&dev->cmd_complete);
@@ -673,11 +672,12 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
}
/*
- * We must disable the adapter before unlocking the &dev->lock mutex
- * below. Otherwise the hardware might continue generating interrupts
- * which in turn causes a race condition with the following transfer.
- * Needs some more investigation if the additional interrupts are
- * a hardware bug or this driver doesn't handle them correctly yet.
+ * We must disable the adapter before returning and signaling the end
+ * of the current transfer. Otherwise the hardware might continue
+ * generating interrupts which in turn causes a race condition with
+ * the following transfer. Needs some more investigation if the
+ * additional interrupts are a hardware bug or this driver doesn't
+ * handle them correctly yet.
*/
__i2c_dw_enable(dev, false);
@@ -706,7 +706,6 @@ done:
done_nolock:
pm_runtime_mark_last_busy(dev->dev);
pm_runtime_put_autosuspend(dev->dev);
- mutex_unlock(&dev->lock);
return ret;
}
@@ -860,7 +859,6 @@ int i2c_dw_probe(struct dw_i2c_dev *dev)
int r;
init_completion(&dev->cmd_complete);
- mutex_init(&dev->lock);
r = i2c_dw_init(dev);
if (r)
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 9ffb63a60f95..cd409e7fbc71 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -36,7 +36,6 @@
* @dev: driver model device node
* @base: IO registers pointer
* @cmd_complete: tx completion indicator
- * @lock: protect this struct and IO registers
* @clk: input reference clock
* @cmd_err: run time hadware error code
* @msgs: points to an array of messages currently being transfered
@@ -73,7 +72,6 @@ struct dw_i2c_dev {
struct device *dev;
void __iomem *base;
struct completion cmd_complete;
- struct mutex lock;
struct clk *clk;
u32 (*get_clk_rate_khz) (struct dw_i2c_dev *dev);
struct dw_pci_controller *controller;
--
2.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: designware: remove redundant lock
2016-01-12 13:16 [PATCH] i2c: designware: remove redundant lock Baruch Siach
@ 2016-01-13 7:25 ` Mika Westerberg
2016-02-12 18:52 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2016-01-13 7:25 UTC (permalink / raw)
To: Baruch Siach; +Cc: Andy Shevchenko, Jarkko Nikula, linux-i2c, Rongrong Zou
On Tue, Jan 12, 2016 at 03:16:35PM +0200, Baruch Siach wrote:
> The per adapter bus_lock already projects from concurrent calls to the
> master_xfer callback. No need to add a driver internal lock.
>
> Also, rephrase a comment to drop mention of this lock.
>
> Reported-by: Rongrong Zou <zourongrong@gmail.com>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: designware: remove redundant lock
2016-01-12 13:16 [PATCH] i2c: designware: remove redundant lock Baruch Siach
2016-01-13 7:25 ` Mika Westerberg
@ 2016-02-12 18:52 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2016-02-12 18:52 UTC (permalink / raw)
To: Baruch Siach
Cc: Andy Shevchenko, Jarkko Nikula, Mika Westerberg, linux-i2c,
Rongrong Zou
[-- Attachment #1: Type: text/plain, Size: 405 bytes --]
On Tue, Jan 12, 2016 at 03:16:35PM +0200, Baruch Siach wrote:
> The per adapter bus_lock already projects from concurrent calls to the
> master_xfer callback. No need to add a driver internal lock.
>
> Also, rephrase a comment to drop mention of this lock.
>
> Reported-by: Rongrong Zou <zourongrong@gmail.com>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Applied to for-next, thanks!
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-12 18:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-12 13:16 [PATCH] i2c: designware: remove redundant lock Baruch Siach
2016-01-13 7:25 ` Mika Westerberg
2016-02-12 18:52 ` Wolfram Sang
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).