On 4 Apr 2003, Michel Dänzer wrote: > > But why does this cause a hang? > > I'm not sure, maybe some kernels and/or machines don't like the > interrupt being enabled without the handler being installed. I couldn't > reproduce the problem on my Macs.
Let's walk through it. First, the setup conditions: - let's say you have your graphics card on irq X. - it so happens that the network controller is _also_ on irq X, and the network driver has registered a interrupt handler for that irq. Ok. Now look at what happens in two cases: Case 1: enable interrupts before installing the handler - no display irq handler, but interrupt X comes in. - the irq dispatch sends the interrupt to the network driver, which has told it that it is interested in irq X. - the network driver looks at its hardware state, and most likely returns without doing anything, since the network card told it that there was nothing to do. - the interrupt dispatch returns. - MACHINE GOES BOOM AND HANGS! PCI interrupts are level-triggered, so the hardware will re-assert the interrupt that is still pending , and we will forever re-do this endless loop of calling the network driver, which will not do anything. Nothing will ever acknowledge the interrupt, and nothign will ever make it go away. And since the CPU is busy taking interrupts, the code sequence that _caused_ the lock-up in the first place will also never make any progress, and will never get to the point where it registers the video card interrupt handler. Now, look at case 2: Case 2: the driver installs the handler before it enables video card interrupts: - irq X comes in, the irq dispatch logic dispatches it to both the network driver and the the DRI driver. The network driver still has nothing to do (but the dispatcher can't know that - irq X is irq X, and there's no way to know them apart from a higher level), but the DRI driver will do the right thing AND THEN IT WILL ACK IT SO THAT IT SHUTS UP! - the irq dispatch returns, and things continue happily onward. See? IT IS A *MAJOR* BUG TO ENABLE INTERRUPTS BEFORE YOU HAVE INSTALLED THE HANDLER FOR IT. (And yes, it sometimes just happens to work by pure luck. Maybe you don't have any pending events, so enabling interrupts won't _do_ anything. This is possibly why things hang on the _restart_ - because the first invocation of X may have left stuff pending). It also just "happens" to work if you don't have shared interrupts (because then the irq dispatch logic will just mask off the irq totally since there are no interrupt handlers at all for it). Again, that's just pure luck, and nothing else. It's still a totally and utterly broken driver, now it's just that it happens to work perfectly fine on some hardware. Linus ------------------------------------------------------- This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ _______________________________________________ Dri-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dri-devel