From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4194EC77B73 for ; Thu, 20 Apr 2023 23:41:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E2A285F52; Fri, 21 Apr 2023 01:41:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 9C3838605E; Fri, 21 Apr 2023 01:41:32 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id E458486315 for ; Fri, 21 Apr 2023 01:41:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F295F1480; Thu, 20 Apr 2023 16:42:12 -0700 (PDT) Received: from slackpad.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5EF963F5A1; Thu, 20 Apr 2023 16:41:28 -0700 (PDT) Date: Fri, 21 Apr 2023 00:41:17 +0100 From: Andre Przywara To: John Sanpe Cc: jagan@amarulasolutions.com, u-boot@lists.denx.de, Icenowy Zheng , Jernej =?UTF-8?B?xaBrcmFiZWM=?= Subject: Re: [PATCH] suniv: fix dramc autofresh freq calculation issue Message-ID: <20230421004117.014e471b@slackpad.lan> In-Reply-To: <20230320005959.176726-1-sanpeqf@gmail.com> References: <20230320005959.176726-1-sanpeqf@gmail.com> Organization: Arm Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On Mon, 20 Mar 2023 08:59:59 +0800 John Sanpe wrote: Hi John, thanks for sending this, and sorry for the delay. > External use mhz to express frequency, autofresh use hz, > no unit conversion is performed when calling, cause dram > instability at low frequency. What low frequency? Are you running it with less than 156 MHz? Anyway I had a deeper look at this DRAM driver a while ago, and made some significant cleanups. One of them affects dram_set_autofresh_cycle(), which is ... weird ... to say at least. Not only does it support specifying the frequency both in MHz or Hz, it also uses some quite obfuscated arithmetic to avoid divisions. This is what I made of this function: https://github.com/apritzel/u-boot/commit/729d3c61b62 This is part of the whole cleanup series, which is not quite ready yet, but I put a WIP branch up anyway: https://github.com/apritzel/u-boot/commits/suniv-dram-WIP As a bonus this allows to run the DRAM at 204 MHz, with JEDEC timings, which was not only quite stable for me (ran memtester over the weekend), but also provided quite some performance advantage. It would be nice if you could give this series a go, and see if it works for you. Feel free to play around with the frequency, it should now program optimised timings for each rate. Regarding your patch: I am afraid this is somewhat obsoleted by my series, also it seems to just paper over the actual problems, which probably are in the crude arithmetic. Cheers, Andre > Incorporated xboot repair patch for this driver. > > Signed-off-by: John Sanpe > --- > arch/arm/mach-sunxi/dram_suniv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm/mach-sunxi/dram_suniv.c b/arch/arm/mach-sunxi/dram_suniv.c > index 3aa3ce7627..830fa7895d 100644 > --- a/arch/arm/mach-sunxi/dram_suniv.c > +++ b/arch/arm/mach-sunxi/dram_suniv.c > @@ -310,7 +310,7 @@ static u32 dram_get_dram_size(struct dram_para *para) > para->size = 64; > else > para->size = 32; > - dram_set_autofresh_cycle(para->clk); > + dram_set_autofresh_cycle(para->clk * 1000000); > para->access_mode = 0; > dram_para_setup(para); >