Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp853372ybi; Fri, 12 Jul 2019 05:44:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxne24wipv/h0fn+eIYiMP0JZcF6bcTAjUPOzN2aiWVEPvo9+fbIxU/O/Y9wCIJAPfDpqq X-Received: by 2002:a17:90a:bf0e:: with SMTP id c14mr11046991pjs.55.1562935477277; Fri, 12 Jul 2019 05:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935477; cv=none; d=google.com; s=arc-20160816; b=jtXSfpC+m+V102RSin9XRESVWFsBVFh1Jfe51nTJPHPNRRJpCXSaci0GARNVsatYoL KNYbL7SfU5D27ZmFEeDGsx1GkZy0O81ruLk18eGNyymk0hOt1dXmnJK6UFymksRVHDNv 1uUobaNA5AhywwJGE1NZ83KYRGeq2c/oWF2ZnaqxC3eB1ksqYWzQHrLoHghfXFDoW7tS lgCkSvuXpDgqyT7xfLT/hx8AuS1pSFBpkeLLXTZw0mMCT5dzPX0aZ/lXNMt+VBAbt2Fz i1ArAk5VtLOT2J6UKyxdPmRi+hcEkC9udOWd01SWudJ3Yuad/RvtgWxpLtVaqM9E6uHr 26kQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9XGSQDO/v9x35NPbyaM1QYzAGue7o9aZyVqNU2eeg10=; b=gNelmarbnLfmSomoNP4OQaKoAlfZDppxXgKadrbRKLA/A8W2yjY/L0wY0ITkGBoU1j KeNxrlXqhvmdXOdCz4J1jSUAIOOqpzfpAYvIPghmt353yj0qZ2C8AdOlngH4mmfzKl9C 02imqKMp7U8IPzMC39vQq4PPrr9xAlgXiJ6RCqGEDB3OQaBymKRDahMSzPkxEdYNkL+A 0vDTHAPRbdEPsRxT2LG1dedOAVPlYyg8AQCm8FQW74GM/qASul279D8tKltyV/homde3 JbHwdV4/9ZrvjnHj09KtfvRRMpdT+BG3tU8jaRCc0+hM+juTAcoBKLvsgjNVDk+GZLjO QguA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2n+iyTbd; 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 d33si7538156pla.417.2019.07.12.05.44.22; Fri, 12 Jul 2019 05:44:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=2n+iyTbd; 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 S1727492AbfGLMU6 (ORCPT + 99 others); Fri, 12 Jul 2019 08:20:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:54614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727482AbfGLMU4 (ORCPT ); Fri, 12 Jul 2019 08:20:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8D31208E4; Fri, 12 Jul 2019 12:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934055; bh=AyMrDlvK9JOOsXx47vtxuqCDRX8Yg+Jq+LLv0NVejhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2n+iyTbdl3wElYHCXQAuyDVu22w1mpU+gE9IM9XvY/5dQ7D0ZdNhFNWdKjiKJhZ9H q97Sh9Xo9oX7ZTTd3eaMSJo1C8dJKycHM0ZAt+HUTSGkCu/txcqTvXHpQClqReoyye Gfr6LN9xvPTsG+DP2sFk1w2EBB9GoAOGA+O8KS9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Hu , Palmer Dabbelt , Paul Walmsley , Sasha Levin Subject: [PATCH 4.19 30/91] riscv: Fix udelay in RV32. Date: Fri, 12 Jul 2019 14:18:33 +0200 Message-Id: <20190712121622.986765867@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121621.422224300@linuxfoundation.org> References: <20190712121621.422224300@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d0e1f2110a5eeb6e410b2dd37d98bc5b30da7bc7 ] In RV32, udelay would delay the wrong cycle. When it shifts right "UDELAY_SHIFT" 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 Reviewed-by: Palmer Dabbelt [paul.walmsley@sifive.com: fixed minor spelling error] Signed-off-by: Paul Walmsley Signed-off-by: Sasha Levin --- 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..ee6853c1e341 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; + u64 ucycles = (u64)usecs * lpj_fine * UDELAY_MULT; if (unlikely(usecs > MAX_UDELAY_US)) { __delay((u64)usecs * riscv_timebase / 1000000ULL); -- 2.20.1