Bug 49351 - vga_switcheroo results in black screen (bisected)
Summary: vga_switcheroo results in black screen (bisected)
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Video(DRI - non Intel) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_video-dri
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-22 21:31 UTC by Igor Murzov
Modified: 2012-11-04 21:05 UTC (History)
1 user (show)

See Also:
Kernel Version: 3.7-rc1+
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
lspci -vvv (30.42 KB, text/plain)
2012-10-22 21:31 UTC, Igor Murzov
Details
debug output (652 bytes, patch)
2012-10-22 21:45 UTC, Alex Deucher
Details | Diff
dmesg output for v3.7.0-rc2+ with the patch applied (59.21 KB, text/plain)
2012-10-23 01:26 UTC, Igor Murzov
Details
debug output (664 bytes, patch)
2012-10-23 13:50 UTC, Alex Deucher
Details | Diff
dmesg output for v3.7.0-rc2+ (59.01 KB, text/plain)
2012-10-23 15:44 UTC, Igor Murzov
Details
possible fix 1 (2.35 KB, patch)
2012-10-23 17:17 UTC, Alex Deucher
Details | Diff
possible fix 2 (3.22 KB, patch)
2012-10-23 17:22 UTC, Alex Deucher
Details | Diff
dmesg output for v3.7.0-rc2+ with kbug49351-2.diff applied (59.57 KB, text/plain)
2012-10-23 18:25 UTC, Igor Murzov
Details
debug output (1.16 KB, patch)
2012-10-23 19:12 UTC, Alex Deucher
Details | Diff
dmesg output for v3.5.2 (59.83 KB, text/plain)
2012-10-23 20:02 UTC, Igor Murzov
Details
dmesg output for v3.7.0-rc2+ with kbug49351.diff applied (59.32 KB, text/plain)
2012-10-23 20:42 UTC, Igor Murzov
Details
possible fix (1.04 KB, patch)
2012-10-23 20:52 UTC, Alex Deucher
Details | Diff
dmesg output for v3.7.0-rc2+ with the patch from comment #17 (59.79 KB, text/plain)
2012-10-23 21:27 UTC, Igor Murzov
Details

Description Igor Murzov 2012-10-22 21:31:56 UTC
Created attachment 84381 [details]
lspci -vvv

On my muxed hybrid system (Lenovo IdeaPad U455) vga_switcheroo doesn't work as expected. Initially after system booting both video cards are powered and the IGD one is active. Then, when i try to switch active gpu with

 # echo DIS > /sys/kernel/debug/vgaswitcheroo/switch

screen goes black.
The first bad commit, that broke vga_switcheroo is:

commit 492b49a2f21a7ce6cb0abce36017daa06036a626
Author: Alex Deucher <alexander.deucher@amd.com>
Date:   Thu Aug 16 14:07:37 2012 -0400

    drm/radeon: reorganize ATPX support (v2)
    
    - rework the acpi execute code
    - User proper parameters for ATPX functions
    
    v2: rebase fixes
    
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Comment 1 Alex Deucher 2012-10-22 21:45:08 UTC
Created attachment 84391 [details]
debug output

Can you attach the dmesg output with this patch applied?  No need to try and switch gpus.  I just need the output.
Comment 2 Igor Murzov 2012-10-23 01:26:13 UTC
Created attachment 84401 [details]
dmesg output for v3.7.0-rc2+ with the patch applied

I'm sure that i did everything right, but there is no "ATPX function mask" message in the log.
Comment 3 Alex Deucher 2012-10-23 13:50:29 UTC
Created attachment 84441 [details]
debug output

Try this version.
Comment 4 Igor Murzov 2012-10-23 15:00:02 UTC
Still no "ATPX function mask" in the log.
Comment 5 Alex Deucher 2012-10-23 15:03:11 UTC
Does it show up if you try switching?
Comment 6 Igor Murzov 2012-10-23 15:15:40 UTC
No.
Comment 7 Alex Deucher 2012-10-23 15:19:20 UTC
It should be printing.  Make sure you've booted the right kernel and are using the right module.  If you are using an initrd, make sure it's up to date.  Make sure you aren't redirecting your kernel output somewhere.  Maybe check /var/log/messages as well.
Comment 8 Igor Murzov 2012-10-23 15:44:39 UTC
Created attachment 84451 [details]
dmesg output for v3.7.0-rc2+ 

This dmesg output was produced with following changes:

----------------------------------------------
static int radeon_atpx_verify_interface(struct radeon_atpx *atpx)
{
        union acpi_object *info;
        struct atpx_verify_interface output;
        size_t size;
        int err = 0;
printk("*\n");
        info = radeon_atpx_call(atpx->handle, ATPX_FUNCTION_VERIFY_INTERFACE, NULL);
        if (!info)
                return -EIO;
printk("**\n");
        memset(&output, 0, sizeof(output));

        size = *(u16 *) info->buffer.pointer;
        if (size < 8) {
                printk("ATPX buffer is too small: %zu\n", size);
                err = -EINVAL;
                goto out;
        }
printk("***\n");
        size = min(sizeof(output), size);

        memcpy(&output, info->buffer.pointer, size);

        /* TODO: check version? */
        printk("ATPX version %u\n", output.version);
printk("****\n");
        radeon_atpx_parse_functions(&atpx->functions, output.function_bits);

out:
        kfree(info);
        return err;
}
----------------------------------------------

And there is only one asterisk in the log:
----------------------------------------------
[   11.199661] vga_switcheroo: enabled
[   11.199747] *
----------------------------------------------

So it is clear that some error is encountered in radeon_atpx_call(atpx->handle, ATPX_FUNCTION_VERIFY_INTERFACE, NULL);  That explains why there is no "ATPX function mask" message in the log.
Comment 9 Alex Deucher 2012-10-23 17:17:15 UTC
Created attachment 84461 [details]
possible fix 1

Try this patch and see if it helps.
Comment 10 Alex Deucher 2012-10-23 17:22:14 UTC
Created attachment 84471 [details]
possible fix 2

If the previous patch doesn't help, try this one.
Comment 11 Igor Murzov 2012-10-23 17:57:53 UTC
The first patch doesn't help.
Comment 12 Igor Murzov 2012-10-23 18:25:48 UTC
Created attachment 84481 [details]
dmesg output for v3.7.0-rc2+  with kbug49351-2.diff applied

The second patch doens't help either. And it results in the following warnings:
--------------------------------------------
[   11.675240] ACPI Warning: For \_SB_.PCI0.AGP_.VGA_.ATIF: Insufficient arguments - needs 2, found 1 (20120913/nspredef-321)
[   11.675688] ACPI Warning: For \_SB_.PCI0.AGP_.VGA_.ATIF: Insufficient arguments - needs 2, found 1 (20120913/nspredef-321)
--------------------------------------------
Comment 13 Alex Deucher 2012-10-23 19:09:28 UTC
Please attach the dmesg output from a working kernel.
Comment 14 Alex Deucher 2012-10-23 19:12:29 UTC
Created attachment 84491 [details]
debug output

Please attach the dmesg output with this patch applied.
Comment 15 Igor Murzov 2012-10-23 20:02:35 UTC
Created attachment 84511 [details]
dmesg output for v3.5.2
Comment 16 Igor Murzov 2012-10-23 20:42:41 UTC
Created attachment 84531 [details]
dmesg output for v3.7.0-rc2+ with kbug49351.diff applied

[   11.833549] vga_switcheroo: enabled
[   11.833648] evaluate ATPX got AE_NOT_FOUND
[   11.833750] buffer.pointer NULL
Comment 17 Alex Deucher 2012-10-23 20:52:43 UTC
Created attachment 84541 [details]
possible fix

Does this patch fix the issue?
Comment 18 Igor Murzov 2012-10-23 21:27:47 UTC
Created attachment 84561 [details]
dmesg output for v3.7.0-rc2+ with the patch from comment #17

vga_switcheroo seems to work fine with the last patch.

[   11.832217] vga_switcheroo: enabled
[   11.852254] ATPX version 1
[   11.852325] ATPX function mask 0x087
Comment 19 Igor Murzov 2012-11-04 21:05:05 UTC
Fixed by:

commit 0b90365e7a32317b948583c4b5c2712d84610b08
Author: Alex Deucher <alexander.deucher@amd.com>
Date:   Tue Oct 23 17:57:54 2012 -0400

    drm/radeon: fix ATPX regression in acpi rework
    
    Copy and paste typo in the apci rework.
    
    Fixes:
    https://bugzilla.kernel.org/show_bug.cgi?id=49351

Note You need to log in before you can comment on or make changes to this bug.