ath10k: remove DMA mapping wrappers
authorMichal Kazior <michal.kazior@tieto.com>
Thu, 27 Feb 2014 16:50:03 +0000 (18:50 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Fri, 28 Feb 2014 09:58:38 +0000 (11:58 +0200)
There's no real benefit from using them. DMA-API
already provides debugging. Some skbuffs are
already mapped directly with DMA-API since wrapper
arguments were insufficient and extending them
would be pointless.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/htc.c
drivers/net/wireless/ath/ath10k/htt_tx.c
drivers/net/wireless/ath/ath10k/mac.c
drivers/net/wireless/ath/ath10k/txrx.c
drivers/net/wireless/ath/ath10k/wmi.c

index d1c5e7a..be7d750 100644 (file)
@@ -62,7 +62,6 @@ struct ath10k;
 
 struct ath10k_skb_cb {
        dma_addr_t paddr;
-       bool is_mapped;
        bool is_aborted;
        u8 vdev_id;
 
@@ -87,32 +86,6 @@ static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
        return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
 }
 
-static inline int ath10k_skb_map(struct device *dev, struct sk_buff *skb)
-{
-       if (ATH10K_SKB_CB(skb)->is_mapped)
-               return -EINVAL;
-
-       ATH10K_SKB_CB(skb)->paddr = dma_map_single(dev, skb->data, skb->len,
-                                                  DMA_TO_DEVICE);
-
-       if (unlikely(dma_mapping_error(dev, ATH10K_SKB_CB(skb)->paddr)))
-               return -EIO;
-
-       ATH10K_SKB_CB(skb)->is_mapped = true;
-       return 0;
-}
-
-static inline int ath10k_skb_unmap(struct device *dev, struct sk_buff *skb)
-{
-       if (!ATH10K_SKB_CB(skb)->is_mapped)
-               return -EINVAL;
-
-       dma_unmap_single(dev, ATH10K_SKB_CB(skb)->paddr, skb->len,
-                        DMA_TO_DEVICE);
-       ATH10K_SKB_CB(skb)->is_mapped = false;
-       return 0;
-}
-
 static inline u32 host_interest_item_address(u32 item_offset)
 {
        return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
index edc57ab..69f1f46 100644 (file)
@@ -63,7 +63,9 @@ static struct sk_buff *ath10k_htc_build_tx_ctrl_skb(void *ar)
 static inline void ath10k_htc_restore_tx_skb(struct ath10k_htc *htc,
                                             struct sk_buff *skb)
 {
-       ath10k_skb_unmap(htc->ar->dev, skb);
+       struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
+
+       dma_unmap_single(htc->ar->dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE);
        skb_pull(skb, sizeof(struct ath10k_htc_hdr));
 }
 
@@ -122,6 +124,8 @@ int ath10k_htc_send(struct ath10k_htc *htc,
                    struct sk_buff *skb)
 {
        struct ath10k_htc_ep *ep = &htc->endpoint[eid];
+       struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
+       struct device *dev = htc->ar->dev;
        int credits = 0;
        int ret;
 
@@ -157,7 +161,8 @@ int ath10k_htc_send(struct ath10k_htc *htc,
 
        ath10k_htc_prepare_tx_skb(ep, skb);
 
-       ret = ath10k_skb_map(htc->ar->dev, skb);
+       skb_cb->paddr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
+       ret = dma_mapping_error(dev, skb_cb->paddr);
        if (ret)
                goto err_credits;
 
@@ -169,7 +174,7 @@ int ath10k_htc_send(struct ath10k_htc *htc,
        return 0;
 
 err_unmap:
-       ath10k_skb_unmap(htc->ar->dev, skb);
+       dma_unmap_single(dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE);
 err_credits:
        if (ep->tx_credit_flow_enabled) {
                spin_lock_bh(&htc->tx_lock);
index acaa046..f5960c5 100644 (file)
@@ -334,7 +334,9 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
                goto err_free_msdu_id;
        }
 
-       res = ath10k_skb_map(dev, msdu);
+       skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
+                                      DMA_TO_DEVICE);
+       res = dma_mapping_error(dev, skb_cb->paddr);
        if (res)
                goto err_free_txdesc;
 
@@ -358,7 +360,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
        return 0;
 
 err_unmap_msdu:
-       ath10k_skb_unmap(dev, msdu);
+       dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
 err_free_txdesc:
        dev_kfree_skb_any(txdesc);
 err_free_msdu_id:
@@ -437,7 +439,9 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
                skb_cb->htt.pad_len = 0;
        }
 
-       res = ath10k_skb_map(dev, msdu);
+       skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
+                                      DMA_TO_DEVICE);
+       res = dma_mapping_error(dev, skb_cb->paddr);
        if (res)
                goto err_pull_txfrag;
 
@@ -509,7 +513,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
        return 0;
 
 err_unmap_msdu:
-       ath10k_skb_unmap(dev, msdu);
+       dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
 err_pull_txfrag:
        skb_pull(msdu, skb_cb->htt.frag_len + skb_cb->htt.pad_len);
 err_free_txdesc:
index 239357f..9230ad5 100644 (file)
@@ -839,7 +839,9 @@ static void ath10k_control_beaconing(struct ath10k_vif *arvif,
 
                spin_lock_bh(&arvif->ar->data_lock);
                if (arvif->beacon) {
-                       ath10k_skb_unmap(arvif->ar->dev, arvif->beacon);
+                       dma_unmap_single(arvif->ar->dev,
+                                        ATH10K_SKB_CB(arvif->beacon)->paddr,
+                                        arvif->beacon->len, DMA_TO_DEVICE);
                        dev_kfree_skb_any(arvif->beacon);
 
                        arvif->beacon = NULL;
index dcf7efd..fe69899 100644 (file)
@@ -51,7 +51,6 @@ void ath10k_txrx_tx_unref(struct ath10k_htt *htt,
        struct ieee80211_tx_info *info;
        struct ath10k_skb_cb *skb_cb;
        struct sk_buff *msdu;
-       int ret;
 
        ath10k_dbg(ATH10K_DBG_HTT, "htt tx completion msdu_id %u discard %d no_ack %d\n",
                   tx_done->msdu_id, !!tx_done->discard, !!tx_done->no_ack);
@@ -65,9 +64,7 @@ void ath10k_txrx_tx_unref(struct ath10k_htt *htt,
        msdu = htt->pending_tx[tx_done->msdu_id];
        skb_cb = ATH10K_SKB_CB(msdu);
 
-       ret = ath10k_skb_unmap(dev, msdu);
-       if (ret)
-               ath10k_warn("data skb unmap failed (%d)\n", ret);
+       dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
 
        if (skb_cb->htt.frag_len)
                skb_pull(msdu, skb_cb->htt.frag_len + skb_cb->htt.pad_len);
index 91e501b..478e7f6 100644 (file)
@@ -1360,7 +1360,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
        struct wmi_bcn_info *bcn_info;
        struct ath10k_vif *arvif;
        struct sk_buff *bcn;
-       int vdev_id = 0;
+       int ret, vdev_id = 0;
 
        ath10k_dbg(ATH10K_DBG_MGMT, "WMI_HOST_SWBA_EVENTID\n");
 
@@ -1435,16 +1435,27 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
                                ath10k_warn("SWBA overrun on vdev %d\n",
                                            arvif->vdev_id);
 
-                       ath10k_skb_unmap(ar->dev, arvif->beacon);
+                       dma_unmap_single(arvif->ar->dev,
+                                        ATH10K_SKB_CB(arvif->beacon)->paddr,
+                                        arvif->beacon->len, DMA_TO_DEVICE);
                        dev_kfree_skb_any(arvif->beacon);
                }
 
-               ath10k_skb_map(ar->dev, bcn);
+               ATH10K_SKB_CB(bcn)->paddr = dma_map_single(arvif->ar->dev,
+                                                          bcn->data, bcn->len,
+                                                          DMA_TO_DEVICE);
+               ret = dma_mapping_error(arvif->ar->dev,
+                                       ATH10K_SKB_CB(bcn)->paddr);
+               if (ret) {
+                       ath10k_warn("failed to map beacon: %d\n", ret);
+                       goto skip;
+               }
 
                arvif->beacon = bcn;
                arvif->beacon_sent = false;
 
                ath10k_wmi_tx_beacon_nowait(arvif);
+skip:
                spin_unlock_bh(&ar->data_lock);
        }
 }