From patchwork Fri Jul 6 13:36:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 141322 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3125768ljj; Fri, 6 Jul 2018 06:37:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcoCx/3niLZuBL7KSEr4RslqQTbIuYYs9ZmaRPFFZPS1u+vt2LtesOIeHv3MqOcA/CwvGhp X-Received: by 2002:a17:902:988c:: with SMTP id s12-v6mr10388855plp.199.1530884240461; Fri, 06 Jul 2018 06:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530884240; cv=none; d=google.com; s=arc-20160816; b=kMF5Gnl1T4FASqZ0c15MwTAd213nNc76HRB7aNFLyfi7/PZv4eoOUk4msgcEoBda4S q3YK9GSHeGYKUmuahFk1Euf6cSZHn5VN3TJSQAp1dj1FuvTXO8ySkrWMwehK+oLNNkAe Y1Y+Kc9wTOqZ5zqCLydLY3f9Ku8aEnO2JhekybrrdijFORtsxHH8fbvu0+/0qicfdd8V EagEioLtN4XT3p8BAb/bv60Hvu9WdWtf11epX3JT8dxQM2R9mov8+bnOShOR6+mwrwA/ OzWJnfaLFxpSvO1Z0jpFLIn4BO30Xh/QXoGAdrtd9KHwri3IkJafEu8sRpJZRz+QbUgY wYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hAF0RTcXsv6CJEdEH/L0MDRHm08liBiFPxgG6g+9AYI=; b=Q5DXbbm301tNqZahTmN0eOl2A/sC0BqoTTzL8Ztpi6NHpQSKCfAQd4W3+vFqaKb63c vD8E1lXjJXDYloSKx3LEUDoRYG8PfiV8bHWHJpxnbs7SCHVYXukdZa6ef77lqOAskueu GnUafJrcfHE7yUp5RzZUuOIbjBgc+vgwfXyHq20onvfMjuTsJza89jMBQlH6C9LIbRC+ dmtc2eX5bbRoaPCJy5tDB9gMGzB8Ufq7j3wn71PN3To9wL3qctVYOBbD1QrUKcFw4bpG BSv/VzJtleNOigLxvr5jkBFkT5+dwn0jvKB/uUaPQ9Q0YxcHB0HMbdUYbhVWqaCmff0z dkyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33-v6si8109431plb.432.2018.07.06.06.37.20; Fri, 06 Jul 2018 06:37:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932944AbeGFNhT (ORCPT + 10 others); Fri, 6 Jul 2018 09:37:19 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:59645 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753729AbeGFNhP (ORCPT ); Fri, 6 Jul 2018 09:37:15 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lh6r1-1fvbIj1GAJ-00oaX4; Fri, 06 Jul 2018 15:36:50 +0200 From: Arnd Bergmann To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" Cc: Arnd Bergmann , "Gustavo A. R. Silva" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] stmmac: fix signed 64-bit division Date: Fri, 6 Jul 2018 15:36:07 +0200 Message-Id: <20180706133646.312427-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:7knJsMGAS7KwwSZw0xl8y9dA14NBAHQdD5kp0MOqjwfVBd1Di37 0QPUQ5igf9o4nx1atH/0VcTqc2gsKYSsNiAdL/rphakAwdP7+hMXydOnLJ6TbFuDcFjERi1 LnQ/4TwiG7N1fMpoqXCanmyQ0nlYrZflJ/k5BUyZdN+PES6nddcE7TpBSDl7hP2ZBel7B48 XN+feB3zF3hN4xFb/5IQg== X-UI-Out-Filterresults: notjunk:1; V01:K0:p4UxxMstQB0=:pP6USaLOfPiZZSVAGkuF5g M8OBIc0bUqK5FqPGnAeBE3YsbFJ9/iOW2MvKdHinxbCA39aXyh8JYaeANcRKFq9LMxEWAOfLj Rut0zpcMzjYY9XY6BGQW14DMqoow7DmOpcUFG4j6KTMwK5Zb6B5zift6yUnPpd55gp6q9sr+N 9KJ9EMT3WzQC/inFjxQua74sf/6lFimXy31ysKVijFJFfHCv0PIxEywcwN04f2g3iKaZebz+4 1hdG9JKe19skgR/1+Vfw9DunJToaTHs8x1OIA7k42tHA4TnNjCfkv7kwot2ett/GtcQW44Kjr EID+sEAAj99PeHN1GzlKWjT680eHi03JijGvxvD+hZOlJ4XLPsPHOVTNSwr929WpCu9SFt75I IunEHzPlZn0WRjm6LElB6MnDfC9Q4MTzYc3Fb7tF1S+ZFBdYGqPkYbDjgGoRIMOe7IZV1kiKB 3S3pjBhjxJyjKRJZgnNABwFFPS/elkzR5R5O25IPdx7QAl3NnY3PDUdVtYgCL8brHZ3RONu8T /WiWWUyPCyP1K9FO+dfNb8rGvKGdZtYhsuyrHskskYW2aCh1gb15TwD9aI6niSJiJu8jtpIye zAVfv1DjHjVC2+1p6dwopKTMjzMMFmO9JbKyQBhUJfwXUn/3xxYUOzIxiZDXaTtt9mpsOppqJ +EjYdJ9e/MOqOMoqMUtUhhE5qBMyRADvHOvr7xNiqebTry8pzQ03yWwlDNwk4LgHEvjg= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I link error on 32-bit ARM points to yet another arithmetic bug: drivers/net/ethernet/stmicro/stmmac/stmmac_tc.o: In function `tc_setup_cbs': stmmac_tc.c:(.text+0x148): undefined reference to `__aeabi_uldivmod' stmmac_tc.c:(.text+0x1fc): undefined reference to `__aeabi_uldivmod' stmmac_tc.c:(.text+0x308): undefined reference to `__aeabi_uldivmod' stmmac_tc.c:(.text+0x320): undefined reference to `__aeabi_uldivmod' stmmac_tc.c:(.text+0x33c): undefined reference to `__aeabi_uldivmod' drivers/net/ethernet/stmicro/stmmac/stmmac_tc.o:stmmac_tc.c:(.text+0x3a4): more undefined references to `__aeabi_uldivmod' follow I observe that the last change to add the 'ul' prefix was incorrect, as it did not turn the result of the multiplication into a 64-bit expression on 32-bit architectures. Further, it seems that the do_div() macro gets confused by the fact that we pass a signed variable rather than unsigned into it. This changes the code to instead use the div_s64() helper that is meant for signed division, along with changing the constant suffix to 'll' to actually make it a 64-bit argument everywhere, fixing both of the issues I pointed out. I'm not completely convinced that this makes the code correct, but I'm fairly sure that we have two problems less than before. Fixes: 1f705bc61aee ("net: stmmac: Add support for CBS QDISC") Fixes: c18a9c096683 ("net: stmmac_tc: use 64-bit arithmetic instead of 32-bit") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.9.0 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 8fedc288d138..1a96dd9c1091 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -321,18 +321,16 @@ static int tc_setup_cbs(struct stmmac_priv *priv, speed_div = (priv->speed == SPEED_100) ? 100000 : 1000000; /* Final adjustments for HW */ - value = qopt->idleslope * 1024UL * ptr; - do_div(value, speed_div); + value = div_s64(qopt->idleslope * 1024ll * ptr, speed_div); priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0); - value = -qopt->sendslope * 1024UL * ptr; - do_div(value, speed_div); + value = div_s64(-qopt->sendslope * 1024ll * ptr, speed_div); priv->plat->tx_queues_cfg[queue].send_slope = value & GENMASK(31, 0); - value = qopt->hicredit * 1024UL * 8; + value = qopt->hicredit * 1024ll * 8; priv->plat->tx_queues_cfg[queue].high_credit = value & GENMASK(31, 0); - value = qopt->locredit * 1024UL * 8; + value = qopt->locredit * 1024ll * 8; priv->plat->tx_queues_cfg[queue].low_credit = value & GENMASK(31, 0); ret = stmmac_config_cbs(priv, priv->hw,