From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 E3AD0C47095 for ; Sun, 4 Oct 2020 21:14:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A00EF2078A for ; Sun, 4 Oct 2020 21:14:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YMyZ9mht" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbgJDVOH (ORCPT ); Sun, 4 Oct 2020 17:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbgJDVOH (ORCPT ); Sun, 4 Oct 2020 17:14:07 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B1E3C0613CE; Sun, 4 Oct 2020 14:14:05 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id c8so7265959edv.5; Sun, 04 Oct 2020 14:14:05 -0700 (PDT) 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=7gA9oTDv2nx4CTXkWjdZU1D66M5iJ2f3g7L7EeYpRzY=; b=YMyZ9mhtEGiDopnT6L0K4z2Bs77YPPsTg7zanex2x0ZRObnttr5PRiug7QsWWcYT44 KiYBX5N+I862z5Rsbrk/yE3ir3PXG+Feg/S3lFMfx6otoKEuiZfXkQ3EZEcurNk3T+4c E34h4mTicLH097dwYQATIvRPY9YhDHvLj9EUpZ9anBzGXbtmdljGP1zrwvIr6Jm4ueZT Yt0J9vv1W6WlvxJcG1t/q7vehZfPZj4labmKU9Er5LSVhA40t9tpygAAB0eO0QKtgbBb f+7sW9zN5ZWr9vUisiKrFQi27xs8EBbIni7gt3rY/UIZRVOY0Ci1xrOOTe9KUClHSSy2 ujYw== 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=7gA9oTDv2nx4CTXkWjdZU1D66M5iJ2f3g7L7EeYpRzY=; b=muIk0eF7cjBVu+9iRCKoWfIYx6bVEsVS7JsOMEKSMX41wUvhATsi8n48CkXnPNr/yY WPHM2stUqJjpt4cbmoiTDrqGuf7p08rP5BJ2t8sJszTW/FQui3yz3XYJI9mSdwye7IYB IzNG4Fs1k0rhTtypfZF5hHC87QtgMfA05VuBiiAEJlDyqRz23u5DhQVKUHfdR9c8I3zx DWo4C9oeqdetSIiixPqZ6cTTbgr6nB61rCJSNKtMTT4YkGu1wWPd1kB4CNyandUPDvth Igf+hGJ5UOfg6pvzPXD9YNydr+rcaKnFRkOlioY/RwH83uuIy3VBEOUTSuAtJHyExbWc 3ezw== X-Gm-Message-State: AOAM533BVy/cw9VU7RsNwDVDPHbK2Yikorx0/5/zvzoj8egzocbIMyI/ FcVoEgZBoCcJAtKCGt5qeSU= X-Google-Smtp-Source: ABdhPJwXO7OuY1abcos1ZhW7HdL6Pk5MgNC3CA6lsWBno1qabXMND3RaKAiSb7vl75XOelA8KtF/IA== X-Received: by 2002:a50:9e87:: with SMTP id a7mr12817999edf.297.1601846043924; Sun, 04 Oct 2020 14:14:03 -0700 (PDT) Received: from localhost.localdomain (host-79-12-92-76.retail.telecomitalia.it. [79.12.92.76]) by smtp.gmail.com with ESMTPSA id r24sm1387803edm.95.2020.10.04.14.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 14:14:03 -0700 (PDT) From: Elia Devito Cc: mgross@linux.intel.com, Elia Devito , Darren Hart , Andy Shevchenko , Hans de Goede , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] platform/x86: hp-wmi: add support for thermal policy Date: Sun, 4 Oct 2020 23:13:05 +0200 Message-Id: <20201004211305.11628-1-eliadevito@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917214957.GD29136@mtg-dev.jf.intel.com> References: <20200917214957.GD29136@mtg-dev.jf.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HP Spectre notebooks (and probably other model as well) support up to 4 thermal policy: - HP Recommended - Performance - Cool - Quiet at least on HP Spectre x360 Convertible 15-df0xxx the firmware sets the thermal policy to default but hardcode the odvp0 variable to 1, this causes thermald to choose the wrong DPTF profile witch result in low performance when notebook is on AC, calling thermal policy write command allow firmware to correctly set the odvp0 variable. Signed-off-by: Elia Devito --- drivers/platform/x86/hp-wmi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 1762f335bac9..6e448a79caee 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -81,6 +81,7 @@ enum hp_wmi_commandtype { HPWMI_FEATURE2_QUERY = 0x0d, HPWMI_WIRELESS2_QUERY = 0x1b, HPWMI_POSTCODEERROR_QUERY = 0x2a, + HPWMI_THERMAL_POLICY_QUERY = 0x4c }; enum hp_wmi_command { @@ -861,6 +862,26 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device) return err; } +static int thermal_policy_setup(struct platform_device *device) +{ + int err, tp; + + tp = hp_wmi_read_int(HPWMI_THERMAL_POLICY_QUERY); + if (tp < 0) + return tp; + + /* + * call thermal policy write command to ensure that the firmware correctly + * sets the OEM variables for the DPTF + */ + err = hp_wmi_perform_query(HPWMI_THERMAL_POLICY_QUERY, HPWMI_WRITE, &tp, + sizeof(tp), 0); + if (err) + return err; + + return 0; +} + static int __init hp_wmi_bios_setup(struct platform_device *device) { /* clear detected rfkill devices */ @@ -872,6 +893,8 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (hp_wmi_rfkill_setup(device)) hp_wmi_rfkill2_setup(device); + thermal_policy_setup(device); + return 0; } -- 2.26.2