From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, "Luke D. Jones" <luke@ljones.dev>,
Hans de Goede <hdegoede@redhat.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10 11/97] asus-wmi: Add dgpu disable method
Date: Mon, 11 Dec 2023 19:21:14 +0100 [thread overview]
Message-ID: <20231211182020.303342402@linuxfoundation.org> (raw)
In-Reply-To: <20231211182019.802717483@linuxfoundation.org>
5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luke D. Jones <luke@ljones.dev>
[ Upstream commit 98829e84dc67630efb7de675f0a70066620468a3 ]
In Windows the ASUS Armory Crate program can enable or disable the
dGPU via a WMI call. This functions much the same as various Linux
methods in software where the dGPU is removed from the device tree.
However the WMI call saves the state of dGPU (enabled or not) and
this then changes the dGPU visibility in Linux with no way for
Linux users to re-enable it. We expose the WMI method so users can
see and change the dGPU ACPI state.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
Link: https://lore.kernel.org/r/20210807023656.25020-3-luke@ljones.dev
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Stable-dep-of: b52cbca22cbf ("platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi code")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/platform/x86/asus-wmi.c | 98 ++++++++++++++++++++++
include/linux/platform_data/x86/asus-wmi.h | 3 +
2 files changed, 101 insertions(+)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index ca3b97b7a6ad8..93b4c61130837 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -207,6 +207,9 @@ struct asus_wmi {
u8 fan_boost_mode_mask;
u8 fan_boost_mode;
+ bool dgpu_disable_available;
+ bool dgpu_disable;
+
bool throttle_thermal_policy_available;
u8 throttle_thermal_policy_mode;
@@ -421,6 +424,93 @@ static void lid_flip_tablet_mode_get_state(struct asus_wmi *asus)
}
}
+/* dGPU ********************************************************************/
+static int dgpu_disable_check_present(struct asus_wmi *asus)
+{
+ u32 result;
+ int err;
+
+ asus->dgpu_disable_available = false;
+
+ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_DGPU, &result);
+ if (err) {
+ if (err == -ENODEV)
+ return 0;
+ return err;
+ }
+
+ if (result & ASUS_WMI_DSTS_PRESENCE_BIT) {
+ asus->dgpu_disable_available = true;
+ asus->dgpu_disable = result & ASUS_WMI_DSTS_STATUS_BIT;
+ }
+
+ return 0;
+}
+
+static int dgpu_disable_write(struct asus_wmi *asus)
+{
+ u32 retval;
+ u8 value;
+ int err;
+
+ /* Don't rely on type conversion */
+ value = asus->dgpu_disable ? 1 : 0;
+
+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_DGPU, value, &retval);
+ if (err) {
+ pr_warn("Failed to set dgpu disable: %d\n", err);
+ return err;
+ }
+
+ if (retval > 1 || retval < 0) {
+ pr_warn("Failed to set dgpu disable (retval): 0x%x\n", retval);
+ return -EIO;
+ }
+
+ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "dgpu_disable");
+
+ return 0;
+}
+
+static ssize_t dgpu_disable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+ u8 mode = asus->dgpu_disable;
+
+ return sysfs_emit(buf, "%d\n", mode);
+}
+
+/*
+ * A user may be required to store the value twice, typcial store first, then
+ * rescan PCI bus to activate power, then store a second time to save correctly.
+ * The reason for this is that an extra code path in the ACPI is enabled when
+ * the device and bus are powered.
+ */
+static ssize_t dgpu_disable_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ bool disable;
+ int result;
+
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ result = kstrtobool(buf, &disable);
+ if (result)
+ return result;
+
+ asus->dgpu_disable = disable;
+
+ result = dgpu_disable_write(asus);
+ if (result)
+ return result;
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(dgpu_disable);
+
/* Battery ********************************************************************/
/* The battery maximum charging percentage */
@@ -2319,6 +2409,7 @@ static struct attribute *platform_attributes[] = {
&dev_attr_camera.attr,
&dev_attr_cardr.attr,
&dev_attr_touchpad.attr,
+ &dev_attr_dgpu_disable.attr,
&dev_attr_lid_resume.attr,
&dev_attr_als_enable.attr,
&dev_attr_fan_boost_mode.attr,
@@ -2344,6 +2435,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
devid = ASUS_WMI_DEVID_LID_RESUME;
else if (attr == &dev_attr_als_enable.attr)
devid = ASUS_WMI_DEVID_ALS_ENABLE;
+ else if (attr == &dev_attr_dgpu_disable.attr)
+ ok = asus->dgpu_disable_available;
else if (attr == &dev_attr_fan_boost_mode.attr)
ok = asus->fan_boost_mode_available;
else if (attr == &dev_attr_throttle_thermal_policy.attr)
@@ -2603,6 +2696,10 @@ static int asus_wmi_add(struct platform_device *pdev)
if (err)
goto fail_platform;
+ err = dgpu_disable_check_present(asus);
+ if (err)
+ goto fail_dgpu_disable;
+
err = fan_boost_mode_check_present(asus);
if (err)
goto fail_fan_boost_mode;
@@ -2699,6 +2796,7 @@ static int asus_wmi_add(struct platform_device *pdev)
fail_sysfs:
fail_throttle_thermal_policy:
fail_fan_boost_mode:
+fail_dgpu_disable:
fail_platform:
kfree(asus);
return err;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 2f274cf528050..7d8d3e9c45d62 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -89,6 +89,9 @@
/* Keyboard dock */
#define ASUS_WMI_DEVID_KBD_DOCK 0x00120063
+/* dgpu on/off */
+#define ASUS_WMI_DEVID_DGPU 0x00090020
+
/* DSTS masks */
#define ASUS_WMI_DSTS_STATUS_BIT 0x00000001
#define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002
--
2.42.0
next prev parent reply other threads:[~2023-12-11 18:37 UTC|newest]
Thread overview: 108+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 18:21 [PATCH 5.10 00/97] 5.10.204-rc1 review Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 01/97] hrtimers: Push pending hrtimers away from outgoing CPU earlier Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 02/97] i2c: designware: Fix corrupted memory seen in the ISR Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 03/97] netfilter: ipset: fix race condition between swap/destroy and kernel side add/del/test Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 04/97] tg3: Move the [rt]x_dropped counters to tg3_napi Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 05/97] tg3: Increment tx_dropped in tg3_tso_bug() Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 06/97] kconfig: fix memory leak from range properties Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 07/97] drm/amdgpu: correct chunk_ptr to a pointer to chunk Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 08/97] platform/x86: asus-wmi: Add support for SW_TABLET_MODE on UX360 Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 09/97] platform/x86: asus-nb-wmi: Allow configuring SW_TABLET_MODE method with a module option Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 10/97] platform/x86: asus-nb-wmi: Add tablet_mode_sw=lid-flip quirk for the TP200s Greg Kroah-Hartman
2023-12-11 18:21 ` Greg Kroah-Hartman [this message]
2023-12-11 18:21 ` [PATCH 5.10 12/97] platform/x86: asus-wmi: Adjust tablet/lidflip handling to use enum Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 13/97] platform/x86: asus-wmi: Add support for ROG X13 tablet mode Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 14/97] platform/x86: asus-wmi: Simplify tablet-mode-switch probing Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 15/97] platform/x86: asus-wmi: Simplify tablet-mode-switch handling Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 16/97] platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi code Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 17/97] of: base: Fix some formatting issues and provide missing descriptions Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 18/97] of: Fix kerneldoc output formatting Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 19/97] of: Add missing Return section in kerneldoc comments Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 20/97] of: dynamic: Fix of_reconfig_get_state_change() return value documentation Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 21/97] ipv6: fix potential NULL deref in fib6_add() Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 22/97] octeontx2-pf: Add missing mutex lock in otx2_get_pauseparam Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 23/97] hv_netvsc: rndis_filter needs to select NLS Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 24/97] mlxbf-bootctl: correctly identify secure boot with development keys Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 25/97] net: arcnet: com20020 fix error handling Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 26/97] arcnet: restoring support for multiple Sohard Arcnet cards Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 27/97] i40e: Fix unexpected MFS warning message Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 28/97] net: bnxt: fix a potential use-after-free in bnxt_init_tc Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 29/97] ionic: fix snprintf format length warning Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 30/97] ionic: Fix dim work handling in split interrupt mode Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 31/97] ipv4: ip_gre: Avoid skb_pull() failure in ipgre_xmit() Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 32/97] net: hns: fix fake link up on xge port Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 33/97] netfilter: xt_owner: Fix for unsafe access of sk->sk_socket Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 34/97] tcp: do not accept ACK of bytes we never sent Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 35/97] bpf: sockmap, updating the sg structure should also update curr Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 36/97] tee: optee: Fix supplicant based device enumeration Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 37/97] arm64: dts: rockchip: Expand reg size of vdec node for RK3399 Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 38/97] RDMA/rtrs-clt: Remove the warnings for req in_use check Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 39/97] RDMA/bnxt_re: Correct module description string Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 40/97] hwmon: (acpi_power_meter) Fix 4.29 MW bug Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 41/97] ASoC: wm_adsp: fix memleak in wm_adsp_buffer_populate Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 42/97] tracing: Fix a warning when allocating buffered events fails Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 43/97] scsi: be2iscsi: Fix a memleak in beiscsi_init_wrb_handle() Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 44/97] ARM: imx: Check return value of devm_kasprintf in imx_mmdc_perf_init Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 45/97] ARM: dts: imx7: Declare timers compatible with fsl,imx6dl-gpt Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 46/97] riscv: fix misaligned access handling of C.SWSP and C.SDSP Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 47/97] ALSA: pcm: fix out-of-bounds in snd_pcm_state_names Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 48/97] ALSA: hda/realtek: Enable headset on Lenovo M90 Gen5 Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 49/97] nilfs2: fix missing error check for sb_set_blocksize call Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 50/97] nilfs2: prevent WARNING in nilfs_sufile_set_segment_usage() Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 51/97] checkstack: fix printed address Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 52/97] tracing: Always update snapshot buffer size Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 53/97] tracing: Disable snapshot buffer when stopping instance tracers Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 54/97] tracing: Fix incomplete locking when disabling buffered events Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 55/97] tracing: Fix a possible race " Greg Kroah-Hartman
2023-12-11 18:21 ` [PATCH 5.10 56/97] packet: Move reference count in packet_sock to atomic_long_t Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 57/97] arm64: dts: mediatek: mt7622: fix memory node warning check Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 58/97] arm64: dts: mediatek: mt8173-evb: Fix regulator-fixed node names Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 59/97] arm64: dts: mediatek: mt8183: Fix unit address for scp reserved memory Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 60/97] misc: mei: client.c: return negative error code in mei_cl_write Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 61/97] misc: mei: client.c: fix problem of return -EOVERFLOW " Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 62/97] ring-buffer: Force absolute timestamp on discard of event Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 63/97] tracing: Set actual size after ring buffer resize Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 64/97] tracing: Stop current tracer when resizing buffer Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 65/97] perf/core: Add a new read format to get a number of lost samples Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 66/97] perf: Fix perf_event_validate_size() Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 67/97] gpiolib: sysfs: Fix error handling on failed export Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 68/97] drm/amdgpu: correct the amdgpu runtime dereference usage count Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 69/97] usb: gadget: f_hid: fix report descriptor allocation Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 70/97] parport: Add support for Brainboxes IX/UC/PX parallel cards Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 71/97] Revert "xhci: Loosen RPM as default policy to cover for AMD xHC 1.1" Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 72/97] usb: typec: class: fix typec_altmode_put_partner to put plugs Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 73/97] ARM: PL011: Fix DMA support Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 74/97] serial: sc16is7xx: address RX timeout interrupt errata Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 75/97] serial: 8250: 8250_omap: Clear UART_HAS_RHR_IT_DIS bit Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 76/97] serial: 8250: 8250_omap: Do not start RX DMA on THRI interrupt Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 77/97] serial: 8250_omap: Add earlycon support for the AM654 UART controller Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 78/97] x86/CPU/AMD: Check vendor in the AMD microcode callback Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 79/97] KVM: s390/mm: Properly reset no-dat Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 80/97] MIPS: Loongson64: Reserve vgabios memory on boot Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 81/97] MIPS: Loongson64: Enable DMA noncoherent support Greg Kroah-Hartman
2023-12-30 19:38 ` Salvatore Bonaccorso
2023-12-30 23:16 ` Jiaxun Yang
2023-12-31 9:33 ` Salvatore Bonaccorso
2024-01-03 10:40 ` Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 82/97] io_uring/af_unix: disable sending io_uring over sockets Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 83/97] netlink: dont call ->netlink_bind with table lock held Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 84/97] genetlink: add CAP_NET_ADMIN test for multicast bind Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 85/97] psample: Require CAP_NET_ADMIN when joining "packets" group Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 86/97] drop_monitor: Require CAP_SYS_ADMIN when joining "events" group Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 87/97] netfilter: nft_set_pipapo: skip inactive elements during set walk Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 88/97] platform/x86: asus-wmi: Fix kbd_dock_devid tablet-switch reporting Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 89/97] tools headers UAPI: Sync linux/perf_event.h with the kernel sources Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 90/97] platform/x86: asus-wmi: Document the dgpu_disable sysfs attribute Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 91/97] mmc: block: Be sure to wait while busy in CQE error recovery Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 92/97] Revert "btrfs: add dmesg output for first mount and last unmount of a filesystem" Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 93/97] cifs: Fix non-availability of dedup breaking generic/304 Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 94/97] smb: client: fix potential NULL deref in parse_dfs_referrals() Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 95/97] devcoredump : Serialize devcd_del work Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 96/97] devcoredump: Send uevent once devcd is ready Greg Kroah-Hartman
2023-12-11 18:22 ` [PATCH 5.10 97/97] r8169: fix rtl8125b PAUSE frames blasting when suspended Greg Kroah-Hartman
2023-12-11 19:17 ` [PATCH 5.10 00/97] 5.10.204-rc1 review Florian Fainelli
2023-12-12 16:29 ` Naresh Kamboju
2023-12-12 17:01 ` Guenter Roeck
2023-12-12 19:08 ` Pavel Machek
2023-12-12 22:20 ` Jon Hunter
2023-12-13 3:43 ` Dominique Martinet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231211182020.303342402@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=luke@ljones.dev \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).