All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] btmrvl: avoid double-disable_irq() race
@ 2017-01-20 11:14 Jeffy Chen
  2017-01-20 11:14 ` [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it Jeffy Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jeffy Chen @ 2017-01-20 11:14 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: Amitkumar Karwar, Marcel Holtmann, Brian Norris, Jeffy Chen,
	Johan Hedberg, Gustavo Padovan, linux-kernel

It's much the same as what we did for mwifiex in:
b9da4d2 mwifiex: avoid double-disable_irq() race

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

 drivers/bluetooth/btmrvl_sdio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index d02f2c1..c738bae 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -1682,8 +1682,12 @@ static int btmrvl_sdio_resume(struct device *dev)
 	/* Disable platform specific wakeup interrupt */
 	if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) {
 		disable_irq_wake(card->plt_wake_cfg->irq_bt);
-		if (!card->plt_wake_cfg->wake_by_bt)
-			disable_irq(card->plt_wake_cfg->irq_bt);
+		disable_irq(card->plt_wake_cfg->irq_bt);
+		if (card->plt_wake_cfg->wake_by_bt)
+			/* Undo our disable, since interrupt handler already
+			 * did this.
+			 */
+			enable_irq(card->plt_wake_cfg->irq_bt);
 	}
 
 	return 0;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it
  2017-01-20 11:14 [PATCH 1/3] btmrvl: avoid double-disable_irq() race Jeffy Chen
@ 2017-01-20 11:14 ` Jeffy Chen
  2017-01-20 19:27   ` Brian Norris
  2017-01-20 11:14 ` [PATCH 3/3] btmrvl: use dt's irqflags for wakeup pin Jeffy Chen
  2017-01-20 19:29 ` [PATCH 1/3] btmrvl: avoid double-disable_irq() race Brian Norris
  2 siblings, 1 reply; 6+ messages in thread
From: Jeffy Chen @ 2017-01-20 11:14 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: Amitkumar Karwar, Marcel Holtmann, Brian Norris, Jeffy Chen,
	Johan Hedberg, Gustavo Padovan, linux-kernel

The irq_of_parse_and_map will return 0 as a invalid irq.

Set irq_bt to -1 in this case, so that the btmrvl resume/suspend code
would not get confused.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

 drivers/bluetooth/btmrvl_sdio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index c738bae..796f719 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -97,6 +97,7 @@ static int btmrvl_sdio_probe_of(struct device *dev,
 		cfg->irq_bt = irq_of_parse_and_map(card->plt_of_node, 0);
 		if (!cfg->irq_bt) {
 			dev_err(dev, "fail to parse irq_bt from device tree");
+			cfg->irq_bt = -1;
 		} else {
 			ret = devm_request_irq(dev, cfg->irq_bt,
 					       btmrvl_wake_irq_bt,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] btmrvl: use dt's irqflags for wakeup pin
  2017-01-20 11:14 [PATCH 1/3] btmrvl: avoid double-disable_irq() race Jeffy Chen
  2017-01-20 11:14 ` [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it Jeffy Chen
@ 2017-01-20 11:14 ` Jeffy Chen
  2017-01-20 19:19   ` Brian Norris
  2017-01-20 19:29 ` [PATCH 1/3] btmrvl: avoid double-disable_irq() race Brian Norris
  2 siblings, 1 reply; 6+ messages in thread
From: Jeffy Chen @ 2017-01-20 11:14 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: Amitkumar Karwar, Marcel Holtmann, Brian Norris, Jeffy Chen,
	Johan Hedberg, Gustavo Padovan, linux-kernel

Use irqflags parsed from dt.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

 drivers/bluetooth/btmrvl_sdio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 796f719..23711fe 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -101,8 +101,7 @@ static int btmrvl_sdio_probe_of(struct device *dev,
 		} else {
 			ret = devm_request_irq(dev, cfg->irq_bt,
 					       btmrvl_wake_irq_bt,
-					       IRQF_TRIGGER_LOW,
-					       "bt_wake", cfg);
+					       0, "bt_wake", cfg);
 			if (ret) {
 				dev_err(dev,
 					"Failed to request irq_bt %d (%d)\n",
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] btmrvl: use dt's irqflags for wakeup pin
  2017-01-20 11:14 ` [PATCH 3/3] btmrvl: use dt's irqflags for wakeup pin Jeffy Chen
@ 2017-01-20 19:19   ` Brian Norris
  0 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2017-01-20 19:19 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-bluetooth, Amitkumar Karwar, Marcel Holtmann,
	Johan Hedberg, Gustavo Padovan, linux-kernel

On Fri, Jan 20, 2017 at 07:14:20PM +0800, Jeffy Chen wrote:
> Use irqflags parsed from dt.
> 
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
>  drivers/bluetooth/btmrvl_sdio.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
> index 796f719..23711fe 100644
> --- a/drivers/bluetooth/btmrvl_sdio.c
> +++ b/drivers/bluetooth/btmrvl_sdio.c
> @@ -101,8 +101,7 @@ static int btmrvl_sdio_probe_of(struct device *dev,
>  		} else {
>  			ret = devm_request_irq(dev, cfg->irq_bt,
>  					       btmrvl_wake_irq_bt,
> -					       IRQF_TRIGGER_LOW,

IRQF_TRIGGER_LOW is often accurate, since Marvell devices seem to always
physically use an active low signal here. But there could always be some
kind of inverter logic on the board, for instance, so it makes sense to
just let the device tree specify these flags for us.

Also, I don't actually see any in-tree users of this yet (at least, I
see no proper "marvell,sd*-bt" compatible properties), so I don't see
anyone who might have specified this incorrectly yet...

So:

Reviewed-by: Brian Norris <briannorris@chromium.org>

> -					       "bt_wake", cfg);
> +					       0, "bt_wake", cfg);
>  			if (ret) {
>  				dev_err(dev,
>  					"Failed to request irq_bt %d (%d)\n",
> -- 
> 2.1.4
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it
  2017-01-20 11:14 ` [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it Jeffy Chen
@ 2017-01-20 19:27   ` Brian Norris
  0 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2017-01-20 19:27 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-bluetooth, Amitkumar Karwar, Marcel Holtmann,
	Johan Hedberg, Gustavo Padovan, linux-kernel

On Fri, Jan 20, 2017 at 07:14:19PM +0800, Jeffy Chen wrote:
> The irq_of_parse_and_map will return 0 as a invalid irq.

irq_of_parse_and_map() is weird to me. In general, Linux IRQ numbers
*can* be 0, but it looks like the OF framework understands that
device-tree based interrupts will not get mapped to a virtual IRQ number
of 0, so it's fine to use '0' as the error value?

In that case, I guess this is the most sensible solution...

> Set irq_bt to -1 in this case, so that the btmrvl resume/suspend code
> would not get confused.

More specifically: the suspend/resume code would have tried to
enable/disable IRQ 0.

> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>

Reviewed-by: Brian Norris <briannorris@chromium.org>

> ---
> 
>  drivers/bluetooth/btmrvl_sdio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
> index c738bae..796f719 100644
> --- a/drivers/bluetooth/btmrvl_sdio.c
> +++ b/drivers/bluetooth/btmrvl_sdio.c
> @@ -97,6 +97,7 @@ static int btmrvl_sdio_probe_of(struct device *dev,
>  		cfg->irq_bt = irq_of_parse_and_map(card->plt_of_node, 0);
>  		if (!cfg->irq_bt) {
>  			dev_err(dev, "fail to parse irq_bt from device tree");
> +			cfg->irq_bt = -1;
>  		} else {
>  			ret = devm_request_irq(dev, cfg->irq_bt,
>  					       btmrvl_wake_irq_bt,
> -- 
> 2.1.4
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] btmrvl: avoid double-disable_irq() race
  2017-01-20 11:14 [PATCH 1/3] btmrvl: avoid double-disable_irq() race Jeffy Chen
  2017-01-20 11:14 ` [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it Jeffy Chen
  2017-01-20 11:14 ` [PATCH 3/3] btmrvl: use dt's irqflags for wakeup pin Jeffy Chen
@ 2017-01-20 19:29 ` Brian Norris
  2 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2017-01-20 19:29 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-bluetooth, Amitkumar Karwar, Marcel Holtmann,
	Johan Hedberg, Gustavo Padovan, linux-kernel

On Fri, Jan 20, 2017 at 07:14:18PM +0800, Jeffy Chen wrote:
> It's much the same as what we did for mwifiex in:
> b9da4d2 mwifiex: avoid double-disable_irq() race

You could still stand to borrow some of the explanation for your commit
message here...

> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>

Fix looks good:

Reviewed-by: Brian Norris <briannorris@chromium.org>

> ---
> 
>  drivers/bluetooth/btmrvl_sdio.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
> index d02f2c1..c738bae 100644
> --- a/drivers/bluetooth/btmrvl_sdio.c
> +++ b/drivers/bluetooth/btmrvl_sdio.c
> @@ -1682,8 +1682,12 @@ static int btmrvl_sdio_resume(struct device *dev)
>  	/* Disable platform specific wakeup interrupt */
>  	if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) {
>  		disable_irq_wake(card->plt_wake_cfg->irq_bt);
> -		if (!card->plt_wake_cfg->wake_by_bt)
> -			disable_irq(card->plt_wake_cfg->irq_bt);
> +		disable_irq(card->plt_wake_cfg->irq_bt);
> +		if (card->plt_wake_cfg->wake_by_bt)
> +			/* Undo our disable, since interrupt handler already
> +			 * did this.
> +			 */
> +			enable_irq(card->plt_wake_cfg->irq_bt);
>  	}
>  
>  	return 0;
> -- 
> 2.1.4
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-20 19:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-20 11:14 [PATCH 1/3] btmrvl: avoid double-disable_irq() race Jeffy Chen
2017-01-20 11:14 ` [PATCH 2/3] btmrvl: set irq_bt to -1 when failed to parse it Jeffy Chen
2017-01-20 19:27   ` Brian Norris
2017-01-20 11:14 ` [PATCH 3/3] btmrvl: use dt's irqflags for wakeup pin Jeffy Chen
2017-01-20 19:19   ` Brian Norris
2017-01-20 19:29 ` [PATCH 1/3] btmrvl: avoid double-disable_irq() race Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.