qtnfmac: skb2rbd_attach cleanup
authorSergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Tue, 15 Aug 2017 13:06:34 +0000 (16:06 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 17 Aug 2017 07:05:01 +0000 (10:05 +0300)
Update PCIE_HDP_TX_HOST_Q_WR_PTR register in skb2rbd_attach as a part of
procedure of passing new Rx buffer to hardware. Sync up all the the
qtnf_rx_bd descriptor updates before passing Rx buffer to hardware.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c

index 079aa1693ff57cb21740fa3c13d80a1e22bb806d..a0b65d487ddbb45721dab3b91aecedd5f5d37b18 100644 (file)
@@ -411,11 +411,6 @@ static int alloc_bd_table(struct qtnf_pcie_bus_priv *priv)
        writel(priv->rx_bd_num | (sizeof(struct qtnf_rx_bd)) << 16,
               PCIE_HDP_TX_HOST_Q_SZ_CTRL(priv->pcie_reg_base));
 
-       priv->hw_txproc_wr_ptr = priv->rx_bd_num - rx_bd_reserved_param;
-
-       writel(priv->hw_txproc_wr_ptr,
-              PCIE_HDP_TX_HOST_Q_WR_PTR(priv->pcie_reg_base));
-
        pr_debug("RX descriptor table: vaddr=0x%p paddr=%pad\n", vaddr, &paddr);
 
        priv->rx_bd_index = 0;
@@ -423,7 +418,7 @@ static int alloc_bd_table(struct qtnf_pcie_bus_priv *priv)
        return 0;
 }
 
-static int skb2rbd_attach(struct qtnf_pcie_bus_priv *priv, u16 rx_bd_index)
+static int skb2rbd_attach(struct qtnf_pcie_bus_priv *priv, u16 index)
 {
        struct qtnf_rx_bd *rxbd;
        struct sk_buff *skb;
@@ -431,13 +426,12 @@ static int skb2rbd_attach(struct qtnf_pcie_bus_priv *priv, u16 rx_bd_index)
 
        skb = __netdev_alloc_skb_ip_align(NULL, SKB_BUF_SIZE, GFP_ATOMIC);
        if (!skb) {
-               priv->rx_skb[rx_bd_index] = NULL;
+               priv->rx_skb[index] = NULL;
                return -ENOMEM;
        }
 
-       priv->rx_skb[rx_bd_index] = skb;
-
-       rxbd = &priv->rx_bd_vbase[rx_bd_index];
+       priv->rx_skb[index] = skb;
+       rxbd = &priv->rx_bd_vbase[index];
 
        paddr = pci_map_single(priv->pdev, skb->data,
                               SKB_BUF_SIZE, PCI_DMA_FROMDEVICE);
@@ -446,17 +440,20 @@ static int skb2rbd_attach(struct qtnf_pcie_bus_priv *priv, u16 rx_bd_index)
                return -ENOMEM;
        }
 
-       writel(QTN_HOST_LO32(paddr),
-              PCIE_HDP_HHBM_BUF_PTR(priv->pcie_reg_base));
-       writel(QTN_HOST_HI32(paddr),
-              PCIE_HDP_HHBM_BUF_PTR_H(priv->pcie_reg_base));
-
        /* keep rx skb paddrs in rx buffer descriptors for cleanup purposes */
        rxbd->addr = cpu_to_le32(QTN_HOST_LO32(paddr));
        rxbd->addr_h = cpu_to_le32(QTN_HOST_HI32(paddr));
-
        rxbd->info = 0x0;
 
+       /* sync up all descriptor updates */
+       wmb();
+
+       writel(QTN_HOST_HI32(paddr),
+              PCIE_HDP_HHBM_BUF_PTR_H(priv->pcie_reg_base));
+       writel(QTN_HOST_LO32(paddr),
+              PCIE_HDP_HHBM_BUF_PTR(priv->pcie_reg_base));
+
+       writel(index, PCIE_HDP_TX_HOST_Q_WR_PTR(priv->pcie_reg_base));
        return 0;
 }
 
@@ -787,8 +784,6 @@ static int qtnf_rx_poll(struct napi_struct *napi, int budget)
                        break;
                }
 
-               writel(priv->hw_txproc_wr_ptr,
-                      PCIE_HDP_TX_HOST_Q_WR_PTR(priv->pcie_reg_base));
        }
 
        if (processed < budget) {