Radeon S3/resume: VGA ROM POST from kernel
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): e1c05edd04070109394afd3332-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
I've implemented VGA POSTing using a real-mode tunnel from kernel space. IMO, this has some advantages over user space methods:
1. It works with the aty/radeon_pm.c resume code. I don't see how to easily achieve this with user space methods.
2. Real mode seems faster than userspace vm86
3. It is the right way. Bringing up the hardware is clearly the responsibility of the kernel/drivers resume code.
Ole
arch/i386/kernel/acpi/sleep.c +26 -0
@@ -5,6 +5,7 @@* Copyright (C) 2001-2003 Pavel Machek <[email protected]> */ +#include <linux/module.h> #include <linux/acpi.h> #include <linux/bootmem.h> #include <asm/smp.h>
@@ -63,6 +64,31 @@zap_low_mappings (); } +/* +* acpi_vgapost +*/ + +extern void do_vgapost_lowlevel (unsigned long ); + +void acpi_vgapost (unsigned long slot) +{ +unsigned long flags, saved_video_flags = acpi_video_flags; + acpi_video_flags = (slot &0xffff ) <<16 |1 ; +/* Map low memory and copy information */ +init_low_mapping (swapper_pg_dir,USER_PTRS_PER_PGD ); +memcpy ((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); +acpi_copy_wakeup_routine (acpi_wakeup_address); +/* Tunnel thru real mode */ +local_irq_save (flags); +do_vgapost_lowlevel (acpi_wakeup_address); +local_irq_restore (flags); +/* Restore mapping etc */ +zap_low_mappings (); + acpi_video_flags = saved_video_flags; +} + +EXPORT_SYMBOL (acpi_vgapost); +/** * acpi_reserve_bootmem - do _very_ early ACPI initialisation *
arch/i386/kernel/acpi/wakeup.S +80 -0
98 lines not on this page · raw message
drivers/video/aty/radeon_pm.c +4 -0
@@ -897,6 +897,10 @@if (pdev->dev.power_state ==0 )return 0 ; +pci_restore_state (pdev, pdev->saved_config_space); + +acpi_vgapost (pdev->devfn); +acquire_console_sem ();/* Wakeup chip */
A message that is not in the archive (sent off-list or not yet received): yzoy8lggx6v.fsf_-_-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Hello,
Quoted 2 lines
I've implemented VGA POSTing using a real-mode tunnel from kernel space. IMO, this has some advantages over user space methods:
Great!!!!
For some reason, it doesn't work for me(Kernel 2.6.8-rc2). I cleaned up my source directory and I'll try again with a clean build again. If it doesn't work I'll try 2.6.7.
Do I need any other patches?
Quoted 2 lines
1. It works with the
aty/radeon_pm.cresume code. I don't see how to easily achieve this with user space methods.
Do you have radeonfb and fbcon loaded(or compiled into the kernel)?
Quoted 4 lines
2. Real mode seems faster than userspace vm86
3. It is the right way. Bringing up the hardware is clearly the responsibility of the kernel/drivers resume code.
Agreed. Someone wrote that this reset can't be performed by kernel code.
This is really great, and as soon as it works for me I'll upload it to my website.
Cheers,
Stefan
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
A message that is not in the archive (sent off-list or not yet received): [email protected]
Haven't tried it yet, but I was having problems just doing basic suspend/resume with 2.6.8-rcX as well. After a resume with an unpatched kernel I was unable to get the machine to respond to commands to reboot the VGA bios or spin the harddrive. Something changed between .7 and .8 but I'm not sure what - its not in the radeon specific code since I didn't have that loaded in the kernel.
Aman Gupta
Quoted 18 lines · Stefan Dösinger
Hello,
Quoted 2 lines
I've implemented VGA POSTing using a real-mode tunnel from kernel space. IMO, this has some advantages over user space methods:
Great!!!!
For some reason, it doesn't work for me(Kernel 2.6.8-rc2). I cleaned up my source directory and I'll try again with a clean build again. If it doesn't work I'll try 2.6.7.Do I need any other patches?
Quoted 2 lines
1. It works with the
aty/radeon_pm.cresume code. I don't see how to easily achieve this with user space methods.Do you have radeonfb and fbcon loaded(or compiled into the kernel)?
Quoted 4 lines
2. Real mode seems faster than userspace vm86
3. It is the right way. Bringing up the hardware is clearly the responsibility of the kernel/drivers resume code.
Quoted 8 lines
Agreed. Someone wrote that this reset can't be performed by kernel code.
This is really great, and as soon as it works for me I'll upload it to my website.
Cheers,
Stefan
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
Just curious but is this any different from the Int 10 hack performed when you boot with acpi_sleep=s3_bios?
-Herman
Quoted 27 lines · Stefan Dösinger
Hello,
Quoted 2 lines
I've implemented VGA POSTing using a real-mode tunnel from kernel space. IMO, this has some advantages over user space methods:
Great!!!!
For some reason, it doesn't work for me(Kernel 2.6.8-rc2). I cleaned up my source directory and I'll try again with a clean build again. If it doesn't work I'll try 2.6.7.Do I need any other patches?
Quoted 2 lines
1. It works with the
aty/radeon_pm.cresume code. I don't see how to easily achieve this with user space methods.Do you have radeonfb and fbcon loaded(or compiled into the kernel)?
Quoted 4 lines
2. Real mode seems faster than userspace vm86
3. It is the right way. Bringing up the hardware is clearly the responsibility of the kernel/drivers resume code.
Agreed. Someone wrote that this reset can't be performed by kernel code.
This is really great, and as soon as it works for me I'll upload it to my website.
Cheers,
Stefan
Quoted 9 lines
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Acpi-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/acpi-devel
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 2 lines
Just curious but is this any different from the Int 10 hack performed when you boot with acpi_sleep=s3_bios?
This is after PCI is reinitialized, so has better chance to work.
Pavel
Signature · 8 lines
When do you have heart between your knees? ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
Hi!
Quoted 8 lines
I've implemented VGA POSTing using a real-mode tunnel from kernel space. IMO, this has some advantages over user space methods:
1. It works with the
aty/radeon_pm.cresume code. I don't see how to easily achieve this with user space methods.
2. Real mode seems faster than userspace vm86
3. It is the right way. Bringing up the hardware is clearly the responsibility of the kernel/drivers resume code.
Agreed, I like this patch.
Content-Description: patch
Quoted 12 lines
diff -ru -X dontdiff
linux-2.6.7/arch/i386/kernel/acpi/sleep.clinux-2.6.7-p2120/arch/i386/kernel/acpi/sleep.carch/i386/kernel/acpi/sleep.c +1
-0@@ -5,6 +5,7 @@* Copyright (C) 2001-2003 Pavel Machek <[email protected]> */ +#include <linux/module.h> #include <linux/acpi.h> #include <linux/bootmem.h> #include <asm/smp.h>
arch/i386/kernel/acpi/sleep.c line 69
Quoted 6 lines
arch/i386/kernel/acpi/sleep.c +3
-0@@ -63,6 +64,31 @@zap_low_mappings (); } +/* +* acpi_vgapost +*/
If you are adding comment with function name, you should at least explain what the function does... or not add the comment at all.
arch/i386/kernel/acpi/sleep.c line 75
Quoted 5 lines
arch/i386/kernel/acpi/sleep.c +5
-0+extern void do_vgapost_lowlevel (unsigned long ); + +void acpi_vgapost (unsigned long slot) +{ +unsigned long flags, saved_video_flags = acpi_video_flags;
Please indent using one tab.
arch/i386/kernel/acpi/sleep.c line 86
Quoted 11 lines
arch/i386/kernel/acpi/sleep.c +11
-0+ acpi_video_flags = (slot &0xffff ) <<16 |1 ; +/* Map low memory and copy information */ +init_low_mapping (swapper_pg_dir,USER_PTRS_PER_PGD ); +memcpy ((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); +acpi_copy_wakeup_routine (acpi_wakeup_address); +/* Tunnel thru real mode */ +local_irq_save (flags); +do_vgapost_lowlevel (acpi_wakeup_address); +local_irq_restore (flags); +/* Restore mapping etc */ +zap_low_mappings ();
This needs BUG_ON(num_online_cpus() != 1) to avoid bad disaster, right?
arch/i386/kernel/acpi/wakeup.S line 49
Quoted 11 lines
diff -ru -X dontdiff
linux-2.6.7/arch/i386/kernel/acpi/wakeup.Slinux-2.6.7-p2120/arch/i386/kernel/acpi/wakeup.Sarch/i386/kernel/acpi/wakeup.S +1
-0@@ -43,6 +43,7 @@ testl $1, video_flags - wakeup_code jz 1f + movw video_flags - wakeup_code + 2, %ax lcall $0xc000,$3 movw %cs, %ax movw %ax, %ds # Bios
Are you sure you wanted to touch this code? Zeroing %ax on entry to BIOS might be good idea, but...
Quoted 67 lines
arch/i386/kernel/acpi/wakeup.S +56
-0@@ -159,6 +160,32 @@ _setbad: jmp setbad +# +# Real mode switch - verbatim from reboot.c +# +go_real: + movl %cr0, %eax + andl $0x00000011, %eax + orl $0x60000000, %eax + movl %eax, %cr0 + movl %eax, %cr3 + movl %cr0, %ebx + andl $0x60000000, %ebx + jz 1f + wbinvd +1: andb $0x10, %al + movl %eax, %cr0 +go_real_jmp: .byte 0xea +go_real_jmp_off: .word 0x0000 +go_real_jmp_seg: .word 0x0000 +# +# Real mode descriptor table +# + .align 8 +go_real_desc: .quad 0x0000000000000000 +go_real_cseg: .quad 0x00009a000000ffff +go_real_dseg: .quad 0x000092000000ffff + .code32 ALIGN@@ -284,6 +311,59 @@ call acpi_enter_sleep_state_s4bios ret +ENTRY(do_vgapost_lowlevel) + # Convert target offset to physical address + movl %eax, %ecx + subl $__PAGE_OFFSET, %ecx + # Fixup GDT pointer + movl %ecx, %edx + addl $go_real_desc - wakeup_start, %edx + movl %edx, go_real_gdt + 2 + # Fixup 16-bit CS descriptor + movl %ecx, %edx + movw %dx, go_real_cseg - wakeup_start + 2 (%eax) + shrl $16, %edx + movb %dl, go_real_cseg - wakeup_start + 4 (%eax) + movb %dh, go_real_cseg - wakeup_start + 7 (%eax) + # Fixup 16-bit jump + movl %ecx, %edx + shrl $4, %edx + movw %dx, go_real_jmp_seg - wakeup_start (%eax) + # Save state and registers + call save_processor_state + call save_registers + # Reload page table with low mapping + movl $swapper_pg_dir-__PAGE_OFFSET, %eax + movl %eax, %cr3 + # Load IDTR and GDTR for real mode + lidt go_real_idt + lgdt go_real_gdt + # Load DS & al + movl $0x0010, %eax + movl %eax, %ss
arch/i386/kernel/acpi/wakeup.S line 353
Quoted 10 lines
arch/i386/kernel/acpi/wakeup.S +10
-0+ movl %eax, %ds + movl %eax, %es + movl %eax, %fs + movl %eax, %gs + # Load CS + call $0x0008, $(go_real - wakeup_start) + # Phony return code + call restore_registers + call restore_processor_state + ret
Ouch, so you call wakeup_start once again?
...that's certainly interesting design. Does that mean that 'phony return code' is never reached? How do you manage to return from this routine?
Pavel
Signature · 8 lines
When do you have heart between your knees? ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
A message that is not in the archive (sent off-list or not yet received): 20040724131432.GB3004-I/[email protected]
Pavel> Agreed, I like this patch.
Cool... Let's see if it's still like that when I've explained how it works.
Pavel> If you are adding comment with function name, you should at least Pavel> explain what the function does... or not add the comment at all.
Sure. Ditto for acpi_restore_state from the stock kernel sources that I started with:-)
Pavel> Please indent using one tab.
Sorry, I must have forgotten to M-x load linux-c-mode
Quoted 3 lines
Quoted 3 lines
(...)
+do_vgapost_lowlevel(acpi_wakeup_address);
(...)
Pavel> This needs BUG_ON(num_online_cpus() != 1) to avoid bad Pavel> disaster, right?
Sounds like a good idea.
Quoted 4 lines
Quoted 4 lines
testl $1,
video_flags-wakeup_code
jz 1farch/i386/kernel/acpi/wakeup.S +1
-0+ movw video_flags - wakeup_code + 2, %axlcall $0xc000,$3
Pavel> Are you sure you wanted to touch this code? Zeroing %ax on entry to Pavel> BIOS might be good idea, but...
It is absolutely necessary, see below for how I've reused the real->pmode switch. The VGA BIOS expect the PCI bus/slot/function from %ax and C passes us that information in the upper 16 bits of acpi_video_flags.
Pavel> Ouch, so you call wakeup_start once again?
Yes, I didn't want to implement yet another real->pmode switch, it would have been a blue-print copy of wakeup_start and acpi_copy_wakeup_routine anyway.
Pavel> ...that's certainly interesting design. Does that mean that Pavel> 'phony return code' is never reached?
It is never reached and should be deleted. It is just a remnant of an early test stage.
Pavel> How do you manage to return from this routine?
Precisely like do_suspend_lowlevel_s4bios: calling save_registers and effectively reusing the tail-end of do_suspend_lowlevel.
Ole
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
A message that is not in the archive (sent off-list or not yet received): yzosmbhpgsn.fsf-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Hi!
Quoted 4 lines
Pavel> Agreed, I like this patch.
Cool... Let's see if it's still like that when I've explained how it works.
:-))))
Quoted 5 lines
Pavel> If you are adding comment with function name, you should at least Pavel> explain what the function does... or not add the comment at all.
Sure. Ditto for
acpi_restore_statefrom the stock kernel sources that I started with:-)
Okay, I'll fix that.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
testl $1,
video_flags-wakeup_code
jz 1farch/i386/kernel/acpi/wakeup.S +1
-0+ movw video_flags - wakeup_code + 2, %axlcall $0xc000,$3
Pavel> Are you sure you wanted to touch this code? Zeroing %ax on entry to Pavel> BIOS might be good idea, but...
Quoted 4 lines
It is absolutely necessary, see below for how I've reused the
real->pmodeswitch. The VGA BIOS expect the PCI bus/slot/function from %ax and C passes us that information in the upper 16 bits ofacpi_video_flags.
Hmm, that's perhaps why so little BIOSen work with this hack.. Is there chance that passing this value when acpi_sleep=s3_bios is going to help?
Quoted 5 lines
Pavel> Ouch, so you call
wakeup_startonce again?Yes, I didn't want to implement yet another
real->pmodeswitch, it would have been a blue-print copy ofwakeup_startandacpi_copy_wakeup_routineanyway.
Aha, its actually okay.
Quoted 4 lines
Pavel> How do you manage to return from this routine?
Precisely like
do_suspend_lowlevel_s4bios: callingsave_registersand effectively reusing the tail-end ofdo_suspend_lowlevel.
Hmm, okay, nice hack but you want it documented at some point. Perhaps comment just after jump to acpi_wakeup is good idea?
Pavel
Signature · 9 lines
Horseback riding is like software... ...vgf orggre jura vgf serr. ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
works for me on a Dell d600, radeon 9000 M9, (on fedora 2 kernel which has 4G/4G patch, init_low_mapping becomes map_low). This is much better than the patched X driver.
This has given me the opportunity to see how far the S3 status has evolved with recent kernels on the Dell D600 hardware. Ole's patch improves over the previous solution for the graphics resume (cleaner, faster, and more robust). Also, the USB problems I used to have seem to have been fixed (given the intense activity on the usb tree, it's certainly hard to pinpoint). IOW, usability of S3 on the d600 has risen up a lot ;-))
Many thanks,
E.
Quoted 11 lines · On Mon, Jul 19, 2004 at 11:31:36AM +0200…
I've implemented VGA POSTing using a real-mode tunnel from kernel space. IMO, this has some advantages over user space methods:
1. It works with the
aty/radeon_pm.cresume code. I don't see how to easily achieve this with user space methods.
2. Real mode seems faster than userspace vm86
3. It is the right way. Bringing up the hardware is clearly the responsibility of the kernel/drivers resume code.Ole
Content-Description: patch
Quoted 151 lines
diff -ru -X dontdiff
linux-2.6.7/arch/i386/kernel/acpi/sleep.clinux-2.6.7-p2120/arch/i386/kernel/acpi/sleep.carch/i386/kernel/acpi/sleep.c +26
-0@@ -5,6 +5,7 @@* Copyright (C) 2001-2003 Pavel Machek <[email protected]> */ +#include <linux/module.h> #include <linux/acpi.h> #include <linux/bootmem.h> #include <asm/smp.h> @@ -63,6 +64,31 @@zap_low_mappings (); } +/* +* acpi_vgapost +*/ + +extern void do_vgapost_lowlevel (unsigned long ); + +void acpi_vgapost (unsigned long slot) +{ +unsigned long flags, saved_video_flags = acpi_video_flags; + acpi_video_flags = (slot &0xffff ) <<16 |1 ; +/* Map low memory and copy information */ +init_low_mapping (swapper_pg_dir,USER_PTRS_PER_PGD ); +memcpy ((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start); +acpi_copy_wakeup_routine (acpi_wakeup_address); +/* Tunnel thru real mode */ +local_irq_save (flags); +do_vgapost_lowlevel (acpi_wakeup_address); +local_irq_restore (flags); +/* Restore mapping etc */ +zap_low_mappings (); + acpi_video_flags = saved_video_flags; +} + +EXPORT_SYMBOL (acpi_vgapost); +/** * acpi_reserve_bootmem - do _very_ early ACPI initialisation * diff -ru -X dontdiff
linux-2.6.7/arch/i386/kernel/acpi/wakeup.Slinux-2.6.7-p2120/arch/i386/kernel/acpi/wakeup.Sarch/i386/kernel/acpi/wakeup.S +80
-0@@ -43,6 +43,7 @@ testl $1, video_flags - wakeup_code jz 1f + movw video_flags - wakeup_code + 2, %ax lcall $0xc000,$3 movw %cs, %ax movw %ax, %ds # Bios might have played with that@@ -159,6 +160,32 @@ _setbad: jmp setbad +# +# Real mode switch - verbatim from reboot.c +# +go_real: + movl %cr0, %eax + andl $0x00000011, %eax + orl $0x60000000, %eax + movl %eax, %cr0 + movl %eax, %cr3 + movl %cr0, %ebx + andl $0x60000000, %ebx + jz 1f + wbinvd +1: andb $0x10, %al + movl %eax, %cr0 +go_real_jmp: .byte 0xea +go_real_jmp_off: .word 0x0000 +go_real_jmp_seg: .word 0x0000 +# +# Real mode descriptor table +# + .align 8 +go_real_desc: .quad 0x0000000000000000 +go_real_cseg: .quad 0x00009a000000ffff +go_real_dseg: .quad 0x000092000000ffff + .code32 ALIGN@@ -284,6 +311,59 @@ call acpi_enter_sleep_state_s4bios ret +ENTRY(do_vgapost_lowlevel) + # Convert target offset to physical address + movl %eax, %ecx + subl $__PAGE_OFFSET, %ecx + # Fixup GDT pointer + movl %ecx, %edx + addl $go_real_desc - wakeup_start, %edx + movl %edx, go_real_gdt + 2 + # Fixup 16-bit CS descriptor + movl %ecx, %edx + movw %dx, go_real_cseg - wakeup_start + 2 (%eax) + shrl $16, %edx + movb %dl, go_real_cseg - wakeup_start + 4 (%eax) + movb %dh, go_real_cseg - wakeup_start + 7 (%eax) + # Fixup 16-bit jump + movl %ecx, %edx + shrl $4, %edx + movw %dx, go_real_jmp_seg - wakeup_start (%eax) + # Save state and registers + call save_processor_state + call save_registers + # Reload page table with low mapping + movl $swapper_pg_dir-__PAGE_OFFSET, %eax + movl %eax, %cr3 + # Load IDTR and GDTR for real mode + lidt go_real_idt + lgdt go_real_gdt + # Load DS & al + movl $0x0010, %eax + movl %eax, %ss + movl %eax, %ds + movl %eax, %es + movl %eax, %fs + movl %eax, %gs + # Load CS + call $0x0008, $(go_real - wakeup_start) + # Phony return code + call restore_registers + call restore_processor_state + ret + + .align 4 + .word 0 +go_real_idt: + .word 0x3ff + .long 0 + + .align 4 + .word 0 +go_real_gdt: + .word 3*8-1 + .long 0 + ALIGN # saved registers saved_gdt: .long 0,0diff -ru -X dontdiff
linux-2.6.7/drivers/video/aty/radeon_pm.clinux-2.6.7-p2120/drivers/video/aty/radeon_pm.c
drivers/video/aty/radeon_pm.c line 906
Quoted 10 lines
drivers/video/aty/radeon_pm.c +4
-0@@ -897,6 +897,10 @@if (pdev->dev.power_state ==0 )return 0 ; +pci_restore_state (pdev, pdev->saved_config_space); + +acpi_vgapost (pdev->devfn); +acquire_console_sem ();/* Wakeup chip */
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com