From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934106AbdKBQMR (ORCPT ); Thu, 2 Nov 2017 12:12:17 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:40922 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933941AbdKBQMP (ORCPT ); Thu, 2 Nov 2017 12:12:15 -0400 Date: Thu, 2 Nov 2017 17:12:13 +0100 From: Boris Brezillon To: Baruch Siach Cc: Marc Gonzalez , Mark Rutland , Alan Cox , Russell King , Jonathan Austin , Arnd Bergmann , Mason , Peter Zijlstra , Will Deacon , Michael Turquette , Nicolas Pitre , Stephen Boyd , LKML , Steven Rostedt , Douglas Anderson , Kevin Hilman , John Stultz , linux-mtd@lists.infradead.org, Thomas Gleixner , Linus Torvalds , Ingo Molnar , Linux ARM Subject: Re: [RFC] Improving udelay/ndelay on platforms where that is possible Message-ID: <20171102171213.6449268c@bbrezillon> In-Reply-To: <20171101194822.hd76z7zjazlqbsmy@tarshish> References: <20171101175325.2557ce85@alans-desktop> <4b707ce0-6067-ab36-e167-1acf348d26bf@free.fr> <20171101194822.hd76z7zjazlqbsmy@tarshish> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Nov 2017 21:48:22 +0200 Baruch Siach wrote: > Hi Marc, > > On Wed, Nov 01, 2017 at 08:03:20PM +0100, Marc Gonzalez wrote: > > On 01/11/2017 18:53, Alan Cox wrote: > > > For that matter given the bad blocks don't randomly change why not cache > > > them ? > > > > That's a good question, I'll ask the NAND framework maintainer. > > Store them where, by the way? On the NAND chip itself? > > Yes. In the bad block table (bbt). See drivers/mtd/nand/nand_bbt.c. Yes, you can cache this information in a bad block table stored on the flash. But still, the ndelay()/udelay() problem remains: reading the out-of-band area of each eraseblock to re-create the bad block table is just one use case. This ndelay() is something you can have on all kind of read/write operations. As Thomas Gleixner stated, this is not really needed on modern NAND controllers which take care of various timing constraints internally, but still, we have some controllers that are not that smart, and we have to support them. I'm not concerned about performances here, and if I'm told that we should turn all ndelay() calls into usleep_range() ones, then I'm perfectly fine with that, but I need a guarantee that when I say "I want to wait at least X ns/us", the function does not return before that time has expired. Not sure if that would work, but maybe we could create a wrapper like void nand_ndelay(unsigned long nanoseconds) { ktime_t end = ktime_add_ns(ktime_get(), nanoseconds); do { ndelay(nanoseconds); } while (ktime_before(ktime_get(), end)); }