Skip to content

Commit

Permalink
iwlwifi: pcie: refcounting is not necessary anymore
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Luca Coelho authored and Emmanuel Grumbach committed Mar 30, 2016
1 parent 18dcb9a commit 5d93f3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
4 changes: 1 addition & 3 deletions drivers/net/wireless/intel/iwlwifi/pcie/drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 0 additions & 4 deletions drivers/net/wireless/intel/iwlwifi/pcie/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 9 additions & 16 deletions drivers/net/wireless/intel/iwlwifi/pcie/trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5d93f3a

Please sign in to comment.