From: Phil Sutter <phil.sutter@viprinet.com> To: linux-arm-kernel@lists.infradead.org Cc: netdev@vger.kernel.org, Russell King <linux@arm.linux.org.uk>, "David S. Miller" <davem@davemloft.net> Subject: [PATCH] af_packet: flush complete kernel cache in packet_sendmsg Date: Fri, 2 Sep 2011 13:08:06 +0200 [thread overview] Message-ID: <1314961686-30870-1-git-send-email-phil.sutter@viprinet.com> (raw) In-Reply-To: <20110505141107.GC30443@orbit.nwl.cc> This flushes the cache before and after accessing the mmapped packet buffer. It seems like the call to flush_dcache_page from inside __packet_get_status is not enough on Kirkwood (or ARM in general). --- I know this is far from an optimal solution, but it's in fact the only working one I found. And it shouldn't interfere with unaffected target systems. So anyone relying on a working TX_RING on Kirkwood may refer to this patch. Any ARM/cache/Marvell/Kirkwood experts out there feel free to improve this. --- net/packet/af_packet.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 243946d..d7b5c2e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -87,6 +87,14 @@ #include <net/inet_common.h> #endif +/* whether we need additional cacheflushing between user- and kernel-space */ +#ifdef CONFIG_ARCH_KIRKWOOD +# define ENABLE_CACHEPROB_WORKAROUND +# define kw_extra_cache_flush() flush_cache_all() +#else +# define kw_extra_cache_flush() /* nothing */ +#endif + /* Assumptions: - if device has no dev->hard_header routine, it adds and removes ll header @@ -1239,10 +1247,13 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, { struct sock *sk = sock->sk; struct packet_sock *po = pkt_sk(sk); - if (po->tx_ring.pg_vec) - return tpacket_snd(po, msg); - else - return packet_snd(sock, msg, len); + int rc; + + kw_extra_cache_flush(); + rc = po->tx_ring.pg_vec ? tpacket_snd(po, msg) : + packet_snd(sock, msg, len); + kw_extra_cache_flush(); + return rc; } /* @@ -2622,6 +2633,11 @@ static int __init packet_init(void) sock_register(&packet_family_ops); register_pernet_subsys(&packet_net_ops); register_netdevice_notifier(&packet_netdev_notifier); + +#ifdef ENABLE_CACHEPROB_WORKAROUND + printk(KERN_INFO "af_packet: cache coherency workaround for kirkwood is active!\n"); +#endif + out: return rc; } -- 1.7.3.4
WARNING: multiple messages have this Message-ID (diff)
From: phil.sutter@viprinet.com (Phil Sutter) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] af_packet: flush complete kernel cache in packet_sendmsg Date: Fri, 2 Sep 2011 13:08:06 +0200 [thread overview] Message-ID: <1314961686-30870-1-git-send-email-phil.sutter@viprinet.com> (raw) In-Reply-To: <20110505141107.GC30443@orbit.nwl.cc> This flushes the cache before and after accessing the mmapped packet buffer. It seems like the call to flush_dcache_page from inside __packet_get_status is not enough on Kirkwood (or ARM in general). --- I know this is far from an optimal solution, but it's in fact the only working one I found. And it shouldn't interfere with unaffected target systems. So anyone relying on a working TX_RING on Kirkwood may refer to this patch. Any ARM/cache/Marvell/Kirkwood experts out there feel free to improve this. --- net/packet/af_packet.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 243946d..d7b5c2e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -87,6 +87,14 @@ #include <net/inet_common.h> #endif +/* whether we need additional cacheflushing between user- and kernel-space */ +#ifdef CONFIG_ARCH_KIRKWOOD +# define ENABLE_CACHEPROB_WORKAROUND +# define kw_extra_cache_flush() flush_cache_all() +#else +# define kw_extra_cache_flush() /* nothing */ +#endif + /* Assumptions: - if device has no dev->hard_header routine, it adds and removes ll header @@ -1239,10 +1247,13 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, { struct sock *sk = sock->sk; struct packet_sock *po = pkt_sk(sk); - if (po->tx_ring.pg_vec) - return tpacket_snd(po, msg); - else - return packet_snd(sock, msg, len); + int rc; + + kw_extra_cache_flush(); + rc = po->tx_ring.pg_vec ? tpacket_snd(po, msg) : + packet_snd(sock, msg, len); + kw_extra_cache_flush(); + return rc; } /* @@ -2622,6 +2633,11 @@ static int __init packet_init(void) sock_register(&packet_family_ops); register_pernet_subsys(&packet_net_ops); register_netdevice_notifier(&packet_netdev_notifier); + +#ifdef ENABLE_CACHEPROB_WORKAROUND + printk(KERN_INFO "af_packet: cache coherency workaround for kirkwood is active!\n"); +#endif + out: return rc; } -- 1.7.3.4
next prev parent reply other threads:[~2011-09-02 11:08 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-04-08 13:06 ARM, AF_PACKET: caching problems on Marvell Kirkwood Phil Sutter 2011-04-08 13:06 ` Phil Sutter 2011-05-05 14:11 ` Phil Sutter 2011-05-05 14:11 ` Phil Sutter 2011-05-05 14:56 ` Eric Dumazet 2011-05-05 14:56 ` Eric Dumazet 2011-05-06 16:12 ` Phil Sutter 2011-05-06 16:12 ` Phil Sutter 2011-05-05 19:46 ` Andrew Lunn 2011-05-05 19:46 ` Andrew Lunn 2011-05-06 16:17 ` Phil Sutter 2011-05-06 16:17 ` Phil Sutter 2011-05-09 8:59 ` Phil Sutter 2011-05-09 8:59 ` Phil Sutter 2011-05-25 10:32 ` Phil Sutter 2011-05-25 10:32 ` Phil Sutter 2011-09-02 11:08 ` Phil Sutter [this message] 2011-09-02 11:08 ` [PATCH] af_packet: flush complete kernel cache in packet_sendmsg Phil Sutter 2011-09-02 13:46 ` Ben Hutchings 2011-09-02 13:46 ` Ben Hutchings 2011-09-02 13:59 ` Phil Sutter 2011-09-02 13:59 ` Phil Sutter 2011-09-02 17:28 ` Russell King - ARM Linux 2011-09-02 17:28 ` Russell King - ARM Linux 2011-09-05 19:57 ` Phil Sutter 2011-09-05 19:57 ` Phil Sutter 2011-09-06 9:57 ` Russell King - ARM Linux 2011-09-06 9:57 ` Russell King - ARM Linux 2011-09-06 11:05 ` Phil Sutter 2011-09-06 11:05 ` Phil Sutter [not found] ` <D3F292ADF945FB49B35E96C94C2061B90A239361@nsmail.netscout.com> 2011-09-02 14:00 ` FW: " chetan loke 2011-09-02 14:00 ` chetan loke 2011-09-02 15:31 ` Phil Sutter 2011-09-02 15:31 ` Phil Sutter 2011-09-02 16:49 ` chetan loke 2011-09-02 16:49 ` chetan loke 2011-09-06 9:44 ` Phil Sutter 2011-09-06 9:44 ` Phil Sutter
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=1314961686-30870-1-git-send-email-phil.sutter@viprinet.com \ --to=phil.sutter@viprinet.com \ --cc=davem@davemloft.net \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux@arm.linux.org.uk \ --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: linkBe 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.