All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Dirk van der Merwe <dirk.vandermerwe@netronome.com>,
	Leandro Dorileo <leandro.maciel.dorileo@intel.com>,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>
Subject: [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div
Date: Wed, 17 Apr 2019 13:51:57 -0700	[thread overview]
Message-ID: <20190417205159.30938-4-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20190417205159.30938-1-jakub.kicinski@netronome.com>

Recent changes to taprio did not use the correct div64 helpers,
leading to:

net/sched/sch_taprio.o: In function `taprio_dequeue':
sch_taprio.c:(.text+0x34a): undefined reference to `__divdi3'
net/sched/sch_taprio.o: In function `advance_sched':
sch_taprio.c:(.text+0xa0b): undefined reference to `__divdi3'
net/sched/sch_taprio.o: In function `taprio_init':
sch_taprio.c:(.text+0x1450): undefined reference to `__divdi3'
/home/jkicinski/devel/linux/Makefile:1032: recipe for target 'vmlinux' failed

Use math64 helpers.

Fixes: 7b9eba7ba0c1 ("net/sched: taprio: fix picos_per_byte miscalculation")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
CC: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
CC: Vinicius Costa Gomes <vinicius.gomes@intel.com>

 net/sched/sch_taprio.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 1b0fb80162e6..001182aa3959 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -13,6 +13,7 @@
 #include <linux/list.h>
 #include <linux/errno.h>
 #include <linux/skbuff.h>
+#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <net/netlink.h>
@@ -121,7 +122,14 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch)
 
 static inline int length_to_duration(struct taprio_sched *q, int len)
 {
-	return (len * atomic64_read(&q->picos_per_byte)) / 1000;
+	return div_u64(len * atomic64_read(&q->picos_per_byte), 1000);
+}
+
+static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry)
+{
+	atomic_set(&entry->budget,
+		   div64_u64((u64)entry->interval * 1000,
+			     atomic64_read(&q->picos_per_byte)));
 }
 
 static struct sk_buff *taprio_dequeue(struct Qdisc *sch)
@@ -241,8 +249,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer)
 	close_time = ktime_add_ns(entry->close_time, next->interval);
 
 	next->close_time = close_time;
-	atomic_set(&next->budget,
-		   (next->interval * 1000) / atomic64_read(&q->picos_per_byte));
+	taprio_set_budget(q, next);
 
 first_run:
 	rcu_assign_pointer(q->current_entry, next);
@@ -575,9 +582,7 @@ static void taprio_start_sched(struct Qdisc *sch, ktime_t start)
 				 list);
 
 	first->close_time = ktime_add_ns(start, first->interval);
-	atomic_set(&first->budget,
-		   (first->interval * 1000) /
-		   atomic64_read(&q->picos_per_byte));
+	taprio_set_budget(q, first);
 	rcu_assign_pointer(q->current_entry, NULL);
 
 	spin_unlock_irqrestore(&q->current_entry_lock, flags);
-- 
2.21.0


  parent reply	other threads:[~2019-04-17 20:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 1/5] l2tp: fix set but not used variable Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 2/5] sb1000: fix variable set but not used warnings Jakub Kicinski
2019-04-17 20:51 ` Jakub Kicinski [this message]
2019-04-17 22:32   ` [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div Vinicius Costa Gomes
2019-04-30  0:04   ` Leandro Dorileo
2019-04-17 20:51 ` [PATCH net-next 4/5] net: gemini: remove unnecessary assert Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 5/5] net: skb: remove unused asserts Jakub Kicinski
2019-04-19  0:06 ` [PATCH net-next 0/5] net: some build fixes and other improvements David Miller
2019-04-19  0:34   ` Jakub Kicinski
2019-04-19  8:38     ` Guillaume Nault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190417205159.30938-4-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=davem@davemloft.net \
    --cc=dirk.vandermerwe@netronome.com \
    --cc=leandro.maciel.dorileo@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=vinicius.gomes@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.