ath10k: defer irq registration until hif start()
authorMichal Kazior <michal.kazior@tieto.com>
Mon, 25 Nov 2013 13:06:24 +0000 (14:06 +0100)
committerKalle Valo <kvalo@qca.qualcomm.com>
Wed, 27 Nov 2013 14:45:32 +0000 (16:45 +0200)
It's impossible to rely on disable_irq() and/or CE
interrupt masking with legacy shared interrupts.
Other devices sharing the same irq line may assert
it while ath10k is doing something that requires
no interrupts.

Irq handlers are now registered after all
preparations are complete so spurious/foreign
interrupts won't do any harm. The handlers are
unregistered when no interrupts are required (i.e.
during driver teardown).

This also removes the ability to receive FW early
indication (since interrupts are not registered
until early boot is complete). This is not mission
critical (it's more of a hint that early boot
failed due to unexpected FW crash) and will be
re-added in a follow up patch.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath10k/ce.c
drivers/net/wireless/ath/ath10k/ce.h
drivers/net/wireless/ath/ath10k/pci.c

index 476928f2dadcb9379c560bf5bbcd5cb0be804015..d44d618b05f91f17defaddbeed4946fe27b6aa17 100644 (file)
@@ -792,21 +792,6 @@ static void ath10k_ce_per_engine_handler_adjust(struct ath10k_ce_pipe *ce_state,
        ath10k_pci_sleep(ar);
 }
 
-int ath10k_ce_enable_err_irq(struct ath10k *ar)
-{
-       int i, ret;
-
-       ret = ath10k_pci_wake(ar);
-       if (ret)
-               return ret;
-
-       for (i = 0; i < CE_COUNT; i++)
-               ath10k_ce_error_intr_enable(ar, ath10k_ce_base_address(i));
-
-       ath10k_pci_sleep(ar);
-       return 0;
-}
-
 int ath10k_ce_disable_interrupts(struct ath10k *ar)
 {
        int ce_id, ret;
index 8a58bac958a14f3649ae70751baecc76aefd6c03..67dbde6a5c7430fbd4507355755e479d58d4d289 100644 (file)
@@ -235,7 +235,6 @@ void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state);
 void ath10k_ce_per_engine_service_any(struct ath10k *ar);
 void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id);
 int ath10k_ce_disable_interrupts(struct ath10k *ar);
-int ath10k_ce_enable_err_irq(struct ath10k *ar);
 
 /* ce_attr.flags values */
 /* Use NonSnooping PCIe accesses? */
index 05e6f8b4f1b83e7231d85a36e70c16efdaef025d..bd673115ec32d326fe8346988f2f4a433f9568f5 100644 (file)
@@ -919,13 +919,6 @@ static void ath10k_pci_stop_ce(struct ath10k *ar)
        struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
        struct ath10k_pci_compl *compl;
        struct sk_buff *skb;
-       int ret;
-
-       ret = ath10k_ce_disable_interrupts(ar);
-       if (ret)
-               ath10k_warn("failed to disable CE interrupts: %d\n", ret);
-
-       ath10k_pci_kill_tasklet(ar);
 
        /* Mark pending completions as aborted, so that upper layers free up
         * their associated resources */
@@ -1236,10 +1229,17 @@ static int ath10k_pci_hif_start(struct ath10k *ar)
                return ret;
        }
 
+       ret = ath10k_pci_request_irq(ar);
+       if (ret) {
+               ath10k_warn("failed to post RX buffers for all pipes: %d\n",
+                           ret);
+               goto err_free_compl;
+       }
+
        ret = ath10k_pci_setup_ce_irq(ar);
        if (ret) {
                ath10k_warn("failed to setup CE interrupts: %d\n", ret);
-               goto err_free_compl;
+               goto err_stop;
        }
 
        /* Post buffers once to start things off. */
@@ -1247,13 +1247,16 @@ static int ath10k_pci_hif_start(struct ath10k *ar)
        if (ret) {
                ath10k_warn("failed to post RX buffers for all pipes: %d\n",
                            ret);
-               goto err_stop_ce;
+               goto err_stop;
        }
 
        ar_pci->started = 1;
        return 0;
 
-err_stop_ce:
+err_stop:
+       ath10k_ce_disable_interrupts(ar);
+       ath10k_pci_free_irq(ar);
+       ath10k_pci_kill_tasklet(ar);
        ath10k_pci_stop_ce(ar);
        ath10k_pci_process_ce(ar);
 err_free_compl:
@@ -1376,25 +1379,19 @@ static void ath10k_pci_ce_deinit(struct ath10k *ar)
        }
 }
 
-static void ath10k_pci_disable_irqs(struct ath10k *ar)
-{
-       struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
-       int i;
-
-       for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++)
-               disable_irq(ar_pci->pdev->irq + i);
-}
-
 static void ath10k_pci_hif_stop(struct ath10k *ar)
 {
        struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+       int ret;
 
        ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__);
 
-       /* Irqs are never explicitly re-enabled. They are implicitly re-enabled
-        * by upon power_up. */
-       ath10k_pci_disable_irqs(ar);
+       ret = ath10k_ce_disable_interrupts(ar);
+       if (ret)
+               ath10k_warn("failed to disable CE interrupts: %d\n", ret);
 
+       ath10k_pci_free_irq(ar);
+       ath10k_pci_kill_tasklet(ar);
        ath10k_pci_stop_ce(ar);
 
        /* At this point, asynchronous threads are stopped, the target should
@@ -1945,34 +1942,22 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar)
                goto err_ce;
        }
 
-       ret = ath10k_pci_request_irq(ar);
-       if (ret) {
-               ath10k_err("failed to request irqs: %d\n", ret);
-               goto err_deinit_irq;
-       }
-
        ret = ath10k_pci_wait_for_target_init(ar);
        if (ret) {
                ath10k_err("failed to wait for target to init: %d\n", ret);
-               goto err_free_irq;
-       }
-
-       ret = ath10k_ce_enable_err_irq(ar);
-       if (ret) {
-               ath10k_err("failed to enable CE error irq: %d\n", ret);
-               goto err_free_irq;
+               goto err_deinit_irq;
        }
 
        ret = ath10k_pci_init_config(ar);
        if (ret) {
                ath10k_err("failed to setup init config: %d\n", ret);
-               goto err_free_irq;
+               goto err_deinit_irq;
        }
 
        ret = ath10k_pci_wake_target_cpu(ar);
        if (ret) {
                ath10k_err("could not wake up target CPU: %d\n", ret);
-               goto err_free_irq;
+               goto err_deinit_irq;
        }
 
        if (ar_pci->num_msi_intrs > 1)
@@ -1987,14 +1972,11 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar)
 
        return 0;
 
-err_free_irq:
-       ath10k_pci_free_irq(ar);
-       ath10k_pci_kill_tasklet(ar);
-       ath10k_pci_device_reset(ar);
 err_deinit_irq:
        ath10k_pci_deinit_irq(ar);
 err_ce:
        ath10k_pci_ce_deinit(ar);
+       ath10k_pci_device_reset(ar);
 err_ps:
        if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features))
                ath10k_do_pci_sleep(ar);
@@ -2006,7 +1988,6 @@ static void ath10k_pci_hif_power_down(struct ath10k *ar)
 {
        struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 
-       ath10k_pci_free_irq(ar);
        ath10k_pci_deinit_irq(ar);
        ath10k_pci_device_reset(ar);