From: "Richard Röjfors" <richard.rojfors@pelagicore.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, ferringb@gmail.com
Subject: [PATCH] ks8842: Fix TX cache flush issue
Date: Mon, 22 Nov 2010 13:50:57 +0100 [thread overview]
Message-ID: <1290430257.13971.7.camel@debian> (raw)
This patch fixes a cache sync issue found in MeeGo 1.1.
It was found that bytes after the first 64 of the TX buffer was not
flushed from the cache correctly.
The patch switches out kmalloc/dma_map_single/dma_sync_single_for_device
to dma_alloc_coherent.
Signed-off-by: Richard Röjfors <richard.rojfors@pelagicore.com>
---
diff --git a/drivers/net/ks8842.c b/drivers/net/ks8842.c
index 928b2b8..55a11ba 100644
--- a/drivers/net/ks8842.c
+++ b/drivers/net/ks8842.c
@@ -449,10 +449,6 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)
*buf++ = (skb->len >> 8) & 0xff;
skb_copy_from_linear_data(skb, buf, skb->len);
- dma_sync_single_range_for_device(adapter->dev,
- sg_dma_address(&ctl->sg), 0, sg_dma_len(&ctl->sg),
- DMA_TO_DEVICE);
-
/* make sure the length is a multiple of 4 */
if (sg_dma_len(&ctl->sg) % 4)
sg_dma_len(&ctl->sg) += 4 - sg_dma_len(&ctl->sg) % 4;
@@ -908,12 +904,10 @@ static void ks8842_dealloc_dma_bufs(struct ks8842_adapter *adapter)
tasklet_kill(&rx_ctl->tasklet);
- if (sg_dma_address(&tx_ctl->sg))
- dma_unmap_single(adapter->dev, sg_dma_address(&tx_ctl->sg),
- DMA_BUFFER_SIZE, DMA_TO_DEVICE);
+ if (tx_ctl->buf)
+ dma_free_coherent(adapter->dev, DMA_BUFFER_SIZE,
+ tx_ctl->buf, sg_dma_address(&tx_ctl->sg));
sg_dma_address(&tx_ctl->sg) = 0;
-
- kfree(tx_ctl->buf);
tx_ctl->buf = NULL;
}
@@ -945,21 +939,13 @@ static int ks8842_alloc_dma_bufs(struct net_device *netdev)
}
/* allocate DMA buffer */
- tx_ctl->buf = kmalloc(DMA_BUFFER_SIZE, GFP_KERNEL);
+ tx_ctl->buf = dma_alloc_coherent(adapter->dev, DMA_BUFFER_SIZE,
+ &sg_dma_address(&tx_ctl->sg), GFP_KERNEL);
if (!tx_ctl->buf) {
err = -ENOMEM;
goto err;
}
- sg_dma_address(&tx_ctl->sg) = dma_map_single(adapter->dev,
- tx_ctl->buf, DMA_BUFFER_SIZE, DMA_TO_DEVICE);
- err = dma_mapping_error(adapter->dev,
- sg_dma_address(&tx_ctl->sg));
- if (err) {
- sg_dma_address(&tx_ctl->sg) = 0;
- goto err;
- }
-
rx_ctl->chan = dma_request_channel(mask, ks8842_dma_filter_fn,
(void *)(long)rx_ctl->channel);
if (!rx_ctl->chan) {
next reply other threads:[~2010-11-22 12:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-22 12:50 Richard Röjfors [this message]
2010-11-28 18:38 ` [PATCH] ks8842: Fix TX cache flush issue David Miller
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=1290430257.13971.7.camel@debian \
--to=richard.rojfors@pelagicore.com \
--cc=davem@davemloft.net \
--cc=ferringb@gmail.com \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).