2018-03-06 02:49:30

by Hemanth Puranik

[permalink] [raw]
Subject: [PATCH] net: qcom/emac: Use proper free methods during TX

This patch fixes the warning messages/call traces seen if DMA debug is
enabled, In case of fragmented skb's memory was allocated using
dma_map_page but freed using dma_unmap_single. This patch modifies buffer
allocations in TX path to use dma_map_page in all the places and
dma_unmap_page while freeing the buffers.

Signed-off-by: Hemanth Puranik <[email protected]>
---
drivers/net/ethernet/qualcomm/emac/emac-mac.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
index 9cbb2726..d5a32b7 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
@@ -1194,9 +1194,9 @@ void emac_mac_tx_process(struct emac_adapter *adpt, struct emac_tx_queue *tx_q)
while (tx_q->tpd.consume_idx != hw_consume_idx) {
tpbuf = GET_TPD_BUFFER(tx_q, tx_q->tpd.consume_idx);
if (tpbuf->dma_addr) {
- dma_unmap_single(adpt->netdev->dev.parent,
- tpbuf->dma_addr, tpbuf->length,
- DMA_TO_DEVICE);
+ dma_unmap_page(adpt->netdev->dev.parent,
+ tpbuf->dma_addr, tpbuf->length,
+ DMA_TO_DEVICE);
tpbuf->dma_addr = 0;
}

@@ -1353,9 +1353,11 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt,

tpbuf = GET_TPD_BUFFER(tx_q, tx_q->tpd.produce_idx);
tpbuf->length = mapped_len;
- tpbuf->dma_addr = dma_map_single(adpt->netdev->dev.parent,
- skb->data, tpbuf->length,
- DMA_TO_DEVICE);
+ tpbuf->dma_addr = dma_map_page(adpt->netdev->dev.parent,
+ virt_to_page(skb->data),
+ offset_in_page(skb->data),
+ tpbuf->length,
+ DMA_TO_DEVICE);
ret = dma_mapping_error(adpt->netdev->dev.parent,
tpbuf->dma_addr);
if (ret)
@@ -1371,9 +1373,12 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt,
if (mapped_len < len) {
tpbuf = GET_TPD_BUFFER(tx_q, tx_q->tpd.produce_idx);
tpbuf->length = len - mapped_len;
- tpbuf->dma_addr = dma_map_single(adpt->netdev->dev.parent,
- skb->data + mapped_len,
- tpbuf->length, DMA_TO_DEVICE);
+ tpbuf->dma_addr = dma_map_page(adpt->netdev->dev.parent,
+ virt_to_page(skb->data +
+ mapped_len),
+ offset_in_page(skb->data +
+ mapped_len),
+ tpbuf->length, DMA_TO_DEVICE);
ret = dma_mapping_error(adpt->netdev->dev.parent,
tpbuf->dma_addr);
if (ret)
--
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



2018-03-06 03:07:47

by Timur Tabi

[permalink] [raw]
Subject: Re: [PATCH] net: qcom/emac: Use proper free methods during TX

On 3/5/18 8:48 PM, Hemanth Puranik wrote:
> This patch fixes the warning messages/call traces seen if DMA debug is
> enabled, In case of fragmented skb's memory was allocated using
> dma_map_page but freed using dma_unmap_single. This patch modifies buffer
> allocations in TX path to use dma_map_page in all the places and
> dma_unmap_page while freeing the buffers.
>
> Signed-off-by: Hemanth Puranik<[email protected]>

Acked-by: Timur Tabi <[email protected]>

--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

2018-03-07 17:24:18

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: qcom/emac: Use proper free methods during TX

From: Hemanth Puranik <[email protected]>
Date: Tue, 6 Mar 2018 08:18:06 +0530

> This patch fixes the warning messages/call traces seen if DMA debug is
> enabled, In case of fragmented skb's memory was allocated using
> dma_map_page but freed using dma_unmap_single. This patch modifies buffer
> allocations in TX path to use dma_map_page in all the places and
> dma_unmap_page while freeing the buffers.
>
> Signed-off-by: Hemanth Puranik <[email protected]>

Applied.