From patchwork Fri Jun 14 11:37:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10995117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9801A14DB for ; Fri, 14 Jun 2019 11:38:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82D66285A3 for ; Fri, 14 Jun 2019 11:38:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80960285CC; Fri, 14 Jun 2019 11:38:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 15C1C285A3 for ; Fri, 14 Jun 2019 11:38:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbkVz-0001Se-62; Fri, 14 Jun 2019 11:37:03 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbkVy-0001SZ-Nn for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 11:37:02 +0000 X-Inumbo-ID: b9b10fe1-8e98-11e9-8980-bc764e045a96 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id b9b10fe1-8e98-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 11:37:01 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Fri, 14 Jun 2019 05:37:00 -0600 Message-Id: <5D0386DC0200007800238470@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.1 Date: Fri, 14 Jun 2019 05:37:00 -0600 From: "Jan Beulich" To: "xen-devel" References: <5D03853F0200007800238448@prv1-mh.provo.novell.com> In-Reply-To: <5D03853F0200007800238448@prv1-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH 1/3] x86/ACPI: re-park previously parked CPUs upon resume from S3 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Aiui when resuming from S3, CPUs come back out of RESET/INIT. Therefore they need to undergo the same procedure as was added elsewhere by commits d8f974f1a6 ("x86: command line option to avoid use of secondary hyper-threads") and 8797d20a6e ("x86: possibly bring up all CPUs even if not all are supposed to be used"). Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -105,7 +105,7 @@ int cpu_down(unsigned int cpu) if ( err ) goto fail; - if ( unlikely(system_state < SYS_STATE_active) ) + if ( system_state < SYS_STATE_active || system_state == SYS_STATE_resume ) on_selected_cpus(cpumask_of(cpu), _take_cpu_down, NULL, true); else if ( (err = stop_machine_run(take_cpu_down, NULL, cpu)) < 0 ) goto fail; @@ -207,15 +207,19 @@ void enable_nonboot_cpus(void) printk("Enabling non-boot CPUs ...\n"); - for_each_cpu ( cpu, &frozen_cpus ) + for_each_present_cpu ( cpu ) { + if ( park_offline_cpus ? cpu == smp_processor_id() + : !cpumask_test_cpu(cpu, &frozen_cpus) ) + continue; if ( (error = cpu_up(cpu)) ) { printk("Error bringing CPU%d up: %d\n", cpu, error); BUG_ON(error == -EBUSY); } - else - __cpumask_clear_cpu(cpu, &frozen_cpus); + else if ( !__cpumask_test_and_clear_cpu(cpu, &frozen_cpus) && + (error = cpu_down(cpu)) ) + printk("Error re-offlining CPU%d: %d\n", cpu, error); } for_each_cpu ( cpu, &frozen_cpus ) From patchwork Fri Jun 14 11:37:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10995119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE5C6924 for ; Fri, 14 Jun 2019 11:39:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB85C285E5 for ; Fri, 14 Jun 2019 11:39:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC70C285E1; Fri, 14 Jun 2019 11:39:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 67047285B9 for ; Fri, 14 Jun 2019 11:39:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbkWw-0001X6-Hm; Fri, 14 Jun 2019 11:38:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbkWv-0001Wz-Cs for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 11:38:01 +0000 X-Inumbo-ID: da6831f6-8e98-11e9-a542-8b41a1c61c36 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id da6831f6-8e98-11e9-a542-8b41a1c61c36; Fri, 14 Jun 2019 11:37:57 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Fri, 14 Jun 2019 05:37:55 -0600 Message-Id: <5D03870E0200007800238473@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.1 Date: Fri, 14 Jun 2019 05:37:50 -0600 From: "Jan Beulich" To: "xen-devel" References: <5D03853F0200007800238448@prv1-mh.provo.novell.com> In-Reply-To: <5D03853F0200007800238448@prv1-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH RFC 2/3] x86/ACPI: restore VESA mode upon resume from S3 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap , Andrew Cooper , WeiLiu , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order for "acpi_sleep=s3_mode" to have any effect, we should record the video mode we switched to during boot. Since right now there's mode setting code for VESA modes only in the resume case, record the mode just in that one case. Signed-off-by: Jan Beulich --- RFC: On the box that I've been trying to test this on this didn't really make a difference (in the random cases where resume works in the first place there): The graphics card looks to remain powered off even after the Dom0 kernel has resumed. Additionally using "acpi_sleep=s3_bios" didn't make a difference either. Furthermore it looks like the serial console (connected via PCI card) doesn't work (yet) immediately after resume (I suppose it too is powered down), and resume hangs altogether with it in use. Hence it's sort of difficult to actually debug anything here. --- I'm wondering actually whether the user having to explicitly request the mode restoration is a good model: Why would we _not_ want to restore the mode we've set during boot? In the worst case Dom0 kernel or X will change the mode another time. --- a/xen/arch/x86/boot/video.S +++ b/xen/arch/x86/boot/video.S @@ -455,14 +455,17 @@ check_vesa: cmpb $0x99, %al jnz _setbad # Doh! No linear frame buffer. + pushw %bx subb $VIDEO_FIRST_VESA>>8, %bh orw $0x4000, %bx # Use linear frame buffer movw $0x4f02, %ax # VESA BIOS mode set call int $0x10 + popw %bx cmpw $0x004f, %ax # AL=4f if implemented jnz _setbad # AH=0 if OK movb $1, bootsym(graphic_mode) # flag graphic mode + movw %bx, bootsym(video_mode) stc ret From patchwork Fri Jun 14 11:38:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10995123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48D0714DB for ; Fri, 14 Jun 2019 11:40:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382F72846D for ; Fri, 14 Jun 2019 11:40:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 367EC285F9; Fri, 14 Jun 2019 11:40:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ABC1B285B8 for ; Fri, 14 Jun 2019 11:40:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbkXT-0001av-TO; Fri, 14 Jun 2019 11:38:35 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbkXS-0001ao-Uk for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 11:38:34 +0000 X-Inumbo-ID: f089e2ea-8e98-11e9-8980-bc764e045a96 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id f089e2ea-8e98-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 11:38:33 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Fri, 14 Jun 2019 05:38:33 -0600 Message-Id: <5D0387330200007800238476@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.1 Date: Fri, 14 Jun 2019 05:38:27 -0600 From: "Jan Beulich" To: "xen-devel" References: <5D03853F0200007800238448@prv1-mh.provo.novell.com> In-Reply-To: <5D03853F0200007800238448@prv1-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH 3/3] x86: a little bit of 16-bit video mode setting code cleanup X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap , Andrew Cooper , WeiLiu , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP To "compensate" for the code size growth by an earlier change: - drop "trampoline" labels (in almost all cases the target label is reachable with an 8-bit-displacement branch anyway, and a single 16- bit-displacement branch is still better than a pair of two branches) - drop an entirely dead insn - reduce code size in a few other (obvious I hope) cases, by more suitable insn/operands selection Also drop redundant #define-s (move suitable #include a little earlier instead) and add two alignment directives. Signed-off-by: Jan Beulich --- a/xen/arch/x86/boot/trampoline.S +++ b/xen/arch/x86/boot/trampoline.S @@ -176,6 +176,7 @@ start64: jmpq *%rdi +#include "video.h" #include "wakeup.S" .balign 8 @@ -283,8 +284,6 @@ trampoline_boot_cpu_entry: /* Jump to the common bootstrap entry point. */ jmp trampoline_protmode_entry -#include "video.h" - .align 2 /* Keep in sync with cmdline.c:early_boot_opts_t type! */ early_boot_opts: --- a/xen/arch/x86/boot/video.S +++ b/xen/arch/x86/boot/video.S @@ -384,9 +384,6 @@ lmbad: leaw bootsym(unknt), %si jmp mode_menu lmdef: ret -_setrec: jmp setrec # Ugly... -_set_80x25: jmp set_80x25 - # Setting of user mode (AX=mode ID) => CF=success mode_set: movw %ax, bootsym(boot_vid_mode) @@ -396,7 +393,7 @@ mode_set: je setvesabysize testb $VIDEO_RECALC>>8, %ah - jnz _setrec + jnz setrec cmpb $VIDEO_FIRST_SPECIAL>>8, %ah jz setspc @@ -421,7 +418,7 @@ setspc: xorb %bh, %bh setmenu: orb %al, %al # 80x25 is an exception - jz _set_80x25 + jz set_80x25 pushw %bx # Set mode chosen from menu call mode_table # Build the mode table @@ -441,36 +438,32 @@ check_vesa: cmpw $0x004f, %ax jnz setbad - leaw vesa_mode_info, %di - subb $VIDEO_FIRST_VESA>>8, %bh - movw %bx, %cx # Get mode information structure + leaw vesa_mode_info, %di # Get mode information structure + leaw -VIDEO_FIRST_VESA(%bx), %cx movw $0x4f01, %ax int $0x10 - addb $VIDEO_FIRST_VESA>>8, %bh cmpw $0x004f, %ax jnz setbad movb (%di), %al # Check mode attributes. andb $0x99, %al cmpb $0x99, %al - jnz _setbad # Doh! No linear frame buffer. + jnz setbad # Doh! No linear frame buffer. pushw %bx subb $VIDEO_FIRST_VESA>>8, %bh - orw $0x4000, %bx # Use linear frame buffer + orb $0x40, %bh # Use linear frame buffer movw $0x4f02, %ax # VESA BIOS mode set call int $0x10 popw %bx cmpw $0x004f, %ax # AL=4f if implemented - jnz _setbad # AH=0 if OK + jnz setbad # AH=0 if OK movb $1, bootsym(graphic_mode) # flag graphic mode movw %bx, bootsym(video_mode) stc ret -_setbad: jmp setbad # Ugly... - # Recalculate vertical display end registers -- this fixes various # inconsistencies of extended modes on many adapters. Called when # the VIDEO_RECALC flag is set in the mode ID. @@ -515,7 +508,7 @@ setvesabysize: leaw modelist,%si 1: add $8,%si cmpw $ASK_VGA,-8(%si) # End? - je _setbad + je setbad movw -6(%si),%ax cmpw %ax,bootsym(vesa_size)+0 jne 1b @@ -948,6 +941,7 @@ store_edid: #endif ret + .p2align 1 mt_end: .word 0 # End of video mode table if built edit_buf: .space 6 # Line editor buffer card_name: .word 0 # Pointer to adapter name @@ -991,6 +985,7 @@ vesa_name: .asciz "VESA" name_bann: .asciz "Video adapter: " + .p2align 1 force_size: .word 0 # Use this size instead of the one in BIOS vars GLOBAL(boot_vid_info) --- a/xen/arch/x86/boot/wakeup.S +++ b/xen/arch/x86/boot/wakeup.S @@ -30,7 +30,7 @@ ENTRY(wakeup_start) jne bogus_real_magic # for acpi_sleep=s3_bios - testl $1, wakesym(video_flags) + testb $1, wakesym(video_flags) jz 1f lcall $0xc000, $3 movw %cs, %ax # In case messed by BIOS @@ -38,9 +38,9 @@ ENTRY(wakeup_start) movw %ax, %ss # Need this? How to ret if clobbered? 1: # for acpi_sleep=s3_mode - testl $2, wakesym(video_flags) + testb $2, wakesym(video_flags) jz 1f - movl wakesym(video_mode), %eax + movw wakesym(video_mode), %ax call mode_setw 1: # Show some progress if VGA is resumed @@ -55,48 +55,26 @@ ENTRY(wakeup_start) lmsw %ax # Turn on CR0.PE ljmpl $BOOT_CS32, $bootsym_rel(wakeup_32, 6) -/* This code uses an extended set of video mode numbers. These include: - * Aliases for standard modes - * NORMAL_VGA (-1) - * EXTENDED_VGA (-2) - * ASK_VGA (-3) - * Video modes numbered by menu position -- NOT RECOMMENDED because of lack - * of compatibility when extending the table. These are between 0x00 and 0xff. - */ -#define VIDEO_FIRST_MENU 0x0000 - -/* Standard BIOS video modes (BIOS number + 0x0100) */ -#define VIDEO_FIRST_BIOS 0x0100 - -/* VESA BIOS video modes (VESA number + 0x0200) */ -#define VIDEO_FIRST_VESA 0x0200 - -/* Video7 special modes (BIOS number + 0x0900) */ -#define VIDEO_FIRST_V7 0x0900 - # Setting of user mode (AX=mode ID) => CF=success mode_setw: movw %ax, %bx cmpb $VIDEO_FIRST_VESA>>8, %ah jnc check_vesaw - decb %ah setbadw: clc ret check_vesaw: subb $VIDEO_FIRST_VESA>>8, %bh - orw $0x4000, %bx # Use linear frame buffer + orb $0x40, %bh # Use linear frame buffer movw $0x4f02, %ax # VESA BIOS mode set call int $0x10 cmpw $0x004f, %ax # AL=4f if implemented - jnz _setbadw # AH=0 if OK + jnz setbadw # AH=0 if OK stc ret -_setbadw: jmp setbadw - bogus_real_magic: movw $0x0e00 + 'B', %fs:(0x12) jmp bogus_real_magic