* Re: [PATCH 0/2] xfrm: Do not hash socket policies
From: Herbert Xu @ 2014-11-13 9:08 UTC (permalink / raw)
To: Steffen Klassert; +Cc: David S. Miller, netdev
In-Reply-To: <20141113090048.GA3120@gondor.apana.org.au>
On Thu, Nov 13, 2014 at 05:00:48PM +0800, Herbert Xu wrote:
> Hi Steffen:
>
> I'm working on converting the xfrm policy hashing over to RCU
> due to performance complaints. While doing this I noticed that
> we're needlessly hashing socket policies.
>
> Here are two patches to get rid of that and slightly clean things
> up.
Oops that didn't work very well as I left out some rather important
bits :)
Here is a second revision.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH 0/3] sh_eth: Remove redundant alignment adjustment
From: Geert Uytterhoeven @ 2014-11-13 9:04 UTC (permalink / raw)
To: Yoshihiro Kaneko
Cc: netdev@vger.kernel.org, David S. Miller, Simon Horman,
Magnus Damm, Linux-sh list
In-Reply-To: <1415862301-28032-1-git-send-email-ykaneko0929@gmail.com>
Hi Kaneko-san,
On Thu, Nov 13, 2014 at 8:04 AM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
> This series is based on net tree.
>
> Mitsuhiro Kimura (3):
> sh_eth: Remove redundant alignment adjustment
> sh_eth: Fix skb alloc size and alignment adjust rule.
> sh_eth: Fix dma mapping issue
Thanks!
I've applied this series, and your series "[PATCH 0/2] Fix sleeping function
called from invalid context", and the warnings from dma-debug.c I was
seeing on r8a7791/koelsch are gone.
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* [PATCH 2/2] xfrm: Use __xfrm_policy_link in xfrm_policy_insert
From: Herbert Xu @ 2014-11-13 9:01 UTC (permalink / raw)
To: Steffen Klassert, David S. Miller, netdev
In-Reply-To: <20141113090048.GA3120@gondor.apana.org.au>
For a long time we couldn't actually use __xfrm_policy_link in
xfrm_policy_insert because the latter wanted to do hashing at
a specific position.
Now that __xfrm_policy_link no longer does hashing it can now
be safely used in xfrm_policy_insert to kill some duplicate code,
finally reuniting general policies with socket policies.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
net/xfrm/xfrm_policy.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 2c4daf2..0a69c87 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -55,6 +55,7 @@ static int stale_bundle(struct dst_entry *dst);
static int xfrm_bundle_ok(struct xfrm_dst *xdst);
static void xfrm_policy_queue_process(unsigned long arg);
+static void __xfrm_policy_link(struct xfrm_policy *pol, int dir);
static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
int dir);
@@ -779,8 +780,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
hlist_add_behind(&policy->bydst, newpos);
else
hlist_add_head(&policy->bydst, chain);
- xfrm_pol_hold(policy);
- net->xfrm.policy_count[dir]++;
+ __xfrm_policy_link(policy, dir);
atomic_inc(&net->xfrm.flow_cache_genid);
/* After previous checking, family can either be AF_INET or AF_INET6 */
@@ -799,7 +799,6 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
policy->curlft.use_time = 0;
if (!mod_timer(&policy->timer, jiffies + HZ))
xfrm_pol_hold(policy);
- list_add(&policy->walk.all, &net->xfrm.policy_all);
write_unlock_bh(&net->xfrm.xfrm_policy_lock);
if (delpol)
^ permalink raw reply related
* [PATCH 1/2] xfrm: Do not hash socket policies
From: Herbert Xu @ 2014-11-13 9:01 UTC (permalink / raw)
To: Steffen Klassert, David S. Miller, netdev
In-Reply-To: <20141113090048.GA3120@gondor.apana.org.au>
Back in 2003 when I added policy expiration, I half-heartedly
did a clean-up and renamed xfrm_sk_policy_link/xfrm_sk_policy_unlink
to __xfrm_policy_link/__xfrm_policy_unlink, because the latter
could be reused for all policies. I never actually got around
to using __xfrm_policy_link for non-socket policies.
Later on hashing was added to all xfrm policies, including socket
policies. In fact, we don't need hashing on socket policies at
all since they're always looked up via a linked list.
This patch restores xfrm_sk_policy_link/xfrm_sk_policy_unlink
as wrappers around __xfrm_policy_link/__xfrm_policy_unlink so
that it's obvious we're dealing with socket policies.
This patch also removes hashing from __xfrm_policy_link as for
now it's only used by socket policies which do not need to be
hashed. Ironically this will in fact allow us to use this helper
for non-socket policies which I shall do later.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/net/netns/xfrm.h | 4 ++--
net/xfrm/xfrm_policy.c | 35 +++++++++++++++++++++--------------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
index 9da7982..730d82a 100644
--- a/include/net/netns/xfrm.h
+++ b/include/net/netns/xfrm.h
@@ -50,8 +50,8 @@ struct netns_xfrm {
struct list_head policy_all;
struct hlist_head *policy_byidx;
unsigned int policy_idx_hmask;
- struct hlist_head policy_inexact[XFRM_POLICY_MAX * 2];
- struct xfrm_policy_hash policy_bydst[XFRM_POLICY_MAX * 2];
+ struct hlist_head policy_inexact[XFRM_POLICY_MAX];
+ struct xfrm_policy_hash policy_bydst[XFRM_POLICY_MAX];
unsigned int policy_count[XFRM_POLICY_MAX * 2];
struct work_struct policy_hash_work;
struct xfrm_policy_hthresh policy_hthresh;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 88bf289..2c4daf2 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1247,17 +1247,10 @@ out:
static void __xfrm_policy_link(struct xfrm_policy *pol, int dir)
{
struct net *net = xp_net(pol);
- struct hlist_head *chain = policy_hash_bysel(net, &pol->selector,
- pol->family, dir);
list_add(&pol->walk.all, &net->xfrm.policy_all);
- hlist_add_head(&pol->bydst, chain);
- hlist_add_head(&pol->byidx, net->xfrm.policy_byidx+idx_hash(net, pol->index));
net->xfrm.policy_count[dir]++;
xfrm_pol_hold(pol);
-
- if (xfrm_bydst_should_resize(net, dir, NULL))
- schedule_work(&net->xfrm.policy_hash_work);
}
static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
@@ -1265,17 +1258,31 @@ static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
{
struct net *net = xp_net(pol);
- if (hlist_unhashed(&pol->bydst))
+ if (list_empty(&pol->walk.all))
return NULL;
- hlist_del_init(&pol->bydst);
- hlist_del(&pol->byidx);
- list_del(&pol->walk.all);
+ /* Socket policies are not hashed. */
+ if (!hlist_unhashed(&pol->bydst)) {
+ hlist_del(&pol->bydst);
+ hlist_del(&pol->byidx);
+ }
+
+ list_del_init(&pol->walk.all);
net->xfrm.policy_count[dir]--;
return pol;
}
+static void xfrm_sk_policy_link(struct xfrm_policy *pol, int dir)
+{
+ __xfrm_policy_link(pol, XFRM_POLICY_MAX + dir);
+}
+
+static void xfrm_sk_policy_unlink(struct xfrm_policy *pol, int dir)
+{
+ __xfrm_policy_unlink(pol, XFRM_POLICY_MAX + dir);
+}
+
int xfrm_policy_delete(struct xfrm_policy *pol, int dir)
{
struct net *net = xp_net(pol);
@@ -1307,7 +1314,7 @@ int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
if (pol) {
pol->curlft.add_time = get_seconds();
pol->index = xfrm_gen_index(net, XFRM_POLICY_MAX+dir, 0);
- __xfrm_policy_link(pol, XFRM_POLICY_MAX+dir);
+ xfrm_sk_policy_link(pol, dir);
}
if (old_pol) {
if (pol)
@@ -1316,7 +1323,7 @@ int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)
/* Unlinking succeeds always. This is the only function
* allowed to delete or replace socket policy.
*/
- __xfrm_policy_unlink(old_pol, XFRM_POLICY_MAX+dir);
+ xfrm_sk_policy_unlink(old_pol, dir);
}
write_unlock_bh(&net->xfrm.xfrm_policy_lock);
@@ -1349,7 +1356,7 @@ static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir)
memcpy(newp->xfrm_vec, old->xfrm_vec,
newp->xfrm_nr*sizeof(struct xfrm_tmpl));
write_lock_bh(&net->xfrm.xfrm_policy_lock);
- __xfrm_policy_link(newp, XFRM_POLICY_MAX+dir);
+ xfrm_sk_policy_link(newp, dir);
write_unlock_bh(&net->xfrm.xfrm_policy_lock);
xfrm_pol_put(newp);
}
^ permalink raw reply related
* [PATCH 0/2] xfrm: Do not hash socket policies
From: Herbert Xu @ 2014-11-13 9:00 UTC (permalink / raw)
To: Steffen Klassert; +Cc: David S. Miller, netdev
Hi Steffen:
I'm working on converting the xfrm policy hashing over to RCU
due to performance complaints. While doing this I noticed that
we're needlessly hashing socket policies.
Here are two patches to get rid of that and slightly clean things
up.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* [BUG] index is out of range for nfnl_group2type[]
From: Andrey Ryabinin @ 2014-11-13 9:00 UTC (permalink / raw)
To: Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
David S. Miller
Cc: netfilter-devel, coreteam, netdev@vger.kernel.org, linux-kernel
FYI I've spotted this:
[ 180.202810] ================================================================================
[ 180.203600] UBSan: Undefined behaviour in ../net/netfilter/nfnetlink.c:467:28
[ 180.204249] index 9 is out of range for type 'int [9]'
[ 180.204697] CPU: 0 PID: 1771 Comm: trinity-main Not tainted 3.18.0-rc4-mm1+ #122
[ 180.205365] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014
[ 180.206498] 0000000000000018 0000000000000000 0000000000000009 ffff88007bdf7da8
[ 180.207220] ffffffff82b0ef5f 0000000000000092 ffffffff845ae2e0 ffff88007bdf7db8
[ 180.207887] ffffffff8199e489 ffff88007bdf7e18 ffffffff8199ea22 0000003900000000
[ 180.208639] Call Trace:
[ 180.208857] dump_stack (lib/dump_stack.c:52)
[ 180.209370] ubsan_epilogue (lib/ubsan.c:174)
[ 180.209849] __ubsan_handle_out_of_bounds (lib/ubsan.c:400)
[ 180.210512] nfnetlink_bind (net/netfilter/nfnetlink.c:467)
[ 180.210986] netlink_bind (net/netlink/af_netlink.c:1483)
[ 180.211495] SYSC_bind (net/socket.c:1541)
[ 180.211940] ? security_socket_setsockopt (security/security.c:1208)
[ 180.212541] ? SyS_setsockopt (net/socket.c:1920 net/socket.c:1900)
[ 180.213057] ? SyS_write (fs/read_write.c:276 fs/read_write.c:588 fs/read_write.c:577)
[ 180.213506] SyS_bind (net/socket.c:1527)
[ 180.213919] system_call_fastpath (arch/x86/kernel/entry_64.S:423)
[ 180.214479] ================================================================================
^ permalink raw reply
* Re: [PATCH net-next] tun: fix issues of iovec iterators using in tun_put_user()
From: Herbert Xu @ 2014-11-13 8:58 UTC (permalink / raw)
To: Jason Wang; +Cc: davem, netdev, linux-kernel, mst
In-Reply-To: <1415868854-4913-1-git-send-email-jasowang@redhat.com>
On Thu, Nov 13, 2014 at 04:54:14PM +0800, Jason Wang wrote:
> This patch fixes two issues after using iovec iterators:
> - vlan_offset should be initialized to zero, otherwise unexpected offset
> will be used in skb_copy_datagram_iter()
> - advance iovec iterator when vnet_hdr_sz is greater than sizeof(gso), this
> is the case when mergeable rx buffer were enabled for a virt guest.
>
> Fixes e0b46d0ee9c240c7430a47e9b0365674d4a04522 ("tun: Use iovec iterators")
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Good catch.
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Thanks!
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* [PATCH net-next] tun: fix issues of iovec iterators using in tun_put_user()
From: Jason Wang @ 2014-11-13 8:54 UTC (permalink / raw)
To: davem, jasowang, netdev, linux-kernel; +Cc: mst, Herbert Xu
This patch fixes two issues after using iovec iterators:
- vlan_offset should be initialized to zero, otherwise unexpected offset
will be used in skb_copy_datagram_iter()
- advance iovec iterator when vnet_hdr_sz is greater than sizeof(gso), this
is the case when mergeable rx buffer were enabled for a virt guest.
Fixes e0b46d0ee9c240c7430a47e9b0365674d4a04522 ("tun: Use iovec iterators")
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/tun.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 2ff769b..e3fa65a 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1235,7 +1235,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
{
struct tun_pi pi = { 0, skb->protocol };
ssize_t total;
- int vlan_offset;
+ int vlan_offset = 0;
int vlan_hlen = 0;
int vnet_hdr_sz = 0;
@@ -1304,6 +1304,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
if (copy_to_iter(&gso, sizeof(gso), iter) != sizeof(gso))
return -EFAULT;
+
+ iov_iter_advance(iter, vnet_hdr_sz - sizeof(gso));
}
if (vlan_hlen) {
--
1.9.1
^ permalink raw reply related
* Re: [PATCH 2/2] virtio-net: fix buggy features advertised by host
From: Cornelia Huck @ 2014-11-13 8:53 UTC (permalink / raw)
To: Jason Wang; +Cc: netdev, virtualization, linux-kernel, mst
In-Reply-To: <1415857974-23326-2-git-send-email-jasowang@redhat.com>
On Thu, 13 Nov 2014 13:52:54 +0800
Jason Wang <jasowang@redhat.com> wrote:
> This patch tries to detect the possible buggy features advertised by host
> and fix them. One example is booting virtio-net with only ctrl_vq disabled,
> qemu may still advertise many features which depends on it. This will
> trigger several BUG()s in virtnet_send_command().
>
> This patch utilizes the fix_features() method, and disables all features that
> depends on ctrl_vq if it was not advertised.
>
> This fixes the crash when booting with ctrl_vq=off.
That's a qemu device property, right? Might want to mention that, as
this line sounds like it is a kernel parameter.
>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> Changes from V1:
> - fix the cut-and-paste error
> ---
> drivers/net/virtio_net.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index ec2a8b4..6ce125e 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1948,6 +1948,40 @@ static int virtnet_restore(struct virtio_device *vdev)
> }
> #endif
>
> +static void virtnet_fix_features(struct virtio_device *dev)
> +{
> + if (!virtio_has_feature(dev, VIRTIO_NET_F_CTRL_VQ)) {
> + if (virtio_has_feature(dev, VIRTIO_NET_F_CTRL_RX)) {
> + pr_warning("Disable VIRTIO_NET_F_CTRL_RX since host "
> + "does not advertise VIRTIO_NET_F_CTRL_VQ");
> + virtio_disable_feature(dev, VIRTIO_NET_F_CTRL_RX);
> + }
You should probably use dev_warn() or so, so that the user can figure
out which device the message is for. And perhaps add "buggy hypervisor"
to the message to make clear that it's not a guest problem.
I also like the suggestion to use a dependency array.
^ permalink raw reply
* Re: [PATCH 1/2] virito: introduce methods of fixing device features
From: Cornelia Huck @ 2014-11-13 8:46 UTC (permalink / raw)
To: Jason Wang; +Cc: netdev, virtualization, linux-kernel, mst
In-Reply-To: <1415857974-23326-1-git-send-email-jasowang@redhat.com>
On Thu, 13 Nov 2014 13:52:53 +0800
Jason Wang <jasowang@redhat.com> wrote:
typo in subject-prefix: s/virito/virtio/
> Buggy host may advertised buggy host features (a usual case is that host
> advertise a feature whose dependencies were missed). In this case, driver
> should detect and disable the buggy features by itself.
>
> This patch introduces driver specific fix_features() method which is called
> just before features finalizing to detect and disable buggy features
> advertised by host.
So the basic problem this patch fixes is that an individual driver may
only specify a static set of features but cannot specify any
dependencies, right? Adding a sanitizer step makes sense, I guess.
>
> Virtio-net will be the first user.
>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> drivers/virtio/virtio.c | 4 ++++
> include/linux/virtio.h | 1 +
> include/linux/virtio_config.h | 12 ++++++++++++
> 3 files changed, 17 insertions(+)
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index df598dd..7001d6e 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -181,6 +181,10 @@ static int virtio_dev_probe(struct device *_d)
> if (device_features & (1 << i))
> set_bit(i, dev->features);
>
> + /* Fix buggy features advertised by host */
> + if (drv->fix_features)
> + drv->fix_features(dev);
I'd probably call this "sanitize_features" instead.
> +
> dev->config->finalize_features(dev);
>
> err = drv->probe(dev);
> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
> index 7f4ef66..7bd89ea 100644
> --- a/include/linux/virtio_config.h
> +++ b/include/linux/virtio_config.h
> @@ -96,6 +96,18 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
> return test_bit(fbit, vdev->features);
> }
>
> +static inline void virtio_disable_feature(struct virtio_device *vdev,
> + unsigned int fbit)
> +{
> + BUG_ON(fbit >= VIRTIO_TRANSPORT_F_START);
> + BUG_ON(vdev->config->get_status(vdev) &
> + ~(VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER));
When we add virtio-1 support, we can add a check for FEATURES_OK here,
so we're really on the safe side.
> +
> + virtio_check_driver_offered_feature(vdev, fbit);
> +
> + clear_bit(fbit, vdev->features);
> +}
> +
> static inline
> struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
> vq_callback_t *c, const char *n)
The approach looks good to me.
^ permalink raw reply
* [PATCH] ixgbe: make VLAN filter conditional in SR-IOV case
From: Hiroshi Shimamoto @ 2014-11-13 8:28 UTC (permalink / raw)
To: e1000-devel@lists.sourceforge.net
Cc: netdev@vger.kernel.org, Choi, Sy Jong, Hayato Momma,
linux-kernel@vger.kernel.org
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Disable hardware VLAN filtering if netdev->features VLAN flag is dropped.
In SR-IOV case, there is a use case which needs to disable VLAN filter.
For example, we need to make a network function with VF in virtualized
environment. That network function may be a software switch, a router
or etc. It means that that network function will be an end point which
terminates many VLANs.
In the current implementation, VLAN filtering always be turned on and
VF can receive only 63 VLANs. It means that only 63 VLANs can be used
and it's not enough at all for building a virtual router.
With this patch, if the user turns VLAN filtering off on the host, VF
can receive every VLAN packet.
The behavior is changed only if VLAN filtering is turned off by ethtool.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
CC: Choi, Sy Jong <sy.jong.choi@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 ++++++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d2df4e3..91ce3a8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3948,6 +3948,12 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
hw->addr_ctrl.user_set_promisc = false;
}
+ /* Disable hardware VLAN filter if the feature flag is dropped */
+ if (!(netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) {
+ dev_info(&adapter->pdev->dev, "Disable HW VLAN filter\n");
+ vlnctrl &= ~(IXGBE_VLNCTRL_VFE | IXGBE_VLNCTRL_CFIEN);
+ }
+
/*
* Write addresses to available RAR registers, if there is not
* sufficient space to store all the addresses then enable
@@ -7634,6 +7640,10 @@ static int ixgbe_set_features(struct net_device *netdev,
else
ixgbe_vlan_strip_disable(adapter);
+ /* reset if HW VLAN filter is changed */
+ if (changed & NETIF_F_HW_VLAN_CTAG_FILTER)
+ need_reset = true;
+
if (changed & NETIF_F_RXALL)
need_reset = true;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 13916d8..5508d8a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -776,6 +776,10 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter,
u32 bits;
u8 tcs = netdev_get_num_tc(adapter->netdev);
+ /* Ignore if VLAN filter is disabled */
+ if (!(adapter->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER))
+ return 0;
+
if (adapter->vfinfo[vf].pf_vlan || tcs) {
e_warn(drv,
"VF %d attempted to override administratively set VLAN configuration\n"
--
1.9.0
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply related
* Re: [PATCH] smsc911x: power-up phydev before doing a software reset.
From: Javier Martinez Canillas @ 2014-11-13 8:27 UTC (permalink / raw)
To: Enric Balletbo Serra
Cc: David Miller, netdev, Steve Glendinning, Enrico Butera
In-Reply-To: <CAFqH_50cpvdvCgD-=HQDZ1OT9vmzWkExNHzoASNaruSKLnJZBA@mail.gmail.com>
Hello Enric,
On Thu, Nov 13, 2014 at 8:57 AM, Enric Balletbo Serra
<eballetbo@gmail.com> wrote:
>
> Yes, I'm agree. I'll send version 2 of the patch changing this. Also
> there are other places that use the mdelay family intead of
> usleep_range() and can only be invoked from process context. Maybe
> would be interesting send another patch changing this.
>
Agreed, that could be a separate patch though.
Also there is a mdelay(100) before enabling energy detect mode in
smsc911x_phy_enable_energy_detect() which I believe can be removed.
Best regards,
Javier
^ permalink raw reply
* [PATCHv2] smsc911x: power-up phydev before doing a software reset.
From: Enric Balletbo i Serra @ 2014-11-13 8:14 UTC (permalink / raw)
To: netdev, Steve Glendinning; +Cc: javier, ebutera, davem, Enric Balletbo i Serra
With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going
to HALTED"), the PHY device will be put in a low-power mode using
BMCR_PDOWN if the the interface is set down. The smsc911x driver does
a software_reset opening the device driver (ndo_open). In such case,
the PHY must be powered-up before access to any register and before
calling the software_reset function. Otherwise, as the PHY is powered
down the software reset fails and the interface can not be enabled
again.
This patch fixes this scenario that is easy to reproduce setting down
the network interface and setting up again.
$ ifconfig eth0 down
$ ifconfig eth0 up
ifconfig: SIOCSIFFLAGS: Input/output error
Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com>
---
drivers/net/ethernet/smsc/smsc911x.c | 46 ++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index affb29d..dc76df9 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1342,6 +1342,42 @@ static void smsc911x_rx_multicast_update_workaround(struct smsc911x_data *pdata)
spin_unlock(&pdata->mac_lock);
}
+static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata)
+{
+ int rc = 0;
+
+ if (!pdata->phy_dev)
+ return rc;
+
+ /* If the internal PHY is in General Power-Down mode, all, except the
+ * management interface, is powered-down and stays in that condition as
+ * long as Phy register bit 0.11 is HIGH.
+ *
+ * In that case, clear the bit 0.11, so the PHY powers up and we can
+ * access to the phy registers.
+ */
+ rc = phy_read(pdata->phy_dev, MII_BMCR);
+ if (rc < 0) {
+ SMSC_WARN(pdata, drv, "Failed reading PHY control reg");
+ return rc;
+ }
+
+ /* If the PHY general power-down bit is not set is not necessary to
+ * disable the general power down-mode.
+ */
+ if (rc & BMCR_PDOWN) {
+ rc = phy_write(pdata->phy_dev, MII_BMCR, rc & ~BMCR_PDOWN);
+ if (rc < 0) {
+ SMSC_WARN(pdata, drv, "Failed writing PHY control reg");
+ return rc;
+ }
+
+ usleep_range(1000, 1500);
+ }
+
+ return 0;
+}
+
static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
{
int rc = 0;
@@ -1415,6 +1451,16 @@ static int smsc911x_soft_reset(struct smsc911x_data *pdata)
int ret;
/*
+ * Make sure to power-up the PHY chip before doing a reset, otherwise
+ * the reset fails.
+ */
+ ret = smsc911x_phy_general_power_up(pdata);
+ if (ret) {
+ SMSC_WARN(pdata, drv, "Failed to power-up the PHY chip");
+ return ret;
+ }
+
+ /*
* LAN9210/LAN9211/LAN9220/LAN9221 chips have an internal PHY that
* are initialized in a Energy Detect Power-Down mode that prevents
* the MAC chip to be software reseted. So we have to wakeup the PHY
--
1.9.1
^ permalink raw reply related
* Re: [PATCH 19/22] dt/bindings: add micrel,rmii_ref_clk_sel_25_mhz to eth-phy binding
From: Sascha Hauer @ 2014-11-13 8:09 UTC (permalink / raw)
To: Johan Hovold
Cc: Mark Rutland, Florian Fainelli, David S. Miller,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org
In-Reply-To: <20141112091920.GC15215@localhost>
On Wed, Nov 12, 2014 at 10:19:20AM +0100, Johan Hovold wrote:
> On Wed, Nov 12, 2014 at 08:01:27AM +0100, Sascha Hauer wrote:
> > On Tue, Nov 11, 2014 at 07:18:25PM +0100, Johan Hovold wrote:
> > > On Tue, Nov 11, 2014 at 05:57:42PM +0000, Mark Rutland wrote:
> > > > On Tue, Nov 11, 2014 at 05:37:37PM +0000, Johan Hovold wrote:
> > > > > Add "micrel,rmii_ref_clk_sel_25_mhz" to Micrel ethernet PHY binding
> > > > > documentation.
> > > > >
> > > > > Cc: devicetree@vger.kernel.org
> > > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > > ---
> > > > > Documentation/devicetree/bindings/net/micrel.txt | 5 +++++
> > > > > 1 file changed, 5 insertions(+)
> > > > >
> > > > > diff --git a/Documentation/devicetree/bindings/net/micrel.txt b/Documentation/devicetree/bindings/net/micrel.txt
> > > > > index a1bab5eaae02..9b08dd6551dd 100644
> > > > > --- a/Documentation/devicetree/bindings/net/micrel.txt
> > > > > +++ b/Documentation/devicetree/bindings/net/micrel.txt
> > > > > @@ -19,6 +19,11 @@ Optional properties:
> > > > >
> > > > > See the respective PHY datasheet for the mode values.
> > > > >
> > > > > + - micrel,rmii_ref_clk_sel_25_mhz: rmii_ref_clk_sel bit selects 25 MHz mode
> > > > > +
> > > > > + Whether 25 MHz (rather than 50 Mhz) clock mode is selected
> > > > > + when the rmii_ref_clk_sel bit is set.
> > > >
> > > > s/_/-/ in property names please.
> > >
> > > Ouch, copied from variable name, sorry.
> > >
> > > > That said, I don't follow the meaning. Does this cause the kernel to do
> > > > something different, or is is simply that a 25MHz ref clock is wired up?
> > >
> > > Yes, the driver currently sets this configuration bit based on a common
> > > clock binding.
> > >
> > > However, it turns out the meaning of the bit is reversed on some PHY
> > > variants. On most PHYs 50 MHz mode is selected by setting this bit,
> > > whereas on the PHYs that need this new property, setting it selects 25
> > > MHz mode instead.
> >
> > Maybe rename the property to something like rmii-ref-clk-25mhz-active-high
> > then? Also you should probably make it more explicit that this is a
> > hardware property and not for adjusting the clock.
>
> You're right, but how about calling it
>
> micrel,rmii-reference-clock-select-inverted
>
> Then no one will set it believing it will change the clock mode and
> without reading the binding doc first.
>
> The description could then read something like
>
> micrel,rmii-reference-clock-select-inverted: RMII Reference
> Clock Select bit is inverted
>
> The RMII Reference Clock Select bit is inverted so that setting
> it selects 25 MHz rather than 50 MHz clock mode.
>
> Note that this is only needed for PHY variants that has this bit
> inverted and that a clock reference ("rmii-ref" below) is always
> needed to select the actual mode.
"Inverted" only has a meaning when everybody agrees what's the normal
case. Since that not the case I really prefer talking about
"active-high" or "active-low".
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* Re: [PATCH] smsc911x: power-up phydev before doing a software reset.
From: Enric Balletbo Serra @ 2014-11-13 7:57 UTC (permalink / raw)
To: David Miller
Cc: netdev, Steve Glendinning, Javier Martinez Canillas,
Enrico Butera
In-Reply-To: <20141111.183042.469456165241690341.davem@davemloft.net>
Hi,
2014-11-12 0:30 GMT+01:00 David Miller <davem@davemloft.net>:
> From: Enric Balletbo i Serra <eballetbo@iseebcn.com>
> Date: Mon, 10 Nov 2014 19:23:09 +0100
>
>> With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going
>> to HALTED"), the PHY device will be put in a low-power mode using
>> BMCR_PDOWN if the the interface is set down. The smsc911x driver does
>> a software_reset opening the device driver (ndo_open). In such case,
>> the PHY must be powered-up before access to any register and before
>> calling the software_reset function. Otherwise, as the PHY is powered
>> down the software reset fails and the interface can not be enabled
>> again.
>>
>> This patch fixes this scenario that is easy to reproduce setting down
>> the network interface and setting up again.
>>
>> $ ifconfig eth0 down
>> $ ifconfig eth0 up
>> ifconfig: SIOCSIFFLAGS: Input/output error
>>
>> Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com>
> ...
>> + mdelay(1);
>
> As per Javier's feedback, please convert this to usleep_range()
> if you agree that this can only be invoked from process context.
>
Yes, I'm agree. I'll send version 2 of the patch changing this. Also
there are other places that use the mdelay family intead of
usleep_range() and can only be invoked from process context. Maybe
would be interesting send another patch changing this.
Cheers,
Enric
> Thanks.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: lib: rhashtable - Remove weird non-ASCII characters from comments
From: Thomas Graf @ 2014-11-13 7:54 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, netdev
In-Reply-To: <20141113051048.GA1801@gondor.apana.org.au>
On 11/13/14 at 01:10pm, Herbert Xu wrote:
> My editor spewed garbage that looked like memory corruption on
> my screen. It turns out that a number of occurences of "fi" got
> turned into a ligature.
>
> This patch replaces these ligatures with the ASCII letters "fi".
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Fun ;-) These are the comments I copied from the PDF whitepaper.
Acked-by: Thomas Graf <tgraf@suug.ch>
^ permalink raw reply
* Re: [PATCH net-next v2] net: generic dev_disable_lro() stacked device handling
From: Veaceslav Falico @ 2014-11-13 7:15 UTC (permalink / raw)
To: Michal Kubecek
Cc: David S. Miller, netdev, linux-kernel, Jay Vosburgh,
Andy Gospodarek, Jiri Pirko
In-Reply-To: <20141113065450.1645FA0BEF@unicorn.suse.cz>
On Thu, Nov 13, 2014 at 07:54:50AM +0100, Michal Kubecek wrote:
>Large receive offloading is known to cause problems if received packets
>are passed to other host. Therefore the kernel disables it by calling
>dev_disable_lro() whenever a network device is enslaved in a bridge or
>forwarding is enabled for it (or globally). For virtual devices we need
>to disable LRO on the underlying physical device (which is actually
>receiving the packets).
>
>Current dev_disable_lro() code handles this propagation for a vlan
>(including 802.1ad nested vlan), macvlan or a vlan on top of a macvlan.
>It doesn't handle other stacked devices and their combinations, in
>particular propagation from a bond to its slaves which often causes
>problems in virtualization setups.
>
>As we now have generic data structures describing the upper-lower device
>relationship, dev_disable_lro() can be generalized to disable LRO also
>for all lower devices (if any) once it is disabled for the device
>itself.
>
>For bonding and teaming devices, it is necessary to disable LRO not only
>on current slaves at the moment when dev_disable_lro() is called but
>also on any slave (port) added later.
>
>v2: use lower device links for all devices (including vlan and macvlan)
>
>Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Seems ok to me.
Acked-by: Veaceslav Falico <vfalico@gmail.com>
>---
> drivers/net/bonding/bond_main.c | 3 +++
> drivers/net/team/team.c | 3 +++
> net/core/dev.c | 15 +++++----------
> 3 files changed, 11 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index b9b3456..8575fee 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -1526,6 +1526,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> }
> #endif
>
>+ if (!(bond_dev->features & NETIF_F_LRO))
>+ dev_disable_lro(slave_dev);
>+
> res = netdev_rx_handler_register(slave_dev, bond_handle_frame,
> new_slave);
> if (res) {
>diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
>index 2368395..93e2242 100644
>--- a/drivers/net/team/team.c
>+++ b/drivers/net/team/team.c
>@@ -1179,6 +1179,9 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
> goto err_enable_netpoll;
> }
>
>+ if (!(dev->features & NETIF_F_LRO))
>+ dev_disable_lro(port_dev);
>+
> err = netdev_rx_handler_register(port_dev, team_handle_frame,
> port);
> if (err) {
>diff --git a/net/core/dev.c b/net/core/dev.c
>index bb09b03..1ab168e 100644
>--- a/net/core/dev.c
>+++ b/net/core/dev.c
>@@ -1437,22 +1437,17 @@ EXPORT_SYMBOL(dev_close);
> */
> void dev_disable_lro(struct net_device *dev)
> {
>- /*
>- * If we're trying to disable lro on a vlan device
>- * use the underlying physical device instead
>- */
>- if (is_vlan_dev(dev))
>- dev = vlan_dev_real_dev(dev);
>-
>- /* the same for macvlan devices */
>- if (netif_is_macvlan(dev))
>- dev = macvlan_dev_real_dev(dev);
>+ struct net_device *lower_dev;
>+ struct list_head *iter;
>
> dev->wanted_features &= ~NETIF_F_LRO;
> netdev_update_features(dev);
>
> if (unlikely(dev->features & NETIF_F_LRO))
> netdev_WARN(dev, "failed to disable LRO!\n");
>+
>+ netdev_for_each_lower_dev(dev, lower_dev, iter)
>+ dev_disable_lro(lower_dev);
> }
> EXPORT_SYMBOL(dev_disable_lro);
>
>--
>1.8.4.5
>
^ permalink raw reply
* [PATCH 2/3] sh_eth: Fix skb alloc size and alignment adjust rule.
From: Yoshihiro Kaneko @ 2014-11-13 7:05 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
In-Reply-To: <1415862301-28032-1-git-send-email-ykaneko0929@gmail.com>
From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
In the current driver, allocation size of skb does not care the alignment
adjust after allocation.
And also, in the current implementation, buffer alignment method by
sh_eth_set_receive_align function has a bug that this function displace
buffer start address forcedly when the alignment is corrected.
In the result, tail of the skb will exceed allocated area and kernel panic
will be occurred.
This patch fix this issue.
Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
drivers/net/ethernet/renesas/sh_eth.c | 35 ++++++++++++++---------------------
drivers/net/ethernet/renesas/sh_eth.h | 2 ++
2 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 49e963e..0e4a407 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -917,21 +917,12 @@ static int sh_eth_reset(struct net_device *ndev)
return ret;
}
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
static void sh_eth_set_receive_align(struct sk_buff *skb)
{
- int reserve;
-
- reserve = SH4_SKB_RX_ALIGN - ((u32)skb->data & (SH4_SKB_RX_ALIGN - 1));
+ u32 reserve = (u32)skb->data & (SH_ETH_RX_ALIGN - 1);
if (reserve)
- skb_reserve(skb, reserve);
-}
-#else
-static void sh_eth_set_receive_align(struct sk_buff *skb)
-{
- skb_reserve(skb, SH2_SH3_SKB_RX_ALIGN);
+ skb_reserve(skb, SH_ETH_RX_ALIGN - reserve);
}
-#endif
/* CPU <-> EDMAC endian convert */
@@ -1119,6 +1110,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
struct sh_eth_txdesc *txdesc = NULL;
int rx_ringsize = sizeof(*rxdesc) * mdp->num_rx_ring;
int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring;
+ int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN - 1;
mdp->cur_rx = 0;
mdp->cur_tx = 0;
@@ -1131,21 +1123,21 @@ static void sh_eth_ring_format(struct net_device *ndev)
for (i = 0; i < mdp->num_rx_ring; i++) {
/* skb */
mdp->rx_skbuff[i] = NULL;
- skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz);
+ skb = netdev_alloc_skb(ndev, skbuff_size);
mdp->rx_skbuff[i] = skb;
if (skb == NULL)
break;
- dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz,
- DMA_FROM_DEVICE);
sh_eth_set_receive_align(skb);
/* RX descriptor */
rxdesc = &mdp->rx_ring[i];
+ /* The size of the buffer is 16 byte boundary. */
+ rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16);
+ dma_map_single(&ndev->dev, skb->data, rxdesc->buffer_length,
+ DMA_FROM_DEVICE);
rxdesc->addr = virt_to_phys(skb->data);
rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP);
- /* The size of the buffer is 16 byte boundary. */
- rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16);
/* Rx descriptor address set */
if (i == 0) {
sh_eth_write(ndev, mdp->rx_desc_dma, RDLAR);
@@ -1397,6 +1389,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
struct sk_buff *skb;
u16 pkt_len = 0;
u32 desc_status;
+ int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN - 1;
rxdesc = &mdp->rx_ring[entry];
while (!(rxdesc->status & cpu_to_edmac(mdp, RD_RACT))) {
@@ -1448,8 +1441,8 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
if (mdp->cd->rpadir)
skb_reserve(skb, NET_IP_ALIGN);
dma_sync_single_for_cpu(&ndev->dev, rxdesc->addr,
- mdp->rx_buf_sz,
- DMA_FROM_DEVICE);
+ ALIGN(mdp->rx_buf_sz, 16),
+ DMA_FROM_DEVICE);
skb_put(skb, pkt_len);
skb->protocol = eth_type_trans(skb, ndev);
netif_receive_skb(skb);
@@ -1468,13 +1461,13 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16);
if (mdp->rx_skbuff[entry] == NULL) {
- skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz);
+ skb = netdev_alloc_skb(ndev, skbuff_size);
mdp->rx_skbuff[entry] = skb;
if (skb == NULL)
break; /* Better luck next round. */
- dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz,
- DMA_FROM_DEVICE);
sh_eth_set_receive_align(skb);
+ dma_map_single(&ndev->dev, skb->data,
+ rxdesc->buffer_length, DMA_FROM_DEVICE);
skb_checksum_none_assert(skb);
rxdesc->addr = virt_to_phys(skb->data);
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index b37c427..d138ebe 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -163,8 +163,10 @@ enum {
/* Driver's parameters */
#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
#define SH4_SKB_RX_ALIGN 32
+#define SH_ETH_RX_ALIGN (SH4_SKB_RX_ALIGN)
#else
#define SH2_SH3_SKB_RX_ALIGN 2
+#define SH_ETH_RX_ALIGN (SH2_SH3_SKB_RX_ALIGN)
#endif
/* Register's bits
--
1.9.1
^ permalink raw reply related
* [PATCH 3/3] sh_eth: Fix dma mapping issue
From: Yoshihiro Kaneko @ 2014-11-13 7:05 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
In-Reply-To: <1415862301-28032-1-git-send-email-ykaneko0929@gmail.com>
From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
When CONFIG_DMA_API_DEBUG=y, many DMA error messages reports.
In order to use DMA debug, This patch fix following issues.
Issue 1:
If dma_mapping_error function is not called appropriately after
DMA mapping, DMA debug will report error message when DMA unmap
function is called.
Issue 2:
If skb_reserve function is called after DMA mapping, the relationship
between mapping addr and mapping size will be broken.
In this case, DMA debug will report error messages when DMA sync
function and DMA unmap function are called.
Issue 3:
If the size of frame data is less than ETH_ZLEN, the size is resized
to ETH_ZLEN after DMA map function is called.
In the TX skb freeing function, dma unmap function is called with that
resized value. So, unmap size error will reported.
Issue 4:
In the rx function, DMA map function is called without DMA unmap function
is called for RX skb reallocating.
It will case the DMA debug error that number of debug entry is full and
DMA debug logic is stopped.
Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
drivers/net/ethernet/renesas/sh_eth.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 0e4a407..23318cf 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1136,6 +1136,11 @@ static void sh_eth_ring_format(struct net_device *ndev)
dma_map_single(&ndev->dev, skb->data, rxdesc->buffer_length,
DMA_FROM_DEVICE);
rxdesc->addr = virt_to_phys(skb->data);
+ if (dma_mapping_error(&ndev->dev, rxdesc->addr)) {
+ dev_kfree_skb(mdp->rx_skbuff[i]);
+ mdp->rx_skbuff[i] = NULL;
+ break;
+ }
rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP);
/* Rx descriptor address set */
@@ -1364,7 +1369,7 @@ static int sh_eth_txfree(struct net_device *ndev)
if (mdp->tx_skbuff[entry]) {
dma_unmap_single(&ndev->dev, txdesc->addr,
txdesc->buffer_length, DMA_TO_DEVICE);
- dev_kfree_skb_irq(mdp->tx_skbuff[entry]);
+ dev_kfree_skb_any(mdp->tx_skbuff[entry]);
mdp->tx_skbuff[entry] = NULL;
free_num++;
}
@@ -1466,11 +1471,19 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
if (skb == NULL)
break; /* Better luck next round. */
sh_eth_set_receive_align(skb);
+ dma_unmap_single(&ndev->dev, rxdesc->addr,
+ rxdesc->buffer_length,
+ DMA_FROM_DEVICE);
dma_map_single(&ndev->dev, skb->data,
rxdesc->buffer_length, DMA_FROM_DEVICE);
skb_checksum_none_assert(skb);
rxdesc->addr = virt_to_phys(skb->data);
+ if (dma_mapping_error(&ndev->dev, rxdesc->addr)) {
+ dev_kfree_skb_any(mdp->rx_skbuff[entry]);
+ mdp->rx_skbuff[entry] = NULL;
+ break;
+ }
}
if (entry >= mdp->num_rx_ring - 1)
rxdesc->status |=
@@ -2104,12 +2117,18 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
if (!mdp->cd->hw_swap)
sh_eth_soft_swap(phys_to_virt(ALIGN(txdesc->addr, 4)),
skb->len + 2);
- txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len,
- DMA_TO_DEVICE);
if (skb->len < ETH_ZLEN)
txdesc->buffer_length = ETH_ZLEN;
else
txdesc->buffer_length = skb->len;
+ txdesc->addr = dma_map_single(&ndev->dev, skb->data,
+ txdesc->buffer_length,
+ DMA_TO_DEVICE);
+ if (dma_mapping_error(&ndev->dev, txdesc->addr)) {
+ dev_kfree_skb_any(mdp->tx_skbuff[entry]);
+ mdp->tx_skbuff[entry] = NULL;
+ goto out;
+ }
if (entry >= mdp->num_tx_ring - 1)
txdesc->status |= cpu_to_edmac(mdp, TD_TACT | TD_TDLE);
@@ -2121,6 +2140,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
if (!(sh_eth_read(ndev, EDTRR) & sh_eth_get_edtrr_trns(mdp)))
sh_eth_write(ndev, sh_eth_get_edtrr_trns(mdp), EDTRR);
+out:
return NETDEV_TX_OK;
}
--
1.9.1
^ permalink raw reply related
* [PATCH 1/3] sh_eth: Remove redundant alignment adjustment
From: Yoshihiro Kaneko @ 2014-11-13 7:04 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
In-Reply-To: <1415862301-28032-1-git-send-email-ykaneko0929@gmail.com>
From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
PTR_ALIGN macro after skb_reserve is redundant, because skb_reserve
function adjusts the alignment of skb->data.
Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
drivers/net/ethernet/renesas/sh_eth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 60e9c2c..49e963e 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1141,7 +1141,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
/* RX descriptor */
rxdesc = &mdp->rx_ring[i];
- rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4));
+ rxdesc->addr = virt_to_phys(skb->data);
rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP);
/* The size of the buffer is 16 byte boundary. */
@@ -1477,7 +1477,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
sh_eth_set_receive_align(skb);
skb_checksum_none_assert(skb);
- rxdesc->addr = virt_to_phys(PTR_ALIGN(skb->data, 4));
+ rxdesc->addr = virt_to_phys(skb->data);
}
if (entry >= mdp->num_rx_ring - 1)
rxdesc->status |=
--
1.9.1
^ permalink raw reply related
* [PATCH 0/3] sh_eth: Remove redundant alignment adjustment
From: Yoshihiro Kaneko @ 2014-11-13 7:04 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
This series is based on net tree.
Mitsuhiro Kimura (3):
sh_eth: Remove redundant alignment adjustment
sh_eth: Fix skb alloc size and alignment adjust rule.
sh_eth: Fix dma mapping issue
drivers/net/ethernet/renesas/sh_eth.c | 65 +++++++++++++++++++++--------------
drivers/net/ethernet/renesas/sh_eth.h | 2 ++
2 files changed, 41 insertions(+), 26 deletions(-)
--
1.9.1
^ permalink raw reply
* RE: [PATCH 0/4] move pci_assivned_vfs() check (while disabling VFs) to pci sub-system
From: Sathya Perla @ 2014-11-13 7:04 UTC (permalink / raw)
To: Alex Williamson, Don Dutile
Cc: linux-pci@vger.kernel.org, netdev@vger.kernel.org,
ariel.elior@qlogic.com, linux.nics@intel.com,
shahed.shaikh@qlogic.com
In-Reply-To: <1415738372.16601.335.camel@ul30vt.home>
> -----Original Message-----
> From: Alex Williamson [mailto:alex.williamson@redhat.com]
>
> On Tue, 2014-11-11 at 14:09 -0500, Don Dutile wrote:
> > On 11/10/2014 06:53 AM, Sathya Perla wrote:
> > > A user must not be allowed to disable VFs while they are already assigned
> to
> > > a guest. This check is being made in each individual driver that
> implements
> > > the sriov_configure PCI method.
> > > This patch-set fixes this code duplication by moving this check from
> > > drivers to the sriov_nuvfs_store() routine just before invoking
> > > sriov_configure() when num_vfs is equal to 0.
> > >
> > > Vasundhara Volam (4):
> > > pci: move pci_assivned_vfs() check while disabling VFs to pci
> > > sub-system
> > > bnx2x: remove pci_assigned_vfs() check while disabling VFs
> > > i40e: remove pci_assigned_vfs() check while disabling VFs
> > > qlcnic: remove pci_assigned_vfs() check while disabling VFs
> > >
> > > drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 2 +-
> > > drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 7 +------
> > > .../net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c | 10 ----------
> > > drivers/pci/pci-sysfs.c | 5 +++++
> > > 4 files changed, 7 insertions(+), 17 deletions(-)
> > >
> > I have had a side conversation with Alex Williamson, VFIO author.
> >
> > VFIO is the upstream method that device-assignment is managed/handled
> on kvm now.
> > It does not set the PCI_DEV_FLAGS_ASSIGNED pci dev-flags, and thus,
> > this check will not work when VFIO is used.
> >
> > This patch set will only work for the former, kvm-managed, device-
> assignment method,
> > which is currently being deprecated in qemu as well.
> >
> > So, yes, it works for kvm managed device-assignment, but not the
> > newer, VFIO-based device-assignment.
> >
> > Note, also, that the pci_assigned_vfs() check in the drivers will
> > always return 0 when VFIO is used for device assignment, so keeping
> > these checks in the drivers doesn't do what they imply either.
> >
> > So, taking in the patch solves old, kvm-managed, device assignment,
> > but a new method is needed when VFIO is involved.
> >
> > - Don
> >
> > ps -- Note: just adding the flag setting in vfio-pci does not necessarily
> > solve this problem. VFIO does not know if a device is assigned to a
> guest;
> > it only knows a caller of the ioctl requesting the device to be assigned
> > to vfio, and to be dma-mapped for a region of memory, has been
> requested.
> > So, a new PF<->VF mechanism needs to be put in place to
> > determine the equivalent information.
>
> pps -- Note: testing pci_assivned_vfs() is racy, nothing prevents the flag
> being added to a device between your check and removing the VF
> device.
> This is one of the reasons that vfio-pci doesn't use it and that this
> interface should be discouraged in the kernel.
Alex/Don, I agree with the points you've raised.
But, I'd like to know whether you think this patch-set should be accepted or not.
Even though this patch-set doesn't fix any of the pending issues raised here,
it's a small step forward as it reduces the number of invocations of pci_assigned_vfs()
check which is a good thing.
thanks,
-Sathya
^ permalink raw reply
* [PATCH 2/2] sh_eth: Fix asynchronous external abort
From: Yoshihiro Kaneko @ 2014-11-13 7:02 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
In-Reply-To: <1415862135-27972-1-git-send-email-ykaneko0929@gmail.com>
From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
When clock is disabled, Ethernet register access raise Bus error.
----
[ 792.240535] Unhandled fault: asynchronous external abort (0x1211) at 0x00000000
[ 792.262485] Internal error: : 1211 [#1] PREEMPT SMP ARM
[ 792.278165] Modules linked in:
[ 792.287340] CPU: 1 PID: 1495 Comm: ethtool Not tainted 3.10.31-ltsi-00046-gefa0b46-dirty #1089
[ 792.313195] task: d68e30c0 ti: d6878000 task.ti: d6878000
[ 792.329404] PC is at sh_eth_reset+0x2cc/0x3a8
[ 792.342476] LR is at sh_eth_dmac_init+0x18/0x374
[ 792.356327] pc : [<c029907c>] lr : [<c029ed20>] psr: 20070013
[ 792.356327] sp : d6879d78 ip : d6879d98 fp : d6879d94
[ 792.390792] r10: d6385c80 r9 : d6878000 r8 : 00000000
[ 792.406470] r7 : 00000000 r6 : 00000000 r5 : 00000001 r4 : d6385800
[ 792.426061] r3 : e78dc200 r2 : e78dc000 r1 : 00000000 r0 : d6385800
[ 792.445653] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 792.467072] Control: 30c53c7d Table: 55c0a140 DAC: 55555555
[ 792.484315] Process ethtool (pid: 1495, stack limit = 0xd6878238)
[ 792.502601] Stack: (0xd6879d78 to 0xd687a000)
[ 792.515669] 9d60: c049ca32 d6385800
[ 792.540221] 9d80: 00000000 00000000 d6879dbc d6879d98 c029ed20 c0298dbc c049ca32 d6385800
[ 792.564771] 9da0: 00000000 c06502c0 00000000 00000000 d6879dec d6879dc0 c029f7c8 c029ed14
[ 792.589321] 9dc0: c029f610 be976b6c 00000011 c06502c0 00000000 00000000 d6878000 d6385800
[ 792.613871] 9de0: d6879e6c d6879df0 c03b70f0 c029f61c 00004000 00000000 d6879e1c 00000011
[ 792.638420] 9e00: 00000000 00000000 00000000 d6160000 00000011 00000400 00000000 00000000
[ 792.662969] 9e20: 00000400 00000400 00000000 00000000 00000040 00000000 d6879e5c d6879e48
[ 792.687519] 9e40: c0452f20 00008946 be976c20 c06502c0 00000000 00000000 d6878000 be976c20
[ 792.712069] 9e60: d6879ec4 d6879e70 c03c4870 c03b64f0 000000d0 d69d1a40 30687465 00000000
[ 792.736618] 9e80: 00000000 00000000 be976b6c 00000000 00000000 00000000 c03f85e0 00008946
[ 792.761168] 9ea0: fffffdfd be976c20 00008946 d65686a0 d6878000 be976c20 d6879ee4 d6879ec8
[ 792.785717] 9ec0: c039feb0 c03c435c c039fc48 be976c20 d6ae38c0 00000003 d6879ef4 d6879ee8
[ 792.810267] 9ee0: c00c8540 c039fc54 d6879f74 d6879ef8 c00c9114 c00c851c d6879fac d6879f08
[ 792.834817] 9f00: c0009288 c001b168 d6879f40 00000003 d6879f3c d6879f20 c00bafe0 c00bae6c
[ 792.859366] 9f20: d6879f44 d6879f30 d6879f44 d6879f38 c0454c04 c0049738 d6879f64 d6879f48
[ 792.883916] 9f40: c00d2978 c0454be4 00000003 be976c20 d6ae38c0 00000000 00008946 00000003
[ 792.908466] 9f60: d6878000 00000000 d6879fa4 d6879f78 c00c91ac c00c8b84 d6879fb0 00000000
[ 792.933015] 9f80: d6879fac be976c18 be976b88 be976b60 00000036 c000f068 00000000 d6879fa8
[ 792.957565] 9fa0: c000eec0 c00c9178 be976c18 be976b88 00000003 00008946 be976c20 be976c18
[ 792.982114] 9fc0: be976c18 be976b88 be976b60 00000036 be976b5c be976b58 be976b80 0001f754
[ 793.006664] 9fe0: 000433f0 be976b4c 0000d8e8 b6e035ac 200d0010 00000003 c90515a9 0f9c2043
[ 793.031212] Backtrace:
[ 793.038564] [<c0298db0>] (sh_eth_reset+0x0/0x3a8) from [<c029ed20>] (sh_eth_dmac_init+0x18/0x374)
[ 793.065199] r6:00000000 r5:00000000 r4:d6385800 r3:c049ca32
[ 793.082257] [<c029ed08>] (sh_eth_dmac_init+0x0/0x374) from [<c029f7c8>] (sh_eth_set_ringparam+0x1b8/0x2cc)
[ 793.111241] r8:00000000 r7:00000000 r6:c06502c0 r5:00000000 r4:d6385800
r3:c049ca32
[ 793.134860] [<c029f610>] (sh_eth_set_ringparam+0x0/0x2cc) from [<c03b70f0>] (dev_ethtool+0xc0c/0x1e4c)
[ 793.162807] [<c03b64e4>] (dev_ethtool+0x0/0x1e4c) from [<c03c4870>] (dev_ioctl+0x520/0x688)
[ 793.187881] [<c03c4350>] (dev_ioctl+0x0/0x688) from [<c039feb0>] (sock_ioctl+0x268/0x2a0)
[ 793.212435] [<c039fc48>] (sock_ioctl+0x0/0x2a0) from [<c00c8540>] (vfs_ioctl+0x30/0x44)
[ 793.236461] r6:00000003 r5:d6ae38c0 r4:be976c20 r3:c039fc48
[ 793.253516] [<c00c8510>] (vfs_ioctl+0x0/0x44) from [<c00c9114>] (do_vfs_ioctl+0x59c/0x5f4)
[ 793.278328] [<c00c8b78>] (do_vfs_ioctl+0x0/0x5f4) from [<c00c91ac>] (SyS_ioctl+0x40/0x68)
[ 793.302882] [<c00c916c>] (SyS_ioctl+0x0/0x68) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
[ 793.327952] r8:c000f068 r7:00000036 r6:be976b60 r5:be976b88 r4:be976c18
[ 793.348155] Code: e0823003 e5935000 f57ff04f e3855001 (f57ff04f)
[ 793.366445] ---[ end trace 6885a6a6c1fc41e3 ]---
----
Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
drivers/net/ethernet/renesas/sh_eth.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 862a691..dadbd00 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1839,6 +1839,9 @@ static int sh_eth_set_settings(struct net_device *ndev,
unsigned long flags;
int ret;
+ if (!mdp->is_opened)
+ return -EAGAIN;
+
spin_lock_irqsave(&mdp->lock, flags);
/* disable tx and rx */
@@ -1975,6 +1978,9 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
mdp->num_rx_ring = ring->rx_pending;
mdp->num_tx_ring = ring->tx_pending;
+ if (!mdp->is_opened)
+ return 0;
+
ret = sh_eth_ring_init(ndev);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
--
1.9.1
^ permalink raw reply related
* [PATCH 1/2] sh_eth: Fix sleeping function called from invalid context
From: Yoshihiro Kaneko @ 2014-11-13 7:02 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
In-Reply-To: <1415862135-27972-1-git-send-email-ykaneko0929@gmail.com>
From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Fix the bug as follows:
----
[ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
[ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
[ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
[ 1238.230737] Backtrace:
[ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
[ 1238.263499] r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
[ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
[ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
[ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
[ 1238.357170] r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
[ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
[ 1238.402468] r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
[ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
[ 1238.446204] r5:d5c21000 r4:d5ed7e08
[ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
[ 1238.484413] r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
[ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
[ 1238.529196] r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
[ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
[ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
[ 1238.598554] r5:c049716c r4:d5c21240
[ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
[ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
[ 1238.657944] r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
[ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
----
Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
drivers/net/ethernet/renesas/sh_eth.c | 64 +++++++++++++++++++----------------
drivers/net/ethernet/renesas/sh_eth.h | 1 +
2 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 60e9c2c..862a691 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2042,6 +2042,8 @@ static int sh_eth_open(struct net_device *ndev)
if (ret)
goto out_free_irq;
+ mdp->is_opened = 1;
+
return ret;
out_free_irq:
@@ -2131,6 +2133,36 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_OK;
}
+static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
+{
+ struct sh_eth_private *mdp = netdev_priv(ndev);
+
+ if (sh_eth_is_rz_fast_ether(mdp))
+ return &ndev->stats;
+
+ if (!mdp->is_opened)
+ return &ndev->stats;
+
+ ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
+ sh_eth_write(ndev, 0, TROCR); /* (write clear) */
+ ndev->stats.collisions += sh_eth_read(ndev, CDCR);
+ sh_eth_write(ndev, 0, CDCR); /* (write clear) */
+ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
+ sh_eth_write(ndev, 0, LCCR); /* (write clear) */
+
+ if (sh_eth_is_gether(mdp)) {
+ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
+ sh_eth_write(ndev, 0, CERCR); /* (write clear) */
+ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
+ sh_eth_write(ndev, 0, CEECR); /* (write clear) */
+ } else {
+ ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
+ sh_eth_write(ndev, 0, CNDCR); /* (write clear) */
+ }
+
+ return &ndev->stats;
+}
+
/* device close function */
static int sh_eth_close(struct net_device *ndev)
{
@@ -2145,6 +2177,7 @@ static int sh_eth_close(struct net_device *ndev)
sh_eth_write(ndev, 0, EDTRR);
sh_eth_write(ndev, 0, EDRRR);
+ sh_eth_get_stats(ndev);
/* PHY Disconnect */
if (mdp->phydev) {
phy_stop(mdp->phydev);
@@ -2163,36 +2196,9 @@ static int sh_eth_close(struct net_device *ndev)
pm_runtime_put_sync(&mdp->pdev->dev);
- return 0;
-}
-
-static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
-
- if (sh_eth_is_rz_fast_ether(mdp))
- return &ndev->stats;
-
- pm_runtime_get_sync(&mdp->pdev->dev);
-
- ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
- sh_eth_write(ndev, 0, TROCR); /* (write clear) */
- ndev->stats.collisions += sh_eth_read(ndev, CDCR);
- sh_eth_write(ndev, 0, CDCR); /* (write clear) */
- ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
- sh_eth_write(ndev, 0, LCCR); /* (write clear) */
- if (sh_eth_is_gether(mdp)) {
- ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
- sh_eth_write(ndev, 0, CERCR); /* (write clear) */
- ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
- sh_eth_write(ndev, 0, CEECR); /* (write clear) */
- } else {
- ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
- sh_eth_write(ndev, 0, CNDCR); /* (write clear) */
- }
- pm_runtime_put_sync(&mdp->pdev->dev);
+ mdp->is_opened = 0;
- return &ndev->stats;
+ return 0;
}
/* ioctl to device function */
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index b37c427..9a1c550 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -508,6 +508,7 @@ struct sh_eth_private {
u32 rx_buf_sz; /* Based on MTU+slack. */
int edmac_endian;
struct napi_struct napi;
+ bool is_opened;
/* MII transceiver section. */
u32 phy_id; /* PHY ID */
struct mii_bus *mii_bus; /* MDIO bus control */
--
1.9.1
^ permalink raw reply related
* [PATCH 0/2] Fix sleeping function called from invalid context
From: Yoshihiro Kaneko @ 2014-11-13 7:02 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
This series is based on net tree.
Mitsuhiro Kimura (2):
sh_eth: Fix sleeping function called from invalid context
sh_eth: Fix asynchronous external abort
drivers/net/ethernet/renesas/sh_eth.c | 70 ++++++++++++++++++++---------------
drivers/net/ethernet/renesas/sh_eth.h | 1 +
2 files changed, 42 insertions(+), 29 deletions(-)
--
1.9.1
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox