From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752424AbbK2K0D (ORCPT ); Sun, 29 Nov 2015 05:26:03 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:46373 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751602AbbK2KZ7 (ORCPT ); Sun, 29 Nov 2015 05:25:59 -0500 Date: Sun, 29 Nov 2015 21:25:53 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Ondrej Zary , "James E.J. Bottomley" , Michael Schmitz , Linux/m68k , scsi , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 22/71] ncr5380: Eliminate selecting state In-Reply-To: Message-ID: References: <20151118083455.331768508@telegraphics.com.au> <201511252259.26792.linux@rainbow-software.org> <201511262035.40920.linux@rainbow-software.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 29 Nov 2015, Geert Uytterhoeven wrote: > This still heavily depends on the processing time spent in > NCR5380_read(). You should never use a value derived from > loops_per_jiffy for a non-empty loop, Sure but the time-out condition isn't supposed to be precise. Plus/minus a jiffy is no problem. Plus/minus a second is no good. > as it may take much longer. Always compare with an maximum end time > instead. That can't work with interrupts disabled, which was the problem I was trying to solve by use of loops_per_jiffy. NCR5380_poll_politely() in mainline doesn't work with interrupts disabled either, hence patch 21. > > E.g.: > > end = jiffies + 2; /* 1 jiffie + 1 safeguard */ > do { > if ((NCR5380_read(reg1) & bit1) == val1) > return 0; > cpu_relax(); > } while (time_before(jiffies, end); > > And a similar loop for "Busy-wait for up to 20 ms". Interrupts may be disabled during that loop also. Please refer to (and/or respond to) patch 21, "ncr5380: Sleep when polling, if possible", in which these changes were made. -- > > Gr{oetje,eeting}s, > > Geert >