Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-10 Thread Shilimkar, Santosh
On Fri, Aug 10, 2012 at 11:38 AM, DebBarma, Tarun Kanti
 wrote:
>
> On Thu, Aug 9, 2012 at 8:28 PM, Kevin Hilman  wrote:
> > "DebBarma, Tarun Kanti"  writes:
> >
> >> On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman  wrote:
> >>> Tarun Kanti DebBarma  writes:
> >>>
>  Add *remove* callback so that necessary cleanup operations are
>  performed when device is unregistered. The device is deleted
>  from the list and associated clock handle is released by
>  calling clk_put() and irq descriptor is released using the
>  irq_free_desc() api.
> 
>  Signed-off-by: Tarun Kanti DebBarma 
>  Reported-by: Paul Walmsley 
>  Reviewed-by: Jon Hunter 
>  Cc: Kevin Hilman 
>  Cc: Rajendra Nayak 
>  Cc: Santosh Shilimkar 
>  Cc: Cousson, Benoit 
>  Cc: Paul Walmsley 
>  ---
>  v2:
>  Baseline:
>  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
>  Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
> 
>  (1) Use irq_free_descs() instead of irq_free_desc().
>  Besides, irq_free_desc() was using wrong parameter,
>  irq_base, instead of bank->irq.
>  (2) irq_free_descs() moved outside spin_lock/unlock_*()
>  in order to avoid exception warnings.
> 
>  (3) pm_runtime_disable() added so that bind can happen successfully
> 
>  Test Detail:
>  Step 1: Unbind gpio.5 device in order to invoke the *remove*
>  callback.
>  #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind
> 
>  Step 2: Bind gpio.5 device and confirm probe() for the device
>  succeeds.
>  #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind
> 
>  Step 3: Execute read/write GPIO test case.
> >>>
> >>> What happens when GPIOs are in use (requested)?
> >> If I try to unbind a currently active GPIO bank then I see an exception
> >> after the irq descriptor is freed by the remove. I believe this is
> >> expected
> >> because interrupt raised by the system would not be handled.
> >
> > ... and the GPIO is still configured to trigger interrupts.
> Right!
>
> >
> > The point is that there is lots to cleanup/unconfigure properly for this
> > to work properly.
> As far as I can think of, all active gpio requests done either in
> board files or through DT
> have to be freed. But if this is done then when we bind() the device
> again initialization
> done in omap_gpio_probe() would not restore the board/DT related
> configuration.
> So the point is are we supposed to do all these cleanup in *remove*
> callback?
> If yes, how do we manage board level gpio usage?

More and more I think of the .remove() for GPIO, the interface not seems to
make sense. Being an infrastructure driver which can be used by many client
drivers like Ethernet, MMC card detect, sensors etc etc. And hence it can
not be made a loadable module.

So I am in favor of dropping the $subject patch completely unless and until
we need it genuinely.

Regards
Santosh
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-10 Thread DebBarma, Tarun Kanti
On Thu, Aug 9, 2012 at 8:28 PM, Kevin Hilman  wrote:
> "DebBarma, Tarun Kanti"  writes:
>
>> On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman  wrote:
>>> Tarun Kanti DebBarma  writes:
>>>
 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma 
 Reported-by: Paul Walmsley 
 Reviewed-by: Jon Hunter 
 Cc: Kevin Hilman 
 Cc: Rajendra Nayak 
 Cc: Santosh Shilimkar 
 Cc: Cousson, Benoit 
 Cc: Paul Walmsley 
 ---
 v2:
 Baseline: 
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank->irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.
>>>
>>> What happens when GPIOs are in use (requested)?
>> If I try to unbind a currently active GPIO bank then I see an exception
>> after the irq descriptor is freed by the remove. I believe this is expected
>> because interrupt raised by the system would not be handled.
>
> ... and the GPIO is still configured to trigger interrupts.
Right!

>
> The point is that there is lots to cleanup/unconfigure properly for this
> to work properly.
As far as I can think of, all active gpio requests done either in
board files or through DT
have to be freed. But if this is done then when we bind() the device
again initialization
done in omap_gpio_probe() would not restore the board/DT related configuration.
So the point is are we supposed to do all these cleanup in *remove* callback?
If yes, how do we manage board level gpio usage?
---
Tarun
>
> Kevin
>
>> [   18.859405] irq_free_descs: calling free_desc(192)...
>> [   18.866180] irq_free_descs: calling free_desc(192)...
>> [   18.872680] irq_free_descs: calling free_desc(192)...
>> [   18.877990] irq_free_descs: calling free_desc(192)...
>> [   18.883270] irq_free_descs: calling free_desc(192)...
>> [   18.888549] irq_free_descs: calling free_desc(192)...
>> [   18.893859] irq_free_descs: calling free_desc(192)...
>> [   18.899139] irq_free_descs: calling free_desc(192)...
>> [   18.904418] irq_free_descs: calling free_desc(192)...
>> [   18.909729] irq_free_descs: calling free_desc(192)...
>> [   18.915008] irq_free_descs: calling free_desc(192)...
>> [   18.920288] irq_free_descs: calling free_desc(192)...
>> [   18.925598] irq_free_descs: calling free_desc(192)...
>> [   18.930877] irq_free_descs: calling free_desc(192)...
>> [   18.936157] irq_free_descs: calling free_desc(192)...
>> [   18.941467] irq_free_descs: calling free_desc(192)...
>> [   18.946746] irq_free_descs: calling free_desc(192)...
>> [   18.952026] irq_free_descs: calling free_desc(192)...
>> [   18.957336] irq_free_descs: calling free_desc(192)...
>> [   18.962615] irq_free_descs: calling free_desc(192)...
>> [   18.967895] irq_free_descs: calling free_desc(192)...
>> [   18.973205] irq_free_descs: calling free_desc(192)...
>> [   18.978485] irq_free_descs: calling free_desc(192)...
>> [   18.983764] irq_free_descs: calling free_desc(192)...
>> [   18.989074] irq_free_descs: calling free_desc(192)...
>> [   18.994354] irq_free_descs: calling free_desc(192)...
>> [   18.999633] irq_free_descs: calling free_desc(192)...
>> [   19.004913] irq_free_descs: calling free_desc(192)...
>> [   19.010223] irq_free_descs: calling free_desc(192)...
>> [   19.015502] irq_free_descs: calling free_desc(192)...
>> [   19.020782] irq_free_descs: calling free_desc(192)...
>> [   19.026092] irq_free_descs: calling free_desc(192)...
>> [   19.032440] irq 194, desc: c072f340, depth: 1, count: 0, unhandled: 0
>> [   19.039154] ->handle_irq():  c00a3e08, handle_bad_irq+0x0/0x260
>> [   19.045379] ->irq_data.chip(): c078ff7c, no_irq_chip+0x0/0x5c
>> [   19.051391] ->action(): ef0d42c0
>> [   19.054748] ->action->handler(): c0399ee0, ks8851_irq+0x0/0x1c
>> [   19.060852]IRQ_NOPROBE set
>> [   19.064056]  IRQ_NOREQUEST set
>> [   19.067230] Unable to handle kernel paging request at virtual address 
>> 203a6c9
>> [   19.074768] pgd = c0004000
>> [   19.077606] [203a6c99] *pgd=
>> [   19.081329] Internal error: Oops: 5 [#1] SMP ARM
>> 

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-10 Thread DebBarma, Tarun Kanti
On Thu, Aug 9, 2012 at 8:28 PM, Kevin Hilman khil...@ti.com wrote:
 DebBarma, Tarun Kanti tarun.ka...@ti.com writes:

 On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman khil...@ti.com wrote:
 Tarun Kanti DebBarma tarun.ka...@ti.com writes:

 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reported-by: Paul Walmsley p...@pwsan.com
 Reviewed-by: Jon Hunter jon-hun...@ti.com
 Cc: Kevin Hilman khil...@ti.com
 Cc: Rajendra Nayak rna...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Cc: Cousson, Benoit b-cous...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 ---
 v2:
 Baseline: 
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank-irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.

 What happens when GPIOs are in use (requested)?
 If I try to unbind a currently active GPIO bank then I see an exception
 after the irq descriptor is freed by the remove. I believe this is expected
 because interrupt raised by the system would not be handled.

 ... and the GPIO is still configured to trigger interrupts.
Right!


 The point is that there is lots to cleanup/unconfigure properly for this
 to work properly.
As far as I can think of, all active gpio requests done either in
board files or through DT
have to be freed. But if this is done then when we bind() the device
again initialization
done in omap_gpio_probe() would not restore the board/DT related configuration.
So the point is are we supposed to do all these cleanup in *remove* callback?
If yes, how do we manage board level gpio usage?
---
Tarun

 Kevin

 [   18.859405] irq_free_descs: calling free_desc(192)...
 [   18.866180] irq_free_descs: calling free_desc(192)...
 [   18.872680] irq_free_descs: calling free_desc(192)...
 [   18.877990] irq_free_descs: calling free_desc(192)...
 [   18.883270] irq_free_descs: calling free_desc(192)...
 [   18.888549] irq_free_descs: calling free_desc(192)...
 [   18.893859] irq_free_descs: calling free_desc(192)...
 [   18.899139] irq_free_descs: calling free_desc(192)...
 [   18.904418] irq_free_descs: calling free_desc(192)...
 [   18.909729] irq_free_descs: calling free_desc(192)...
 [   18.915008] irq_free_descs: calling free_desc(192)...
 [   18.920288] irq_free_descs: calling free_desc(192)...
 [   18.925598] irq_free_descs: calling free_desc(192)...
 [   18.930877] irq_free_descs: calling free_desc(192)...
 [   18.936157] irq_free_descs: calling free_desc(192)...
 [   18.941467] irq_free_descs: calling free_desc(192)...
 [   18.946746] irq_free_descs: calling free_desc(192)...
 [   18.952026] irq_free_descs: calling free_desc(192)...
 [   18.957336] irq_free_descs: calling free_desc(192)...
 [   18.962615] irq_free_descs: calling free_desc(192)...
 [   18.967895] irq_free_descs: calling free_desc(192)...
 [   18.973205] irq_free_descs: calling free_desc(192)...
 [   18.978485] irq_free_descs: calling free_desc(192)...
 [   18.983764] irq_free_descs: calling free_desc(192)...
 [   18.989074] irq_free_descs: calling free_desc(192)...
 [   18.994354] irq_free_descs: calling free_desc(192)...
 [   18.999633] irq_free_descs: calling free_desc(192)...
 [   19.004913] irq_free_descs: calling free_desc(192)...
 [   19.010223] irq_free_descs: calling free_desc(192)...
 [   19.015502] irq_free_descs: calling free_desc(192)...
 [   19.020782] irq_free_descs: calling free_desc(192)...
 [   19.026092] irq_free_descs: calling free_desc(192)...
 [   19.032440] irq 194, desc: c072f340, depth: 1, count: 0, unhandled: 0
 [   19.039154] -handle_irq():  c00a3e08, handle_bad_irq+0x0/0x260
 [   19.045379] -irq_data.chip(): c078ff7c, no_irq_chip+0x0/0x5c
 [   19.051391] -action(): ef0d42c0
 [   19.054748] -action-handler(): c0399ee0, ks8851_irq+0x0/0x1c
 [   19.060852]IRQ_NOPROBE set
 [   19.064056]  IRQ_NOREQUEST set
 [   19.067230] Unable to handle kernel paging request at virtual address 
 203a6c9
 [   19.074768] pgd = c0004000
 [   19.077606] [203a6c99] *pgd=
 [   19.081329] Internal error: Oops: 5 [#1] SMP ARM
 [   19.086151] Modules linked in:
 [   19.089355] CPU: 0Not tainted  

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-10 Thread Shilimkar, Santosh
On Fri, Aug 10, 2012 at 11:38 AM, DebBarma, Tarun Kanti
tarun.ka...@ti.com wrote:

 On Thu, Aug 9, 2012 at 8:28 PM, Kevin Hilman khil...@ti.com wrote:
  DebBarma, Tarun Kanti tarun.ka...@ti.com writes:
 
  On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman khil...@ti.com wrote:
  Tarun Kanti DebBarma tarun.ka...@ti.com writes:
 
  Add *remove* callback so that necessary cleanup operations are
  performed when device is unregistered. The device is deleted
  from the list and associated clock handle is released by
  calling clk_put() and irq descriptor is released using the
  irq_free_desc() api.
 
  Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
  Reported-by: Paul Walmsley p...@pwsan.com
  Reviewed-by: Jon Hunter jon-hun...@ti.com
  Cc: Kevin Hilman khil...@ti.com
  Cc: Rajendra Nayak rna...@ti.com
  Cc: Santosh Shilimkar santosh.shilim...@ti.com
  Cc: Cousson, Benoit b-cous...@ti.com
  Cc: Paul Walmsley p...@pwsan.com
  ---
  v2:
  Baseline:
  git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
  Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
 
  (1) Use irq_free_descs() instead of irq_free_desc().
  Besides, irq_free_desc() was using wrong parameter,
  irq_base, instead of bank-irq.
  (2) irq_free_descs() moved outside spin_lock/unlock_*()
  in order to avoid exception warnings.
 
  (3) pm_runtime_disable() added so that bind can happen successfully
 
  Test Detail:
  Step 1: Unbind gpio.5 device in order to invoke the *remove*
  callback.
  #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind
 
  Step 2: Bind gpio.5 device and confirm probe() for the device
  succeeds.
  #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind
 
  Step 3: Execute read/write GPIO test case.
 
  What happens when GPIOs are in use (requested)?
  If I try to unbind a currently active GPIO bank then I see an exception
  after the irq descriptor is freed by the remove. I believe this is
  expected
  because interrupt raised by the system would not be handled.
 
  ... and the GPIO is still configured to trigger interrupts.
 Right!

 
  The point is that there is lots to cleanup/unconfigure properly for this
  to work properly.
 As far as I can think of, all active gpio requests done either in
 board files or through DT
 have to be freed. But if this is done then when we bind() the device
 again initialization
 done in omap_gpio_probe() would not restore the board/DT related
 configuration.
 So the point is are we supposed to do all these cleanup in *remove*
 callback?
 If yes, how do we manage board level gpio usage?

More and more I think of the .remove() for GPIO, the interface not seems to
make sense. Being an infrastructure driver which can be used by many client
drivers like Ethernet, MMC card detect, sensors etc etc. And hence it can
not be made a loadable module.

So I am in favor of dropping the $subject patch completely unless and until
we need it genuinely.

Regards
Santosh
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-09 Thread Kevin Hilman
"DebBarma, Tarun Kanti"  writes:

> On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman  wrote:
>> Tarun Kanti DebBarma  writes:
>>
>>> Add *remove* callback so that necessary cleanup operations are
>>> performed when device is unregistered. The device is deleted
>>> from the list and associated clock handle is released by
>>> calling clk_put() and irq descriptor is released using the
>>> irq_free_desc() api.
>>>
>>> Signed-off-by: Tarun Kanti DebBarma 
>>> Reported-by: Paul Walmsley 
>>> Reviewed-by: Jon Hunter 
>>> Cc: Kevin Hilman 
>>> Cc: Rajendra Nayak 
>>> Cc: Santosh Shilimkar 
>>> Cc: Cousson, Benoit 
>>> Cc: Paul Walmsley 
>>> ---
>>> v2:
>>> Baseline: 
>>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
>>> Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
>>>
>>> (1) Use irq_free_descs() instead of irq_free_desc().
>>> Besides, irq_free_desc() was using wrong parameter,
>>> irq_base, instead of bank->irq.
>>> (2) irq_free_descs() moved outside spin_lock/unlock_*()
>>> in order to avoid exception warnings.
>>>
>>> (3) pm_runtime_disable() added so that bind can happen successfully
>>>
>>> Test Detail:
>>> Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
>>> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind
>>>
>>> Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
>>> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind
>>>
>>> Step 3: Execute read/write GPIO test case.
>>
>> What happens when GPIOs are in use (requested)?
> If I try to unbind a currently active GPIO bank then I see an exception
> after the irq descriptor is freed by the remove. I believe this is expected
> because interrupt raised by the system would not be handled.

... and the GPIO is still configured to trigger interrupts.

The point is that there is lots to cleanup/unconfigure properly for this
to work properly.

Kevin

> [   18.859405] irq_free_descs: calling free_desc(192)...
> [   18.866180] irq_free_descs: calling free_desc(192)...
> [   18.872680] irq_free_descs: calling free_desc(192)...
> [   18.877990] irq_free_descs: calling free_desc(192)...
> [   18.883270] irq_free_descs: calling free_desc(192)...
> [   18.888549] irq_free_descs: calling free_desc(192)...
> [   18.893859] irq_free_descs: calling free_desc(192)...
> [   18.899139] irq_free_descs: calling free_desc(192)...
> [   18.904418] irq_free_descs: calling free_desc(192)...
> [   18.909729] irq_free_descs: calling free_desc(192)...
> [   18.915008] irq_free_descs: calling free_desc(192)...
> [   18.920288] irq_free_descs: calling free_desc(192)...
> [   18.925598] irq_free_descs: calling free_desc(192)...
> [   18.930877] irq_free_descs: calling free_desc(192)...
> [   18.936157] irq_free_descs: calling free_desc(192)...
> [   18.941467] irq_free_descs: calling free_desc(192)...
> [   18.946746] irq_free_descs: calling free_desc(192)...
> [   18.952026] irq_free_descs: calling free_desc(192)...
> [   18.957336] irq_free_descs: calling free_desc(192)...
> [   18.962615] irq_free_descs: calling free_desc(192)...
> [   18.967895] irq_free_descs: calling free_desc(192)...
> [   18.973205] irq_free_descs: calling free_desc(192)...
> [   18.978485] irq_free_descs: calling free_desc(192)...
> [   18.983764] irq_free_descs: calling free_desc(192)...
> [   18.989074] irq_free_descs: calling free_desc(192)...
> [   18.994354] irq_free_descs: calling free_desc(192)...
> [   18.999633] irq_free_descs: calling free_desc(192)...
> [   19.004913] irq_free_descs: calling free_desc(192)...
> [   19.010223] irq_free_descs: calling free_desc(192)...
> [   19.015502] irq_free_descs: calling free_desc(192)...
> [   19.020782] irq_free_descs: calling free_desc(192)...
> [   19.026092] irq_free_descs: calling free_desc(192)...
> [   19.032440] irq 194, desc: c072f340, depth: 1, count: 0, unhandled: 0
> [   19.039154] ->handle_irq():  c00a3e08, handle_bad_irq+0x0/0x260
> [   19.045379] ->irq_data.chip(): c078ff7c, no_irq_chip+0x0/0x5c
> [   19.051391] ->action(): ef0d42c0
> [   19.054748] ->action->handler(): c0399ee0, ks8851_irq+0x0/0x1c
> [   19.060852]IRQ_NOPROBE set
> [   19.064056]  IRQ_NOREQUEST set
> [   19.067230] Unable to handle kernel paging request at virtual address 
> 203a6c9
> [   19.074768] pgd = c0004000
> [   19.077606] [203a6c99] *pgd=
> [   19.081329] Internal error: Oops: 5 [#1] SMP ARM
> [   19.086151] Modules linked in:
> [   19.089355] CPU: 0Not tainted  (3.6.0-rc1-3-g43a916d-dirty #885)
> [   19.096374] PC is at gpio_irq_handler+0x7c/0x26c
> [   19.101165] LR is at handle_bad_irq+0x1cc/0x260
> [   19.105895] pc : []lr : []psr: 6093
> [   19.105895] sp : c0725df8  ip : 6fc6  fp : 0001
> [   19.117889] r10:   r9 : fa05502c  r8 : 0020
> [   19.123352] r7 :   r6 :   r5 :   r4 : ef0bbe10
> [   19.130157] r3 : ef0c1980  r2 : 203a6c65  r1 : 0034  r0 : 
> [   19.136993] 

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-09 Thread Kevin Hilman
DebBarma, Tarun Kanti tarun.ka...@ti.com writes:

 On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman khil...@ti.com wrote:
 Tarun Kanti DebBarma tarun.ka...@ti.com writes:

 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reported-by: Paul Walmsley p...@pwsan.com
 Reviewed-by: Jon Hunter jon-hun...@ti.com
 Cc: Kevin Hilman khil...@ti.com
 Cc: Rajendra Nayak rna...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Cc: Cousson, Benoit b-cous...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 ---
 v2:
 Baseline: 
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank-irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.

 What happens when GPIOs are in use (requested)?
 If I try to unbind a currently active GPIO bank then I see an exception
 after the irq descriptor is freed by the remove. I believe this is expected
 because interrupt raised by the system would not be handled.

... and the GPIO is still configured to trigger interrupts.

The point is that there is lots to cleanup/unconfigure properly for this
to work properly.

Kevin

 [   18.859405] irq_free_descs: calling free_desc(192)...
 [   18.866180] irq_free_descs: calling free_desc(192)...
 [   18.872680] irq_free_descs: calling free_desc(192)...
 [   18.877990] irq_free_descs: calling free_desc(192)...
 [   18.883270] irq_free_descs: calling free_desc(192)...
 [   18.888549] irq_free_descs: calling free_desc(192)...
 [   18.893859] irq_free_descs: calling free_desc(192)...
 [   18.899139] irq_free_descs: calling free_desc(192)...
 [   18.904418] irq_free_descs: calling free_desc(192)...
 [   18.909729] irq_free_descs: calling free_desc(192)...
 [   18.915008] irq_free_descs: calling free_desc(192)...
 [   18.920288] irq_free_descs: calling free_desc(192)...
 [   18.925598] irq_free_descs: calling free_desc(192)...
 [   18.930877] irq_free_descs: calling free_desc(192)...
 [   18.936157] irq_free_descs: calling free_desc(192)...
 [   18.941467] irq_free_descs: calling free_desc(192)...
 [   18.946746] irq_free_descs: calling free_desc(192)...
 [   18.952026] irq_free_descs: calling free_desc(192)...
 [   18.957336] irq_free_descs: calling free_desc(192)...
 [   18.962615] irq_free_descs: calling free_desc(192)...
 [   18.967895] irq_free_descs: calling free_desc(192)...
 [   18.973205] irq_free_descs: calling free_desc(192)...
 [   18.978485] irq_free_descs: calling free_desc(192)...
 [   18.983764] irq_free_descs: calling free_desc(192)...
 [   18.989074] irq_free_descs: calling free_desc(192)...
 [   18.994354] irq_free_descs: calling free_desc(192)...
 [   18.999633] irq_free_descs: calling free_desc(192)...
 [   19.004913] irq_free_descs: calling free_desc(192)...
 [   19.010223] irq_free_descs: calling free_desc(192)...
 [   19.015502] irq_free_descs: calling free_desc(192)...
 [   19.020782] irq_free_descs: calling free_desc(192)...
 [   19.026092] irq_free_descs: calling free_desc(192)...
 [   19.032440] irq 194, desc: c072f340, depth: 1, count: 0, unhandled: 0
 [   19.039154] -handle_irq():  c00a3e08, handle_bad_irq+0x0/0x260
 [   19.045379] -irq_data.chip(): c078ff7c, no_irq_chip+0x0/0x5c
 [   19.051391] -action(): ef0d42c0
 [   19.054748] -action-handler(): c0399ee0, ks8851_irq+0x0/0x1c
 [   19.060852]IRQ_NOPROBE set
 [   19.064056]  IRQ_NOREQUEST set
 [   19.067230] Unable to handle kernel paging request at virtual address 
 203a6c9
 [   19.074768] pgd = c0004000
 [   19.077606] [203a6c99] *pgd=
 [   19.081329] Internal error: Oops: 5 [#1] SMP ARM
 [   19.086151] Modules linked in:
 [   19.089355] CPU: 0Not tainted  (3.6.0-rc1-3-g43a916d-dirty #885)
 [   19.096374] PC is at gpio_irq_handler+0x7c/0x26c
 [   19.101165] LR is at handle_bad_irq+0x1cc/0x260
 [   19.105895] pc : [c02e13b0]lr : [c00a3fd4]psr: 6093
 [   19.105895] sp : c0725df8  ip : 6fc6  fp : 0001
 [   19.117889] r10:   r9 : fa05502c  r8 : 0020
 [   19.123352] r7 :   r6 :   r5 :   r4 : ef0bbe10
 [   19.130157] r3 : ef0c1980  r2 : 203a6c65  r1 : 0034  r0 : 
 [   

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread DebBarma, Tarun Kanti
On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman  wrote:
> Tarun Kanti DebBarma  writes:
>
>> Add *remove* callback so that necessary cleanup operations are
>> performed when device is unregistered. The device is deleted
>> from the list and associated clock handle is released by
>> calling clk_put() and irq descriptor is released using the
>> irq_free_desc() api.
>>
>> Signed-off-by: Tarun Kanti DebBarma 
>> Reported-by: Paul Walmsley 
>> Reviewed-by: Jon Hunter 
>> Cc: Kevin Hilman 
>> Cc: Rajendra Nayak 
>> Cc: Santosh Shilimkar 
>> Cc: Cousson, Benoit 
>> Cc: Paul Walmsley 
>> ---
>> v2:
>> Baseline: 
>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
>> Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
>>
>> (1) Use irq_free_descs() instead of irq_free_desc().
>> Besides, irq_free_desc() was using wrong parameter,
>> irq_base, instead of bank->irq.
>> (2) irq_free_descs() moved outside spin_lock/unlock_*()
>> in order to avoid exception warnings.
>>
>> (3) pm_runtime_disable() added so that bind can happen successfully
>>
>> Test Detail:
>> Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
>> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind
>>
>> Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
>> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind
>>
>> Step 3: Execute read/write GPIO test case.
>
> What happens when GPIOs are in use (requested)?
If I try to unbind a currently active GPIO bank then I see an exception
after the irq descriptor is freed by the remove. I believe this is expected
because interrupt raised by the system would not be handled.

[   18.859405] irq_free_descs: calling free_desc(192)...
[   18.866180] irq_free_descs: calling free_desc(192)...
[   18.872680] irq_free_descs: calling free_desc(192)...
[   18.877990] irq_free_descs: calling free_desc(192)...
[   18.883270] irq_free_descs: calling free_desc(192)...
[   18.888549] irq_free_descs: calling free_desc(192)...
[   18.893859] irq_free_descs: calling free_desc(192)...
[   18.899139] irq_free_descs: calling free_desc(192)...
[   18.904418] irq_free_descs: calling free_desc(192)...
[   18.909729] irq_free_descs: calling free_desc(192)...
[   18.915008] irq_free_descs: calling free_desc(192)...
[   18.920288] irq_free_descs: calling free_desc(192)...
[   18.925598] irq_free_descs: calling free_desc(192)...
[   18.930877] irq_free_descs: calling free_desc(192)...
[   18.936157] irq_free_descs: calling free_desc(192)...
[   18.941467] irq_free_descs: calling free_desc(192)...
[   18.946746] irq_free_descs: calling free_desc(192)...
[   18.952026] irq_free_descs: calling free_desc(192)...
[   18.957336] irq_free_descs: calling free_desc(192)...
[   18.962615] irq_free_descs: calling free_desc(192)...
[   18.967895] irq_free_descs: calling free_desc(192)...
[   18.973205] irq_free_descs: calling free_desc(192)...
[   18.978485] irq_free_descs: calling free_desc(192)...
[   18.983764] irq_free_descs: calling free_desc(192)...
[   18.989074] irq_free_descs: calling free_desc(192)...
[   18.994354] irq_free_descs: calling free_desc(192)...
[   18.999633] irq_free_descs: calling free_desc(192)...
[   19.004913] irq_free_descs: calling free_desc(192)...
[   19.010223] irq_free_descs: calling free_desc(192)...
[   19.015502] irq_free_descs: calling free_desc(192)...
[   19.020782] irq_free_descs: calling free_desc(192)...
[   19.026092] irq_free_descs: calling free_desc(192)...
[   19.032440] irq 194, desc: c072f340, depth: 1, count: 0, unhandled: 0
[   19.039154] ->handle_irq():  c00a3e08, handle_bad_irq+0x0/0x260
[   19.045379] ->irq_data.chip(): c078ff7c, no_irq_chip+0x0/0x5c
[   19.051391] ->action(): ef0d42c0
[   19.054748] ->action->handler(): c0399ee0, ks8851_irq+0x0/0x1c
[   19.060852]IRQ_NOPROBE set
[   19.064056]  IRQ_NOREQUEST set
[   19.067230] Unable to handle kernel paging request at virtual address 203a6c9
[   19.074768] pgd = c0004000
[   19.077606] [203a6c99] *pgd=
[   19.081329] Internal error: Oops: 5 [#1] SMP ARM
[   19.086151] Modules linked in:
[   19.089355] CPU: 0Not tainted  (3.6.0-rc1-3-g43a916d-dirty #885)
[   19.096374] PC is at gpio_irq_handler+0x7c/0x26c
[   19.101165] LR is at handle_bad_irq+0x1cc/0x260
[   19.105895] pc : []lr : []psr: 6093
[   19.105895] sp : c0725df8  ip : 6fc6  fp : 0001
[   19.117889] r10:   r9 : fa05502c  r8 : 0020
[   19.123352] r7 :   r6 :   r5 :   r4 : ef0bbe10
[   19.130157] r3 : ef0c1980  r2 : 203a6c65  r1 : 0034  r0 : 
[   19.136993] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kel
[   19.144714] Control: 10c53c7d  Table: ae89804a  DAC: 0017
[   19.150695] Process swapper/0 (pid: 0, stack limit = 0xc07242f8)
[   19.156982] Stack: (0xc0725df8 to 0xc0726000)
[   19.161529] 5de0:   c0740
[   19.170074] 5e00: 

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Kevin Hilman
Tarun Kanti DebBarma  writes:

> Add *remove* callback so that necessary cleanup operations are
> performed when device is unregistered. The device is deleted
> from the list and associated clock handle is released by
> calling clk_put() and irq descriptor is released using the
> irq_free_desc() api.
>
> Signed-off-by: Tarun Kanti DebBarma 
> Reported-by: Paul Walmsley 
> Reviewed-by: Jon Hunter 
> Cc: Kevin Hilman 
> Cc: Rajendra Nayak 
> Cc: Santosh Shilimkar 
> Cc: Cousson, Benoit 
> Cc: Paul Walmsley 
> ---
> v2:
> Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
>
> (1) Use irq_free_descs() instead of irq_free_desc().
> Besides, irq_free_desc() was using wrong parameter,
> irq_base, instead of bank->irq.
> (2) irq_free_descs() moved outside spin_lock/unlock_*()
> in order to avoid exception warnings.
>
> (3) pm_runtime_disable() added so that bind can happen successfully
>
> Test Detail:
> Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind
>
> Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind
>
> Step 3: Execute read/write GPIO test case.

What happens when GPIOs are in use (requested)?   

Kevin

>  drivers/gpio/gpio-omap.c |   35 +++
>  1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index e6efd77..50de875 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1152,6 +1152,40 @@ static int __devinit omap_gpio_probe(struct 
> platform_device *pdev)
>   return ret;
>  }
>  
> +/**
> + * omap_gpio_remove - cleanup a registered gpio device
> + * @pdev:   pointer to current gpio platform device
> + *
> + * Called by driver framework whenever a gpio device is unregistered.
> + * GPIO is deleted from the list and associated clock handle freed.
> + */
> +static int __devexit omap_gpio_remove(struct platform_device *pdev)
> +{
> + struct device *dev = >dev;
> + struct gpio_bank *bank;
> + unsigned long flags;
> + int ret = -EINVAL;
> +
> + list_for_each_entry(bank, _gpio_list, node) {
> + spin_lock_irqsave(>lock, flags);
> + if (bank->dev == dev) {
> + clk_put(bank->dbck);
> + list_del(>node);
> + ret = 0;
> + spin_unlock_irqrestore(>lock, flags);
> + break;
> + }
> + spin_unlock_irqrestore(>lock, flags);
> + }
> +
> + if (!ret) {
> + pm_runtime_disable(bank->dev);
> + irq_free_descs(bank->irq_base, bank->width);
> + }
> +
> + return ret;
> +}
> +
>  #ifdef CONFIG_ARCH_OMAP2PLUS
>  
>  #if defined(CONFIG_PM_RUNTIME)
> @@ -1478,6 +1512,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
>  
>  static struct platform_driver omap_gpio_driver = {
>   .probe  = omap_gpio_probe,
> + .remove = __devexit_p(omap_gpio_remove),
>   .driver = {
>   .name   = "omap_gpio",
>   .pm = _pm_ops,
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread DebBarma, Tarun Kanti
On Wed, Aug 8, 2012 at 7:33 PM, Shilimkar, Santosh
 wrote:
> On Wed, Aug 8, 2012 at 7:28 PM, Tarun Kanti DebBarma  
> wrote:
>> Add *remove* callback so that necessary cleanup operations are
>> performed when device is unregistered. The device is deleted
>> from the list and associated clock handle is released by
>> calling clk_put() and irq descriptor is released using the
>> irq_free_desc() api.
>>
>> Signed-off-by: Tarun Kanti DebBarma 
>> Reported-by: Paul Walmsley 
>> Reviewed-by: Jon Hunter 
>> Cc: Kevin Hilman 
>> Cc: Rajendra Nayak 
>> Cc: Santosh Shilimkar 
>> Cc: Cousson, Benoit 
>> Cc: Paul Walmsley 
>> ---
>> v2:
>> Baseline: 
>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
>> Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
>>
>> (1) Use irq_free_descs() instead of irq_free_desc().
>> Besides, irq_free_desc() was using wrong parameter,
>> irq_base, instead of bank->irq.
>> (2) irq_free_descs() moved outside spin_lock/unlock_*()
>> in order to avoid exception warnings.
>>
>> (3) pm_runtime_disable() added so that bind can happen successfully
>>
>> Test Detail:
>> Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
>> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind
>>
>> Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
>> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind
>>
>> Step 3: Execute read/write GPIO test case.
>>
> Thanks details about test. Whe  you to "Unbind->bind", do
> you see that PM is not broken.
>
> In other words, can you also test and ensure that the OMAP3 suspend and
> CPUIDLE are not broken because of this patch.
> PER and CORE domains should transition to low power states.
Sure, I will do the PM test on OMAP3 and confirm this.
---
Tarun
>
> Regards
> Santosh
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Shilimkar, Santosh
On Wed, Aug 8, 2012 at 7:28 PM, Tarun Kanti DebBarma  wrote:
> Add *remove* callback so that necessary cleanup operations are
> performed when device is unregistered. The device is deleted
> from the list and associated clock handle is released by
> calling clk_put() and irq descriptor is released using the
> irq_free_desc() api.
>
> Signed-off-by: Tarun Kanti DebBarma 
> Reported-by: Paul Walmsley 
> Reviewed-by: Jon Hunter 
> Cc: Kevin Hilman 
> Cc: Rajendra Nayak 
> Cc: Santosh Shilimkar 
> Cc: Cousson, Benoit 
> Cc: Paul Walmsley 
> ---
> v2:
> Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)
>
> (1) Use irq_free_descs() instead of irq_free_desc().
> Besides, irq_free_desc() was using wrong parameter,
> irq_base, instead of bank->irq.
> (2) irq_free_descs() moved outside spin_lock/unlock_*()
> in order to avoid exception warnings.
>
> (3) pm_runtime_disable() added so that bind can happen successfully
>
> Test Detail:
> Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind
>
> Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
> #echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind
>
> Step 3: Execute read/write GPIO test case.
>
Thanks details about test. Whe  you to "Unbind->bind", do
you see that PM is not broken.

In other words, can you also test and ensure that the OMAP3 suspend and
CPUIDLE are not broken because of this patch.
PER and CORE domains should transition to low power states.

Regards
Santosh
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Tarun Kanti DebBarma
Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma 
Reported-by: Paul Walmsley 
Reviewed-by: Jon Hunter 
Cc: Kevin Hilman 
Cc: Rajendra Nayak 
Cc: Santosh Shilimkar 
Cc: Cousson, Benoit 
Cc: Paul Walmsley 
---
v2:
Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

(1) Use irq_free_descs() instead of irq_free_desc().
Besides, irq_free_desc() was using wrong parameter,
irq_base, instead of bank->irq.
(2) irq_free_descs() moved outside spin_lock/unlock_*()
in order to avoid exception warnings.

(3) pm_runtime_disable() added so that bind can happen successfully

Test Detail:
Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind

Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind

Step 3: Execute read/write GPIO test case.

 drivers/gpio/gpio-omap.c |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index e6efd77..50de875 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1152,6 +1152,40 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
return ret;
 }
 
+/**
+ * omap_gpio_remove - cleanup a registered gpio device
+ * @pdev:   pointer to current gpio platform device
+ *
+ * Called by driver framework whenever a gpio device is unregistered.
+ * GPIO is deleted from the list and associated clock handle freed.
+ */
+static int __devexit omap_gpio_remove(struct platform_device *pdev)
+{
+   struct device *dev = >dev;
+   struct gpio_bank *bank;
+   unsigned long flags;
+   int ret = -EINVAL;
+
+   list_for_each_entry(bank, _gpio_list, node) {
+   spin_lock_irqsave(>lock, flags);
+   if (bank->dev == dev) {
+   clk_put(bank->dbck);
+   list_del(>node);
+   ret = 0;
+   spin_unlock_irqrestore(>lock, flags);
+   break;
+   }
+   spin_unlock_irqrestore(>lock, flags);
+   }
+
+   if (!ret) {
+   pm_runtime_disable(bank->dev);
+   irq_free_descs(bank->irq_base, bank->width);
+   }
+
+   return ret;
+}
+
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
 #if defined(CONFIG_PM_RUNTIME)
@@ -1478,6 +1512,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
 
 static struct platform_driver omap_gpio_driver = {
.probe  = omap_gpio_probe,
+   .remove = __devexit_p(omap_gpio_remove),
.driver = {
.name   = "omap_gpio",
.pm = _pm_ops,
-- 
1.7.0.4

--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Tarun Kanti DebBarma
Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reported-by: Paul Walmsley p...@pwsan.com
Reviewed-by: Jon Hunter jon-hun...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
---
v2:
Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

(1) Use irq_free_descs() instead of irq_free_desc().
Besides, irq_free_desc() was using wrong parameter,
irq_base, instead of bank-irq.
(2) irq_free_descs() moved outside spin_lock/unlock_*()
in order to avoid exception warnings.

(3) pm_runtime_disable() added so that bind can happen successfully

Test Detail:
Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
#echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
#echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

Step 3: Execute read/write GPIO test case.

 drivers/gpio/gpio-omap.c |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index e6efd77..50de875 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1152,6 +1152,40 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
return ret;
 }
 
+/**
+ * omap_gpio_remove - cleanup a registered gpio device
+ * @pdev:   pointer to current gpio platform device
+ *
+ * Called by driver framework whenever a gpio device is unregistered.
+ * GPIO is deleted from the list and associated clock handle freed.
+ */
+static int __devexit omap_gpio_remove(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct gpio_bank *bank;
+   unsigned long flags;
+   int ret = -EINVAL;
+
+   list_for_each_entry(bank, omap_gpio_list, node) {
+   spin_lock_irqsave(bank-lock, flags);
+   if (bank-dev == dev) {
+   clk_put(bank-dbck);
+   list_del(bank-node);
+   ret = 0;
+   spin_unlock_irqrestore(bank-lock, flags);
+   break;
+   }
+   spin_unlock_irqrestore(bank-lock, flags);
+   }
+
+   if (!ret) {
+   pm_runtime_disable(bank-dev);
+   irq_free_descs(bank-irq_base, bank-width);
+   }
+
+   return ret;
+}
+
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
 #if defined(CONFIG_PM_RUNTIME)
@@ -1478,6 +1512,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
 
 static struct platform_driver omap_gpio_driver = {
.probe  = omap_gpio_probe,
+   .remove = __devexit_p(omap_gpio_remove),
.driver = {
.name   = omap_gpio,
.pm = gpio_pm_ops,
-- 
1.7.0.4

--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Shilimkar, Santosh
On Wed, Aug 8, 2012 at 7:28 PM, Tarun Kanti DebBarma tarun.ka...@ti.com wrote:
 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reported-by: Paul Walmsley p...@pwsan.com
 Reviewed-by: Jon Hunter jon-hun...@ti.com
 Cc: Kevin Hilman khil...@ti.com
 Cc: Rajendra Nayak rna...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Cc: Cousson, Benoit b-cous...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 ---
 v2:
 Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank-irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.

Thanks details about test. Whe  you to Unbind-bind, do
you see that PM is not broken.

In other words, can you also test and ensure that the OMAP3 suspend and
CPUIDLE are not broken because of this patch.
PER and CORE domains should transition to low power states.

Regards
Santosh
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread DebBarma, Tarun Kanti
On Wed, Aug 8, 2012 at 7:33 PM, Shilimkar, Santosh
santosh.shilim...@ti.com wrote:
 On Wed, Aug 8, 2012 at 7:28 PM, Tarun Kanti DebBarma tarun.ka...@ti.com 
 wrote:
 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reported-by: Paul Walmsley p...@pwsan.com
 Reviewed-by: Jon Hunter jon-hun...@ti.com
 Cc: Kevin Hilman khil...@ti.com
 Cc: Rajendra Nayak rna...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Cc: Cousson, Benoit b-cous...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 ---
 v2:
 Baseline: 
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank-irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.

 Thanks details about test. Whe  you to Unbind-bind, do
 you see that PM is not broken.

 In other words, can you also test and ensure that the OMAP3 suspend and
 CPUIDLE are not broken because of this patch.
 PER and CORE domains should transition to low power states.
Sure, I will do the PM test on OMAP3 and confirm this.
---
Tarun

 Regards
 Santosh
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Kevin Hilman
Tarun Kanti DebBarma tarun.ka...@ti.com writes:

 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reported-by: Paul Walmsley p...@pwsan.com
 Reviewed-by: Jon Hunter jon-hun...@ti.com
 Cc: Kevin Hilman khil...@ti.com
 Cc: Rajendra Nayak rna...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Cc: Cousson, Benoit b-cous...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 ---
 v2:
 Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank-irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.

What happens when GPIOs are in use (requested)?   

Kevin

  drivers/gpio/gpio-omap.c |   35 +++
  1 files changed, 35 insertions(+), 0 deletions(-)

 diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
 index e6efd77..50de875 100644
 --- a/drivers/gpio/gpio-omap.c
 +++ b/drivers/gpio/gpio-omap.c
 @@ -1152,6 +1152,40 @@ static int __devinit omap_gpio_probe(struct 
 platform_device *pdev)
   return ret;
  }
  
 +/**
 + * omap_gpio_remove - cleanup a registered gpio device
 + * @pdev:   pointer to current gpio platform device
 + *
 + * Called by driver framework whenever a gpio device is unregistered.
 + * GPIO is deleted from the list and associated clock handle freed.
 + */
 +static int __devexit omap_gpio_remove(struct platform_device *pdev)
 +{
 + struct device *dev = pdev-dev;
 + struct gpio_bank *bank;
 + unsigned long flags;
 + int ret = -EINVAL;
 +
 + list_for_each_entry(bank, omap_gpio_list, node) {
 + spin_lock_irqsave(bank-lock, flags);
 + if (bank-dev == dev) {
 + clk_put(bank-dbck);
 + list_del(bank-node);
 + ret = 0;
 + spin_unlock_irqrestore(bank-lock, flags);
 + break;
 + }
 + spin_unlock_irqrestore(bank-lock, flags);
 + }
 +
 + if (!ret) {
 + pm_runtime_disable(bank-dev);
 + irq_free_descs(bank-irq_base, bank-width);
 + }
 +
 + return ret;
 +}
 +
  #ifdef CONFIG_ARCH_OMAP2PLUS
  
  #if defined(CONFIG_PM_RUNTIME)
 @@ -1478,6 +1512,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
  
  static struct platform_driver omap_gpio_driver = {
   .probe  = omap_gpio_probe,
 + .remove = __devexit_p(omap_gpio_remove),
   .driver = {
   .name   = omap_gpio,
   .pm = gpio_pm_ops,
--
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 v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread DebBarma, Tarun Kanti
On Wed, Aug 8, 2012 at 10:40 PM, Kevin Hilman khil...@ti.com wrote:
 Tarun Kanti DebBarma tarun.ka...@ti.com writes:

 Add *remove* callback so that necessary cleanup operations are
 performed when device is unregistered. The device is deleted
 from the list and associated clock handle is released by
 calling clk_put() and irq descriptor is released using the
 irq_free_desc() api.

 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reported-by: Paul Walmsley p...@pwsan.com
 Reviewed-by: Jon Hunter jon-hun...@ti.com
 Cc: Kevin Hilman khil...@ti.com
 Cc: Rajendra Nayak rna...@ti.com
 Cc: Santosh Shilimkar santosh.shilim...@ti.com
 Cc: Cousson, Benoit b-cous...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 ---
 v2:
 Baseline: 
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

 (1) Use irq_free_descs() instead of irq_free_desc().
 Besides, irq_free_desc() was using wrong parameter,
 irq_base, instead of bank-irq.
 (2) irq_free_descs() moved outside spin_lock/unlock_*()
 in order to avoid exception warnings.

 (3) pm_runtime_disable() added so that bind can happen successfully

 Test Detail:
 Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

 Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
 #echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

 Step 3: Execute read/write GPIO test case.

 What happens when GPIOs are in use (requested)?
If I try to unbind a currently active GPIO bank then I see an exception
after the irq descriptor is freed by the remove. I believe this is expected
because interrupt raised by the system would not be handled.

[   18.859405] irq_free_descs: calling free_desc(192)...
[   18.866180] irq_free_descs: calling free_desc(192)...
[   18.872680] irq_free_descs: calling free_desc(192)...
[   18.877990] irq_free_descs: calling free_desc(192)...
[   18.883270] irq_free_descs: calling free_desc(192)...
[   18.888549] irq_free_descs: calling free_desc(192)...
[   18.893859] irq_free_descs: calling free_desc(192)...
[   18.899139] irq_free_descs: calling free_desc(192)...
[   18.904418] irq_free_descs: calling free_desc(192)...
[   18.909729] irq_free_descs: calling free_desc(192)...
[   18.915008] irq_free_descs: calling free_desc(192)...
[   18.920288] irq_free_descs: calling free_desc(192)...
[   18.925598] irq_free_descs: calling free_desc(192)...
[   18.930877] irq_free_descs: calling free_desc(192)...
[   18.936157] irq_free_descs: calling free_desc(192)...
[   18.941467] irq_free_descs: calling free_desc(192)...
[   18.946746] irq_free_descs: calling free_desc(192)...
[   18.952026] irq_free_descs: calling free_desc(192)...
[   18.957336] irq_free_descs: calling free_desc(192)...
[   18.962615] irq_free_descs: calling free_desc(192)...
[   18.967895] irq_free_descs: calling free_desc(192)...
[   18.973205] irq_free_descs: calling free_desc(192)...
[   18.978485] irq_free_descs: calling free_desc(192)...
[   18.983764] irq_free_descs: calling free_desc(192)...
[   18.989074] irq_free_descs: calling free_desc(192)...
[   18.994354] irq_free_descs: calling free_desc(192)...
[   18.999633] irq_free_descs: calling free_desc(192)...
[   19.004913] irq_free_descs: calling free_desc(192)...
[   19.010223] irq_free_descs: calling free_desc(192)...
[   19.015502] irq_free_descs: calling free_desc(192)...
[   19.020782] irq_free_descs: calling free_desc(192)...
[   19.026092] irq_free_descs: calling free_desc(192)...
[   19.032440] irq 194, desc: c072f340, depth: 1, count: 0, unhandled: 0
[   19.039154] -handle_irq():  c00a3e08, handle_bad_irq+0x0/0x260
[   19.045379] -irq_data.chip(): c078ff7c, no_irq_chip+0x0/0x5c
[   19.051391] -action(): ef0d42c0
[   19.054748] -action-handler(): c0399ee0, ks8851_irq+0x0/0x1c
[   19.060852]IRQ_NOPROBE set
[   19.064056]  IRQ_NOREQUEST set
[   19.067230] Unable to handle kernel paging request at virtual address 203a6c9
[   19.074768] pgd = c0004000
[   19.077606] [203a6c99] *pgd=
[   19.081329] Internal error: Oops: 5 [#1] SMP ARM
[   19.086151] Modules linked in:
[   19.089355] CPU: 0Not tainted  (3.6.0-rc1-3-g43a916d-dirty #885)
[   19.096374] PC is at gpio_irq_handler+0x7c/0x26c
[   19.101165] LR is at handle_bad_irq+0x1cc/0x260
[   19.105895] pc : [c02e13b0]lr : [c00a3fd4]psr: 6093
[   19.105895] sp : c0725df8  ip : 6fc6  fp : 0001
[   19.117889] r10:   r9 : fa05502c  r8 : 0020
[   19.123352] r7 :   r6 :   r5 :   r4 : ef0bbe10
[   19.130157] r3 : ef0c1980  r2 : 203a6c65  r1 : 0034  r0 : 
[   19.136993] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kel
[   19.144714] Control: 10c53c7d  Table: ae89804a  DAC: 0017
[   19.150695] Process swapper/0 (pid: 0, stack limit = 0xc07242f8)
[   19.156982] Stack: (0xc0725df8 to 0xc0726000)
[   19.161529]