From: "Luke D. Jones" <luke@ljones.dev>
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" <luke@ljones.dev>
Subject: [PATCH 8/9] platform/x86: asus-wmi: add apu_mem setting
Date: Tue, 28 May 2024 13:36:25 +1200 [thread overview]
Message-ID: <20240528013626.14066-9-luke@ljones.dev> (raw)
In-Reply-To: <20240528013626.14066-1-luke@ljones.dev>
Exposes the APU memory setting available on a few ASUS models such as
the ROG Ally.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
.../ABI/testing/sysfs-platform-asus-wmi | 8 ++
drivers/platform/x86/asus-wmi.c | 109 ++++++++++++++++++
include/linux/platform_data/x86/asus-wmi.h | 3 +
3 files changed, 120 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
index ac881e72e374..d221a3bc1a81 100644
--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
+++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
@@ -245,3 +245,11 @@ Description:
Show the maximum performance and efficiency core countin format
0x[E][P] where [E] is the efficiency core count, and [P] is
the perfromance core count.
+
+What: /sys/devices/platform/<platform>/apu_mem
+Date: Jun 2024
+KernelVersion: 6.11
+Contact: "Luke Jones" <luke@ljones.dev>
+Description:
+ Set the maximum available system memory for the APU.
+ * Min=0, Max=8
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index f62a36dfcd4b..4b5fbae8c563 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -855,6 +855,112 @@ static DEVICE_ATTR_RW(cores_enabled);
WMI_SIMPLE_SHOW(cores_max, "0x%x\n", ASUS_WMI_DEVID_CORES_MAX);
static DEVICE_ATTR_RO(cores_max);
+/* Device memory available to APU */
+
+static ssize_t apu_mem_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+ int err;
+ u32 mem;
+
+ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_APU_MEM, &mem);
+ if (err < 0)
+ return err;
+
+ switch (mem) {
+ case 256:
+ mem = 0;
+ break;
+ case 258:
+ mem = 1;
+ break;
+ case 259:
+ mem = 2;
+ break;
+ case 260:
+ mem = 3;
+ break;
+ case 261:
+ mem = 4;
+ break;
+ case 262:
+ mem = 8;
+ break;
+ case 263:
+ mem = 5;
+ break;
+ case 264:
+ mem = 6;
+ break;
+ case 265:
+ mem = 7;
+ break;
+ default:
+ mem = 4;
+ break;
+ }
+
+ return sysfs_emit(buf, "%d\n", mem);
+}
+
+static ssize_t apu_mem_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+ int result, err;
+ u32 mem;
+
+ result = kstrtou32(buf, 10, &mem);
+ if (result)
+ return result;
+
+ switch (mem) {
+ case 0:
+ mem = 0;
+ break;
+ case 1:
+ mem = 258;
+ break;
+ case 2:
+ mem = 259;
+ break;
+ case 3:
+ mem = 260;
+ break;
+ case 4:
+ mem = 261;
+ break;
+ case 5:
+ mem = 263;
+ break;
+ case 6:
+ mem = 264;
+ break;
+ case 7:
+ mem = 265;
+ break;
+ case 8:
+ mem = 262;
+ break;
+ default:
+ return -EIO;
+ }
+
+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_APU_MEM, mem, &result);
+ if (err) {
+ pr_warn("Failed to set apu_mem: %d\n", err);
+ return err;
+ }
+
+ pr_info("APU memory changed, reboot required\n");
+ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "apu_mem");
+
+ return count;
+}
+static DEVICE_ATTR_RW(apu_mem);
+
/* Tablet mode ****************************************************************/
static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus)
@@ -4100,6 +4206,7 @@ static struct attribute *platform_attributes[] = {
&dev_attr_panel_fhd.attr,
&dev_attr_cores_enabled.attr,
&dev_attr_cores_max.attr,
+ &dev_attr_apu_mem.attr,
&dev_attr_mini_led_mode.attr,
&dev_attr_available_mini_led_mode.attr,
NULL
@@ -4176,6 +4283,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
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);
+ else if (attr == &dev_attr_apu_mem.attr)
+ ok = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_APU_MEM);
else if (attr == &dev_attr_mini_led_mode.attr)
ok = asus->mini_led_dev_id != 0;
else if (attr == &dev_attr_available_mini_led_mode.attr)
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 5a56e7e97785..efe608861e55 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -121,6 +121,9 @@
/* Maximum Intel E-core and P-core availability */
#define ASUS_WMI_DEVID_CORES_MAX 0x001200D3
+/* Set the memory available to the APU */
+#define ASUS_WMI_DEVID_APU_MEM 0x000600C1
+
/* MCU powersave mode */
#define ASUS_WMI_DEVID_MCU_POWERSAVE 0x001200E2
--
2.45.1
next prev parent reply other threads:[~2024-05-28 1:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 1:36 [PATCH 0/9] platform-x86-asus-wmi: multiple fixes, improvements, features Luke D. Jones
2024-05-28 1:36 ` [PATCH 1/9] platform/x86: asus-wmi: add debug print in more key places Luke D. Jones
2024-05-28 1:36 ` [PATCH 2/9] platform/x86: asus-wmi: don't fail if platform_profile already registered Luke D. Jones
2024-05-28 1:36 ` [PATCH 3/9] platform/x86: asus-wmi: add macros and expose min/max sysfs for ppt tunables Luke D. Jones
2024-05-28 8:50 ` Ilpo Järvinen
2024-06-04 5:14 ` kernel test robot
2024-05-28 1:36 ` [PATCH 4/9] platform/x86: asus-wmi: reduce code duplication with macros Luke D. Jones
2024-05-28 8:55 ` Ilpo Järvinen
2024-05-28 9:03 ` Ilpo Järvinen
2024-05-28 1:36 ` [PATCH 5/9] platform/x86: asus-wmi: use WMI_SIMPLE_SHOW in more places Luke D. Jones
2024-05-28 9:06 ` Ilpo Järvinen
2024-05-28 1:36 ` [PATCH 6/9] platform/x86: asus-wmi: add panel-fhd functionality Luke D. Jones
2024-05-28 9:18 ` Ilpo Järvinen
2024-05-28 1:36 ` [PATCH 7/9] platform/x86: asus-wmi: add enable/disable CPU cores Luke D. Jones
2024-05-28 9:27 ` Ilpo Järvinen
2024-05-28 21:37 ` Luke Jones
2024-05-28 1:36 ` Luke D. Jones [this message]
2024-05-28 2:19 ` [PATCH 8/9] platform/x86: asus-wmi: add apu_mem setting Limonciello, Mario
2024-05-28 2:40 ` Luke Jones
2024-05-28 13:27 ` Mario Limonciello
2024-05-28 21:04 ` Luke Jones
2024-05-28 21:16 ` Mario Limonciello
2024-05-28 21:34 ` Luke Jones
2024-05-28 21:36 ` Mario Limonciello
2024-05-28 21:37 ` Mario Limonciello
2024-05-28 1:36 ` [PATCH 9/9] platform/x86: asus-wmi: add setting dGPU TGP Luke D. Jones
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=20240528013626.14066-9-luke@ljones.dev \
--to=luke@ljones.dev \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@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
all inboxes | Powered by JetHome®