Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp276357ybi; Wed, 29 May 2019 21:12:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBxtnhJ6HbrWS9uFDRaC51uIvUtkoVFi6A0FOww2bLE6MRLB+H+ZE6yTZqpwSP9CtNr6/b X-Received: by 2002:a62:5f42:: with SMTP id t63mr1710537pfb.83.1559189520797; Wed, 29 May 2019 21:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189520; cv=none; d=google.com; s=arc-20160816; b=JZplgWKRKjTQk84lKTJNJ7JP78Hy+t3g1sLxcZ8CK/4HgTIbF8vA8KFJlo1OQO5kKa 4npvEbGhDspCRRE3eXxekDrqcv9SUtqFZnKar6xcXt71zlUK1ZuAoyRCIaI3XD5FCO0I +JB+FMBdZBhfRyBNpt61/9M0Cs/Q13qU8/S96bf5+a9v8Q4YMiktzCXXu3AcWs+Jd5c8 +CZqiObbQJYQYNr5WS8SXKkYrzltUzWSUFXfwCGBqiIw4qoJxp2b716uug2FGW4HAXlp oHGAjCLzrOuVOm07zrv2bTi3QCkcv3ir55m1psR8JHAF9h5Bc3EhnAEbyW5F2FuJCpzY /gmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date; bh=RgBvtow3SG/L3onZEkvF3GT1l11iLnZpHBpHe6+yVVA=; b=nWnQhumMx29VkjA/Jv5dN2A0fChJku/xlwWHQvNIk8CAqmY5aT/Pzm8yUB1YY7BMvf nGdF0nYj7QfO0T50fUBhyWFO1tVOy5qx4tRNA/CCQMXLtZEJAQaylk/9iddrWBAilm7Q mxAhmttRJECUwN3Lra5fEow5US+SRlK6PMaPatyHm2Buu4mTKF/ew0Ga79VuuYmKyxde BM8uqqWg5Tqo4CwIv7xoBMRZ4v7OvY9F6EHS2BBZoY4zus3q1KeSvVrCm55i5I0qOLC2 RtKMgz36YcFq7H2NTRjFFEgPW0THPJgBa0hq0nGwdaG+CjEa8QCZXTFwMLUDaTPmP0Eg qhXw== 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 z33si1888906pgk.516.2019.05.29.21.11.44; Wed, 29 May 2019 21:12:00 -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 S1728635AbfE3EJW (ORCPT + 99 others); Thu, 30 May 2019 00:09:22 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42476 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbfE3EJT (ORCPT ); Thu, 30 May 2019 00:09:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id r22so3047870pfh.9 for ; Wed, 29 May 2019 21:09:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=RgBvtow3SG/L3onZEkvF3GT1l11iLnZpHBpHe6+yVVA=; b=SigOXi6vok01p/DElvycZ2DP261VnH9DpaGGk5REMSbPepOBj/LeSAdm9gG4pxFx9V jC1u4EERcEcCnkpuvcglK9mFxhW6N0rJBt35bk+IBoMxBOF6GKLVdveevIupSnPDiu+I m8rphBeXiDsi9Cy5ZwyzT0Tr3XyS5Zl+7N2xolgvLEQvNFpT3mY0wvVt1eGJjZkXcAq+ mZT/hCC/DsBWWOxUqEEL5bWmhDgtqabJ1opGzpnVaiOJXcRLyBr2Juo/2xnj6oIKg00b E4icAxQrF/eKxBMmU2TjJhcWCslBqk/eLNqc1444ZkEFgxB6zlNEkPtYGPpBdy+F/5VD Gnkg== X-Gm-Message-State: APjAAAXLnYzE9bUdjLVYFrUX16m+UV4bJ15McXmj2VjpBMSuc83F1Oag qyjxtqV7x0wpt2ch9vQLdIqHLA== X-Received: by 2002:aa7:8e46:: with SMTP id d6mr1664198pfr.91.1559189358490; Wed, 29 May 2019 21:09:18 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id v93sm1035350pjb.6.2019.05.29.21.09.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 21:09:17 -0700 (PDT) Date: Wed, 29 May 2019 21:09:17 -0700 (PDT) X-Google-Original-Date: Wed, 29 May 2019 20:42:12 PDT (-0700) Subject: Re: [PATCH] riscv: Fix udelay in RV32. In-Reply-To: <381ee6950c84b868ca6a3c676eb981a1980889a3.1559035050.git.nickhu@andestech.com> CC: greentime@andestech.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, nickhu@andestech.com, green.hu@gmail.com From: Palmer Dabbelt To: nickhu@andestech.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 May 2019 02:26:49 PDT (-0700), nickhu@andestech.com wrote: > 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); Reviewed-by: Palmer Dabbelt