From patchwork Fri Aug 18 19:49:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 110441 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1345292qge; Fri, 18 Aug 2017 12:52:03 -0700 (PDT) X-Received: by 10.99.2.68 with SMTP id 65mr9200064pgc.97.1503085923057; Fri, 18 Aug 2017 12:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503085923; cv=none; d=google.com; s=arc-20160816; b=DddXEweDoxYZzXU8igOeXpHyJlBAtDRNiwlkg4mhHqX1m0i/134jdZB/YcQ3e8HPmz vz8fYlQA5xx8Q/tJD7LCFStmBbHgSClATkgcrIN0W1whgjsg0PrKBf0FJVaWUexAcmOi PN1KQDraLsSzlP8d72kp35UhD51bOqPkr1sQW3pVGd6+QY0Diyvrxul/WwPo/iWiCBxQ J8tGKlINIh296geYWbbZc9rZe+LxZC+ALeRT+0c3S5uXlNvDMlPYKKCv4D4RISSvVrz6 T2b6aSXtD36H4chSxSHUs5mIDgBhYoMiAfOnfnRPbXGvkjn8vH89Bx76QEqmQx47HCW8 S/Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=DOci+TmtmRv4ua/yTEseqTYIFGVW//ZUhUVjWRattIs=; b=PgqjHvJImg934japDG2nYeriX8nZ9TJPaLh9OsIw987MvGm0MKUsAoHIBhSxGmWVlq D3G29shaSarJ8G94YHf20xLDHSGA0oT1ClTiD42Dech3tQjwg/NuZx0s725MIEYkbXYp OKYMLYciUy5xOX0+jJPMr0dKiQGGgbOCQCKDpWBengO8JNo9FFTdf5VS0xFWW56r+DmU rUlFBh1YVe3Cj5Si1yRvLNsidClskamntIWMlNF+6H+jzxjx1IJYSnCVT8MOLuvtzvKd xvW2gK88vnP5cWbThuIaKf+duW/0XmK3w2Jq+Qg5Bp5A1nYrUHLIkoq+rbeMfrHYjwyQ gGEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gHOZP+NV; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32si4261670pld.52.2017.08.18.12.52.02; Fri, 18 Aug 2017 12:52:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gHOZP+NV; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbdHRTuV (ORCPT + 2 others); Fri, 18 Aug 2017 15:50:21 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:33993 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752394AbdHRTuQ (ORCPT ); Fri, 18 Aug 2017 15:50:16 -0400 Received: by mail-wm0-f48.google.com with SMTP id c14so2103788wmh.1 for ; Fri, 18 Aug 2017 12:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bQ7Vb3VVp0p7ammYV1+sRKKpl+n3KWGGXTsTTshJOFw=; b=gHOZP+NVrJPdgyxQKH0pFKEnfze1BwrQ5qEKcoW/5xF3YAjHoWMd9ofVsl6XU6ymtD kwiKGhvUMSxd6cJAi/hak4ZArY7FErJaFVahgEXTJRzAlB9n/r8XfJRWEVd+3YXfCj+p Lzi6QhGrdJf6FegdDawkGddIwAdtqiSkDN828= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bQ7Vb3VVp0p7ammYV1+sRKKpl+n3KWGGXTsTTshJOFw=; b=PNMPKEjSID/fnSuVG25LcNdLJa+fa7o7md/RRB02u2thtWbs0Z6KE9RUKBburZqvZb WAojNXi6m3+7rY85dkHCU1PCgLFNUCzXbPl6VMy13u5bBaOEhfVxKAcp4k+oT2XBQvee byvzVriG4cTzcC7ubSVM9T84mku7hYzvMHwUgKY2o04CB9X7vBDeBI320AlJJJUQPFKP TcCm7o8FWrNwleRmJUber6F4Iyd9pRBUOoUiadZw6dHfa7KslK512/xVN5izB2Y9b0F8 TE+PrCP05ra6fPNG38UUNxOL8jg/OJ/Z3nWeqykKQ210MvHZG/Vh/pI4hXUs4t1TIxRi IA6A== X-Gm-Message-State: AHYfb5gtCfbpk/+F66Awu4qO2BbiHfrT7RuHq44BDry1sHfRYUtBZU4L 1dHU68aN4l1uCpPcOsjbbg== X-Received: by 10.28.62.149 with SMTP id l143mr2251126wma.126.1503085815058; Fri, 18 Aug 2017 12:50:15 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id k29sm5571168wrk.56.2017.08.18.12.50.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 12:50:14 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Hans de Goede , Ard Biesheuvel , linux-kernel@vger.kernel.org, Mark Salter , Len Brown , "Rafael J. Wysocki" , Andy Shevchenko , Peter Jones , Matt Fleming Subject: [PATCH 06/14] efi/reboot: Fall back to original power-off method if EFI_RESET_SHUTDOWN returns Date: Fri, 18 Aug 2017 20:49:39 +0100 Message-Id: <20170818194947.19347-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170818194947.19347-1-ard.biesheuvel@linaro.org> References: <20170818194947.19347-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Hans de Goede Commit 44be28e9dd98 ("x86/reboot: Add EFI reboot quirk for ACPI Hardware Reduced flag") sets pm_power_off to efi_power_off() when the acpi_gbl_reduced_hardware flag is set. According to its commit message this is necessary because: "BayTrail-T class of hardware requires EFI in order to powerdown and reboot and no other reliable method exists" But I have a Bay Trail CR tablet where the EFI_RESET_SHUTDOWN call does not work, it simply returns without doing anything (AFAICT). So it seems that some Bay Trail devices must use EFI for power-off, while for others only ACPI works. Note that efi_power_off() only gets used if the platform code defines efi_poweroff_required() and that returns true, this currently only ever happens on x86. Since on the devices which need ACPI for power-off the EFI_RESET_SHUTDOWN call simply returns, this patch makes the efi-reboot code remember the old pm_power_off handler and if EFI_RESET_SHUTDOWN returns it falls back to calling that. This seems preferable to dmi-quirking our way out of this, since there are likely quite a few devices suffering from this. Signed-off-by: Hans de Goede Cc: Mark Salter Cc: Ard Biesheuvel Cc: Len Brown Cc: "Rafael J. Wysocki" Cc: Andy Shevchenko Cc: Peter Jones Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/reboot.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.c index 62ead9b9d871..7117e2d0c7f9 100644 --- a/drivers/firmware/efi/reboot.c +++ b/drivers/firmware/efi/reboot.c @@ -5,6 +5,8 @@ #include #include +void (*orig_pm_power_off)(void); + int efi_reboot_quirk_mode = -1; void efi_reboot(enum reboot_mode reboot_mode, const char *__unused) @@ -51,6 +53,12 @@ bool __weak efi_poweroff_required(void) static void efi_power_off(void) { efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); + /* + * The above call should not return, if it does fall back to + * the original power off method (typically ACPI poweroff). + */ + if (orig_pm_power_off) + orig_pm_power_off(); } static int __init efi_shutdown_init(void) @@ -58,8 +66,10 @@ static int __init efi_shutdown_init(void) if (!efi_enabled(EFI_RUNTIME_SERVICES)) return -ENODEV; - if (efi_poweroff_required()) + if (efi_poweroff_required()) { + orig_pm_power_off = pm_power_off; pm_power_off = efi_power_off; + } return 0; }