Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] ath10k: add error handling to ath10k_pci_wait()
@ 2013-10-17  8:36 Kalle Valo
  2013-10-17 14:24 ` Michal Kazior
  2013-10-21 14:19 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Kalle Valo @ 2013-10-17  8:36 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless

ath10k_pci_wait() didn't notify any errors to callers, it
just printed a warning so add proper error handling.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |   28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 1e9cfcc9..92759cd 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -525,15 +525,19 @@ static bool ath10k_pci_target_is_awake(struct ath10k *ar)
 	return (RTC_STATE_V_GET(val) == RTC_STATE_V_ON);
 }
 
-static void ath10k_pci_wait(struct ath10k *ar)
+static int ath10k_pci_wait(struct ath10k *ar)
 {
 	int n = 100;
 
 	while (n-- && !ath10k_pci_target_is_awake(ar))
 		msleep(10);
 
-	if (n < 0)
+	if (n < 0) {
 		ath10k_warn("Unable to wakeup target\n");
+		return -ETIMEDOUT;
+	}
+
+	return 0;
 }
 
 int ath10k_do_pci_wake(struct ath10k *ar)
@@ -2227,7 +2231,13 @@ static int ath10k_pci_start_intr_legacy(struct ath10k *ar)
 		  ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
 		  PCIE_SOC_WAKE_ADDRESS);
 
-	ath10k_pci_wait(ar);
+	ret = ath10k_pci_wait(ar);
+	if (ret) {
+		ath10k_warn("Failed to enable legacy interrupt, target did not wake up: %d\n",
+			    ret);
+		free_irq(ar_pci->pdev->irq, ar);
+		return ret;
+	}
 
 	/*
 	 * A potential race occurs here: The CORE_BASE write
@@ -2290,6 +2300,10 @@ static int ath10k_pci_start_intr(struct ath10k *ar)
 	}
 
 	ret = ath10k_pci_start_intr_legacy(ar);
+	if (ret) {
+		ath10k_warn("Failed to start legacy interrupts: %d\n", ret);
+		return ret;
+	}
 
 exit:
 	ar_pci->num_msi_intrs = num;
@@ -2315,13 +2329,19 @@ static int ath10k_pci_reset_target(struct ath10k *ar)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	int wait_limit = 300; /* 3 sec */
+	int ret;
 
 	/* Wait for Target to finish initialization before we proceed. */
 	iowrite32(PCIE_SOC_WAKE_V_MASK,
 		  ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
 		  PCIE_SOC_WAKE_ADDRESS);
 
-	ath10k_pci_wait(ar);
+	ret = ath10k_pci_wait(ar);
+	if (ret) {
+		ath10k_warn("Failed to reset target, target did not wake up: %d\n",
+			    ret);
+		return ret;
+	}
 
 	while (wait_limit-- &&
 	       !(ioread32(ar_pci->mem + FW_INDICATOR_ADDRESS) &


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

* Re: [PATCH] ath10k: add error handling to ath10k_pci_wait()
  2013-10-17  8:36 [PATCH] ath10k: add error handling to ath10k_pci_wait() Kalle Valo
@ 2013-10-17 14:24 ` Michal Kazior
  2013-10-17 14:27   ` Kalle Valo
  2013-10-21 14:19 ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Kazior @ 2013-10-17 14:24 UTC (permalink / raw)
  To: Kalle Valo; +Cc: ath10k, linux-wireless

On 17 October 2013 01:36, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> ath10k_pci_wait() didn't notify any errors to callers, it
> just printed a warning so add proper error handling.
>
> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
> ---
>  drivers/net/wireless/ath/ath10k/pci.c |   28 ++++++++++++++++++++++++----
>  1 file changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
> index 1e9cfcc9..92759cd 100644
> --- a/drivers/net/wireless/ath/ath10k/pci.c
> +++ b/drivers/net/wireless/ath/ath10k/pci.c
> @@ -525,15 +525,19 @@ static bool ath10k_pci_target_is_awake(struct ath10k *ar)
>         return (RTC_STATE_V_GET(val) == RTC_STATE_V_ON);
>  }
>
> -static void ath10k_pci_wait(struct ath10k *ar)
> +static int ath10k_pci_wait(struct ath10k *ar)
>  {
>         int n = 100;
>
>         while (n-- && !ath10k_pci_target_is_awake(ar))
>                 msleep(10);
>
> -       if (n < 0)
> +       if (n < 0) {
>                 ath10k_warn("Unable to wakeup target\n");
> +               return -ETIMEDOUT;
> +       }
> +
> +       return 0;
>  }
>
>  int ath10k_do_pci_wake(struct ath10k *ar)
> @@ -2227,7 +2231,13 @@ static int ath10k_pci_start_intr_legacy(struct ath10k *ar)
>                   ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
>                   PCIE_SOC_WAKE_ADDRESS);
>
> -       ath10k_pci_wait(ar);
> +       ret = ath10k_pci_wait(ar);
> +       if (ret) {
> +               ath10k_warn("Failed to enable legacy interrupt, target did not wake up: %d\n",
> +                           ret);
> +               free_irq(ar_pci->pdev->irq, ar);
> +               return ret;
> +       }

I think we could actually use ath10k_do_pci_wake/sleep() here (see
above iowrite). It does basically the same thing - sets the wake
register and waits until HW wakes up. I think ath10k_pci_wait() could
even go away.


>
>         /*
>          * A potential race occurs here: The CORE_BASE write
> @@ -2290,6 +2300,10 @@ static int ath10k_pci_start_intr(struct ath10k *ar)
>         }
>
>         ret = ath10k_pci_start_intr_legacy(ar);
> +       if (ret) {
> +               ath10k_warn("Failed to start legacy interrupts: %d\n", ret);
> +               return ret;
> +       }
>
>  exit:
>         ar_pci->num_msi_intrs = num;
> @@ -2315,13 +2329,19 @@ static int ath10k_pci_reset_target(struct ath10k *ar)
>  {
>         struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
>         int wait_limit = 300; /* 3 sec */
> +       int ret;
>
>         /* Wait for Target to finish initialization before we proceed. */
>         iowrite32(PCIE_SOC_WAKE_V_MASK,
>                   ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
>                   PCIE_SOC_WAKE_ADDRESS);
>
> -       ath10k_pci_wait(ar);
> +       ret = ath10k_pci_wait(ar);
> +       if (ret) {
> +               ath10k_warn("Failed to reset target, target did not wake up: %d\n",
> +                           ret);
> +               return ret;
> +       }

Ditto.


Michał

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

* Re: [PATCH] ath10k: add error handling to ath10k_pci_wait()
  2013-10-17 14:24 ` Michal Kazior
@ 2013-10-17 14:27   ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2013-10-17 14:27 UTC (permalink / raw)
  To: Michal Kazior; +Cc: ath10k, linux-wireless

Michal Kazior <michal.kazior@tieto.com> writes:

> On 17 October 2013 01:36, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
>> ath10k_pci_wait() didn't notify any errors to callers, it
>> just printed a warning so add proper error handling.
>>
>> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

[...]

>> @@ -2227,7 +2231,13 @@ static int ath10k_pci_start_intr_legacy(struct ath10k *ar)
>>                   ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS +
>>                   PCIE_SOC_WAKE_ADDRESS);
>>
>> -       ath10k_pci_wait(ar);
>> +       ret = ath10k_pci_wait(ar);
>> +       if (ret) {
>> +               ath10k_warn("Failed to enable legacy interrupt, target did not wake up: %d\n",
>> +                           ret);
>> +               free_irq(ar_pci->pdev->irq, ar);
>> +               return ret;
>> +       }
>
> I think we could actually use ath10k_do_pci_wake/sleep() here (see
> above iowrite). It does basically the same thing - sets the wake
> register and waits until HW wakes up. I think ath10k_pci_wait() could
> even go away.

That would be nice, I'll take a look. Thanks for the review.

-- 
Kalle Valo

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

* Re: [PATCH] ath10k: add error handling to ath10k_pci_wait()
  2013-10-17  8:36 [PATCH] ath10k: add error handling to ath10k_pci_wait() Kalle Valo
  2013-10-17 14:24 ` Michal Kazior
@ 2013-10-21 14:19 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2013-10-21 14:19 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless

Kalle Valo <kvalo@qca.qualcomm.com> writes:

> ath10k_pci_wait() didn't notify any errors to callers, it
> just printed a warning so add proper error handling.
>
> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

Applied, I just changed the commit log to this:

commit f3782744c9b50edf94d28e37a937ff84f267dfab
Author: Kalle Valo <kvalo@qca.qualcomm.com>
Date:   Thu Oct 17 11:36:15 2013 +0300

    ath10k: add error handling to ath10k_pci_wait()
    
    ath10k_pci_wait() didn't notify any errors to callers, it
    just printed a warning so add proper error handling. This fixes
    a crash Ben reported:
    
    ath10k: MSI-X interrupt handling (8 intrs)
    ath10k: Unable to wakeup target
    ath10k: target took longer 5000 us to wake up (awake count 1)
    ath10k: Failed to get pcie state addr: -16
    ath10k: early firmware event indicated
    BUG: unable to handle kernel NULL pointer dereference at 0000000000000004
    IP: [<ffffffffa06ae46c>] ath10k_ce_completed_send_next+0x47/0x122 [ath10k_pci]
    
    Reported-by: Ben Greear <greearb@candelatech.com>
    Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

-- 
Kalle Valo

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

end of thread, other threads:[~2013-10-21 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-17  8:36 [PATCH] ath10k: add error handling to ath10k_pci_wait() Kalle Valo
2013-10-17 14:24 ` Michal Kazior
2013-10-17 14:27   ` Kalle Valo
2013-10-21 14:19 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox