All of lore.kernel.org
 help / color / mirror / Atom feed
From: <yhchuang@realtek.com>
To: <kvalo@codeaurora.org>
Cc: <linux-wireless@vger.kernel.org>, <briannorris@chromium.org>
Subject: [PATCH 04/15] rtw88: pci: extract skbs free routine for trx rings
Date: Mon, 16 Sep 2019 15:03:34 +0800	[thread overview]
Message-ID: <1568617425-28062-5-git-send-email-yhchuang@realtek.com> (raw)
In-Reply-To: <1568617425-28062-1-git-send-email-yhchuang@realtek.com>

From: Yan-Hsuan Chuang <yhchuang@realtek.com>

These skbs free routines could be used when driver wants
to stop PCI bus, because some of the skbs remained in the
queue may not have been returned via DMA interrupt.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
---
 drivers/net/wireless/realtek/rtw88/pci.c | 36 +++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
index 9cc068a..3238161 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -90,16 +90,13 @@ static inline void *rtw_pci_get_tx_desc(struct rtw_pci_tx_ring *tx_ring, u8 idx)
 	return tx_ring->r.head + offset;
 }
 
-static void rtw_pci_free_tx_ring(struct rtw_dev *rtwdev,
-				 struct rtw_pci_tx_ring *tx_ring)
+static void rtw_pci_free_tx_ring_skbs(struct rtw_dev *rtwdev,
+				      struct rtw_pci_tx_ring *tx_ring)
 {
 	struct pci_dev *pdev = to_pci_dev(rtwdev->dev);
 	struct rtw_pci_tx_data *tx_data;
 	struct sk_buff *skb, *tmp;
 	dma_addr_t dma;
-	u8 *head = tx_ring->r.head;
-	u32 len = tx_ring->r.len;
-	int ring_sz = len * tx_ring->r.desc_size;
 
 	/* free every skb remained in tx list */
 	skb_queue_walk_safe(&tx_ring->queue, skb, tmp) {
@@ -110,21 +107,30 @@ static void rtw_pci_free_tx_ring(struct rtw_dev *rtwdev,
 		pci_unmap_single(pdev, dma, skb->len, PCI_DMA_TODEVICE);
 		dev_kfree_skb_any(skb);
 	}
+}
+
+static void rtw_pci_free_tx_ring(struct rtw_dev *rtwdev,
+				 struct rtw_pci_tx_ring *tx_ring)
+{
+	struct pci_dev *pdev = to_pci_dev(rtwdev->dev);
+	u8 *head = tx_ring->r.head;
+	u32 len = tx_ring->r.len;
+	int ring_sz = len * tx_ring->r.desc_size;
+
+	rtw_pci_free_tx_ring_skbs(rtwdev, tx_ring);
 
 	/* free the ring itself */
 	pci_free_consistent(pdev, ring_sz, head, tx_ring->r.dma);
 	tx_ring->r.head = NULL;
 }
 
-static void rtw_pci_free_rx_ring(struct rtw_dev *rtwdev,
-				 struct rtw_pci_rx_ring *rx_ring)
+static void rtw_pci_free_rx_ring_skbs(struct rtw_dev *rtwdev,
+				      struct rtw_pci_rx_ring *rx_ring)
 {
 	struct pci_dev *pdev = to_pci_dev(rtwdev->dev);
 	struct sk_buff *skb;
-	dma_addr_t dma;
-	u8 *head = rx_ring->r.head;
 	int buf_sz = RTK_PCI_RX_BUF_SIZE;
-	int ring_sz = rx_ring->r.desc_size * rx_ring->r.len;
+	dma_addr_t dma;
 	int i;
 
 	for (i = 0; i < rx_ring->r.len; i++) {
@@ -137,6 +143,16 @@ static void rtw_pci_free_rx_ring(struct rtw_dev *rtwdev,
 		dev_kfree_skb(skb);
 		rx_ring->buf[i] = NULL;
 	}
+}
+
+static void rtw_pci_free_rx_ring(struct rtw_dev *rtwdev,
+				 struct rtw_pci_rx_ring *rx_ring)
+{
+	struct pci_dev *pdev = to_pci_dev(rtwdev->dev);
+	u8 *head = rx_ring->r.head;
+	int ring_sz = rx_ring->r.desc_size * rx_ring->r.len;
+
+	rtw_pci_free_rx_ring_skbs(rtwdev, rx_ring);
 
 	pci_free_consistent(pdev, ring_sz, head, rx_ring->r.dma);
 }
-- 
2.7.4


  parent reply	other threads:[~2019-09-16  7:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16  7:03 [PATCH 00/15] rtw88: Add support for deep PS mode yhchuang
2019-09-16  7:03 ` [PATCH 01/15] rtw88: remove redundant flag check helper function yhchuang
2019-10-01  9:17   ` Kalle Valo
2019-09-16  7:03 ` [PATCH 02/15] rtw88: configure firmware after HCI started yhchuang
2019-09-21  5:51   ` Kalle Valo
2019-09-16  7:03 ` [PATCH 03/15] rtw88: pci: reset H2C queue indexes in a single write yhchuang
2019-09-16  7:03 ` yhchuang [this message]
2019-09-21  5:47   ` [PATCH 04/15] rtw88: pci: extract skbs free routine for trx rings Kalle Valo
2019-09-16  7:03 ` [PATCH 05/15] rtw88: pci: release tx skbs DMAed when stop yhchuang
2019-09-18  0:41   ` Brian Norris
2019-09-18  2:10     ` Tony Chuang
2019-09-20  0:35       ` Brian Norris
2019-09-20  7:26         ` Kalle Valo
2019-09-20  8:29           ` Tony Chuang
2019-09-20  8:35             ` Kalle Valo
2019-09-20 22:33             ` Brian Norris
2019-09-16  7:03 ` [PATCH 06/15] rtw88: not to enter or leave PS under IRQ yhchuang
2019-09-16  7:03 ` [PATCH 07/15] rtw88: not to control LPS by each vif yhchuang
2019-09-16  7:03 ` [PATCH 08/15] rtw88: remove unused lps state check helper yhchuang
2019-09-16  7:03 ` [PATCH 09/15] rtw88: LPS enter/leave should be protected by lock yhchuang
2019-09-16  7:03 ` [PATCH 10/15] rtw88: leave PS state for dynamic mechanism yhchuang
2019-09-16  7:03 ` [PATCH 11/15] rtw88: add deep power save support yhchuang
2019-09-16  7:03 ` [PATCH 12/15] rtw88: not to enter LPS by coex strategy yhchuang
2019-09-16  7:03 ` [PATCH 13/15] rtw88: select deep PS mode when module is inserted yhchuang
2019-09-16  7:03 ` [PATCH 14/15] rtw88: add deep PS PG mode for 8822c yhchuang
2019-09-16  7:03 ` [PATCH 15/15] rtw88: remove misleading module parameter rtw_fw_support_lps yhchuang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1568617425-28062-5-git-send-email-yhchuang@realtek.com \
    --to=yhchuang@realtek.com \
    --cc=briannorris@chromium.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.