Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4860143ybi; Tue, 28 May 2019 03:48:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwr8ZZNBnlELZt1d73GY6fvDfuG1I9sGsu5Igyd6T6pgCUpZ2f+U/JxKt0rq8zfc/+muTQ/ X-Received: by 2002:a17:902:8c8c:: with SMTP id t12mr58740109plo.116.1559040536294; Tue, 28 May 2019 03:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559040536; cv=none; d=google.com; s=arc-20160816; b=frWeqdK2kxBmi20zU8IENM1Js5N5de/MZg5ilNtqr42RpqmnHshbTT0gIPgoVLs6y1 K0GT3+jLeXQGHclCVycrlueFgwrozFBjHXttnNx3QyVbFn0lltmWVT9IEQypiqs+4EwT lddh/O5sN0JeynYYCQf8mheYPWzGAm/8ZA4N40HRjeJi3S815OeWcz9bVXFwOhB3r9An 9tSrAYDKjvCpeKLpR4Pe8Z3+wmBXjdioI0jHyz6bBAJkd4xkSTljlYCIaxZFHbfBplHX mlN0elfz68sAKPKrY96gVw9wRC3rerdE32WNshUspih5GOQWyHG/IqRB3ylO5d/orkNn nAtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=p36xEsJs9QaHoREVd+2TyAm2ST1yvviOzVzHDsOs1yw=; b=cBdbY5bOCZWfuqIGbENJ7PFIBCJiBgzsfLoFbccnfpHMubeTyLRVt7jdPhkA/fOKtr 85D9qBPbsfhx8BMo611xIqrxgCok5SypaI/6F24IhsCTXPOyoUzo2oIo/mn2nACArElj HuufVC0o1Q6sOve2RyGsVo8K7Oj1U6J15bJrdpszJB34CBaPkSCVD8DkumqbRnaZ4IIQ wVaD/wmlqpg75ixVujQmBQKeiOcnXpvtc+qlbQS7VsUF3Aud3KJeP7Xdep0UiEgzxm+X pzdwHoeTxe1x7myh4fWLqWXDhx0fv7wog9IsYJJqfGOlqPZK2WJ2IwVIOXwmaGUwPSfW ZTVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 x9si3065119pjv.49.2019.05.28.03.48.40; Tue, 28 May 2019 03:48:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfE1J65 (ORCPT + 99 others); Tue, 28 May 2019 05:58:57 -0400 Received: from 59-120-53-16.HINET-IP.hinet.net ([59.120.53.16]:49982 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726334AbfE1J64 (ORCPT ); Tue, 28 May 2019 05:58:56 -0400 X-Greylist: delayed 1899 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 May 2019 05:58:55 EDT Received: from ATCSQR.andestech.com (localhost [127.0.0.2] (may be forged)) by ATCSQR.andestech.com with ESMTP id x4S9LnXV081387 for ; Tue, 28 May 2019 17:21:49 +0800 (GMT-8) (envelope-from nickhu@andestech.com) Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id x4S9LYv8081364; Tue, 28 May 2019 17:21:34 +0800 (GMT-8) (envelope-from nickhu@andestech.com) Received: from atcsqa06.andestech.com (10.0.15.65) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Tue, 28 May 2019 17:27:00 +0800 From: Nick Hu To: , , , CC: Nick Hu , Subject: [PATCH] riscv: Fix udelay in RV32. Date: Tue, 28 May 2019 17:26:49 +0800 Message-ID: <381ee6950c84b868ca6a3c676eb981a1980889a3.1559035050.git.nickhu@andestech.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.15.65] X-DNSRBL: X-MAIL: ATCSQR.andestech.com x4S9LYv8081364 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In RV32, udelay would delay the wrong cycle. When it shifts right "UDELAY_SHITFT" bits, it either delays 0 cycle or 1 cycle. It only works correctly in RV64. Because the 'ucycles' always needs to be 64 bits variable. Signed-off-by: Nick Hu --- arch/riscv/lib/delay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/lib/delay.c b/arch/riscv/lib/delay.c index dce8ae24c6d3..da847f49fb74 100644 --- a/arch/riscv/lib/delay.c +++ b/arch/riscv/lib/delay.c @@ -88,7 +88,7 @@ EXPORT_SYMBOL(__delay); void udelay(unsigned long usecs) { - unsigned long ucycles = usecs * lpj_fine * UDELAY_MULT; + unsigned long long ucycles = (unsigned long long)usecs * lpj_fine * UDELAY_MULT; if (unlikely(usecs > MAX_UDELAY_US)) { __delay((u64)usecs * riscv_timebase / 1000000ULL); -- 2.17.0