Re: [PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-08-14 Thread Linus Walleij
On Sun, Jul 29, 2012 at 4:54 AM, Axel Lin  wrote:

> gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
> ioh_gpio_get and ioh_gpio_direction_input functions.
> Thus those functions are not callable from interrupt context.
> This patch converts mutex into spinlock.
>
> Signed-off-by: Axel Lin 

Applied to my devel branch for the next merge window, it doesn't
seem like a regression to me atleast.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-08-14 Thread Linus Walleij
On Sun, Jul 29, 2012 at 4:54 AM, Axel Lin axel@gmail.com wrote:

 gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
 ioh_gpio_get and ioh_gpio_direction_input functions.
 Thus those functions are not callable from interrupt context.
 This patch converts mutex into spinlock.

 Signed-off-by: Axel Lin axel@gmail.com

Applied to my devel branch for the next merge window, it doesn't
seem like a regression to me atleast.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-08-13 Thread Feng Tang
On Mon, 13 Aug 2012 14:01:31 +0200
Linus Walleij  wrote:

> On Sun, Jul 29, 2012 at 4:54 AM, Axel Lin  wrote:
> 
> > gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
> > ioh_gpio_get and ioh_gpio_direction_input functions.
> > Thus those functions are not callable from interrupt context.
> > This patch converts mutex into spinlock.
> >
> > Signed-off-by: Axel Lin 
> 
> So IOH guys what are you saying about this?

I'm not the IOH guy, but just happened to work on it for some time :) Anyway,
the 2 patches both look good to me.

Thanks,
Feng

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-08-13 Thread Linus Walleij
On Sun, Jul 29, 2012 at 4:54 AM, Axel Lin  wrote:

> gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
> ioh_gpio_get and ioh_gpio_direction_input functions.
> Thus those functions are not callable from interrupt context.
> This patch converts mutex into spinlock.
>
> Signed-off-by: Axel Lin 

So IOH guys what are you saying about this?

If you say nothing I will apply these patches.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-08-13 Thread Linus Walleij
On Sun, Jul 29, 2012 at 4:54 AM, Axel Lin axel@gmail.com wrote:

 gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
 ioh_gpio_get and ioh_gpio_direction_input functions.
 Thus those functions are not callable from interrupt context.
 This patch converts mutex into spinlock.

 Signed-off-by: Axel Lin axel@gmail.com

So IOH guys what are you saying about this?

If you say nothing I will apply these patches.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-08-13 Thread Feng Tang
On Mon, 13 Aug 2012 14:01:31 +0200
Linus Walleij linus.wall...@linaro.org wrote:

 On Sun, Jul 29, 2012 at 4:54 AM, Axel Lin axel@gmail.com wrote:
 
  gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
  ioh_gpio_get and ioh_gpio_direction_input functions.
  Thus those functions are not callable from interrupt context.
  This patch converts mutex into spinlock.
 
  Signed-off-by: Axel Lin axel@gmail.com
 
 So IOH guys what are you saying about this?

I'm not the IOH guy, but just happened to work on it for some time :) Anyway,
the 2 patches both look good to me.

Thanks,
Feng

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-07-28 Thread Axel Lin
gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
ioh_gpio_get and ioh_gpio_direction_input functions.
Thus those functions are not callable from interrupt context.
This patch converts mutex into spinlock.

Signed-off-by: Axel Lin 
---
 drivers/gpio/gpio-ml-ioh.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index db01f15..6a29ee1 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -87,8 +87,7 @@ struct ioh_gpio_reg_data {
  * @gpio_use_sel:  Save GPIO_USE_SEL1~4 register for PM
  * @ch:Indicate GPIO channel
  * @irq_base:  Save base of IRQ number for interrupt
- * @spinlock:  Used for register access protection in
- * interrupt context ioh_irq_type and PM;
+ * @spinlock:  Used for register access protection
  */
 struct ioh_gpio {
void __iomem *base;
@@ -97,7 +96,6 @@ struct ioh_gpio {
struct gpio_chip gpio;
struct ioh_gpio_reg_data ioh_gpio_reg;
u32 gpio_use_sel;
-   struct mutex lock;
int ch;
int irq_base;
spinlock_t spinlock;
@@ -109,8 +107,9 @@ static void ioh_gpio_set(struct gpio_chip *gpio, unsigned 
nr, int val)
 {
u32 reg_val;
struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio);
+   unsigned long flags;
 
-   mutex_lock(>lock);
+   spin_lock_irqsave(>spinlock, flags);
reg_val = ioread32(>reg->regs[chip->ch].po);
if (val)
reg_val |= (1 << nr);
@@ -118,7 +117,7 @@ static void ioh_gpio_set(struct gpio_chip *gpio, unsigned 
nr, int val)
reg_val &= ~(1 << nr);
 
iowrite32(reg_val, >reg->regs[chip->ch].po);
-   mutex_unlock(>lock);
+   spin_unlock_irqrestore(>spinlock, flags);
 }
 
 static int ioh_gpio_get(struct gpio_chip *gpio, unsigned nr)
@@ -134,8 +133,9 @@ static int ioh_gpio_direction_output(struct gpio_chip 
*gpio, unsigned nr,
struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio);
u32 pm;
u32 reg_val;
+   unsigned long flags;
 
-   mutex_lock(>lock);
+   spin_lock_irqsave(>spinlock, flags);
pm = ioread32(>reg->regs[chip->ch].pm) &
((1 << num_ports[chip->ch]) - 1);
pm |= (1 << nr);
@@ -148,7 +148,7 @@ static int ioh_gpio_direction_output(struct gpio_chip 
*gpio, unsigned nr,
reg_val &= ~(1 << nr);
iowrite32(reg_val, >reg->regs[chip->ch].po);
 
-   mutex_unlock(>lock);
+   spin_unlock_irqrestore(>spinlock, flags);
 
return 0;
 }
@@ -157,13 +157,14 @@ static int ioh_gpio_direction_input(struct gpio_chip 
*gpio, unsigned nr)
 {
struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio);
u32 pm;
+   unsigned long flags;
 
-   mutex_lock(>lock);
+   spin_lock_irqsave(>spinlock, flags);
pm = ioread32(>reg->regs[chip->ch].pm) &
((1 << num_ports[chip->ch]) - 1);
pm &= ~(1 << nr);
iowrite32(pm, >reg->regs[chip->ch].pm);
-   mutex_unlock(>lock);
+   spin_unlock_irqrestore(>spinlock, flags);
 
return 0;
 }
@@ -447,7 +448,6 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
chip->base = base;
chip->reg = chip->base;
chip->ch = i;
-   mutex_init(>lock);
spin_lock_init(>spinlock);
ioh_gpio_setup(chip, num_ports[i]);
ret = gpiochip_add(>gpio);
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RFT 1/2] gpio: gpio-ml-ioh: Use spinlock for register access protection

2012-07-28 Thread Axel Lin
gpio_chip.can_sleep is 0, but current code uses mutex in ioh_gpio_set,
ioh_gpio_get and ioh_gpio_direction_input functions.
Thus those functions are not callable from interrupt context.
This patch converts mutex into spinlock.

Signed-off-by: Axel Lin axel@gmail.com
---
 drivers/gpio/gpio-ml-ioh.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index db01f15..6a29ee1 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -87,8 +87,7 @@ struct ioh_gpio_reg_data {
  * @gpio_use_sel:  Save GPIO_USE_SEL1~4 register for PM
  * @ch:Indicate GPIO channel
  * @irq_base:  Save base of IRQ number for interrupt
- * @spinlock:  Used for register access protection in
- * interrupt context ioh_irq_type and PM;
+ * @spinlock:  Used for register access protection
  */
 struct ioh_gpio {
void __iomem *base;
@@ -97,7 +96,6 @@ struct ioh_gpio {
struct gpio_chip gpio;
struct ioh_gpio_reg_data ioh_gpio_reg;
u32 gpio_use_sel;
-   struct mutex lock;
int ch;
int irq_base;
spinlock_t spinlock;
@@ -109,8 +107,9 @@ static void ioh_gpio_set(struct gpio_chip *gpio, unsigned 
nr, int val)
 {
u32 reg_val;
struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio);
+   unsigned long flags;
 
-   mutex_lock(chip-lock);
+   spin_lock_irqsave(chip-spinlock, flags);
reg_val = ioread32(chip-reg-regs[chip-ch].po);
if (val)
reg_val |= (1  nr);
@@ -118,7 +117,7 @@ static void ioh_gpio_set(struct gpio_chip *gpio, unsigned 
nr, int val)
reg_val = ~(1  nr);
 
iowrite32(reg_val, chip-reg-regs[chip-ch].po);
-   mutex_unlock(chip-lock);
+   spin_unlock_irqrestore(chip-spinlock, flags);
 }
 
 static int ioh_gpio_get(struct gpio_chip *gpio, unsigned nr)
@@ -134,8 +133,9 @@ static int ioh_gpio_direction_output(struct gpio_chip 
*gpio, unsigned nr,
struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio);
u32 pm;
u32 reg_val;
+   unsigned long flags;
 
-   mutex_lock(chip-lock);
+   spin_lock_irqsave(chip-spinlock, flags);
pm = ioread32(chip-reg-regs[chip-ch].pm) 
((1  num_ports[chip-ch]) - 1);
pm |= (1  nr);
@@ -148,7 +148,7 @@ static int ioh_gpio_direction_output(struct gpio_chip 
*gpio, unsigned nr,
reg_val = ~(1  nr);
iowrite32(reg_val, chip-reg-regs[chip-ch].po);
 
-   mutex_unlock(chip-lock);
+   spin_unlock_irqrestore(chip-spinlock, flags);
 
return 0;
 }
@@ -157,13 +157,14 @@ static int ioh_gpio_direction_input(struct gpio_chip 
*gpio, unsigned nr)
 {
struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio);
u32 pm;
+   unsigned long flags;
 
-   mutex_lock(chip-lock);
+   spin_lock_irqsave(chip-spinlock, flags);
pm = ioread32(chip-reg-regs[chip-ch].pm) 
((1  num_ports[chip-ch]) - 1);
pm = ~(1  nr);
iowrite32(pm, chip-reg-regs[chip-ch].pm);
-   mutex_unlock(chip-lock);
+   spin_unlock_irqrestore(chip-spinlock, flags);
 
return 0;
 }
@@ -447,7 +448,6 @@ static int __devinit ioh_gpio_probe(struct pci_dev *pdev,
chip-base = base;
chip-reg = chip-base;
chip-ch = i;
-   mutex_init(chip-lock);
spin_lock_init(chip-spinlock);
ioh_gpio_setup(chip, num_ports[i]);
ret = gpiochip_add(chip-gpio);
-- 
1.7.9.5



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/