From patchwork Thu Feb 11 20:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 381899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 389DEC433E0 for ; Thu, 11 Feb 2021 20:18:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08BDC64DBA for ; Thu, 11 Feb 2021 20:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbhBKUSH (ORCPT ); Thu, 11 Feb 2021 15:18:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbhBKUR6 (ORCPT ); Thu, 11 Feb 2021 15:17:58 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16005C0613D6; Thu, 11 Feb 2021 12:17:18 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id f14so11985527ejc.8; Thu, 11 Feb 2021 12:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M42x2vdXUf7iABaSw/DfzeNpDBBVtTjcyxsHTr3EEdA=; b=gP3z+vu82mgwwojod39XLEzEHCxx+VfVn7qE4nukM6NzCRpOPC5bB9OktOleLpHk0L 83KYNS5aANgXc7guOSY6YCjuS3PNuphLZbWxJRlQJq9/5g/6E8HQywlNOYXzVuYgUTER HFhonCFIltvZZaaEjCZ5Kjk86H8twyvPnhjCo9X2bu5nRU5SH1W69ZQVjrXILymN84qT UFQg2GGwRZNL5sGFFtU+7650/CQ5ZAd8rWQEPFcxX+sKK6ab9ioE/0AGzxT/++zRUIPL f8p0pYWCqYgZj6Ry2XGGA0z7U6mmXxPeXk6g82GSOy5UzYo0TzYms6WDhcl2Nhkb40Wd TUmw== 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:mime-version:content-transfer-encoding; bh=M42x2vdXUf7iABaSw/DfzeNpDBBVtTjcyxsHTr3EEdA=; b=Haiav619SRSvhjtZfO4Jps5t/tsW0X0fAGiuN46h3YMr2XDnkURAXUrf7dlLrFteSU ZD76QbMReXT4v+zDawwjH8Ry1jYeK4vYMXKOXLzWtUs2GvmtymVL6/S2SAM/ZYrY31G7 NS5WxR5YNZyNKKbhXdbucaSr71ve9A9vmKKE2qPvTY1NX9KXAeU9tUcNKPuw6m6pKkXv 4BrL5SHe1rcIjNEKbchNyZPoCMuQ2NhXcyg8QJ4R3jdigXjh1DVW5Z5l63S+dcZDo9MS mdmiLQIUNgwcxyjV4U5TBpyXnubQIdER74S9FKVJ+YDhXdxNa6IBQPwRIRvOecIJJJlz +v/Q== X-Gm-Message-State: AOAM531Bu5wf/gQNg/737ZNLxBAhmO+E9/5bD28Ngdoi1ZEUW9E/43DF WeqFzgPD0DOQPhTqXI80W6Q= X-Google-Smtp-Source: ABdhPJxMKkcvVoAPB5cskH7X5sezrbX1ms82uFpipsc8gmoxx6+z4S1fHVmnhwOtoNqX7l66zWNA5w== X-Received: by 2002:a17:906:d8ae:: with SMTP id qc14mr10236017ejb.129.1613074636879; Thu, 11 Feb 2021 12:17:16 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id a1sm4938177edj.6.2021.02.11.12.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:17:16 -0800 (PST) From: Maximilian Luz To: Hans de Goede , "Rafael J. Wysocki" Cc: Maximilian Luz , Mark Gross , Len Brown , Mark Pearson , Jiaxun Yang , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] ACPI: platform: Hide ACPI_PLATFORM_PROFILE option Date: Thu, 11 Feb 2021 21:17:00 +0100 Message-Id: <20210211201703.658240-2-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211201703.658240-1-luzmaximilian@gmail.com> References: <20210211201703.658240-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The ACPI_PLATFORM_PROFILE option essentially provides a library and not really an independent module. Thus it seems to be more user-friendly to hide this option and simply make drivers depending on it select it. Suggested-by: Hans de Goede Signed-off-by: Maximilian Luz --- drivers/acpi/Kconfig | 16 +--------------- drivers/platform/x86/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5ddff93e38c2..030678965159 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -327,21 +327,7 @@ config ACPI_THERMAL the module will be called thermal. config ACPI_PLATFORM_PROFILE - tristate "ACPI Platform Profile Driver" - default m - help - This driver adds support for platform-profiles on platforms that - support it. - - Platform-profiles can be used to control the platform behaviour. For - example whether to operate in a lower power mode, in a higher - power performance mode or between the two. - - This driver provides the sysfs interface and is used as the registration - point for platform specific drivers. - - Which profiles are supported is determined on a per-platform basis and - should be obtained from the platform specific driver. + tristate config ACPI_CUSTOM_DSDT_FILE string "Custom DSDT Table file to include" diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 56353e8c792a..ad4e630e73e2 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -450,7 +450,7 @@ config IDEAPAD_LAPTOP depends on BACKLIGHT_CLASS_DEVICE depends on ACPI_VIDEO || ACPI_VIDEO = n depends on ACPI_WMI || ACPI_WMI = n - depends on ACPI_PLATFORM_PROFILE + select ACPI_PLATFORM_PROFILE select INPUT_SPARSEKMAP select NEW_LEDS select LEDS_CLASS @@ -484,7 +484,7 @@ config THINKPAD_ACPI depends on RFKILL || RFKILL = n depends on ACPI_VIDEO || ACPI_VIDEO = n depends on BACKLIGHT_CLASS_DEVICE - depends on ACPI_PLATFORM_PROFILE + select ACPI_PLATFORM_PROFILE select HWMON select NVRAM select NEW_LEDS From patchwork Thu Feb 11 20:17:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 381096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F2BBC433DB for ; Thu, 11 Feb 2021 20:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8F9864E4A for ; Thu, 11 Feb 2021 20:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbhBKUSK (ORCPT ); Thu, 11 Feb 2021 15:18:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231749AbhBKUSA (ORCPT ); Thu, 11 Feb 2021 15:18:00 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459DDC061786; Thu, 11 Feb 2021 12:17:19 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id f14so11985622ejc.8; Thu, 11 Feb 2021 12:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vG1SnwWHtBNBHayDF+yVo2bQqBQka0EM0VyXHrOitPY=; b=BTTzgjXcZszTRG3K8JiFHUpcLkh5b7eprjzLhrt7nDzybIQ4QIEhbYlZwp2nQ+4zAZ 12fQ49xSW2Q6QbDHzA5sK7i+s31NoIBjbZWDysNd3sC0shtFIjPCh87/x53o2TsYMRxM mhrxlJDnsSKm39srvIkYtx8W7M6IXFCWQ224d8QuJXHHopSzEa5aRxcTqGWXtOjssbJ4 9GQ7/mxiqzJUq8GaXnHXSRxJM/xgafEQrP/+QgO8UYN3bbfIwtG0ktZjHmHIN4vGclLQ fIhzo5QoBijtrLEpyqkCPvKfPRQ2M190bDuBWpAfhv+QCdvp3S/9QAexPXTe0qs9g161 +4mQ== 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:mime-version:content-transfer-encoding; bh=vG1SnwWHtBNBHayDF+yVo2bQqBQka0EM0VyXHrOitPY=; b=KWXr3SseERYLrtKiC3XtC8S9vvokCQElNV0Doansb355071FqKmZTpajRuo7PSS/Hu Hv5Mlj+h7IH08+nY+z2efkP1YQZeZTic+V4i6zFimhmNZcZLhl0VkKa5fY5wmCjYiUsQ lNiHckAMQ+JPd/WNG38/pksF8WHKjzEIsjerm0kRm8jE0OTQeC1TQY2wfoR5IilWUMDn sWtBteaeXWfp/b6VkKw2J6JeAkhNIrvGLFoFxPmkOOdZthoFFwBSp3mlq+tLJbLSmfNd l61K+FODcjCoNF2P4iVP9d5Vt3YSXcS1pl9C/2ZWBPrUwscl3MISYp1YQIJpO25O+1a1 jSUA== X-Gm-Message-State: AOAM5329iHOsq8MlX1gcoPyFsiO79Bok91Kps/Pn7wHdr66zvnSDLWiN cNpAy2JHXnQi1evKjUtwXCA= X-Google-Smtp-Source: ABdhPJxqgDV00V2rhEkcUN9lbWmyAjsYANQIwAdTCgvbI6rliAe2FOVLUX3gDhu5E7fZt9LCgjDrgQ== X-Received: by 2002:a17:906:24d1:: with SMTP id f17mr10052540ejb.503.1613074638097; Thu, 11 Feb 2021 12:17:18 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id a1sm4938177edj.6.2021.02.11.12.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:17:17 -0800 (PST) From: Maximilian Luz To: Hans de Goede , "Rafael J. Wysocki" Cc: Maximilian Luz , Mark Gross , Len Brown , Mark Pearson , Jiaxun Yang , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] ACPI: platform: Fix file references in comment Date: Thu, 11 Feb 2021 21:17:01 +0100 Message-Id: <20210211201703.658240-3-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211201703.658240-1-luzmaximilian@gmail.com> References: <20210211201703.658240-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The referenced files are named slightly different. Replace '-' with '_' and drop the .rst ending. Signed-off-by: Maximilian Luz --- include/linux/platform_profile.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index a26542d53058..b4794027e759 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -12,9 +12,8 @@ #include /* - * If more options are added please update profile_names - * array in platform-profile.c and sysfs-platform-profile.rst - * documentation. + * If more options are added please update profile_names array in + * platform_profile.c and sysfs-platform_profile documentation. */ enum platform_profile_option { From patchwork Thu Feb 11 20:17:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 381898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6A5BC433E0 for ; Thu, 11 Feb 2021 20:18:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BECCA64DBA for ; Thu, 11 Feb 2021 20:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230246AbhBKUSQ (ORCPT ); Thu, 11 Feb 2021 15:18:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbhBKUSB (ORCPT ); Thu, 11 Feb 2021 15:18:01 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF1EC061788; Thu, 11 Feb 2021 12:17:20 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id l25so11990124eja.9; Thu, 11 Feb 2021 12:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fc2OT1cScZA8JM0hMwx8BqoVclia9O93ocGUXBkaHO4=; b=GB24+9GxyTapQ+S8/IwOLYWbhKUorY5fIWYrXe5XjpzifNAoqyWLEjiff2C4QUOqmx XGM7EaRjPO/EEGu2JReQKNxMlM3tpXlc4kiBNVZXCi+lpj/GPckg55k/dCXKsKw8ax2u eE57s3vvP0jMaNvmZpZhRrkXZIL3yXrdYWBySU4Erv47VOHLqA6YmSOQhpoVyOiDQUq1 farPUsKLLXj1g2lT2UnYNWGS8MTiyWNAyrT/vrrd9Piojbw/d5YfPM2M2+rbNYg7fTZ4 724cy03ExmVaMXobbR7R5i0mJtBo9r0CVZBOkANjRlVePDEUb/f9bpxoDpFCn0EJ9xUx iT6A== 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:mime-version:content-transfer-encoding; bh=fc2OT1cScZA8JM0hMwx8BqoVclia9O93ocGUXBkaHO4=; b=fK1UAoN/uXP31EulsTGWP5mPcU8HQD46x1xqp+FrNTOyxUiiL+pReqmGLG9sLLj58L e7M24e7pDlYZas0HfzqQ+PkbADVphr5my30Fg0GIWN1f/pSKm+cy3LqrFz2PSHGimo9G qYk4ogz3kTzs5QLfSAPDc5JaI90bA1krUMyvgbCF6YAxh6kl33j3wJMvcfwX+x//0goe A6uY9BOT2vE97AvlsKbbDU+KQio7aCFXYB9Qb4Jz582xd1bHHCiCnBn/4IijiTPPGYyG tG2q+GgsPtiTUrrD55QXrRvWhcAa466Ac4F9/KBoEZ/4rwsuIKz0qdycOv1ILtEvtlUa n5jA== X-Gm-Message-State: AOAM5317pBZwFs1OVDsmUK4o04//6wm0p5E+TubWJ+wB6VyWPsrSncdp pHPZMnNggP6uwz1I083lcvM= X-Google-Smtp-Source: ABdhPJwZs8PgysLkav93ywnokc6CaMzdG3wvxq/xM12TzDebxYgGhWQez4KsLxFjWDrfgdTU9X7NwQ== X-Received: by 2002:a17:906:149a:: with SMTP id x26mr10102837ejc.486.1613074639308; Thu, 11 Feb 2021 12:17:19 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id a1sm4938177edj.6.2021.02.11.12.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:17:18 -0800 (PST) From: Maximilian Luz To: Hans de Goede , "Rafael J. Wysocki" Cc: Maximilian Luz , Mark Gross , Len Brown , Mark Pearson , Jiaxun Yang , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] ACPI: platform: Add balanced-performance platform profile Date: Thu, 11 Feb 2021 21:17:02 +0100 Message-Id: <20210211201703.658240-4-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211201703.658240-1-luzmaximilian@gmail.com> References: <20210211201703.658240-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Some devices, including most Microsoft Surface devices, have a platform profile somewhere inbetween balanced and performance. More specifically, adding this profile allows the following mapping on Surface devices: Vendor Name Platform Profile ------------------------------------------ Battery Saver low-power Recommended balanced Better Performance balanced-performance Best Performance performance Suggested-by: Hans de Goede Signed-off-by: Maximilian Luz --- .../ABI/testing/sysfs-platform_profile | 18 +++++++++++------- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile index 9d6b89b66cca..dae9c8941905 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -5,13 +5,17 @@ Description: This file contains a space-separated list of profiles supported for Drivers must use the following standard profile-names: - ============ ============================================ - low-power Low power consumption - cool Cooler operation - quiet Quieter operation - balanced Balance between low power consumption and performance - performance High performance operation - ============ ============================================ + ==================== ======================================== + low-power Low power consumption + cool Cooler operation + quiet Quieter operation + balanced Balance between low power consumption + and performance + balanced-performance Balance between performance and low + power consumption with a slight bias + towards performance + performance High performance operation + ==================== ======================================== Userspace may expect drivers to offer more than one of these standard profile names. diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4a59c5993bde..dd2fbf38e414 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -17,6 +17,7 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_COOL] = "cool", [PLATFORM_PROFILE_QUIET] = "quiet", [PLATFORM_PROFILE_BALANCED] = "balanced", + [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] = "performance", }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index b4794027e759..a6329003aee7 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -21,6 +21,7 @@ enum platform_profile_option { PLATFORM_PROFILE_COOL, PLATFORM_PROFILE_QUIET, PLATFORM_PROFILE_BALANCED, + PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, PLATFORM_PROFILE_LAST, /*must always be last */ }; From patchwork Thu Feb 11 20:17:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 381095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 478C3C433E0 for ; Thu, 11 Feb 2021 20:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0150364E57 for ; Thu, 11 Feb 2021 20:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231395AbhBKUTF (ORCPT ); Thu, 11 Feb 2021 15:19:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231728AbhBKUS2 (ORCPT ); Thu, 11 Feb 2021 15:18:28 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8F5CC06178A; Thu, 11 Feb 2021 12:17:21 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id hs11so12043562ejc.1; Thu, 11 Feb 2021 12:17:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ChSb7jAu63yN2PTu1qjhx29H+AwyGHK2chc2roix8M4=; b=Mn897Wfe4E/hMRE8oORZfFesshNO63+9mpn8tf4vKQC0vIcIlH9jL6qKZjICNuL18O 3wBXtTosTblidxjSQ0OG7Ev1q4zEThZUMOx12bQfb7UIv5YW9H2s/jeqnU4DASO++5lc mkpGz60UM+v5bJVD7oG5JikfwH/TuD5twOST1+ig1ZEq/kob+Tqtu1EH+aw3qBd38cnx HUxAOGeqQoTFxCHzIicY81uMcCCJqDfoImbXobGLabXaIliIoX9mPvxpD/XEcwLiNxHq Us9uDPQ8JnUH3Noc4oTJkQpIMNCsOiWO+D+pM0BSCFTnwf4dFxcC5CwE+gvwGM9NSXze /Zbg== 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:mime-version:content-transfer-encoding; bh=ChSb7jAu63yN2PTu1qjhx29H+AwyGHK2chc2roix8M4=; b=CXmiRU4H1B2Ty7emKm4TEYT12dcbCHJc7jSIfNnlmA5rgnBVKOj0AQkPvHRaeB/4R2 +C0LFPYyegjbs1baGIzSRHD+pL42VmR/olLRsv5ZweGl223VQi71OY6Q8Fup2VL2ehZI Xw5Zxti1Z61FL5Jq5NchtGq2Evn2TLVbDhMVQUqjKtrxamtCLgXZERn/sYkMAVjcD5B2 n1M/W0cLEKbsxFzA/lPmYrIMdsN9jlUJtT5wwqj8Udvrty1ajJhfQM6KPhBo/DhG5OuM WvWFbpT2alT4YiRkj37qCOqsWfDPoWzNrwTVV6Y7TvzqXwrYYezhkT2vqOYKsfM45+Jh RQXA== X-Gm-Message-State: AOAM5316Vda16i31zDplcwLcGP8hqwkHbnkA+6rCU0zpddEUjA06WwD3 lfx24BiSEV3Tw8Xjyl3YakI= X-Google-Smtp-Source: ABdhPJwnjOw40nzNXFmuMaZv3zAs5SlEJtgIwmwLXT6pYbMygZ3WNxchPPmAs/omonfnrdAgMpRH2Q== X-Received: by 2002:a17:906:24ca:: with SMTP id f10mr9883900ejb.96.1613074640648; Thu, 11 Feb 2021 12:17:20 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id a1sm4938177edj.6.2021.02.11.12.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:17:20 -0800 (PST) From: Maximilian Luz To: Hans de Goede , "Rafael J. Wysocki" Cc: Maximilian Luz , Mark Gross , Len Brown , Mark Pearson , Jiaxun Yang , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] platform/surface: Add platform profile driver Date: Thu, 11 Feb 2021 21:17:03 +0100 Message-Id: <20210211201703.658240-5-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211201703.658240-1-luzmaximilian@gmail.com> References: <20210211201703.658240-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add a driver to provide platform profile support on 5th- and later generation Microsoft Surface devices with a Surface System Aggregator Module. On those devices, the platform profile can be used to influence cooling behavior and power consumption. For example, the default 'quiet' profile limits fan noise and in turn sacrifices performance of the discrete GPU found on Surface Books. Its full performance can only be unlocked on the 'performance' profile. Signed-off-by: Maximilian Luz --- MAINTAINERS | 6 + drivers/platform/surface/Kconfig | 22 ++ drivers/platform/surface/Makefile | 1 + .../surface/surface_platform_profile.c | 190 ++++++++++++++++++ 4 files changed, 219 insertions(+) create mode 100644 drivers/platform/surface/surface_platform_profile.c diff --git a/MAINTAINERS b/MAINTAINERS index 000a82f59c76..a08d65f8f0df 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11811,6 +11811,12 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: drivers/platform/surface/surface_hotplug.c +MICROSOFT SURFACE PLATFORM PROFILE DRIVER +M: Maximilian Luz +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/surface/surface_platform_profile.c + MICROSOFT SURFACE PRO 3 BUTTON DRIVER M: Chen Yu L: platform-driver-x86@vger.kernel.org diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig index 179b8c93d7fd..a045425026ae 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig @@ -132,6 +132,28 @@ config SURFACE_HOTPLUG Select M or Y here, if you want to (fully) support hot-plugging of dGPU devices on the Surface Book 2 and/or 3 during D3cold. +config SURFACE_PLATFORM_PROFILE + tristate "Surface Platform Profile Driver" + depends on SURFACE_AGGREGATOR_REGISTRY + select ACPI_PLATFORM_PROFILE + help + Provides support for the ACPI platform profile on 5th- and later + generation Microsoft Surface devices. + + More specifically, this driver provides ACPI platform profile support + on Microsoft Surface devices with a Surface System Aggregator Module + (SSAM) connected via the Surface Serial Hub (SSH / SAM-over-SSH). In + other words, this driver provides platform profile support on the + Surface Pro 5, Surface Book 2, Surface Laptop, Surface Laptop Go and + later. On those devices, the platform profile can significantly + influence cooling behavior, e.g. setting it to 'quiet' (default) or + 'low-power' can significantly limit performance of the discrete GPU on + Surface Books, while in turn leading to lower power consumption and/or + less fan noise. + + Select M or Y here, if you want to include ACPI platform profile + support on the above mentioned devices. + config SURFACE_PRO3_BUTTON tristate "Power/home/volume buttons driver for Microsoft Surface Pro 3/4 tablet" depends on INPUT diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile index 80035ee540bf..99372c427b73 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_SURFACE_AGGREGATOR_CDEV) += surface_aggregator_cdev.o obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o obj-$(CONFIG_SURFACE_HOTPLUG) += surface_hotplug.o +obj-$(CONFIG_SURFACE_PLATFORM_PROFILE) += surface_platform_profile.o obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c new file mode 100644 index 000000000000..0081b01a5b0f --- /dev/null +++ b/drivers/platform/surface/surface_platform_profile.c @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Surface Platform Profile / Performance Mode driver for Surface System + * Aggregator Module (thermal subsystem). + * + * Copyright (C) 2021 Maximilian Luz + */ + +#include +#include +#include +#include +#include + +#include + +enum ssam_tmp_profile { + SSAM_TMP_PROFILE_NORMAL = 1, + SSAM_TMP_PROFILE_BATTERY_SAVER = 2, + SSAM_TMP_PROFILE_BETTER_PERFORMANCE = 3, + SSAM_TMP_PROFILE_BEST_PERFORMANCE = 4, +}; + +struct ssam_tmp_profile_info { + __le32 profile; + __le16 unknown1; + __le16 unknown2; +} __packed; + +struct ssam_tmp_profile_device { + struct ssam_device *sdev; + struct platform_profile_handler handler; +}; + +static SSAM_DEFINE_SYNC_REQUEST_CL_R(__ssam_tmp_profile_get, struct ssam_tmp_profile_info, { + .target_category = SSAM_SSH_TC_TMP, + .command_id = 0x02, +}); + +static SSAM_DEFINE_SYNC_REQUEST_CL_W(__ssam_tmp_profile_set, __le32, { + .target_category = SSAM_SSH_TC_TMP, + .command_id = 0x03, +}); + +static int ssam_tmp_profile_get(struct ssam_device *sdev, enum ssam_tmp_profile *p) +{ + struct ssam_tmp_profile_info info; + int status; + + status = ssam_retry(__ssam_tmp_profile_get, sdev, &info); + if (status < 0) + return status; + + *p = le32_to_cpu(info.profile); + return 0; +} + +static int ssam_tmp_profile_set(struct ssam_device *sdev, enum ssam_tmp_profile p) +{ + __le32 profile_le = cpu_to_le32(p); + + return ssam_retry(__ssam_tmp_profile_set, sdev, &profile_le); +} + +static int convert_ssam_to_profile(struct ssam_device *sdev, enum ssam_tmp_profile p) +{ + switch (p) { + case SSAM_TMP_PROFILE_NORMAL: + return PLATFORM_PROFILE_BALANCED; + + case SSAM_TMP_PROFILE_BATTERY_SAVER: + return PLATFORM_PROFILE_LOW_POWER; + + case SSAM_TMP_PROFILE_BETTER_PERFORMANCE: + return PLATFORM_PROFILE_BALANCED_PERFORMANCE; + + case SSAM_TMP_PROFILE_BEST_PERFORMANCE: + return PLATFORM_PROFILE_PERFORMANCE; + + default: + dev_err(&sdev->dev, "invalid performance profile: %d", p); + return -EINVAL; + } +} + +static int convert_profile_to_ssam(struct ssam_device *sdev, enum platform_profile_option p) +{ + switch (p) { + case PLATFORM_PROFILE_LOW_POWER: + return SSAM_TMP_PROFILE_BATTERY_SAVER; + + case PLATFORM_PROFILE_BALANCED: + return SSAM_TMP_PROFILE_NORMAL; + + case PLATFORM_PROFILE_BALANCED_PERFORMANCE: + return SSAM_TMP_PROFILE_BETTER_PERFORMANCE; + + case PLATFORM_PROFILE_PERFORMANCE: + return SSAM_TMP_PROFILE_BEST_PERFORMANCE; + + default: + /* This should have already been caught by platform_profile_store(). */ + WARN(true, "unsupported platform profile"); + return -EOPNOTSUPP; + } +} + +static int ssam_platform_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile) +{ + struct ssam_tmp_profile_device *tpd; + enum ssam_tmp_profile tp; + int status; + + tpd = container_of(pprof, struct ssam_tmp_profile_device, handler); + + status = ssam_tmp_profile_get(tpd->sdev, &tp); + if (status) + return status; + + status = convert_ssam_to_profile(tpd->sdev, tp); + if (status < 0) + return status; + + *profile = status; + return 0; +} + +static int ssam_platform_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + struct ssam_tmp_profile_device *tpd; + int tp; + + tpd = container_of(pprof, struct ssam_tmp_profile_device, handler); + + tp = convert_profile_to_ssam(tpd->sdev, profile); + if (tp < 0) + return tp; + + return ssam_tmp_profile_set(tpd->sdev, tp); +} + +static int surface_platform_profile_probe(struct ssam_device *sdev) +{ + struct ssam_tmp_profile_device *tpd; + + tpd = devm_kzalloc(&sdev->dev, sizeof(*tpd), GFP_KERNEL); + if (!tpd) + return -ENOMEM; + + tpd->sdev = sdev; + + tpd->handler.profile_get = ssam_platform_profile_get; + tpd->handler.profile_set = ssam_platform_profile_set; + + set_bit(PLATFORM_PROFILE_LOW_POWER, tpd->handler.choices); + set_bit(PLATFORM_PROFILE_BALANCED, tpd->handler.choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices); + + platform_profile_register(&tpd->handler); + return 0; +} + +static void surface_platform_profile_remove(struct ssam_device *sdev) +{ + platform_profile_remove(); +} + +static const struct ssam_device_id ssam_platform_profile_match[] = { + { SSAM_SDEV(TMP, 0x01, 0x00, 0x01) }, + { }, +}; +MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match); + +static struct ssam_device_driver surface_platform_profile = { + .probe = surface_platform_profile_probe, + .remove = surface_platform_profile_remove, + .match_table = ssam_platform_profile_match, + .driver = { + .name = "surface_platform_profile", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, +}; +module_ssam_device_driver(surface_platform_profile); + +MODULE_AUTHOR("Maximilian Luz "); +MODULE_DESCRIPTION("Platform Profile Support for Surface System Aggregator Module"); +MODULE_LICENSE("GPL");