iwlwifi: pcie: refcounting is not necessary anymore
authorLuca Coelho <luciano.coelho@intel.com>
Fri, 4 Mar 2016 13:25:47 +0000 (15:25 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Wed, 30 Mar 2016 13:21:20 +0000 (16:21 +0300)
We don't use the refcount value anymore, all the refcounting is done
in the runtime PM usage_count value.  Remove it.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
drivers/net/wireless/intel/iwlwifi/pcie/trans.c

index 05b968506836af92426ee275d8efb35dc78c64cb..34566691f90e57f8b23248e663da427dc13f05d7 100644 (file)
@@ -651,10 +651,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        /* The PCI device starts with a reference taken and we are
         * supposed to release it here.  But to simplify the
         * interaction with the opmode, we don't do it now, but let
-        * the opmode release it when it's ready.  To account for this
-        * reference, we start with ref_count set to 1.
+        * the opmode release it when it's ready.
         */
-       trans_pcie->ref_count = 1;
 
        return 0;
 
index 34bf7cede7f454f80ffe4140ea63e1c13ed2aca6..9ce4ec6cab2f1fcfc994f1d01c9eab859c12a351 100644 (file)
@@ -403,10 +403,6 @@ struct iwl_trans_pcie {
        bool cmd_hold_nic_awake;
        bool ref_cmd_in_flight;
 
-       /* protect ref counter */
-       spinlock_t ref_lock;
-       u32 ref_count;
-
        dma_addr_t fw_mon_phys;
        struct page *fw_mon_page;
        u32 fw_mon_size;
index d4306e23e2869ae7f66a925132ba820fa35fcce8..007bcb594946249a8c9ce6280574e542ba9a5e8e 100644 (file)
@@ -2015,38 +2015,32 @@ static void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg,
 void iwl_trans_pcie_ref(struct iwl_trans *trans)
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
-       unsigned long flags;
 
        if (iwlwifi_mod_params.d0i3_disable)
                return;
 
-       spin_lock_irqsave(&trans_pcie->ref_lock, flags);
-       IWL_DEBUG_RPM(trans, "ref_counter: %d\n", trans_pcie->ref_count);
-       trans_pcie->ref_count++;
        pm_runtime_get(&trans_pcie->pci_dev->dev);
-       spin_unlock_irqrestore(&trans_pcie->ref_lock, flags);
+
+#ifdef CONFIG_PM
+       IWL_DEBUG_RPM(trans, "runtime usage count: %d\n",
+                     atomic_read(&trans_pcie->pci_dev->dev.power.usage_count));
+#endif /* CONFIG_PM */
 }
 
 void iwl_trans_pcie_unref(struct iwl_trans *trans)
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
-       unsigned long flags;
 
        if (iwlwifi_mod_params.d0i3_disable)
                return;
 
-       spin_lock_irqsave(&trans_pcie->ref_lock, flags);
-       IWL_DEBUG_RPM(trans, "ref_counter: %d\n", trans_pcie->ref_count);
-       if (WARN_ON_ONCE(trans_pcie->ref_count == 0)) {
-               spin_unlock_irqrestore(&trans_pcie->ref_lock, flags);
-               return;
-       }
-       trans_pcie->ref_count--;
-
        pm_runtime_mark_last_busy(&trans_pcie->pci_dev->dev);
        pm_runtime_put_autosuspend(&trans_pcie->pci_dev->dev);
 
-       spin_unlock_irqrestore(&trans_pcie->ref_lock, flags);
+#ifdef CONFIG_PM
+       IWL_DEBUG_RPM(trans, "runtime usage count: %d\n",
+                     atomic_read(&trans_pcie->pci_dev->dev.power.usage_count));
+#endif /* CONFIG_PM */
 }
 
 static const char *get_csr_string(int cmd)
@@ -2794,7 +2788,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
        trans_pcie->trans = trans;
        spin_lock_init(&trans_pcie->irq_lock);
        spin_lock_init(&trans_pcie->reg_lock);
-       spin_lock_init(&trans_pcie->ref_lock);
        mutex_init(&trans_pcie->mutex);
        init_waitqueue_head(&trans_pcie->ucode_write_waitq);
        trans_pcie->tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page);