Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756131Ab0FCWiJ (ORCPT ); Thu, 3 Jun 2010 18:38:09 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:56148 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755263Ab0FCWiI (ORCPT ); Thu, 3 Jun 2010 18:38:08 -0400 Date: Thu, 3 Jun 2010 15:33:23 -0700 (PDT) From: Linus Torvalds To: Stephen Hemminger cc: Andrew Morton , Alan Cox , linux-kernel@vger.kernel.org Subject: Re: floppy driver assumes INITIAL_JIFFIES == 0 In-Reply-To: Message-ID: References: <20100603101501.5e5d7148@nehalam> <20100603120313.10a73b20@nehalam> <20100603144913.24828629@nehalam> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) 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 Content-Length: 1938 Lines: 42 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. Linus -- 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/