linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: local APIC may cause XFree86 hang
@ 2002-11-14  0:29 Nakajima, Jun
  2002-11-14  0:48 ` Linus Torvalds
  0 siblings, 1 reply; 11+ messages in thread
From: Nakajima, Jun @ 2002-11-14  0:29 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel



Are we disabling vm86 code to access to PIT or PIC? I saw some video ROM
code (either BIOS call or far call) did access PIT, confusing the OS.

Thanks,
Jun

> -----Original Message-----
> From: torvalds@transmeta.com [mailto:torvalds@transmeta.com]
> Sent: Wednesday, November 13, 2002 3:53 PM
> To: linux-kernel@vger.kernel.org
> Subject: Re: local APIC may cause XFree86 hang
> 
> In article <15826.53818.621879.661253@kim.it.uu.se>,
> Mikael Pettersson  <mikpe@csd.uu.se> wrote:
> >
> >Does XFree86 (its core or particular drivers) use vm86() to
> >invoke, possibly graphics card specific, BIOS code?
> >That would explain the hangs I got. The fix would be to
> >disable the local APIC around vm86()'s BIOS calls, just like
> >we now disable it before APM suspend.
> 
> It does.
> 
> HOWEVER, vm86() mode is very very different from APM, which uses real
> mode.  External interrupts in vm86 mode will not be taken inside vm86
> mode - and disabling the local timer (by disabling the APIC) around a
> vm86 mode is definitely _not_ a good idea, since it would be an instant
> denial-of-service attack on SMP machines (the PIT timer only goes to
> CPU0, so we depend on the local timer to do process timeouts etc on
> other CPUs).  The vm86 code might just be looping forever.
> 
> In other words, if it is really vm86-related, then
>  (a) it's a CPU bug
>  (b) we're screwed
> 
> I bet it's something else.  Possibly just timing-specific (the APIC
> makes interrupts much faster), but also possibly something to do with
> the VGA interrupt (some XFree86 drivers actually use the gfx interrupts
> these days)
> 
> 		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/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: local APIC may cause XFree86 hang
  2002-11-14  0:29 local APIC may cause XFree86 hang Nakajima, Jun
@ 2002-11-14  0:48 ` Linus Torvalds
  0 siblings, 0 replies; 11+ messages in thread
From: Linus Torvalds @ 2002-11-14  0:48 UTC (permalink / raw)
  To: Nakajima, Jun; +Cc: linux-kernel


On Wed, 13 Nov 2002, Nakajima, Jun wrote:
> 
> Are we disabling vm86 code to access to PIT or PIC? I saw some video ROM
> code (either BIOS call or far call) did access PIT, confusing the OS.

Well, the kernel itself doesn't actually disable/enable anything, it 
leaves that decision to the caller. 

XFree86 obviously does have IO rights, and I suspect it may allow the 
video BIOS to do just about anything, simply because it doesn't have much 
choise (the video bios clearly needs a lot of IO privileges too). So yes, 
that could easily confuse the OS if it happens, but it should be 
independent of IO-APIC vs not.

		Linus


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: local APIC may cause XFree86 hang
  2002-11-14  8:08   ` george anzinger
@ 2002-11-14 14:27     ` Alan Cox
  0 siblings, 0 replies; 11+ messages in thread
From: Alan Cox @ 2002-11-14 14:27 UTC (permalink / raw)
  To: george anzinger; +Cc: Linus Torvalds, Nakajima, Jun, Linux Kernel Mailing List

On Thu, 2002-11-14 at 08:08, george anzinger wrote:
> Linus Torvalds wrote:
> > 
> > On Wed, 13 Nov 2002, Nakajima, Jun wrote:
> > >
> > > The one instance I saw was that the BIOS was reading 8254 in a tight loop
> > > for a calibration purpose, and it was assuming the time proceeded in a
> > > constant speed, to exit the loop. In other words, it never assumed it could
> > > get interrupts. To vm86, interrupts are invisible, but they have impacts on
> > > the actual speed.
> > 
> > That sound slike a perfectly ok thing to do - apart from the hw latching
> > which might confuse the kernel.
> 
> Yes, it has been speculated that some "time warps" were
> caused by "someone" reading only one of the two bytes from
> the PIT.  It puts the following reads out of sync.  If this
> was caused by an interrupt (which, of course, is where the
> PIT is read by the kernel) between two reads, it could well
> cause the "time warps" that have been observed.

The 2.5 kernel also has another bug in the way it handles the latches
reading the exact count value they wrap on. Some chips expose that value
momentarily before resetting


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: local APIC may cause XFree86 hang
  2002-11-14  1:38 ` Linus Torvalds
@ 2002-11-14  8:08   ` george anzinger
  2002-11-14 14:27     ` Alan Cox
  0 siblings, 1 reply; 11+ messages in thread
From: george anzinger @ 2002-11-14  8:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Nakajima, Jun, linux-kernel

Linus Torvalds wrote:
> 
> On Wed, 13 Nov 2002, Nakajima, Jun wrote:
> >
> > The one instance I saw was that the BIOS was reading 8254 in a tight loop
> > for a calibration purpose, and it was assuming the time proceeded in a
> > constant speed, to exit the loop. In other words, it never assumed it could
> > get interrupts. To vm86, interrupts are invisible, but they have impacts on
> > the actual speed.
> 
> That sound slike a perfectly ok thing to do - apart from the hw latching
> which might confuse the kernel.

Yes, it has been speculated that some "time warps" were
caused by "someone" reading only one of the two bytes from
the PIT.  It puts the following reads out of sync.  If this
was caused by an interrupt (which, of course, is where the
PIT is read by the kernel) between two reads, it could well
cause the "time warps" that have been observed.

George
> 
> When enabling the local APIC, Linux doesn't actually disable legacy PIT
> interrupts, so again I don't really see what the apparent connection
> between the hang and the APIC is. So I'd still suspect it's more
> timing-related than anything else.
> 
>                 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/

-- 
George Anzinger   george@mvista.com
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: local APIC may cause XFree86 hang
  2002-11-13 22:29 Mikael Pettersson
  2002-11-13 23:19 ` Alan Cox
  2002-11-13 23:52 ` Linus Torvalds
@ 2002-11-14  7:58 ` Gregoire Favre
  2 siblings, 0 replies; 11+ messages in thread
From: Gregoire Favre @ 2002-11-14  7:58 UTC (permalink / raw)
  To: linux-kernel

Hello,

I don't know if it's related or not, but under .47 if I enable fb,
switching from X to the console hangs my system, with just VGA console I
don't have this problem (and anyway, with my Mach 64 card since a lots
of 2.5 the console is not usable: the white is replaced by an ilisible
blue???).

Have a great day,

	Grégoire
________________________________________________________________
http://ulima.unil.ch/greg ICQ:16624071 mailto:greg@ulima.unil.ch

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: local APIC may cause XFree86 hang
  2002-11-14  1:16 Nakajima, Jun
@ 2002-11-14  1:38 ` Linus Torvalds
  2002-11-14  8:08   ` george anzinger
  0 siblings, 1 reply; 11+ messages in thread
From: Linus Torvalds @ 2002-11-14  1:38 UTC (permalink / raw)
  To: Nakajima, Jun; +Cc: linux-kernel


On Wed, 13 Nov 2002, Nakajima, Jun wrote:
> 
> The one instance I saw was that the BIOS was reading 8254 in a tight loop
> for a calibration purpose, and it was assuming the time proceeded in a
> constant speed, to exit the loop. In other words, it never assumed it could
> get interrupts. To vm86, interrupts are invisible, but they have impacts on
> the actual speed. 

That sound slike a perfectly ok thing to do - apart from the hw latching
which might confuse the kernel.

When enabling the local APIC, Linux doesn't actually disable legacy PIT
interrupts, so again I don't really see what the apparent connection
between the hang and the APIC is. So I'd still suspect it's more
timing-related than anything else.

		Linus


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: local APIC may cause XFree86 hang
@ 2002-11-14  1:16 Nakajima, Jun
  2002-11-14  1:38 ` Linus Torvalds
  0 siblings, 1 reply; 11+ messages in thread
From: Nakajima, Jun @ 2002-11-14  1:16 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel


The one instance I saw was that the BIOS was reading 8254 in a tight loop
for a calibration purpose, and it was assuming the time proceeded in a
constant speed, to exit the loop. In other words, it never assumed it could
get interrupts. To vm86, interrupts are invisible, but they have impacts on
the actual speed. 

Jun

> -----Original Message-----
> From: Linus Torvalds [mailto:torvalds@transmeta.com]
> Sent: Wednesday, November 13, 2002 4:48 PM
> To: Nakajima, Jun
> Cc: linux-kernel@vger.kernel.org
> Subject: RE: local APIC may cause XFree86 hang
> 
> 
> On Wed, 13 Nov 2002, Nakajima, Jun wrote:
> >
> > Are we disabling vm86 code to access to PIT or PIC? I saw some video ROM
> > code (either BIOS call or far call) did access PIT, confusing the OS.
> 
> Well, the kernel itself doesn't actually disable/enable anything, it
> leaves that decision to the caller.
> 
> XFree86 obviously does have IO rights, and I suspect it may allow the
> video BIOS to do just about anything, simply because it doesn't have much
> choise (the video bios clearly needs a lot of IO privileges too). So yes,
> that could easily confuse the OS if it happens, but it should be
> independent of IO-APIC vs not.
> 
> 		Linus

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: local APIC may cause XFree86 hang
  2002-11-13 22:29 Mikael Pettersson
  2002-11-13 23:19 ` Alan Cox
@ 2002-11-13 23:52 ` Linus Torvalds
  2002-11-14  7:58 ` Gregoire Favre
  2 siblings, 0 replies; 11+ messages in thread
From: Linus Torvalds @ 2002-11-13 23:52 UTC (permalink / raw)
  To: linux-kernel

In article <15826.53818.621879.661253@kim.it.uu.se>,
Mikael Pettersson  <mikpe@csd.uu.se> wrote:
>
>Does XFree86 (its core or particular drivers) use vm86() to
>invoke, possibly graphics card specific, BIOS code?
>That would explain the hangs I got. The fix would be to
>disable the local APIC around vm86()'s BIOS calls, just like
>we now disable it before APM suspend.

It does.

HOWEVER, vm86() mode is very very different from APM, which uses real
mode.  External interrupts in vm86 mode will not be taken inside vm86
mode - and disabling the local timer (by disabling the APIC) around a
vm86 mode is definitely _not_ a good idea, since it would be an instant
denial-of-service attack on SMP machines (the PIT timer only goes to
CPU0, so we depend on the local timer to do process timeouts etc on
other CPUs).  The vm86 code might just be looping forever.

In other words, if it is really vm86-related, then 
 (a) it's a CPU bug
 (b) we're screwed

I bet it's something else.  Possibly just timing-specific (the APIC
makes interrupts much faster), but also possibly something to do with
the VGA interrupt (some XFree86 drivers actually use the gfx interrupts
these days)

		Linus

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: local APIC may cause XFree86 hang
  2002-11-13 22:29 Mikael Pettersson
@ 2002-11-13 23:19 ` Alan Cox
  2002-11-13 23:01   ` Mikael Pettersson
  2002-11-13 23:52 ` Linus Torvalds
  2002-11-14  7:58 ` Gregoire Favre
  2 siblings, 1 reply; 11+ messages in thread
From: Alan Cox @ 2002-11-13 23:19 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: Linux Kernel Mailing List

On Wed, 2002-11-13 at 22:29, Mikael Pettersson wrote:
> Does XFree86 (its core or particular drivers) use vm86() to
> invoke, possibly graphics card specific, BIOS code?
> That would explain the hangs I got. The fix would be to
> disable the local APIC around vm86()'s BIOS calls, just like
> we now disable it before APM suspend.

It does yes


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: local APIC may cause XFree86 hang
  2002-11-13 23:19 ` Alan Cox
@ 2002-11-13 23:01   ` Mikael Pettersson
  0 siblings, 0 replies; 11+ messages in thread
From: Mikael Pettersson @ 2002-11-13 23:01 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

Alan Cox writes:
 > On Wed, 2002-11-13 at 22:29, Mikael Pettersson wrote:
 > > Does XFree86 (its core or particular drivers) use vm86() to
 > > invoke, possibly graphics card specific, BIOS code?
 > > That would explain the hangs I got. The fix would be to
 > > disable the local APIC around vm86()'s BIOS calls, just like
 > > we now disable it before APM suspend.
 > 
 > It does yes

Ok. I'll start working on a patch to vm86() tomorrow.

/Mikael

^ permalink raw reply	[flat|nested] 11+ messages in thread

* local APIC may cause XFree86 hang
@ 2002-11-13 22:29 Mikael Pettersson
  2002-11-13 23:19 ` Alan Cox
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Mikael Pettersson @ 2002-11-13 22:29 UTC (permalink / raw)
  To: linux-kernel

Yesterday I installed a Radeon 8500 in a box. Suddenly the box
consistently hung hard every time I tried to shut down XFree86.

It turned out to be the local APIC timer: with it enabled,
the hangs occur; with it disabled but with the rest of the
local APIC and the performance counters in use, there are no
problems at all.

Does XFree86 (its core or particular drivers) use vm86() to
invoke, possibly graphics card specific, BIOS code?
That would explain the hangs I got. The fix would be to
disable the local APIC around vm86()'s BIOS calls, just like
we now disable it before APM suspend.

Doesn't the PCI code also do BIOS calls?

/Mikael

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-11-14 13:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-14  0:29 local APIC may cause XFree86 hang Nakajima, Jun
2002-11-14  0:48 ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2002-11-14  1:16 Nakajima, Jun
2002-11-14  1:38 ` Linus Torvalds
2002-11-14  8:08   ` george anzinger
2002-11-14 14:27     ` Alan Cox
2002-11-13 22:29 Mikael Pettersson
2002-11-13 23:19 ` Alan Cox
2002-11-13 23:01   ` Mikael Pettersson
2002-11-13 23:52 ` Linus Torvalds
2002-11-14  7:58 ` Gregoire Favre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).