From patchwork Thu Oct 22 18:20:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lennert Buytenhek X-Patchwork-Id: 55422 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9MIs2eM009039 for ; Thu, 22 Oct 2009 18:54:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756730AbZJVSxy (ORCPT ); Thu, 22 Oct 2009 14:53:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756656AbZJVSxy (ORCPT ); Thu, 22 Oct 2009 14:53:54 -0400 Received: from fw.wantstofly.org ([80.101.37.227]:59625 "EHLO mail.wantstofly.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756579AbZJVSxt (ORCPT ); Thu, 22 Oct 2009 14:53:49 -0400 Received: by mail.wantstofly.org (Postfix, from userid 500) id 651B618E249; Thu, 22 Oct 2009 20:20:56 +0200 (CEST) Date: Thu, 22 Oct 2009 20:20:56 +0200 From: Lennert Buytenhek To: linux-wireless@vger.kernel.org Subject: [PATCH 18/28] mwl8k: use pci_unmap_addr{, set}() to keep track of unmap addresses on rx Message-ID: <20091022182056.GT1583@mail.wantstofly.org> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index 703c306..96faec6 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c @@ -96,7 +96,10 @@ struct mwl8k_rx_queue { struct mwl8k_rx_desc *rxd; dma_addr_t rxd_dma; - struct sk_buff **skb; + struct { + struct sk_buff *skb; + DECLARE_PCI_UNMAP_ADDR(dma) + } *buf; }; struct mwl8k_tx_queue { @@ -790,14 +793,14 @@ static int mwl8k_rxq_init(struct ieee80211_hw *hw, int index) } memset(rxq->rxd, 0, size); - rxq->skb = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->skb), GFP_KERNEL); - if (rxq->skb == NULL) { + rxq->buf = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->buf), GFP_KERNEL); + if (rxq->buf == NULL) { printk(KERN_ERR "%s: failed to alloc RX skbuff list\n", wiphy_name(hw->wiphy)); pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma); return -ENOMEM; } - memset(rxq->skb, 0, MWL8K_RX_DESCS * sizeof(*rxq->skb)); + memset(rxq->buf, 0, MWL8K_RX_DESCS * sizeof(*rxq->buf)); for (i = 0; i < MWL8K_RX_DESCS; i++) { struct mwl8k_rx_desc *rx_desc; @@ -823,6 +826,7 @@ static int rxq_refill(struct ieee80211_hw *hw, int index, int limit) refilled = 0; while (rxq->rxd_count < MWL8K_RX_DESCS && limit--) { struct sk_buff *skb; + dma_addr_t addr; int rx; skb = dev_alloc_skb(MWL8K_RX_MAXSZ); @@ -834,12 +838,13 @@ static int rxq_refill(struct ieee80211_hw *hw, int index, int limit) rx = rxq->tail; rxq->tail = (rx + 1) % MWL8K_RX_DESCS; - rxq->rxd[rx].pkt_phys_addr = - cpu_to_le32(pci_map_single(priv->pdev, skb->data, - MWL8K_RX_MAXSZ, DMA_FROM_DEVICE)); + addr = pci_map_single(priv->pdev, skb->data, + MWL8K_RX_MAXSZ, DMA_FROM_DEVICE); rxq->rxd[rx].pkt_len = cpu_to_le16(MWL8K_RX_MAXSZ); - rxq->skb[rx] = skb; + rxq->rxd[rx].pkt_phys_addr = cpu_to_le32(addr); + rxq->buf[rx].skb = skb; + pci_unmap_addr_set(&rxq->buf[rx], dma, addr); wmb(); rxq->rxd[rx].rx_ctrl = 0; @@ -857,19 +862,19 @@ static void mwl8k_rxq_deinit(struct ieee80211_hw *hw, int index) int i; for (i = 0; i < MWL8K_RX_DESCS; i++) { - if (rxq->skb[i] != NULL) { - unsigned long addr; - - addr = le32_to_cpu(rxq->rxd[i].pkt_phys_addr); - pci_unmap_single(priv->pdev, addr, MWL8K_RX_MAXSZ, - PCI_DMA_FROMDEVICE); - kfree_skb(rxq->skb[i]); - rxq->skb[i] = NULL; + if (rxq->buf[i].skb != NULL) { + pci_unmap_single(priv->pdev, + pci_unmap_addr(&rxq->buf[i], dma), + MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE); + pci_unmap_addr_set(&rxq->buf[i], dma, 0); + + kfree_skb(rxq->buf[i].skb); + rxq->buf[i].skb = NULL; } } - kfree(rxq->skb); - rxq->skb = NULL; + kfree(rxq->buf); + rxq->buf = NULL; pci_free_consistent(priv->pdev, MWL8K_RX_DESCS * sizeof(struct mwl8k_rx_desc), @@ -919,7 +924,6 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit) struct mwl8k_rx_desc *rx_desc; struct sk_buff *skb; struct ieee80211_rx_status status; - unsigned long addr; struct ieee80211_hdr *wh; u16 rate_info; @@ -928,18 +932,19 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit) break; rmb(); - skb = rxq->skb[rxq->head]; + skb = rxq->buf[rxq->head].skb; if (skb == NULL) break; - rxq->skb[rxq->head] = NULL; + rxq->buf[rxq->head].skb = NULL; + + pci_unmap_single(priv->pdev, + pci_unmap_addr(&rxq->buf[rxq->head], dma), + MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE); + pci_unmap_addr_set(&rxq->buf[rxq->head], dma, 0); rxq->head = (rxq->head + 1) % MWL8K_RX_DESCS; rxq->rxd_count--; - addr = le32_to_cpu(rx_desc->pkt_phys_addr); - pci_unmap_single(priv->pdev, addr, - MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE); - skb_put(skb, le16_to_cpu(rx_desc->pkt_len)); mwl8k_remove_dma_header(skb);