Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756596Ab0FCWyT (ORCPT ); Thu, 3 Jun 2010 18:54:19 -0400 Received: from mail.vyatta.com ([76.74.103.46]:44055 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756369Ab0FCWyR (ORCPT ); Thu, 3 Jun 2010 18:54:17 -0400 Date: Thu, 3 Jun 2010 15:54:14 -0700 From: Stephen Hemminger To: Linus Torvalds Cc: Andrew Morton , Alan Cox , linux-kernel@vger.kernel.org Subject: Re: floppy driver assumes INITIAL_JIFFIES == 0 Message-ID: <20100603155414.6ebd1d78@nehalam> In-Reply-To: References: <20100603101501.5e5d7148@nehalam> <20100603120313.10a73b20@nehalam> <20100603144913.24828629@nehalam> Organization: Vyatta X-Mailer: Claws Mail 3.7.5 (GTK+ 2.20.1; 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 Content-Length: 2207 Lines: 46 On Thu, 3 Jun 2010 15:33:23 -0700 (PDT) Linus Torvalds wrote: > > > On Thu, 3 Jun 2010, Linus Torvalds wrote: > > > > > So still a race that shows up with KVM (fast floppy?) and manifests > > > as floppy_ready or reset_interrupt OOPS. > > > > Yes, it's quite possible that the Linux floppy driver is simply broken by > > any floppy device that basically responds immediately to a command with an > > interrupt. And considering how few people use floppies, I do expect that > > driver to get _worse_ rather than better in the future. > > Having looked at that driver some more, I can inf act pretty much > guarantee it. The locking is rather baroque. It has a "floppy_lock", but > that only protects certain small parts. In particular, it looks like the > irq handler and the timers do _not_ take it, and that's where most of the > real work is done. > > And in fact, that does look broken. The interrupt handler really does a > "schedule_work()" to schedule the actual handler outside of irq context, > and I don't see any serialization between the timers that file and the > handler running. > > That driver used to be this state machine that ran entirely from interrupt > context, where one interrupt handler would set the state for the next one > (that's what the "do_floppy" thing is for). But then it became bottom > halves, and now it's using schedule_work() instead - and at the same time, > the _timers_ haven't really changed. Those run in timer context, and can > thus interrupt the work thing. > > It always was a disgusting driver. Now it's just even more so. And yes, > I'm sure it's full of races that are largely hidden by the fact that real > floppy hardware is so slow that you can never hit them. > > Looking too much at that driver will cause PTSD. I have to look away. Thank you for confirming my suspicions. Given the state of destruction there, bug fixing is like playing Jenga. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/