Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp836894ybi; Fri, 12 Jul 2019 05:28:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtrS+ld/JqI+nZNrlscv+rJs6QHbPe7OSo48SziovLZyn76NSA45mUnaTD8CpRJeLc2GLa X-Received: by 2002:a63:e1e:: with SMTP id d30mr10574880pgl.100.1562934507252; Fri, 12 Jul 2019 05:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934507; cv=none; d=google.com; s=arc-20160816; b=Z9Q5Q1W9FHMLmPef50NBZvhlG38TmnWq52Ir9tD6nf9cS3fLFtxdbPiwFzt6TVaTMW caGCGzE9VlanrD2ZrR7yh/Ihrusi3VCLandyVt/KTkBDnOQ9UC/Jex+TtUOPgwfi2Kwp /juFFlqDHKS/yYmPMNcTruLxHn96lnNmh0GvEEAiazw5pECFmmwNayh9ELX+w39mqVc8 C0sYyX9r7p4VGHSoN/n1DBnmGMYeGvTsHPWLPY/rBMNiCou9fXV77Q0q+4CHq37f0t2C 0SguRokvUShbMjTt0q2UCJDHtPSCIamwUSfgJk+Qns02xLpT9trYTVPtgOxo09P8AJqK Spog== 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=LIOUsMqPf+ZA2Rv+H2FMfmXs3Er710Sx291jaMDMwiGMhZBbwjd8SOseSmX8Gnu/g5 aJmYNh9WG039yBoCY2sQQvwCGvyUGoiAeDv3nBLIit+4C4CxVkU2FMsGVCDeeL870GM5 M37co8R9lQOIlcmG2IrSkSOH5iT6qHUBmekcUH5bim2hVLjYKjis6BCi0TlCqak/fO/s lwIbq6a6WbCC8ZxL8WfGMGSpjolIcEEWSM9BlJbEadN5/tz7wTiYD1oHOw6NS5g8rwwb 8VCj9n4fckl7QfMhMPO1iWCqiMCA1bNzZdrWEkadrLjJrTi4Io9AcBwsASEcffy7F6ik 1i3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D0SDyr3A; 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 m9si7630345pgq.336.2019.07.12.05.28.11; Fri, 12 Jul 2019 05:28:27 -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=D0SDyr3A; 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 S1728537AbfGLM1B (ORCPT + 99 others); Fri, 12 Jul 2019 08:27:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:38746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728523AbfGLM04 (ORCPT ); Fri, 12 Jul 2019 08:26: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 8B49421019; Fri, 12 Jul 2019 12:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934416; bh=AyMrDlvK9JOOsXx47vtxuqCDRX8Yg+Jq+LLv0NVejhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D0SDyr3Aju6+KGb4vnKI9Zk+7f/Q/F9hZ3A0E4FB5bL7IBOfQ+xDR0mFSaOa/nPt8 4x3yUl67i/w0jyCZjFSYWPJHqARAOQQqic24ymsYhDy2w5RX22EgjgnsEVPCAg0usA FXp40UVSL4U+xUpxERlZAicS8lysZLQ/SGm1nYT4= 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 5.1 048/138] riscv: Fix udelay in RV32. Date: Fri, 12 Jul 2019 14:18:32 +0200 Message-Id: <20190712121630.508073629@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@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