Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2413336lqb; Mon, 27 May 2024 21:05:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVSxGczd0wKLIOeTYmSmT3RQaZeyzyX1U8GiP+FQK+8B7kweyuRG+epSlAqU02Ji6u+zZBrzPcMHeqNTqCMDICxjapymRy2LM33w7ttSQ== X-Google-Smtp-Source: AGHT+IGyZdPdSHlcQ2HyYD3jiU3f3u7QjH8QUa7dbmysOC1JShs2PHSpzPTAM9YCElHXzo28Dy4u X-Received: by 2002:a05:6830:18d1:b0:6f7:c2a6:970d with SMTP id 46e09a7af769-6f8d0b3129dmr14265811a34.34.1716869150547; Mon, 27 May 2024 21:05:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716869150; cv=pass; d=google.com; s=arc-20160816; b=dKKVlaPdbRU0acyPwp89zOQe7Biuw8i9IsbMp1AqRWH4LGesvAuMJSTx/hWd1uWQqo HHE6sYdebo8iB+TIKQdObnBTsfsgkKlQJB2jfRiHHSXlelovIoBfd6Be+lA/OUjhhXKn vfhO50YCvyQu66feGnGEVvioSbPWotv0bYWExsRO+p3TAo4p0XyAtGji7CEfkySlHLTE iChbH4ruQUsDN6fH+JyjHLzsMB+mb/Ndx4Y7oJnoG3IS7q9KTLPl0ST6v6m2bwjgkpza z1PyLan10luqkRPCsFJHCwx6ZY+2KEhg1EgU27dZp5RDNZqYPMug8WgDdfyQX4JX5QnQ A5UA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:feedback-id:dkim-signature:dkim-signature; bh=oUbMKxb/AnzUhw3GvwikoRj656Q1cIKAuZQGKv+i05A=; fh=KBOOsaW3YEneVcYsdRdNlUHz1Q41m6vPI9Uc3mM7Mz4=; b=AUEm3GYTR1R9IcC/ciYLIPaKMWUH0+7YuXLvVY32jYsTKFzSesYmJ0kVSpdEzKaxDi XhwnxfcxU8/VsGqDR0T0jmR3l86rqRZpen+TXsvn9SWF6d6rkZwPqmXkhFPE+zDUHY2l r7XAZDfEPJ1OSrHBViMitD9/NI1U9C9H2/MQOP5c2YVrIuAP5Qjd9wkTviXFVjPDXlEL a6Spyk5/Lchr7Tn2mC7tgOi0+Hc8/nof+jtLnU9d5QQsGChw465TSTcg30BmJIAMxHu4 djBhTqvBVocQymvpoCLG5c/IF+ohTtVnlOVyoqEgGQU6dNriGXg7IfOgBs8/01yRJrqu gryQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm2 header.b=CMOEec67; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=JD2WTgaR; arc=pass (i=1 dkim=pass dkdomain=ljones.dev dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-191620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191620-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-68229937266si7527896a12.643.2024.05.27.21.05.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 21:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm2 header.b=CMOEec67; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=JD2WTgaR; arc=pass (i=1 dkim=pass dkdomain=ljones.dev dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-191620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191620-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3B9BA2844BC for ; Tue, 28 May 2024 01:39:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B1AE11CB8; Tue, 28 May 2024 01:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="CMOEec67"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JD2WTgaR" Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F8523AC16; Tue, 28 May 2024 01:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716860226; cv=none; b=cS7TcyBfbeks+IPMDU1X9XySIJz/OAiPbpB/169chOkaPobsXrqHE0ooKzHRUlJLe7eeWtee+V0xr5nW6kgPnLul6EBdMTOSFE2EzWR3pSRu/B5Kd2U+Lmma+uwinjChzi2dM0AFohKkfu2NniZjbAVeCsx3q5QDvFTk5y/T/Ts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716860226; c=relaxed/simple; bh=aIav+5EECdqbJcYjdH5A+4TUj/fYjbell3xkt46zAls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JWsHyv9FKLhz7CsmbNXTZaWd6KgKtHCCQnrqKw3IkgW3enhE2UtaAXE80b4FF0RgZ3x11KMN6WVS6lIy9b5pi0AslK46COI+AK5tSgBUkZL3JSbK4MD4YoaJlHZincG6wodxnJH+lzYUhCI6PuSISB10lYHpWkOLV4xVGvbG5FI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=CMOEec67; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JD2WTgaR; arc=none smtp.client-ip=103.168.172.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 8F0B51380142; Mon, 27 May 2024 21:37:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 27 May 2024 21:37:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1716860224; x= 1716946624; bh=oUbMKxb/AnzUhw3GvwikoRj656Q1cIKAuZQGKv+i05A=; b=C MOEec67Cywe9myr1q0v3AhliuPSqC3/HcbZzcCBthK/vUxcUPZKn1HxPv134QkyB U2uCoaV4CXFo0sqUWsvIHRFvecsCrLncBjbtzDRUZDs6xr8u0EiGIovja1Or6RIl U6UjLHlpDkM2WmmS0f7yITJaIDzrFRWeo9ssiP2zEfb6YuaZKM4rZkDSiOKx0fbA G+B0Ff2gllI8coFUEOPcX4VlYcGu9f+dpyU+5arXyqmev4z/dBrqR9ITSrGoEG0K Xp0ANRYFZiPHPlCZce+esI8OrziLxTNCI3CipMM+6oA8DLuWpsKOgwjdTFcY5fX0 V6XJDJ2QLW9Yh3fgxHPEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716860224; x= 1716946624; bh=oUbMKxb/AnzUhw3GvwikoRj656Q1cIKAuZQGKv+i05A=; b=J D2WTgaRELGS+RFOX6D/oY41aMTL7Jad52P2wJdGsRLn6dEHjqQ31l3Z3E2Z+JWU5 cJwYbUAbWDzeYLgfPkC4IXObC1100vJyztmMFhE0Dur6A5iI/f1Tdz0BTqvkawWk QMcvljOn32e25Y4y0TTJ35r2PX/VjFwETpxyj1EE0pWtgr/mP7F40zyZoKY6/Tw6 WIr80INf3Cii0KcUfsroMQlFc9doT4bBFIhnJHoCB4GA74hxK+js0hAxavturfYD DFOV2PvBv5KOA5g1wlc/1z+j8BDDhj+tCAGY4J7M4PXQC6FjvcTknYs2L0h+iUzb pgxN8469U+vZ7bl0pi2NA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdejhedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 May 2024 21:37:01 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: ilpo.jarvinen@linux.intel.com, corentin.chary@gmail.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH 9/9] platform/x86: asus-wmi: add setting dGPU TGP Date: Tue, 28 May 2024 13:36:26 +1200 Message-ID: <20240528013626.14066-10-luke@ljones.dev> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240528013626.14066-1-luke@ljones.dev> References: <20240528013626.14066-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The dGPU TGP can be set on a few ROG laptops. This gnerally needs some extra userspace inference to find the base and limit: - Find max-tgp from nvidia-smi - Find max-boost from nv_dynamic_boost_max (asus_wmi) - (max-tgp - max-boost - initial TGP) = base TGP - (max-tgp - max-boost - base TGP) = max additional TGP On some laptops the dgpu_base_tgp may return 0, in which case the base TGP must be derived as above. Signed-off-by: Luke D. Jones --- .../ABI/testing/sysfs-platform-asus-wmi | 19 +++++++++++++++++++ drivers/platform/x86/asus-wmi.c | 9 +++++++++ include/linux/platform_data/x86/asus-wmi.h | 3 +++ 3 files changed, 31 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi index d221a3bc1a81..46df3452c9da 100644 --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi @@ -253,3 +253,22 @@ Contact: "Luke Jones" Description: Set the maximum available system memory for the APU. * Min=0, Max=8 + +What: /sys/devices/platform//dgpu_tgp +Date: Jun 2024 +KernelVersion: 6.11 +Contact: "Luke Jones" +Description: + Read and set the extra TGP applied to the dGPU. This is applied on + top of the dgpu_base_tgp. + + If the dGPU maximum power including boost is 175 then we can calculate: + 175 - 25 (dynamic boost) - 70 (initial dgpu_tgp) = 80 (dgpu_base_tgp). + For NVIDIA dGPU the max power can be found with nvidia-smi. + +What: /sys/devices/platform//dgpu_base_tgp +Date: Jun 2024 +KernelVersion: 6.11 +Contact: "Luke Jones" +Description: + Read the absolute base TGP of the dGPU. diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 4b5fbae8c563..4d291429e7a1 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -123,6 +123,7 @@ module_param(fnlock_default, bool, 0444); #define NVIDIA_BOOST_MAX 25 #define NVIDIA_TEMP_MIN 75 #define NVIDIA_TEMP_MAX 87 +#define NVIDIA_GPU_POWER_MAX 70 #define ASUS_SCREENPAD_BRIGHT_MIN 20 #define ASUS_SCREENPAD_BRIGHT_MAX 255 @@ -797,6 +798,8 @@ WMI_ATTR_SIMPLE_RO(egpu_connected, ASUS_WMI_DEVID_EGPU_CONNECTED); WMI_ATTR_SIMPLE_RW(panel_od, 0, 1, ASUS_WMI_DEVID_PANEL_OD); WMI_ATTR_SIMPLE_RW(boot_sound, 0, 1, ASUS_WMI_DEVID_BOOT_SOUND); WMI_ATTR_SIMPLE_RO(charge_mode, ASUS_WMI_DEVID_CHARGE_MODE); +WMI_ATTR_SIMPLE_RO(dgpu_base_tgp, ASUS_WMI_DEVID_DGPU_BASE_TGP); +WMI_ATTR_SIMPLE_RW(dgpu_tgp, 0, NVIDIA_GPU_POWER_MAX, ASUS_WMI_DEVID_DGPU_SET_TGP); static ssize_t panel_fhd_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -4204,6 +4207,8 @@ static struct attribute *platform_attributes[] = { &dev_attr_boot_sound.attr, &dev_attr_panel_od.attr, &dev_attr_panel_fhd.attr, + &dev_attr_dgpu_base_tgp.attr, + &dev_attr_dgpu_tgp.attr, &dev_attr_cores_enabled.attr, &dev_attr_cores_max.attr, &dev_attr_apu_mem.attr, @@ -4280,6 +4285,10 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, devid = ASUS_WMI_DEVID_PANEL_OD; else if (attr == &dev_attr_panel_fhd.attr) devid = ASUS_WMI_DEVID_PANEL_FHD; + else if (attr == &dev_attr_dgpu_base_tgp.attr) + devid = ASUS_WMI_DEVID_DGPU_BASE_TGP; + else if (attr == &dev_attr_dgpu_tgp.attr) + ok = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU_SET_TGP); else if (attr == &dev_attr_cores_enabled.attr || attr == &dev_attr_cores_max.attr) ok = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CORES_SET); diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h index efe608861e55..71833bd60f27 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -135,6 +135,9 @@ /* dgpu on/off */ #define ASUS_WMI_DEVID_DGPU 0x00090020 +#define ASUS_WMI_DEVID_DGPU_BASE_TGP 0x00120099 +#define ASUS_WMI_DEVID_DGPU_SET_TGP 0x00120098 + /* gpu mux switch, 0 = dGPU, 1 = Optimus */ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 #define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 -- 2.45.1