* [patch -next] net: eth: xgene: devm_ioremap() returns NULL on error
From: Dan Carpenter @ 2015-01-08 10:52 UTC (permalink / raw)
To: Iyappan Subramanian, Feng Kan
Cc: Keyur Chudgar, Grant Likely, Rob Herring, netdev, kernel-janitors
devm_ioremap() returns NULL on failure, it doesn't return an ERR_PTR.
Fixes: de7b5b3d790a ('net: eth: xgene: change APM X-Gene SoC platform ethernet to support ACPI')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 1e56bf3..02add38 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -804,9 +804,9 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
return -ENODEV;
}
pdata->base_addr = devm_ioremap(dev, res->start, resource_size(res));
- if (IS_ERR(pdata->base_addr)) {
+ if (!pdata->base_addr) {
dev_err(dev, "Unable to retrieve ENET Port CSR region\n");
- return PTR_ERR(pdata->base_addr);
+ return -ENOMEM;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, RES_RING_CSR);
@@ -816,9 +816,9 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
}
pdata->ring_csr_addr = devm_ioremap(dev, res->start,
resource_size(res));
- if (IS_ERR(pdata->ring_csr_addr)) {
+ if (!pdata->ring_csr_addr) {
dev_err(dev, "Unable to retrieve ENET Ring CSR region\n");
- return PTR_ERR(pdata->ring_csr_addr);
+ return -ENOMEM;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, RES_RING_CMD);
@@ -828,9 +828,9 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
}
pdata->ring_cmd_addr = devm_ioremap(dev, res->start,
resource_size(res));
- if (IS_ERR(pdata->ring_cmd_addr)) {
+ if (!pdata->ring_cmd_addr) {
dev_err(dev, "Unable to retrieve ENET Ring command region\n");
- return PTR_ERR(pdata->ring_cmd_addr);
+ return -ENOMEM;
}
ret = platform_get_irq(pdev, 0);
^ permalink raw reply related
* [PATCH net 1/2] gen_stats.c: Duplicate xstats buffer for later use
From: Ignacy Gawędzki @ 2015-01-08 10:35 UTC (permalink / raw)
To: netdev
The gnet_stats_copy_app() function gets called, more often than not, with its
second argument a pointer to an automatic variable in the caller's stack.
Therefore, to avoid copying garbage afterwards when calling
gnet_stats_finish_copy(), this data is better copied to a dynamically allocated
memory that gets freed after use.
Signed-off-by: Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr>
---
net/core/gen_stats.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index 0c08062..5770a0e 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -305,7 +305,10 @@ int
gnet_stats_copy_app(struct gnet_dump *d, void *st, int len)
{
if (d->compat_xstats) {
- d->xstats = st;
+ d->xstats = kmalloc(len, GFP_KERNEL);
+ if (!d->xstats)
+ goto kmalloc_failure;
+ memcpy(d->xstats, st, len);
d->xstats_len = len;
}
@@ -313,6 +316,9 @@ gnet_stats_copy_app(struct gnet_dump *d, void *st, int len)
return gnet_stats_copy(d, TCA_STATS_APP, st, len);
return 0;
+kmalloc_failure:
+ spin_unlock_bh(d->lock);
+ return -1;
}
EXPORT_SYMBOL(gnet_stats_copy_app);
@@ -340,8 +346,13 @@ gnet_stats_finish_copy(struct gnet_dump *d)
return -1;
if (d->compat_xstats && d->xstats) {
- if (gnet_stats_copy(d, d->compat_xstats, d->xstats,
- d->xstats_len) < 0)
+ int result = gnet_stats_copy(d, d->compat_xstats,
+ d->xstats, d->xstats_len);
+ kfree(d->xstats);
+ d->xstats = NULL;
+ d->xstats_len = 0;
+
+ if (result < 0)
return -1;
}
--
1.9.1
^ permalink raw reply related
* [PATCH net 2/2] gen_stats.c: Fix comment above gnet_stats_start_copy()
From: Ignacy Gawędzki @ 2015-01-08 10:35 UTC (permalink / raw)
To: netdev
The original comment was obviously a failed copy/paste.
Signed-off-by: Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr>
---
net/core/gen_stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index 5770a0e..1b25d80 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -77,7 +77,7 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
EXPORT_SYMBOL(gnet_stats_start_copy_compat);
/**
- * gnet_stats_start_copy_compat - start dumping procedure in compatibility mode
+ * gnet_stats_start_copy - start dumping procedure
* @skb: socket buffer to put statistics TLVs into
* @type: TLV type for top level statistic TLV
* @lock: statistics lock
--
1.9.1
^ permalink raw reply related
* Re: REGRESSION in nfnetlink on 3.18.x (bisected)
From: Pablo Neira Ayuso @ 2015-01-08 10:47 UTC (permalink / raw)
To: Andre Tomt; +Cc: netfilter-devel, netdev
In-Reply-To: <54ADAD1E.3060101@tomt.net>
On Wed, Jan 07, 2015 at 11:03:10PM +0100, Andre Tomt wrote:
> On 23. des. 2014 00:23, Andre Tomt wrote:
> >On 22. des. 2014 12:56, Pablo Neira Ayuso wrote:
> >>Could you give a test to this patch? Thanks.
> >>
> >
> >Initial testing looks good with this patch applied on top of 3.18.1
> >I will give it a spin on some more systems tomorrow.
>
> No news is good news :-)
>
> ~10 3.18.x systems in various roles have had this fix for two weeks
> with no issues.
Thanks a lot for testing. I already sent the patch to David:
http://patchwork.ozlabs.org/patch/426205/
^ permalink raw reply
* Re: [PATCH 6/6] openvswitch: Support VXLAN Group Policy extension
From: Thomas Graf @ 2015-01-08 10:22 UTC (permalink / raw)
To: Jesse Gross
Cc: David Miller, Stephen Hemminger, Pravin Shelar, netdev,
dev@openvswitch.org
In-Reply-To: <CAEP_g=_t_KMUdit7WUSg+OORh=FoQtzLyygaVMftyDV-tAxJvA@mail.gmail.com>
On 01/07/15 at 05:18pm, Jesse Gross wrote:
> On Wed, Jan 7, 2015 at 3:01 PM, Thomas Graf <tgraf@suug.ch> wrote:
> > The encoding will be based on struct ovs_vxlan_opts which is extended
> > as needed by appending new members to the end of the struct. Parsers
> > will look at the provided length to see which fields are provided.
>
> But this means that if there are two extensions that are conflicting
> or if one is retired you still need to carry the earlier members of
> the struct. Why not make them real netlink attributes?
I figured that due to the limited space available in the VXLAN header
the structure would never grow big. I have no problem converting this
to use Netlink attributes internally though. Will address this in v2.
^ permalink raw reply
* Re: [PATCH v3 1/4] can: kvaser_usb: Don't free packets when tight on URBs
From: Marc Kleine-Budde @ 2015-01-08 9:59 UTC (permalink / raw)
To: Ahmed S. Darwish, Olivier Sobrie, Oliver Hartkopp,
Wolfgang Grandegger
Cc: David S. Miller, Paul Gortmaker, Linux-CAN, netdev, LKML
In-Reply-To: <20150105174910.GA6304@linux>
[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]
On 01/05/2015 06:49 PM, Ahmed S. Darwish wrote:
> From: Ahmed S. Darwish <ahmed.darwish@valeo.com>
>
> Flooding the Kvaser CAN to USB dongle with multiple reads and
> writes in high frequency caused seemingly-random panics in the
> kernel.
>
> On further inspection, it seems the driver erroneously freed the
> to-be-transmitted packet upon getting tight on URBs and returning
> NETDEV_TX_BUSY, leading to invalid memory writes and double frees
> at a later point in time.
>
> Note:
>
> Finding no more URBs/transmit-contexts and returning NETDEV_TX_BUSY
> is a driver bug in and out of itself: it means that our start/stop
> queue flow control is broken.
>
> This patch only fixes the (buggy) error handling code; the root
> cause shall be fixed in a later commit.
>
> Signed-off-by: Ahmed S. Darwish <ahmed.darwish@valeo.com>
> Acked-by: Olivier Sobrie <olivier@sobrie.be>
Applied 1-3 to can/master + added stable on Cc.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: [PATCH net] gso: do GSO for local skb with size bigger than MTU
From: Fan Du @ 2015-01-08 9:39 UTC (permalink / raw)
To: Jesse Gross
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org, Michael S. Tsirkin,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jason Wang,
Du, Fan, fw-HFFVJYpyMKqzQB+pC5nmwQ@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
In-Reply-To: <CAEP_g=8EBeQUFkRRsG3sznYryd+LE9qJKWQXfS==HG2HDO=UKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
于 2015年01月08日 04:52, Jesse Gross 写道:
>> My understanding is:
>> >controller sets the forwarding rules into kernel datapath, any flow not
>> >matching
>> >with the rules are threw to controller by upcall. Once the rule decision is
>> >made
>> >by controller, then, this flow packet is pushed down to datapath to be
>> >forwarded
>> >again according to the new rule.
>> >
>> >So I'm not sure whether pushing the over-MTU-sized packet or pushing the
>> >forged ICMP
>> >without encapsulation to controller is required by current ovs
>> >implementation. By doing
>> >so, such over-MTU-sized packet is treated as a event for the controller to
>> >be take
>> >care of.
> If flows are implementing routing (again, they are doing things like
> decrementing the TTL) then it is necessary for them to also handle
> this situation using some potentially new primitives (like a size
> check). Otherwise you end up with issues like the ones that I
> mentioned above like needing to forge addresses because you don't know
> what the correct ones are.
Thanks for explaining, Jesse!
btw, I don't get it about "to forge addresses", building ICMP message
with Guest packet doesn't require to forge address when not encapsulating
ICMP message with outer headers.
If the flows aren't doing things to
> implement routing, then you really have a flat L2 network and you
> shouldn't be doing this type of behavior at all as I described in the
> original plan.
For flows implementing routing scenario:
First of all, over-MTU-sized packet could only be detected once the flow
as been consulted(each port could implement a 'check' hook to do this),
and just before send to the actual port.
Then pushing the over-MTU-sized packet back to controller, it's the controller
who will will decide whether to build ICMP message, or whatever routing behaviour
it may take. And sent it back with the port information. This ICMP message will
travel back to Guest.
Why does the flow has to use primitive like a "check size"? "check size"
will only take effect after do_output. I'm not very clear with this approach.
And not all scenario involving flow with routing behaviour, just set up a
vxlan tunnel, and attach KVM guest or Docker onto it for playing or developing.
This wouldn't necessarily require user to set additional specific flows to make
over-MTU-sized packet pass through the tunnel correctly. In such scenario, I
think the original patch in this thread to fragment tunnel packet is still needed
OR workout a generic component to build ICMP for all type tunnel in L2 level.
Both of those will act as a backup plan as there is no such specific flow as
default.
If I missed something obviously, please let me know.
--
No zuo no die but I have to try.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
^ permalink raw reply
* [patch iproute2 v2] iplink: print out addrgenmode attribute
From: Jiri Pirko @ 2015-01-08 8:49 UTC (permalink / raw)
To: netdev; +Cc: stephen, thaller, vadim4j
addrgenmode is currently write only by ip. So display this information
if provided by kernel as well.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
v1->v2:
-rebased on current master (instead of net-next branch)
---
ip/ipaddress.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 28dfe8c..d8bda30 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -255,6 +255,29 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
}
}
+static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
+{
+ struct rtattr *inet6_attr;
+ struct rtattr *tb[IFLA_INET6_MAX + 1];
+
+ inet6_attr = parse_rtattr_one_nested(AF_INET6, af_spec_attr);
+ if (!inet6_attr)
+ return;
+
+ parse_rtattr_nested(tb, IFLA_INET6_MAX, inet6_attr);
+
+ if (tb[IFLA_INET6_ADDR_GEN_MODE]) {
+ switch (rta_getattr_u8(tb[IFLA_INET6_ADDR_GEN_MODE])) {
+ case IN6_ADDR_GEN_MODE_EUI64:
+ fprintf(fp, "addrgenmode eui64 ");
+ break;
+ case IN6_ADDR_GEN_MODE_NONE:
+ fprintf(fp, "addrgenmode none ");
+ break;
+ }
+ }
+}
+
static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
{
struct ifla_vf_mac *vf_mac;
@@ -658,6 +681,9 @@ int print_linkinfo(const struct sockaddr_nl *who,
if (tb[IFLA_LINKINFO] && show_details)
print_linktype(fp, tb[IFLA_LINKINFO]);
+ if (do_link && tb[IFLA_AF_SPEC] && show_details)
+ print_af_spec(fp, tb[IFLA_AF_SPEC]);
+
if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
fprintf(fp, "%s alias %s", _SL_,
rta_getattr_str(tb[IFLA_IFALIAS]));
--
1.9.3
^ permalink raw reply related
* Re: [PATCH net-next v5 0/7]: ixgbevf: Allow querying VFs RSS indirection table and key
From: Vlad Zolotarov @ 2015-01-08 8:42 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: netdev, gleb, avi, Greg Rose, Greg Rose
In-Reply-To: <1420661025.2491.73.camel@jtkirshe-mobl>
On 01/07/15 22:03, Jeff Kirsher wrote:
> On Wed, 2015-01-07 at 21:26 +0200, Vlad Zolotarov wrote:
>> Add the ethtool ops to VF driver to allow querying the RSS indirection
>> table
>> and RSS Random Key.
>>
>> On some devices VFs share the RSS Redirection Table and Hash Key with
>> a PF and letting
>> the VF query this information may introduce some security risks.
>> Therefore we disable this
>> feature by default for such devices (e.g. 82599) and allow it for
>> those where there isn't any
>> possible risk (e.g. on x550). The new netdev op is going to allow a
>> system administrator to
>> change the default behaviour with "ip link set" command.
>>
>> - netdev: Add a new netdev op to allow/block VF from querying RSS
>> Indirection Table and
>> RSS Hash Key.
>> - PF driver: Add new VF-PF channel commands.
>> - VF driver: Utilize these new commands and add the corresponding
>> ethtool callbacks.
>>
>> New in v5:
>> - Added a new netdev op to allow/block VF from querying RSS
>> Indirection Table and
>> RSS Hash Key.
>> - Let VF query the RSS info only if VF is allowed to.
>>
>> New in v4:
>> - Forgot to run checkpatch on v3 and there were a few styling
>> things to fix. ;)
>>
>> New in v3:
>> - Added a missing support for x550 devices.
>> - Mask the indirection table values according to PSRTYPE[n].RQPL.
>> - Minimized the number of added VF-PF commands.
>>
>> New in v2:
>> - Added a detailed description to patches 4 and 5.
>>
>> New in v1 (compared to RFC):
>> - Use "if-else" statement instead of a "switch-case" for a single
>> option case.
>> More specifically: in cases where the newly added API version is
>> the only one
>> allowed. We may consider using a "switch-case" back again when
>> the list of
>> allowed API versions in these specific places grows up.
>>
>> Vlad Zolotarov (7):
>> if_link: Add an additional parameter to ifla_vf_info for RSS
>> querying
>> ixgbe: Add a new netdev op to allow/prevent a VF from querying an
>> RSS
>> info
>> ixgbe: Add a RETA query command to VF-PF channel API
>> ixgbevf: Add a RETA query code
>> ixgbe: Add GET_RSS_KEY command to VF-PF channel commands set
>> ixgbevf: Add RSS Key query code
>> ixgbevf: Add the appropriate ethtool ops to query RSS indirection
>> table and key
>>
>> drivers/net/ethernet/intel/ixgbe/ixgbe.h | 1 +
>> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ++
>> drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h | 10 ++
>> drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 119
>> +++++++++++++++++++
>> drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h | 2 +
>> drivers/net/ethernet/intel/ixgbevf/ethtool.c | 42 +++++++
>> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 4 +-
>> drivers/net/ethernet/intel/ixgbevf/mbx.h | 10 ++
>> drivers/net/ethernet/intel/ixgbevf/vf.c | 132
>> ++++++++++++++++++++++
>> drivers/net/ethernet/intel/ixgbevf/vf.h | 2 +
>> include/linux/if_link.h | 1 +
>> include/linux/netdevice.h | 8 ++
>> include/uapi/linux/if_link.h | 8 ++
>> net/core/rtnetlink.c | 33 +++++-
>> 14 files changed, 372 insertions(+), 7 deletions(-)
> Thanks Vlad, I will add your patches to my queue.
Thanks, guys (Greg and Jeff).
^ permalink raw reply
* Re: [PATCH net-next v2 0/8] net: extend ethtool link mode bitmaps to 48 bits
From: Amir Vadai @ 2015-01-08 8:40 UTC (permalink / raw)
To: David Decotigny
Cc: Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Saeed Mahameed,
David S. Miller, Jason Wang, Michael S. Tsirkin, Herbert Xu,
Al Viro, Ben Hutchings, Masatake YAMATO, Xi Wang, Neil Horman,
WANG Cong, Flavio Leitner, Tom Gundersen, Jiri Pirko,
Vlad Yasevich, Eric W. Biederman, Venkata Duvvuru,
Govindarajulu Varadarajan <_govind
In-Reply-To: <CAG88wWYPDpwkWkL+Pj2VKrX5WVp=at8v0=gcFAVAA8nntv+-nw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 1/6/2015 7:36 PM, David Decotigny wrote:
> Interesting. It seems that the band-aid I was proposing is already
> obsolete. We could still use the remaining reserved 16 bits to encode
> 5 more bits per mask (that is: 53 bits / mask total). But if I
> understand you, it would allow us to survive only a few months longer,
> as opposed to a few weeks.
>
> One short-term alternative solution I can imagine is the following:
> /* For example bitmap-based for variable length: */
> struct ethtool_link_mode {
> __u32 cmd;
> __u8 autoneg :1;
> __u8 duplex :2;
> __u16 supported_nbits;
> __u16 advertising_nbits;
> __u16 lp_advertising_nbits;
> __u32 reserved[4];
> __u8 masks[0];
> };
> /* Or simpler, statically limited to 64b / mask, but easier to migrate
> to for driver authors: */
I think the first options is better. A driver will have to do changes in
order to support >32 link modes, so better change it once now, without
having to change it again for >64 link modes.
> struct ethtool_link_mode {
> __u32 cmd;
> __u8 autoneg :1;
> __u8 duplex :2;
> __u64 supported;
> __u64 advertising;
> __u64 lp_advertising;
> __u32 reserved[4];
> };
> #define ETHTOOL_GLINK_MODE 0x0000004a
> #define ETHTOOL_SLINK_MODE 0x0000004b
> struct ethtool_ops {
> ...
> int (*get_link_mode)(struct net_device *, struct ethtool_link_mode *);
> int (*set_link_mode)(struct net_device *, struct ethtool_link_mode *);
> };
>
> The same thing required for EEE.
Yeh :(
>
> I am not sure about moving the autoneg and duplex fields into the new
> struct. Especially the "duplex" field.
I think so too. ethtool user space will call ETHTOOL_[GS]SET and after
that ETHTOOL_[GS]LINK_MODE (if supported). No need to get the
duplex/autoneg fields again.
>
> Then the idea would be to update the ethtool user-space tool to try
> get/set_link mode when reporting/changing the autoneg/advertising
> settings.
>
> Both will require significant effort from the driver authors.
> Especially if the variable-length bitmap approach is preferred:
> - most drivers currently use simple bitwise arithmetic in their code,
> and that goes far beyond get/set_settings, it is sometimes part of the
> core driver logic. They will have to migrate to the bitmap API if they
> want to use the larger bitmaps (note: no change needed if they are
> happy with <= 32b / mask)
As I said above, it will save as doing this work again in the future,
and more problematic, save another version to backport in the future. In
addition, not all drivers will have to do it, only if >32 link speeds is
needed - this work will be required.
> - we would have to progressively deprecate the use of #define
> ADVERTISED_1000baseT_Full in favor of an enum of the bit indices.
Maybe we could use some macro juggling to define the legacy macro's
using enum for the first 32 bits, and fail the compilation if used on
>32. For example, calling this:
DEFINE_LINK_MODE(ADVERTISED_1000baseT_Full, 5)
Will add the following:
ADVERTISED_1000baseT_Full_SHIFT = 5
ADVERTISED_1000baseT_Full = (1<<5)
DEFINE_LINK_MODE(ADVERTISED_100000baseKR5_Full, 50) will add:
ADVERTISED_100000baseKR5_Full_SHIFT = 50
ADVERTISED_100000baseKR5_Full = #error new link speeds must be defined
using [gs]et_link_speed
This will break compilation if ADVERTISED_100000baseKR5_Full is used in
[gs]et_settings (I know the '#error' will not print something very
pretty - I used it only to explain what I meant)
>
> Any feedback welcome. In the meantime, I am going to propose a v3 of
> current option with 53 bits / mask. I can also propose a prototype of
> the scheme described above, please let me know.
I think that it is better to do it once, and skip the 53 bits / mask
version.
I'll be happy to assist.
Amir
^ permalink raw reply
* [PATCH] net: Prevent multiple NAPI instances co-existing in the list
From: Dennis Chen @ 2015-01-08 8:22 UTC (permalink / raw)
To: netdev, Herbert Xu, Miller, Eric Dumazet; +Cc: Dennis Chen
Some drivers may clear the NAPI_STATE_SCHED bit upon the state of the
NAPI instance after exhaust the budget in the poll function, which
will open a window for next device interrupt handler to insert a same
instance to the list after calling list_add_tail(&n->poll_list,
repoll) if we don't set this bit.
Signed-off-by: Dennis Chen <kernel.org.gnu@gmail.com>
---
net/core/dev.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 683d493..b3107ac 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4619,6 +4619,14 @@ static int napi_poll(struct napi_struct *n,
struct list_head *repoll)
n->dev ? n->dev->name : "backlog");
goto out_unlock;
}
+
+ /* Some drivers may exit the polling mode when exhaust the
+ * budget. Set the NAPI_STATE_SCHED bit to prevent multiple NAPI
+ * instances in the list in case of next device interrupt raised.
+ */
+ if (unlikely(!test_and_set_bit(NAPI_STATE_SCHED, &n->state)))
+ pr_warn_once("%s: exit polling mode after exhaust the budget\n",
+ n->dev ? n->dev->name : "backlog");
list_add_tail(&n->poll_list, repoll);
--
1.7.9.5
--
Den
^ permalink raw reply related
* Re: [PATCH] net/at91_ether: prepare and unprepare clock
From: Boris Brezillon @ 2015-01-08 8:13 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, David S. Miller, linux-arm-kernel, linux-kernel,
netdev
In-Reply-To: <1420671566-30784-1-git-send-email-alexandre.belloni@free-electrons.com>
On Wed, 7 Jan 2015 23:59:26 +0100
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> The clock is enabled without being prepared, this leads to:
>
> WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:889 __clk_enable+0x24/0xa8()
>
> and a non working ethernet interface.
>
> Use clk_prepare_enable() and clk_disable_unprepare() to handle the clock.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/net/ethernet/cadence/at91_ether.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
> index 55eb7f2af2b4..7ef55f5fa664 100644
> --- a/drivers/net/ethernet/cadence/at91_ether.c
> +++ b/drivers/net/ethernet/cadence/at91_ether.c
> @@ -340,7 +340,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
> res = PTR_ERR(lp->pclk);
> goto err_free_dev;
> }
> - clk_enable(lp->pclk);
> + clk_prepare_enable(lp->pclk);
>
> lp->hclk = ERR_PTR(-ENOENT);
> lp->tx_clk = ERR_PTR(-ENOENT);
> @@ -406,7 +406,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
> err_out_unregister_netdev:
> unregister_netdev(dev);
> err_disable_clock:
> - clk_disable(lp->pclk);
> + clk_disable_unprepare(lp->pclk);
> err_free_dev:
> free_netdev(dev);
> return res;
> @@ -424,7 +424,7 @@ static int at91ether_remove(struct platform_device *pdev)
> kfree(lp->mii_bus->irq);
> mdiobus_free(lp->mii_bus);
> unregister_netdev(dev);
> - clk_disable(lp->pclk);
> + clk_disable_unprepare(lp->pclk);
> free_netdev(dev);
>
> return 0;
> @@ -440,7 +440,7 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
> netif_stop_queue(net_dev);
> netif_device_detach(net_dev);
>
> - clk_disable(lp->pclk);
> + clk_disable_unprepare(lp->pclk);
> }
> return 0;
> }
> @@ -451,7 +451,7 @@ static int at91ether_resume(struct platform_device *pdev)
> struct macb *lp = netdev_priv(net_dev);
>
> if (netif_running(net_dev)) {
> - clk_enable(lp->pclk);
> + clk_prepare_enable(lp->pclk);
>
> netif_device_attach(net_dev);
> netif_start_queue(net_dev);
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH] vhost/net: length miscalculation
From: Michael S. Tsirkin @ 2015-01-08 8:08 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: kvm, netdev, linux-kernel, virtualization
In-Reply-To: <54AD9DD8.2080008@cogentembedded.com>
On Wed, Jan 07, 2015 at 11:58:00PM +0300, Sergei Shtylyov wrote:
> Hello.
>
> On 01/07/2015 11:55 AM, Michael S. Tsirkin wrote:
>
> >commit 8b38694a2dc8b18374310df50174f1e4376d6824
> > vhost/net: virtio 1.0 byte swap
> >had this chunk:
> >- heads[headcount - 1].len += datalen;
> >+ heads[headcount - 1].len = cpu_to_vhost32(vq, len - datalen);
>
> >This adds datalen with the wrong sign, causing guest panics.
>
> >Fixes: 8b38694a2dc8b18374310df50174f1e4376d6824
>
> The format of this tag assumes 12-digit SHA1 hash and the commit
> description enclosed in parens and double quotes. See
> Documentation/SubmittingPatches.
>
> >Reported-by: Alex Williamson <alex.williamson@redhat.com>
> >Suggested-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> >Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> WBR, Sergei
I pushed the patches to Linus unfortunately - there's
some urgency since many people are hitting the bug.
Will do my best to do it right next time.
--
MST
^ permalink raw reply
* [PULL] vhost: cleanups and fixes
From: Michael S. Tsirkin @ 2015-01-08 7:51 UTC (permalink / raw)
To: Linus Torvalds
Cc: kvm, mst, netdev, linux-kernel, stable, virtualization,
sasha.levin
The following changes since commit b1940cd21c0f4abdce101253e860feff547291b0:
Linux 3.19-rc3 (2015-01-05 17:05:20 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/for_linus
for you to fetch changes up to 99975cc6ada0d5f2675e83abecae05aba5f437d2:
vhost/net: length miscalculation (2015-01-07 12:22:00 +0200)
----------------------------------------------------------------
virtio, vhost fixes for 3.19
This fixes a couple of bugs triggered by hot-unplug
of virtio devices, as well as a regression in vhost-net.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
----------------------------------------------------------------
Michael S. Tsirkin (4):
virtio: make del_vqs idempotent
virtio_pci: device-specific release callback
virtio_pci: document why we defer kfree
vhost/net: length miscalculation
Sasha Levin (1):
virtio_pci: defer kfree until release callback
drivers/virtio/virtio_pci_common.h | 1 -
drivers/vhost/net.c | 2 +-
drivers/virtio/virtio_pci_common.c | 10 +---------
drivers/virtio/virtio_pci_legacy.c | 12 +++++++++++-
4 files changed, 13 insertions(+), 12 deletions(-)
^ permalink raw reply
* Re: [PATCH net-next] mac80211: silent build warnings
From: Ying Xue @ 2015-01-08 7:45 UTC (permalink / raw)
To: Johannes Berg
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1420702907.2029.2.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
On 01/08/2015 03:41 PM, Johannes Berg wrote:
> On Thu, 2015-01-08 at 15:04 +0800, Ying Xue wrote:
>> Silent the following build warnings:
>>
>> net/mac80211/mlme.c: In function ‘ieee80211_rx_mgmt_beacon’:
>> net/mac80211/mlme.c:1348:3: warning: ‘pwr_level_cisco’ may be used uninitialized in this function [-Wuninitialized]
>> net/mac80211/mlme.c:1315:6: note: ‘pwr_level_cisco’ was declared here
>
> We seem to get this every year or so... just upgrade your compiler and
> it will be smart enough to prove that it's wrong here.
>
> I really *don't* want to shut up the compiler forcefully since it will
> cause modern compilers to *not* warn if it actually *is* unused - and 0
> is not a useful value - this code is tricky enough and we want compiler
> help in case we need to modify it in the future.
>
Thank for your explanation, and please ignore the noise.
Regards,
Ying
> johannes
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH net-next] mac80211: silent build warnings
From: Johannes Berg @ 2015-01-08 7:41 UTC (permalink / raw)
To: Ying Xue
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1420700655-9427-1-git-send-email-ying.xue-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
On Thu, 2015-01-08 at 15:04 +0800, Ying Xue wrote:
> Silent the following build warnings:
>
> net/mac80211/mlme.c: In function ‘ieee80211_rx_mgmt_beacon’:
> net/mac80211/mlme.c:1348:3: warning: ‘pwr_level_cisco’ may be used uninitialized in this function [-Wuninitialized]
> net/mac80211/mlme.c:1315:6: note: ‘pwr_level_cisco’ was declared here
We seem to get this every year or so... just upgrade your compiler and
it will be smart enough to prove that it's wrong here.
I really *don't* want to shut up the compiler forcefully since it will
cause modern compilers to *not* warn if it actually *is* unused - and 0
is not a useful value - this code is tricky enough and we want compiler
help in case we need to modify it in the future.
johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [patch net-next] tc: add BPF based action
From: Jiri Pirko @ 2015-01-08 7:26 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, davem, jhs, stephen, ast
In-Reply-To: <54AD7C03.3010904@redhat.com>
Wed, Jan 07, 2015 at 07:33:39PM CET, dborkman@redhat.com wrote:
>On 01/07/2015 05:43 PM, Jiri Pirko wrote:
>>This action provides a possibility to exec custom BPF code.
>
>Can you elaborate a bit more on the particular use-case, and
>what scenarios are unsolveable with the BPF filter we already
>have in tc? Just wondering, since you're using BPF for the
>purpose of classifying (but just from the context of actions)
>what about a possibility of a generic container for reusing
>(any) classifier from the framework, so we would not need to
>duplicate code?
>
>On the other hand, I would understand if it's at some point in
>time eBPF which would f.e. mangle the packet, but the API you
>propose is clearly classic BPF. ;)
Exactly. I would like to extend cls_bpf and act_bpf to handle eBPF right
after. That is the point.
>
>Thanks,
>Daniel
^ permalink raw reply
* Re: [patch iproute2 2/2] iplink: print out addrgenmode attribute
From: Vadim Kochan @ 2015-01-08 7:13 UTC (permalink / raw)
To: Jiri Pirko; +Cc: Stephen Hemminger, netdev, thaller
In-Reply-To: <20150108070439.GB1860@nanopsycho.orion>
On Thu, Jan 08, 2015 at 08:04:39AM +0100, Jiri Pirko wrote:
> Thu, Jan 08, 2015 at 12:10:36AM CET, stephen@networkplumber.org wrote:
> >On Tue, 6 Jan 2015 17:23:46 +0100
> >Jiri Pirko <jiri@resnulli.us> wrote:
> >
> >> addrgenmode is currently write only by ip. So display this information
> >> if provided by kernel as well.
> >>
> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> >
> >Patch does not apply to current iproute2 git
>
> I made that against net-next branch. Which branch should I use for new
> features?
>
> --
> 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
I am not sure if I am right, but seems to me that net-next should keep
features which depends on the next Linux headers version, and as I
understand these new headers are merged into net-next branch and after
into master. But I tried fix your patch on the master and it compiles
OK, so I assume that it can be based on master branch.
Regards,
^ permalink raw reply
* Re: [patch iproute2 2/2] iplink: print out addrgenmode attribute
From: Jiri Pirko @ 2015-01-08 7:04 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, thaller
In-Reply-To: <20150107151036.2852e1be@urahara>
Thu, Jan 08, 2015 at 12:10:36AM CET, stephen@networkplumber.org wrote:
>On Tue, 6 Jan 2015 17:23:46 +0100
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> addrgenmode is currently write only by ip. So display this information
>> if provided by kernel as well.
>>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>
>Patch does not apply to current iproute2 git
I made that against net-next branch. Which branch should I use for new
features?
^ permalink raw reply
* [PATCH net-next] mac80211: silent build warnings
From: Ying Xue @ 2015-01-08 7:04 UTC (permalink / raw)
To: johannes-cdvu00un1VgdHxzADdlk8Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
Silent the following build warnings:
net/mac80211/mlme.c: In function ‘ieee80211_rx_mgmt_beacon’:
net/mac80211/mlme.c:1348:3: warning: ‘pwr_level_cisco’ may be used uninitialized in this function [-Wuninitialized]
net/mac80211/mlme.c:1315:6: note: ‘pwr_level_cisco’ was declared here
Signed-off-by: Ying Xue <ying.xue-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
---
net/mac80211/mlme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2c36c47..13b5506 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1312,7 +1312,7 @@ static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
{
bool has_80211h_pwr = false, has_cisco_pwr = false;
int chan_pwr = 0, pwr_reduction_80211h = 0;
- int pwr_level_cisco, pwr_level_80211h;
+ int pwr_level_cisco = 0, pwr_level_80211h = 0;
int new_ap_level;
if (country_ie && pwr_constr_ie &&
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v2] sh_eth: Fix access to TRSCER register
From: Nobuhiro Iwamatsu @ 2015-01-08 6:25 UTC (permalink / raw)
To: netdev; +Cc: yoshihiro.shimoda.uh, linux-sh, geert, Nobuhiro Iwamatsu
TRSCER register is configured differently by SoCs. TRSCER of R-Car Gen2 is
RINT8 bit only valid, other bits are reserved bits. This removes access to
TRSCER register reserve bit by adding variable trscer_err_mask to
sh_eth_cpu_data structure, set the register information to each SoCs.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
---
v2: - Add trscer_err_mask to struct sh_eth_cpu_data.
- Add DEFAULT_TRSCER_ERR_MASK.
- Set DESC_I_RINT8 to trscer_err_mask of r8a779x_data.
drivers/net/ethernet/renesas/sh_eth.c | 7 ++++++-
drivers/net/ethernet/renesas/sh_eth.h | 5 +++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index c29ba80..f1688201 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -496,6 +496,8 @@ static struct sh_eth_cpu_data r8a779x_data = {
EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE |
EESR_ECI,
+ .trscer_err_mask = DESC_I_RINT8,
+
.apr = 1,
.mpr = 1,
.tpauser = 1,
@@ -856,6 +858,9 @@ static void sh_eth_set_default_cpu_data(struct sh_eth_cpu_data *cd)
if (!cd->eesr_err_check)
cd->eesr_err_check = DEFAULT_EESR_ERR_CHECK;
+
+ if (!cd->trscer_err_mask)
+ cd->trscer_err_mask = DEFAULT_TRSCER_ERR_MASK;
}
static int sh_eth_check_reset(struct net_device *ndev)
@@ -1294,7 +1299,7 @@ static int sh_eth_dev_init(struct net_device *ndev, bool start)
/* Frame recv control (enable multiple-packets per rx irq) */
sh_eth_write(ndev, RMCR_RNC, RMCR);
- sh_eth_write(ndev, DESC_I_RINT8 | DESC_I_RINT5 | DESC_I_TINT2, TRSCER);
+ sh_eth_write(ndev, mdp->cd->trscer_err_mask, TRSCER);
if (mdp->cd->bculr)
sh_eth_write(ndev, 0x800, BCULR); /* Burst sycle set */
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index 22301bf..71f5de1 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -369,6 +369,8 @@ enum DESC_I_BIT {
DESC_I_RINT1 = 0x0001,
};
+#define DEFAULT_TRSCER_ERR_MASK (DESC_I_RINT8 | DESC_I_RINT5 | DESC_I_TINT2)
+
/* RPADIR */
enum RPADIR_BIT {
RPADIR_PADS1 = 0x20000, RPADIR_PADS0 = 0x10000,
@@ -470,6 +472,9 @@ struct sh_eth_cpu_data {
unsigned long tx_check;
unsigned long eesr_err_check;
+ /* Error mask */
+ unsigned long trscer_err_mask;
+
/* hardware features */
unsigned long irq_flags; /* IRQ configuration flags */
unsigned no_psr:1; /* EtherC DO NOT have PSR */
--
2.1.3
^ permalink raw reply related
* Re: route/max_size sysctl in ipv4
From: Eric Dumazet @ 2015-01-08 5:41 UTC (permalink / raw)
To: Ani Sinha; +Cc: David Miller, netdev@vger.kernel.org
In-Reply-To: <CAOxq_8Pp7fwsV3Y+-LNheziQzP8FXqT3ohgMt7SeEs6+nuGxMg@mail.gmail.com>
On Wed, 2015-01-07 at 19:40 -0800, Ani Sinha wrote:
> true but at least those scripts which does only read the values will
> continue to function in a child namespace. In our case, our script
> only reads the max_size sysctl but since it operates from within a
> child namespace, it doesn't find it.
>
> thoughts?
Fix your script, or do not use namespaces.
^ permalink raw reply
* [PATCH v2 6/6] irda: vlsi_ir: Replace timeval with ktime_t
From: Chunyan Zhang @ 2015-01-08 4:01 UTC (permalink / raw)
To: samuel; +Cc: arnd, zhang.lyra, netdev, linux-kernel
In-Reply-To: <1420689692-8760-1-git-send-email-zhang.chunyan@linaro.org>
The vlsi ir driver uses 'timeval', which we try to remove in the kernel
because all 32-bit time types will break in the year 2038.
This patch also changes do_gettimeofday() to ktime_get() accordingly,
since ktime_get returns a ktime_t, but do_gettimeofday returns a
struct timeval, and the other reason is that ktime_get() uses
the monotonic clock.
This patch uses ktime_us_delta to get the elapsed time of microsecond,
and uses div_s64_rem to get what seconds & microseconds time elapsed
for printing.
This patch also changes the function 'vlsi_hard_start_xmit' to do the
same things as the others drivers, that is passing the remaining time
into udelay() instead of looping until enough time has passed.
Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/irda/vlsi_ir.c | 46 +++++++++++++-------------------------------
drivers/net/irda/vlsi_ir.h | 2 +-
2 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index ac39d9f..a0849f4 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -33,6 +33,7 @@ MODULE_LICENSE("GPL");
/********************************************************/
#include <linux/kernel.h>
+#include <linux/ktime.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
@@ -40,9 +41,9 @@ MODULE_LICENSE("GPL");
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
-#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/math64.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
@@ -180,8 +181,7 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
vlsi_irda_dev_t *idev = netdev_priv(ndev);
u8 byte;
u16 word;
- unsigned delta1, delta2;
- struct timeval now;
+ s32 sec, usec;
unsigned iobase = ndev->base_addr;
seq_printf(seq, "\n%s link state: %s / %s / %s / %s\n", ndev->name,
@@ -277,17 +277,9 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
seq_printf(seq, "\nsw-state:\n");
seq_printf(seq, "IrPHY setup: %d baud - %s encoding\n", idev->baud,
(idev->mode==IFF_SIR)?"SIR":((idev->mode==IFF_MIR)?"MIR":"FIR"));
- do_gettimeofday(&now);
- if (now.tv_usec >= idev->last_rx.tv_usec) {
- delta2 = now.tv_usec - idev->last_rx.tv_usec;
- delta1 = 0;
- }
- else {
- delta2 = 1000000 + now.tv_usec - idev->last_rx.tv_usec;
- delta1 = 1;
- }
- seq_printf(seq, "last rx: %lu.%06u sec\n",
- now.tv_sec - idev->last_rx.tv_sec - delta1, delta2);
+ sec = div_s64_rem(ktime_us_delta(ktime_get(), idev->last_rx),
+ USEC_PER_SEC, &usec);
+ seq_printf(seq, "last rx: %ul.%06u sec\n", sec, usec);
seq_printf(seq, "RX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu",
ndev->stats.rx_packets, ndev->stats.rx_bytes, ndev->stats.rx_errors,
@@ -661,7 +653,7 @@ static void vlsi_rx_interrupt(struct net_device *ndev)
}
}
- do_gettimeofday(&idev->last_rx); /* remember "now" for later mtt delay */
+ idev->last_rx = ktime_get(); /* remember "now" for later mtt delay */
vlsi_fill_rx(r);
@@ -858,9 +850,8 @@ static netdev_tx_t vlsi_hard_start_xmit(struct sk_buff *skb,
unsigned iobase = ndev->base_addr;
u8 status;
u16 config;
- int mtt;
+ int mtt, diff;
int len, speed;
- struct timeval now, ready;
char *msg = NULL;
speed = irda_get_next_speed(skb);
@@ -940,21 +931,10 @@ static netdev_tx_t vlsi_hard_start_xmit(struct sk_buff *skb,
spin_unlock_irqrestore(&idev->lock, flags);
if ((mtt = irda_get_mtt(skb)) > 0) {
-
- ready.tv_usec = idev->last_rx.tv_usec + mtt;
- ready.tv_sec = idev->last_rx.tv_sec;
- if (ready.tv_usec >= 1000000) {
- ready.tv_usec -= 1000000;
- ready.tv_sec++; /* IrLAP 1.1: mtt always < 1 sec */
- }
- for(;;) {
- do_gettimeofday(&now);
- if (now.tv_sec > ready.tv_sec ||
- (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
- break;
- udelay(100);
+ diff = ktime_us_delta(ktime_get(), idev->last_rx);
+ if (mtt > diff)
+ udelay(mtt - diff);
/* must not sleep here - called under netif_tx_lock! */
- }
}
/* tx buffer already owned by CPU due to pci_dma_sync_single_for_cpu()
@@ -1333,7 +1313,7 @@ static int vlsi_start_hw(vlsi_irda_dev_t *idev)
vlsi_fill_rx(idev->rx_ring);
- do_gettimeofday(&idev->last_rx); /* first mtt may start from now on */
+ idev->last_rx = ktime_get(); /* first mtt may start from now on */
outw(0, iobase+VLSI_PIO_PROMPT); /* kick hw state machine */
@@ -1520,7 +1500,7 @@ static int vlsi_open(struct net_device *ndev)
if (!idev->irlap)
goto errout_free_ring;
- do_gettimeofday(&idev->last_rx); /* first mtt may start from now on */
+ idev->last_rx = ktime_get(); /* first mtt may start from now on */
idev->new_baud = 9600; /* start with IrPHY using 9600(SIR) mode */
diff --git a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h
index f9119c6..f9db2ce 100644
--- a/drivers/net/irda/vlsi_ir.h
+++ b/drivers/net/irda/vlsi_ir.h
@@ -723,7 +723,7 @@ typedef struct vlsi_irda_dev {
void *virtaddr;
struct vlsi_ring *tx_ring, *rx_ring;
- struct timeval last_rx;
+ ktime_t last_rx;
spinlock_t lock;
struct mutex mtx;
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 3/6] irda: irda-usb: Replace timeval with ktime_t
From: Chunyan Zhang @ 2015-01-08 4:01 UTC (permalink / raw)
To: samuel; +Cc: arnd, zhang.lyra, netdev, linux-kernel
In-Reply-To: <1420689692-8760-1-git-send-email-zhang.chunyan@linaro.org>
The irda usb driver uses 'timeval', which we try to remove in the kernel
because all 32-bit time types will break in the year 2038.
This patch also changes do_gettimeofday() to ktime_get() accordingly,
since ktime_get returns a ktime_t, but do_gettimeofday returns a
struct timeval, and the other reason is that ktime_get() uses
the monotonic clock.
This patch uses ktime_us_delta to get the elapsed time, and in this
way it no longer needs to check for the overflow, because
ktime_us_delta returns time difference of microsecond.
Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/irda/irda-usb.c | 10 ++--------
drivers/net/irda/irda-usb.h | 5 ++---
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 48b2f9a..f6c9163 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -495,18 +495,12 @@ static netdev_tx_t irda_usb_hard_xmit(struct sk_buff *skb,
mtt = irda_get_mtt(skb);
if (mtt) {
int diff;
- do_gettimeofday(&self->now);
- diff = self->now.tv_usec - self->stamp.tv_usec;
+ diff = ktime_us_delta(ktime_get(), self->stamp);
#ifdef IU_USB_MIN_RTT
/* Factor in USB delays -> Get rid of udelay() that
* would be lost in the noise - Jean II */
diff += IU_USB_MIN_RTT;
#endif /* IU_USB_MIN_RTT */
- /* If the usec counter did wraparound, the diff will
- * go negative (tv_usec is a long), so we need to
- * correct it by one second. Jean II */
- if (diff < 0)
- diff += 1000000;
/* Check if the mtt is larger than the time we have
* already used by all the protocol processing
@@ -869,7 +863,7 @@ static void irda_usb_receive(struct urb *urb)
* reduce the min turn time a bit since we will know
* how much time we have used for protocol processing
*/
- do_gettimeofday(&self->stamp);
+ self->stamp = ktime_get();
/* Check if we need to copy the data to a new skb or not.
* For most frames, we use ZeroCopy and pass the already
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h
index 58ddb52..8ac389f 100644
--- a/drivers/net/irda/irda-usb.h
+++ b/drivers/net/irda/irda-usb.h
@@ -29,7 +29,7 @@
*
*****************************************************************************/
-#include <linux/time.h>
+#include <linux/ktime.h>
#include <net/irda/irda.h>
#include <net/irda/irda_device.h> /* struct irlap_cb */
@@ -157,8 +157,7 @@ struct irda_usb_cb {
char *speed_buff; /* Buffer for speed changes */
char *tx_buff;
- struct timeval stamp;
- struct timeval now;
+ ktime_t stamp;
spinlock_t lock; /* For serializing Tx operations */
--
1.7.9.5
^ permalink raw reply related
* [PATCH v2 5/6] irda: stir4200: Replace timeval with ktime_t
From: Chunyan Zhang @ 2015-01-08 4:01 UTC (permalink / raw)
To: samuel; +Cc: arnd, zhang.lyra, netdev, linux-kernel
In-Reply-To: <1420689692-8760-1-git-send-email-zhang.chunyan@linaro.org>
The stir4200 driver uses 'timeval', which we try to remove in the kernel
because all 32-bit time types will break in the year 2038.
This patch also changes do_gettimeofday() to ktime_get() accordingly,
since ktime_get returns a ktime_t, but do_gettimeofday returns a
struct timeval, and the other reason is that ktime_get() uses
the monotonic clock.
This patch uses ktime_us_delta to get the elapsed time of microsecond.
Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/irda/stir4200.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index dd1bd10..83cc48a 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -40,6 +40,7 @@
#include <linux/moduleparam.h>
#include <linux/kernel.h>
+#include <linux/ktime.h>
#include <linux/types.h>
#include <linux/time.h>
#include <linux/skbuff.h>
@@ -174,7 +175,7 @@ struct stir_cb {
__u8 *fifo_status;
iobuff_t rx_buff; /* receive unwrap state machine */
- struct timeval rx_time;
+ ktime_t rx_time;
int receiving;
struct urb *rx_urb;
};
@@ -650,15 +651,12 @@ static int fifo_txwait(struct stir_cb *stir, int space)
static void turnaround_delay(const struct stir_cb *stir, long us)
{
long ticks;
- struct timeval now;
if (us <= 0)
return;
- do_gettimeofday(&now);
- if (now.tv_sec - stir->rx_time.tv_sec > 0)
- us -= USEC_PER_SEC;
- us -= now.tv_usec - stir->rx_time.tv_usec;
+ us -= ktime_us_delta(ktime_get(), stir->rx_time);
+
if (us < 10)
return;
@@ -823,8 +821,8 @@ static void stir_rcv_irq(struct urb *urb)
pr_debug("receive %d\n", urb->actual_length);
unwrap_chars(stir, urb->transfer_buffer,
urb->actual_length);
-
- do_gettimeofday(&stir->rx_time);
+
+ stir->rx_time = ktime_get();
}
/* kernel thread is stopping receiver don't resubmit */
@@ -876,7 +874,7 @@ static int stir_net_open(struct net_device *netdev)
skb_reserve(stir->rx_buff.skb, 1);
stir->rx_buff.head = stir->rx_buff.skb->data;
- do_gettimeofday(&stir->rx_time);
+ stir->rx_time = ktime_get();
stir->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!stir->rx_urb)
--
1.7.9.5
^ permalink raw reply related
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