* [PATCH 2/2] i2c: altera: cleanup spinlock
@ 2020-05-08 13:14 Atsushi Nemoto
2020-05-14 2:55 ` Thor Thayer
2020-05-20 13:23 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Atsushi Nemoto @ 2020-05-08 13:14 UTC (permalink / raw)
To: Thor Thayer, Wolfram Sang, linux-i2c; +Cc: tomonori.sakita
Protect altr_i2c_int_enable() by the mutex and remove unneeded spinlock.
Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
---
drivers/i2c/busses/i2c-altera.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/i2c/busses/i2c-altera.c b/drivers/i2c/busses/i2c-altera.c
index 16ddc26..997434f 100644
--- a/drivers/i2c/busses/i2c-altera.c
+++ b/drivers/i2c/busses/i2c-altera.c
@@ -69,7 +69,6 @@
* @fifo_size: size of the FIFO passed in.
* @isr_mask: cached copy of local ISR enables.
* @isr_status: cached copy of local ISR status.
- * @lock: spinlock for IRQ synchronization.
* @isr_mutex: mutex for IRQ thread.
*/
struct altr_i2c_dev {
@@ -86,18 +85,14 @@ struct altr_i2c_dev {
u32 fifo_size;
u32 isr_mask;
u32 isr_status;
- spinlock_t lock; /* IRQ synchronization */
struct mutex isr_mutex;
};
static void
altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
{
- unsigned long flags;
u32 int_en;
- spin_lock_irqsave(&idev->lock, flags);
-
int_en = readl(idev->base + ALTR_I2C_ISER);
if (enable)
idev->isr_mask = int_en | mask;
@@ -105,8 +100,6 @@ altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
idev->isr_mask = int_en & ~mask;
writel(idev->isr_mask, idev->base + ALTR_I2C_ISER);
-
- spin_unlock_irqrestore(&idev->lock, flags);
}
static void altr_i2c_int_clear(struct altr_i2c_dev *idev, u32 mask)
@@ -346,6 +339,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
time_left = wait_for_completion_timeout(&idev->msg_complete,
ALTR_I2C_XFER_TIMEOUT);
+ mutex_lock(&idev->isr_mutex);
altr_i2c_int_enable(idev, imask, false);
value = readl(idev->base + ALTR_I2C_STATUS) & ALTR_I2C_STAT_CORE;
@@ -358,6 +352,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
}
altr_i2c_core_disable(idev);
+ mutex_unlock(&idev->isr_mutex);
return idev->msg_err;
}
@@ -415,7 +410,6 @@ static int altr_i2c_probe(struct platform_device *pdev)
idev->dev = &pdev->dev;
init_completion(&idev->msg_complete);
- spin_lock_init(&idev->lock);
mutex_init(&idev->isr_mutex);
ret = device_property_read_u32(idev->dev, "fifo-size",
@@ -453,7 +447,9 @@ static int altr_i2c_probe(struct platform_device *pdev)
return ret;
}
+ mutex_lock(&idev->isr_mutex);
altr_i2c_init(idev);
+ mutex_unlock(&idev->isr_mutex);
i2c_set_adapdata(&idev->adapter, idev);
strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name));
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] i2c: altera: cleanup spinlock
2020-05-08 13:14 [PATCH 2/2] i2c: altera: cleanup spinlock Atsushi Nemoto
@ 2020-05-14 2:55 ` Thor Thayer
2020-05-20 13:23 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Thor Thayer @ 2020-05-14 2:55 UTC (permalink / raw)
To: Atsushi Nemoto, Wolfram Sang, linux-i2c; +Cc: tomonori.sakita
On 5/8/20 8:14 AM, Atsushi Nemoto wrote:
> Protect altr_i2c_int_enable() by the mutex and remove unneeded spinlock.
>
> Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
> ---
> drivers/i2c/busses/i2c-altera.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-altera.c b/drivers/i2c/busses/i2c-altera.c
> index 16ddc26..997434f 100644
> --- a/drivers/i2c/busses/i2c-altera.c
> +++ b/drivers/i2c/busses/i2c-altera.c
> @@ -69,7 +69,6 @@
> * @fifo_size: size of the FIFO passed in.
> * @isr_mask: cached copy of local ISR enables.
> * @isr_status: cached copy of local ISR status.
> - * @lock: spinlock for IRQ synchronization.
> * @isr_mutex: mutex for IRQ thread.
> */
> struct altr_i2c_dev {
> @@ -86,18 +85,14 @@ struct altr_i2c_dev {
> u32 fifo_size;
> u32 isr_mask;
> u32 isr_status;
> - spinlock_t lock; /* IRQ synchronization */
> struct mutex isr_mutex;
> };
>
> static void
> altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
> {
> - unsigned long flags;
> u32 int_en;
>
> - spin_lock_irqsave(&idev->lock, flags);
> -
> int_en = readl(idev->base + ALTR_I2C_ISER);
> if (enable)
> idev->isr_mask = int_en | mask;
> @@ -105,8 +100,6 @@ altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
> idev->isr_mask = int_en & ~mask;
>
> writel(idev->isr_mask, idev->base + ALTR_I2C_ISER);
> -
> - spin_unlock_irqrestore(&idev->lock, flags);
> }
>
> static void altr_i2c_int_clear(struct altr_i2c_dev *idev, u32 mask)
> @@ -346,6 +339,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
>
> time_left = wait_for_completion_timeout(&idev->msg_complete,
> ALTR_I2C_XFER_TIMEOUT);
> + mutex_lock(&idev->isr_mutex);
> altr_i2c_int_enable(idev, imask, false);
>
> value = readl(idev->base + ALTR_I2C_STATUS) & ALTR_I2C_STAT_CORE;
> @@ -358,6 +352,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
> }
>
> altr_i2c_core_disable(idev);
> + mutex_unlock(&idev->isr_mutex);
>
> return idev->msg_err;
> }
> @@ -415,7 +410,6 @@ static int altr_i2c_probe(struct platform_device *pdev)
>
> idev->dev = &pdev->dev;
> init_completion(&idev->msg_complete);
> - spin_lock_init(&idev->lock);
> mutex_init(&idev->isr_mutex);
>
> ret = device_property_read_u32(idev->dev, "fifo-size",
> @@ -453,7 +447,9 @@ static int altr_i2c_probe(struct platform_device *pdev)
> return ret;
> }
>
> + mutex_lock(&idev->isr_mutex);
> altr_i2c_init(idev);
> + mutex_unlock(&idev->isr_mutex);
>
> i2c_set_adapdata(&idev->adapter, idev);
> strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name));
>
Reviewed-by: Thor Thayer <thor.thayer@linux.intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] i2c: altera: cleanup spinlock
2020-05-08 13:14 [PATCH 2/2] i2c: altera: cleanup spinlock Atsushi Nemoto
2020-05-14 2:55 ` Thor Thayer
@ 2020-05-20 13:23 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-05-20 13:23 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: Thor Thayer, linux-i2c, tomonori.sakita
[-- Attachment #1: Type: text/plain, Size: 240 bytes --]
On Fri, May 08, 2020 at 10:14:36PM +0900, Atsushi Nemoto wrote:
> Protect altr_i2c_int_enable() by the mutex and remove unneeded spinlock.
>
> Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-20 13:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 13:14 [PATCH 2/2] i2c: altera: cleanup spinlock Atsushi Nemoto
2020-05-14 2:55 ` Thor Thayer
2020-05-20 13:23 ` 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).