linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces
@ 2025-11-14  8:42 Yo-Jung Leo Lin (AMD)
  2025-11-14  8:42 ` [PATCH v2 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask Yo-Jung Leo Lin (AMD)
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-14  8:42 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org), Yo-Jung Leo Lin (AMD)

The integrated info v2.3 table in the Atom ROM exposes available
options for the VRAM carveout sizes. The carveout size can be changed
using the ATCS function code 0xA for BIOS that supports this.

Make these features available as sysfs files, so that users can set
the carveout size in a way similar to what a Windows user can do in
the "Tuning" tab in the AMD Adrenalin. The newly added sysfs files
are:

- uma_carveout_options: this a read-only file listing all available
  carveout options. They are fetched from the Atom ROM on driver
  initialization.

- uma_carveout: this shows the index of the currently selected option,
  as shown in the uma_carveout_options. Writing a valid option index
  to this file will change the carveout option on next boot.

Note that above files are created only if BIOS indicates support for
it, i.e. where the table shows non-zero UMACarveoutIndexMax.

Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
---
Changes in v2:
- Move VBIOS table parsing and sysfs interface creation from atomfirmware
  initialization code to amdgpu_acpi_init()
- Create structs that abstract the uma options
- Move the parsed carveout options from atom_context to the amdgpu_atcs
- Minor kdoc fixes, as well as adding example output for uma_carveout_options
- Link to v1: https://lore.kernel.org/r/20251103-vram-carveout-tuning-for-upstream-v1-0-17e2a72639c5@amd.com

---
Yo-Jung Leo Lin (AMD) (5):
      drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask
      drm/amdgpu: add helper to read UMA carveout info
      drm/amdgpu: add UMA allocation setting helpers
      drm/amdgpu: add UMA allocation interfaces to sysfs
      Documentation/amdgpu: Add UMA carveout details

 Documentation/gpu/amdgpu/driver-misc.rst         |  26 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  39 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c         | 205 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c |  73 ++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h |   2 +
 drivers/gpu/drm/amd/include/amd_acpi.h           |  34 +++-
 6 files changed, 378 insertions(+), 1 deletion(-)
---
base-commit: ac9914fa72a5a917bb61c5e87bee6b8f9b751f33
change-id: 20251103-vram-carveout-tuning-for-upstream-1d5189688d73

Best regards,
-- 
Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask
  2025-11-14  8:42 [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
@ 2025-11-14  8:42 ` Yo-Jung Leo Lin (AMD)
  2025-11-14  8:42 ` [PATCH v2 2/5] drm/amdgpu: add helper to read UMA carveout info Yo-Jung Leo Lin (AMD)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-14  8:42 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org), Yo-Jung Leo Lin (AMD)

The capabilities of getting and setting VRAM carveout size are exposed
in the ATCS mask. Parse and store these capabilities for future use.

Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 4 ++++
 drivers/gpu/drm/amd/include/amd_acpi.h   | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 6c62e27b9800..0743fd8620e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -116,7 +116,9 @@ struct amdgpu_atcs_functions {
 	bool pcie_perf_req;
 	bool pcie_dev_rdy;
 	bool pcie_bus_width;
+	bool get_uma_size;
 	bool power_shift_control;
+	bool set_uma_allocation_size;
 };
 
 struct amdgpu_atcs {
@@ -588,7 +590,9 @@ static void amdgpu_atcs_parse_functions(struct amdgpu_atcs_functions *f, u32 mas
 	f->pcie_perf_req = mask & ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED;
 	f->pcie_dev_rdy = mask & ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED;
 	f->pcie_bus_width = mask & ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED;
+	f->get_uma_size = mask & ACPI_ATCS_GET_UMA_SIZE_SUPPORTED;
 	f->power_shift_control = mask & ATCS_SET_POWER_SHIFT_CONTROL_SUPPORTED;
+	f->set_uma_allocation_size = mask & ACPI_ATCS_SET_UMA_ALLOCATION_SIZE_SUPPORTED;
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/include/amd_acpi.h b/drivers/gpu/drm/amd/include/amd_acpi.h
index 06badbf0c5b9..e582339e8e8e 100644
--- a/drivers/gpu/drm/amd/include/amd_acpi.h
+++ b/drivers/gpu/drm/amd/include/amd_acpi.h
@@ -427,7 +427,9 @@ struct atcs_pwr_shift_input {
 #       define ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED             (1 << 1)
 #       define ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED       (1 << 2)
 #       define ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED                   (1 << 3)
-#       define ATCS_SET_POWER_SHIFT_CONTROL_SUPPORTED		   (1 << 7)
+#       define ACPI_ATCS_GET_UMA_SIZE_SUPPORTED                    (1 << 5)
+#       define ATCS_SET_POWER_SHIFT_CONTROL_SUPPORTED              (1 << 7)
+#       define ACPI_ATCS_SET_UMA_ALLOCATION_SIZE_SUPPORTED         (1 << 9)
 #define ATCS_FUNCTION_GET_EXTERNAL_STATE                           0x1
 /* ARG0: ATCS_FUNCTION_GET_EXTERNAL_STATE
  * ARG1: none

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/5] drm/amdgpu: add helper to read UMA carveout info
  2025-11-14  8:42 [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
  2025-11-14  8:42 ` [PATCH v2 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask Yo-Jung Leo Lin (AMD)
@ 2025-11-14  8:42 ` Yo-Jung Leo Lin (AMD)
  2025-11-17 19:43   ` Alex Deucher
  2025-11-14  8:42 ` [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers Yo-Jung Leo Lin (AMD)
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-14  8:42 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org), Yo-Jung Leo Lin (AMD)

Currently, the available UMA allocation configs in the integrated system
information table have not been parsed. Add a helper function to retrieve
and store these configs.

Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h              | 32 +++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c         |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 73 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h |  2 +
 4 files changed, 109 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a5574e84694b..2c1123291577 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1675,6 +1675,38 @@ struct amdgpu_numa_info {
 	int nid;
 };
 
+#define MAX_UMA_OPTION_NAME	28
+#define MAX_UMA_OPTION_ENTRIES	19
+
+#define AMDGPU_UMA_FLAG_AUTO	BIT(1)
+#define AMDGPU_UMA_FLAG_CUSTOM	BIT(0)
+
+/**
+ * struct amdgpu_uma_carveut_option - single UMA carveout option
+ * @name: Name of the carveout option
+ * @memory_carved: Amount of memory carved
+ * @flags: ATCS flags supported by this option
+ */
+struct amdgpu_uma_carveout_option {
+	char name[MAX_UMA_OPTION_NAME];
+	uint8_t memory_carved;
+	uint8_t flags;
+};
+
+/**
+ * struct amdgpu_uma_carveut_info - table of available UMA carveout options
+ * @num_entries: Number of available options
+ * @uma_option_index: The index of the option currently applied
+ * @update_lock: Lock to serialize changes to the option
+ * @entries: The array of carveout options
+ */
+struct amdgpu_uma_carveout_info {
+	uint8_t num_entries;
+	uint8_t uma_option_index;
+	struct mutex update_lock;
+	struct amdgpu_uma_carveout_option entries[MAX_UMA_OPTION_ENTRIES];
+};
+
 /* ATCS Device/Driver State */
 #define AMDGPU_ATCS_PSC_DEV_STATE_D0		0
 #define AMDGPU_ATCS_PSC_DEV_STATE_D3_HOT	3
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 0743fd8620e4..d442dc442d34 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -38,6 +38,7 @@
 #include "amdgpu_display.h"
 #include "amd_acpi.h"
 #include "atom.h"
+#include "amdgpu_atomfirmware.h"
 
 /* Declare GUID for AMD _DSM method for XCCs */
 static const guid_t amd_xcc_dsm_guid = GUID_INIT(0x8267f5d5, 0xa556, 0x44f2,
@@ -125,6 +126,7 @@ struct amdgpu_atcs {
 	acpi_handle handle;
 
 	struct amdgpu_atcs_functions functions;
+	struct amdgpu_uma_carveout_info uma_info;
 };
 
 static struct amdgpu_acpi_priv {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index 636385c80f64..b1463bb594aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -296,6 +296,79 @@ static int convert_atom_mem_type_to_vram_type(struct amdgpu_device *adev,
 	return vram_type;
 }
 
+static int amdgpu_atomfirmware_get_uma_carveout_info_v2_3(struct amdgpu_device *adev,
+							  union igp_info *igp_info,
+							  struct amdgpu_uma_carveout_info *uma_info)
+{
+	struct uma_carveout_option *opts;
+	uint8_t nr_uma_options;
+	int i;
+
+	nr_uma_options = igp_info->v23.UMACarveoutIndexMax;
+
+	if (!nr_uma_options)
+		return -ENODEV;
+
+	if (nr_uma_options > MAX_UMA_OPTION_ENTRIES) {
+		drm_dbg(adev_to_drm(adev),
+			"Number of UMA options exceeds max table size. Options will not be parsed");
+		return -EINVAL;
+	}
+
+	uma_info->num_entries = nr_uma_options;
+	uma_info->uma_option_index = igp_info->v23.UMACarveoutIndex;
+
+	opts = igp_info->v23.UMASizeControlOption;
+
+	for (i = 0; i < nr_uma_options; i++) {
+		uma_info->entries[i].memory_carved = opts[i].memoryCarvedGb;
+		uma_info->entries[i].flags = opts[i].uma_carveout_option_flags.all8;
+		strscpy(uma_info->entries[i].name, opts[i].optionName, MAX_UMA_OPTION_NAME);
+	}
+
+	return 0;
+}
+
+int amdgpu_atomfirmware_get_uma_carveout_info(struct amdgpu_device *adev,
+					      struct amdgpu_uma_carveout_info *uma_info)
+{
+	struct amdgpu_mode_info *mode_info = &adev->mode_info;
+	union igp_info *igp_info;
+	u16 data_offset, size;
+	u8 frev, crev;
+	int index;
+
+	if (!(adev->flags & AMD_IS_APU))
+		return -ENODEV;
+
+	index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
+					    integratedsysteminfo);
+
+	if (!amdgpu_atom_parse_data_header(mode_info->atom_context,
+					  index, &size,
+					  &frev, &crev, &data_offset)) {
+		return -EINVAL;
+	}
+
+	igp_info = (union igp_info *)
+			(mode_info->atom_context->bios + data_offset);
+
+	switch (frev) {
+	case 2:
+		switch (crev) {
+		case 3:
+			return amdgpu_atomfirmware_get_uma_carveout_info_v2_3(adev, igp_info, uma_info);
+		break;
+		default:
+			break;
+		}
+		break;
+	default:
+		break;
+	}
+	return -ENODEV;
+}
+
 int
 amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
 				  int *vram_width, int *vram_type,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
index 649b5530d8ae..67c8d105729b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
@@ -32,6 +32,8 @@ void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
 	int *vram_width, int *vram_type, int *vram_vendor);
+int amdgpu_atomfirmware_get_uma_carveout_info(struct amdgpu_device *adev,
+					      struct amdgpu_uma_carveout_info *uma_info);
 int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev);
 bool amdgpu_atomfirmware_mem_ecc_supported(struct amdgpu_device *adev);

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers
  2025-11-14  8:42 [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
  2025-11-14  8:42 ` [PATCH v2 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask Yo-Jung Leo Lin (AMD)
  2025-11-14  8:42 ` [PATCH v2 2/5] drm/amdgpu: add helper to read UMA carveout info Yo-Jung Leo Lin (AMD)
@ 2025-11-14  8:42 ` Yo-Jung Leo Lin (AMD)
  2025-11-17  6:48   ` kernel test robot
  2025-11-14  8:42 ` [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
  2025-11-14  8:42 ` [PATCH v2 5/5] Documentation/amdgpu: Add UMA carveout details Yo-Jung Leo Lin (AMD)
  4 siblings, 1 reply; 14+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-14  8:42 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org), Yo-Jung Leo Lin (AMD)

On some platforms, UMA allocation size can be set using the ATCS
methods. Add helper functions to interact with this functionality.

Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  7 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 43 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/include/amd_acpi.h   | 30 ++++++++++++++++++++++
 3 files changed, 80 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2c1123291577..ac5e4fb17ff5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1718,12 +1718,14 @@ int amdgpu_acpi_init(struct amdgpu_device *adev);
 void amdgpu_acpi_fini(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_pcie_performance_request_supported(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_power_shift_control_supported(void);
+bool amdgpu_acpi_is_set_uma_allocation_size_supported(void);
 int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
 						u8 perf_req, bool advertise);
 int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev,
 				    u8 dev_state, bool drv_state);
 int amdgpu_acpi_smart_shift_update(struct amdgpu_device *adev,
 				   enum amdgpu_ss ss_state);
+int amdgpu_acpi_set_uma_allocation_size(struct amdgpu_device *adev, u8 index, u8 type);
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 int amdgpu_acpi_get_tmr_info(struct amdgpu_device *adev, u64 *tmr_offset,
 			     u64 *tmr_size);
@@ -1752,6 +1754,7 @@ static inline bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev) { re
 static inline void amdgpu_acpi_detect(void) { }
 static inline void amdgpu_acpi_release(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
+static inline bool amdgpu_acpi_is_set_uma_allocation_size_supported(void) { return false; }
 static inline int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev,
 						  u8 dev_state, bool drv_state) { return 0; }
 static inline int amdgpu_acpi_smart_shift_update(struct amdgpu_device *adev,
@@ -1759,6 +1762,10 @@ static inline int amdgpu_acpi_smart_shift_update(struct amdgpu_device *adev,
 {
 	return 0;
 }
+int amdgpu_acpi_set_uma_allocation_size(struct amdgpu_device *adev, u8 index, u8 type)
+{
+	return -EINVAL;
+}
 static inline void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps) { }
 #endif
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index d442dc442d34..444ab4102168 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -671,6 +671,11 @@ bool amdgpu_acpi_is_power_shift_control_supported(void)
 	return amdgpu_acpi_priv.atcs.functions.power_shift_control;
 }
 
+bool amdgpu_acpi_is_set_uma_allocation_size_supported(void)
+{
+	return amdgpu_acpi_priv.atcs.functions.set_uma_allocation_size;
+}
+
 /**
  * amdgpu_acpi_pcie_notify_device_ready
  *
@@ -911,6 +916,44 @@ static struct amdgpu_numa_info *amdgpu_acpi_get_numa_info(uint32_t pxm)
 }
 #endif
 
+/**
+ * amdgpu_acpi_set_uma_allocation_size - Set Unified Memory Architecture allocation size via ACPI
+ * @adev: Pointer to the amdgpu_device structure
+ * @index: Index specifying the UMA allocation
+ * @type: Type of UMA allocation
+ *
+ * This function configures the UMA allocation size for the specified device
+ * using ACPI methods. The allocation is determined by the provided index and type.
+ * Returns 0 on success or a negative error code on failure.
+ */
+int amdgpu_acpi_set_uma_allocation_size(struct amdgpu_device *adev, u8 index, u8 type)
+{
+	struct atcs_set_uma_allocation_size_input atcs_input;
+	struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
+	struct acpi_buffer params;
+	union acpi_object *info;
+
+	if (!amdgpu_acpi_is_set_uma_allocation_size_supported())
+		return -EINVAL;
+
+	atcs_input.size = sizeof(struct atcs_set_uma_allocation_size_input);
+	atcs_input.uma_size_index = index;
+	atcs_input.uma_size_type = type;
+
+	params.length = sizeof(struct atcs_set_uma_allocation_size_input);
+	params.pointer = &atcs_input;
+
+	info = amdgpu_atcs_call(atcs, ATCS_FUNCTION_SET_UMA_ALLOCATION_SIZE, &params);
+	if (!info) {
+		drm_err(adev_to_drm(adev), "ATCS UMA allocation size update failed\n");
+		return -EIO;
+	}
+
+	kfree(info);
+
+	return 0;
+}
+
 /**
  * amdgpu_acpi_get_node_id - obtain the NUMA node id for corresponding amdgpu
  * acpi device handle
diff --git a/drivers/gpu/drm/amd/include/amd_acpi.h b/drivers/gpu/drm/amd/include/amd_acpi.h
index e582339e8e8e..84933c07f720 100644
--- a/drivers/gpu/drm/amd/include/amd_acpi.h
+++ b/drivers/gpu/drm/amd/include/amd_acpi.h
@@ -24,6 +24,8 @@
 #ifndef AMD_ACPI_H
 #define AMD_ACPI_H
 
+#include <linux/types.h>
+
 #define ACPI_AC_CLASS           "ac_adapter"
 
 struct atif_verify_interface {
@@ -112,6 +114,17 @@ struct atcs_pwr_shift_input {
 	u8 drv_state;	/* 0 = operational, 1 = not operational */
 } __packed;
 
+struct atcs_get_uma_size_output {
+	u16 size;		/* structure size in bytes (includes size field) */
+	u32 uma_size_mb;	/* allocated UMA size in MB */
+} __packed;
+
+struct atcs_set_uma_allocation_size_input {
+	u16 size;		/* structure size in bytes (includes size field) */
+	u8 uma_size_index;	/* UMA size index */
+	u8 uma_size_type;	/* UMA size type */
+} __packed;
+
 /* AMD hw uses four ACPI control methods:
  * 1. ATIF
  * ARG0: (ACPI_INTEGER) function code
@@ -494,4 +507,21 @@ struct atcs_pwr_shift_input {
  * OUTPUT: none
  */
 
+#define ATCS_FUNCTION_GET_UMA_SIZE                                 0x6
+/* ARG0: ATCS_FUNCTION_GET_UMA_SIZE
+ * ARG1: none
+ * OUTPUT:
+ * WORD  - structure size in bytes (includes size field)
+ * DWORD - allocated UMA size in MB
+ */
+
+#define ATCS_FUNCTION_SET_UMA_ALLOCATION_SIZE                     0xA
+/* ARG0: ATCS_FUNCTION_SET_UMA_ALLOCATION_SIZE
+ * ARG1:
+ * WORD  - structure size in bytes (includes size field)
+ * BYTE  - UMA size index
+ * BYTE  - UMA size type
+ * OUTPUT: none
+ */
+
 #endif

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
  2025-11-14  8:42 [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
                   ` (2 preceding siblings ...)
  2025-11-14  8:42 ` [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers Yo-Jung Leo Lin (AMD)
@ 2025-11-14  8:42 ` Yo-Jung Leo Lin (AMD)
  2025-11-14 20:26   ` Mario Limonciello (AMD) (kernel.org)
  2025-11-17 19:48   ` Alex Deucher
  2025-11-14  8:42 ` [PATCH v2 5/5] Documentation/amdgpu: Add UMA carveout details Yo-Jung Leo Lin (AMD)
  4 siblings, 2 replies; 14+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-14  8:42 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org), Yo-Jung Leo Lin (AMD)

Add two sysfs files as interfaces to inspect or change UMA carveout
size. These files are:

- uma_carveout_options: a read-only file listing all the available
  UMA allocation options and their index.

- uma_carveout: a file that is both readable and writable. On read,
  it shows the index of the current setting. Writing a valid index
  into this file allows users to change the UMA carveout size to that
  option on the next boot.

Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 127 +++++++++++++++++++++++++++++++
 1 file changed, 127 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 444ab4102168..b9378f34eb79 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -30,6 +30,7 @@
 #include <linux/power_supply.h>
 #include <linux/pm_runtime.h>
 #include <linux/suspend.h>
+#include <linux/device.h>
 #include <acpi/video.h>
 #include <acpi/actbl.h>
 
@@ -1247,6 +1248,125 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
 	return -ENOENT;
 }
 
+static ssize_t uma_carveout_options_show(struct device *dev,
+					 struct device_attribute *attr,
+					 char *buf)
+{
+	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
+	ssize_t size = 0;
+
+	if (!uma_info || !uma_info->num_entries)
+		return -ENODEV;
+
+	for (int i = 0; i < uma_info->num_entries; i++) {
+		size += sysfs_emit_at(buf, size, "%d: %s (%u GB)\n",
+				      i,
+				      uma_info->entries[i].name,
+				      uma_info->entries[i].memory_carved);
+	}
+
+	return size;
+}
+static DEVICE_ATTR_RO(uma_carveout_options);
+
+static ssize_t uma_carveout_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	return sysfs_emit(buf, "%u\n", amdgpu_acpi_priv.atcs.uma_info.uma_option_index);
+}
+
+static ssize_t uma_carveout_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(ddev);
+	struct amdgpu_uma_carveout_option *opt;
+	unsigned long val;
+	uint8_t flags;
+	int r;
+
+	r = kstrtoul(buf, 10, &val);
+	if (r)
+		return r;
+
+	if (val >= uma_info->num_entries)
+		return -EINVAL;
+
+	opt = &uma_info->entries[val];
+
+	if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
+	    !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
+		drm_err_once(ddev, "Option %ul not supported due to lack of Custom/Auto flag", r);
+		return -EINVAL;
+	}
+
+	flags = opt->flags;
+	flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
+
+	guard(mutex)(&uma_info->update_lock);
+
+	r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
+	if (r)
+		return r;
+
+	uma_info->uma_option_index = val;
+
+	return count;
+}
+static DEVICE_ATTR_RW(uma_carveout);
+
+static struct attribute *amdgpu_uma_attrs[] = {
+	&dev_attr_uma_carveout.attr,
+	&dev_attr_uma_carveout_options.attr,
+	NULL
+};
+
+const struct attribute_group amdgpu_uma_attr_group = {
+	.attrs = amdgpu_uma_attrs
+};
+
+static int amdgpu_acpi_uma_option_init(struct amdgpu_device *adev)
+{
+	struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
+	int rc;
+
+	if (!atcs->functions.set_uma_allocation_size)
+		return -ENODEV;
+
+	rc = amdgpu_atomfirmware_get_uma_carveout_info(adev, &atcs->uma_info);
+	if (rc) {
+		drm_dbg(adev_to_drm(adev),
+			"Failed to parse UMA carveout info from VBIOS: %d\n", rc);
+		goto out_info;
+	}
+
+	mutex_init(&atcs->uma_info.update_lock);
+
+	rc = devm_device_add_group(adev->dev, &amdgpu_uma_attr_group);
+	if (rc) {
+		drm_dbg(adev_to_drm(adev), "Failed to add UMA carveout sysfs interfaces %d\n", rc);
+		goto out_attr;
+	}
+
+	return 0;
+
+out_attr:
+	mutex_destroy(&atcs->uma_info.update_lock);
+out_info:
+	return rc;
+}
+
+static void amdgpu_acpi_uma_option_fini(void)
+{
+	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
+
+	mutex_destroy(&uma_info->update_lock);
+	uma_info->num_entries = 0;
+}
+
 /**
  * amdgpu_acpi_event - handle notify events
  *
@@ -1291,6 +1411,12 @@ static int amdgpu_acpi_event(struct notifier_block *nb,
 int amdgpu_acpi_init(struct amdgpu_device *adev)
 {
 	struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
+	int rc;
+
+	rc = amdgpu_acpi_uma_option_init(adev);
+
+	if (rc)
+		drm_dbg(adev_to_drm(adev), "Not creating uma carveout interfaces: %d", rc);
 
 	if (atif->notifications.brightness_change) {
 		if (adev->dc_enabled) {
@@ -1343,6 +1469,7 @@ void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps)
 void amdgpu_acpi_fini(struct amdgpu_device *adev)
 {
 	unregister_acpi_notifier(&adev->acpi_nb);
+	amdgpu_acpi_uma_option_fini();
 }
 
 /**

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 5/5] Documentation/amdgpu: Add UMA carveout details
  2025-11-14  8:42 [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
                   ` (3 preceding siblings ...)
  2025-11-14  8:42 ` [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
@ 2025-11-14  8:42 ` Yo-Jung Leo Lin (AMD)
  2025-11-14 20:23   ` Mario Limonciello (AMD) (kernel.org)
  4 siblings, 1 reply; 14+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-14  8:42 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org), Yo-Jung Leo Lin (AMD)

Add documentation for the uma_carveout_options and uma_carveout
attributes in sysfs

Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
---
 Documentation/gpu/amdgpu/driver-misc.rst | 26 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/Documentation/gpu/amdgpu/driver-misc.rst b/Documentation/gpu/amdgpu/driver-misc.rst
index 25b0c857816e..afefab4fa0ac 100644
--- a/Documentation/gpu/amdgpu/driver-misc.rst
+++ b/Documentation/gpu/amdgpu/driver-misc.rst
@@ -128,3 +128,29 @@ smartshift_bias
 
 .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
    :doc: smartshift_bias
+
+UMA Carveout
+============
+
+Some versions of Atom ROM expose available options for the VRAM carveout sizes,
+and allow changes to the carveout size via the ATCS function code 0xA on supported
+BIOS implementations.
+
+For those platforms, users can use the following file to set the carveout size,
+in a way similar to what Windows users can do in the "Tuning" tab in AMD
+Adrenalin.
+
+Note that for BIOS implementations that don't support this, these files will not
+be created at all.
+
+uma_carveout_options
+--------------------
+
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+   :doc: uma_carveout_options
+
+uma_carveout
+--------------------
+
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+   :doc: uma_carveout
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index b9378f34eb79..10cc6bf28a0f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -1248,6 +1248,24 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
 	return -ENOENT;
 }
 
+/**
+ * DOC: uma_carveout_options
+ *
+ * This is a read-only file that lists all available UMA allocation
+ * options and their corresponding indices. Example output::
+ *
+ *     $ cat uma_carveout_options
+ *     0: Minimum (0 GB)
+ *     1:  (1 GB)
+ *     2:  (2 GB)
+ *     3:  (4 GB)
+ *     4:  (6 GB)
+ *     5:  (8 GB)
+ *     6:  (12 GB)
+ *     7: Medium (16 GB)
+ *     8:  (24 GB)
+ *     9: High (32 GB)
+ */
 static ssize_t uma_carveout_options_show(struct device *dev,
 					 struct device_attribute *attr,
 					 char *buf)
@@ -1269,6 +1287,17 @@ static ssize_t uma_carveout_options_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(uma_carveout_options);
 
+/**
+ * DOC: uma_carveout
+ *
+ * This file is both readable and writable. When read, it shows the
+ * index of the current setting. Writing a valid index to this file
+ * allows users to change the UMA carveout size to the selected option
+ * on the next boot.
+ *
+ * The available options and their corresponding indices can be read
+ * from the uma_carveout_options file.
+ */
 static ssize_t uma_carveout_show(struct device *dev,
 				 struct device_attribute *attr,
 				 char *buf)

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 5/5] Documentation/amdgpu: Add UMA carveout details
  2025-11-14  8:42 ` [PATCH v2 5/5] Documentation/amdgpu: Add UMA carveout details Yo-Jung Leo Lin (AMD)
@ 2025-11-14 20:23   ` Mario Limonciello (AMD) (kernel.org)
  0 siblings, 0 replies; 14+ messages in thread
From: Mario Limonciello (AMD) (kernel.org) @ 2025-11-14 20:23 UTC (permalink / raw)
  To: Yo-Jung Leo Lin (AMD), Alex Deucher, Christian König,
	David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson



On 11/14/2025 2:42 AM, Yo-Jung Leo Lin (AMD) wrote:
> Add documentation for the uma_carveout_options and uma_carveout
> attributes in sysfs
> 
> Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>> ---
>   Documentation/gpu/amdgpu/driver-misc.rst | 26 ++++++++++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 29 +++++++++++++++++++++++++++++
>   2 files changed, 55 insertions(+)
> 
> diff --git a/Documentation/gpu/amdgpu/driver-misc.rst b/Documentation/gpu/amdgpu/driver-misc.rst
> index 25b0c857816e..afefab4fa0ac 100644
> --- a/Documentation/gpu/amdgpu/driver-misc.rst
> +++ b/Documentation/gpu/amdgpu/driver-misc.rst
> @@ -128,3 +128,29 @@ smartshift_bias
>   
>   .. kernel-doc:: drivers/gpu/drm/amd/pm/amdgpu_pm.c
>      :doc: smartshift_bias
> +
> +UMA Carveout
> +============
> +
> +Some versions of Atom ROM expose available options for the VRAM carveout sizes,
> +and allow changes to the carveout size via the ATCS function code 0xA on supported
> +BIOS implementations.
> +
> +For those platforms, users can use the following file to set the carveout size,
> +in a way similar to what Windows users can do in the "Tuning" tab in AMD
> +Adrenalin.
> +
> +Note that for BIOS implementations that don't support this, these files will not
> +be created at all.
> +
> +uma_carveout_options
> +--------------------
> +
> +.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +   :doc: uma_carveout_options
> +
> +uma_carveout
> +--------------------
> +
> +.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +   :doc: uma_carveout
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index b9378f34eb79..10cc6bf28a0f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -1248,6 +1248,24 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
>   	return -ENOENT;
>   }
>   
> +/**
> + * DOC: uma_carveout_options
> + *
> + * This is a read-only file that lists all available UMA allocation
> + * options and their corresponding indices. Example output::
> + *
> + *     $ cat uma_carveout_options
> + *     0: Minimum (0 GB)
> + *     1:  (1 GB)
> + *     2:  (2 GB)
> + *     3:  (4 GB)
> + *     4:  (6 GB)
> + *     5:  (8 GB)
> + *     6:  (12 GB)
> + *     7: Medium (16 GB)
> + *     8:  (24 GB)
> + *     9: High (32 GB)
> + */
>   static ssize_t uma_carveout_options_show(struct device *dev,
>   					 struct device_attribute *attr,
>   					 char *buf)
> @@ -1269,6 +1287,17 @@ static ssize_t uma_carveout_options_show(struct device *dev,
>   }
>   static DEVICE_ATTR_RO(uma_carveout_options);
>   
> +/**
> + * DOC: uma_carveout
> + *
> + * This file is both readable and writable. When read, it shows the
> + * index of the current setting. Writing a valid index to this file
> + * allows users to change the UMA carveout size to the selected option
> + * on the next boot.
> + *
> + * The available options and their corresponding indices can be read
> + * from the uma_carveout_options file.
> + */
>   static ssize_t uma_carveout_show(struct device *dev,
>   				 struct device_attribute *attr,
>   				 char *buf)
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
  2025-11-14  8:42 ` [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
@ 2025-11-14 20:26   ` Mario Limonciello (AMD) (kernel.org)
  2025-11-18 14:32     ` Lin, Leo
  2025-11-17 19:48   ` Alex Deucher
  1 sibling, 1 reply; 14+ messages in thread
From: Mario Limonciello (AMD) (kernel.org) @ 2025-11-14 20:26 UTC (permalink / raw)
  To: Yo-Jung Leo Lin (AMD), Alex Deucher, Christian König,
	David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Jonathan Corbet
  Cc: amd-gfx, dri-devel, linux-kernel, linux-doc, Tsao, Anson



On 11/14/2025 2:42 AM, Yo-Jung Leo Lin (AMD) wrote:
> Add two sysfs files as interfaces to inspect or change UMA carveout
> size. These files are:
> 
> - uma_carveout_options: a read-only file listing all the available
>    UMA allocation options and their index.
> 
> - uma_carveout: a file that is both readable and writable. On read,
>    it shows the index of the current setting. Writing a valid index
>    into this file allows users to change the UMA carveout size to that
>    option on the next boot.
> 
> Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 127 +++++++++++++++++++++++++++++++
>   1 file changed, 127 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 444ab4102168..b9378f34eb79 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -30,6 +30,7 @@
>   #include <linux/power_supply.h>
>   #include <linux/pm_runtime.h>
>   #include <linux/suspend.h>
> +#include <linux/device.h>
>   #include <acpi/video.h>
>   #include <acpi/actbl.h>
>   
> @@ -1247,6 +1248,125 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
>   	return -ENOENT;
>   }
>   
> +static ssize_t uma_carveout_options_show(struct device *dev,
> +					 struct device_attribute *attr,
> +					 char *buf)
> +{
> +	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
> +	ssize_t size = 0;
> +
> +	if (!uma_info || !uma_info->num_entries)
> +		return -ENODEV;
> +
> +	for (int i = 0; i < uma_info->num_entries; i++) {
> +		size += sysfs_emit_at(buf, size, "%d: %s (%u GB)\n",
> +				      i,
> +				      uma_info->entries[i].name,
> +				      uma_info->entries[i].memory_carved);

AFAICT when memory_carved is 0 does this shows as:

0: Minimum (0 GB)

This is actually 512 MB right?

Could you cross reference what Windows shows in that case?  Do they 
special case it to 512 MB?

I'm wondering if maybe that should be special cased here.
> +	}
> +
> +	return size;
> +}
> +static DEVICE_ATTR_RO(uma_carveout_options);
> +
> +static ssize_t uma_carveout_show(struct device *dev,
> +				 struct device_attribute *attr,
> +				 char *buf)
> +{
> +	return sysfs_emit(buf, "%u\n", amdgpu_acpi_priv.atcs.uma_info.uma_option_index);
> +}
> +
> +static ssize_t uma_carveout_store(struct device *dev,
> +				  struct device_attribute *attr,
> +				  const char *buf, size_t count)
> +{
> +	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
> +	struct drm_device *ddev = dev_get_drvdata(dev);
> +	struct amdgpu_device *adev = drm_to_adev(ddev);
> +	struct amdgpu_uma_carveout_option *opt;
> +	unsigned long val;
> +	uint8_t flags;
> +	int r;
> +
> +	r = kstrtoul(buf, 10, &val);
> +	if (r)
> +		return r;
> +
> +	if (val >= uma_info->num_entries)
> +		return -EINVAL;
> +
> +	opt = &uma_info->entries[val];
> +
> +	if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
> +	    !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
> +		drm_err_once(ddev, "Option %ul not supported due to lack of Custom/Auto flag", r);
> +		return -EINVAL;
> +	}
> +
> +	flags = opt->flags;
> +	flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
> +
> +	guard(mutex)(&uma_info->update_lock);
> +
> +	r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
> +	if (r)
> +		return r;
> +
> +	uma_info->uma_option_index = val;
> +
> +	return count;
> +}
> +static DEVICE_ATTR_RW(uma_carveout);
> +
> +static struct attribute *amdgpu_uma_attrs[] = {
> +	&dev_attr_uma_carveout.attr,
> +	&dev_attr_uma_carveout_options.attr,
> +	NULL
> +};
> +
> +const struct attribute_group amdgpu_uma_attr_group = {
> +	.attrs = amdgpu_uma_attrs
> +};
> +
> +static int amdgpu_acpi_uma_option_init(struct amdgpu_device *adev)
> +{
> +	struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
> +	int rc;
> +
> +	if (!atcs->functions.set_uma_allocation_size)
> +		return -ENODEV;
> +
> +	rc = amdgpu_atomfirmware_get_uma_carveout_info(adev, &atcs->uma_info);
> +	if (rc) {
> +		drm_dbg(adev_to_drm(adev),
> +			"Failed to parse UMA carveout info from VBIOS: %d\n", rc);
> +		goto out_info;
> +	}
> +
> +	mutex_init(&atcs->uma_info.update_lock);
> +
> +	rc = devm_device_add_group(adev->dev, &amdgpu_uma_attr_group);
> +	if (rc) {
> +		drm_dbg(adev_to_drm(adev), "Failed to add UMA carveout sysfs interfaces %d\n", rc);
> +		goto out_attr;
> +	}
> +
> +	return 0;
> +
> +out_attr:
> +	mutex_destroy(&atcs->uma_info.update_lock);
> +out_info:
> +	return rc;
> +}
> +
> +static void amdgpu_acpi_uma_option_fini(void)
> +{
> +	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
> +
> +	mutex_destroy(&uma_info->update_lock);
> +	uma_info->num_entries = 0;
> +}
> +
>   /**
>    * amdgpu_acpi_event - handle notify events
>    *
> @@ -1291,6 +1411,12 @@ static int amdgpu_acpi_event(struct notifier_block *nb,
>   int amdgpu_acpi_init(struct amdgpu_device *adev)
>   {
>   	struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
> +	int rc;
> +
> +	rc = amdgpu_acpi_uma_option_init(adev);
> +
> +	if (rc)
> +		drm_dbg(adev_to_drm(adev), "Not creating uma carveout interfaces: %d", rc);
>   
>   	if (atif->notifications.brightness_change) {
>   		if (adev->dc_enabled) {
> @@ -1343,6 +1469,7 @@ void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps)
>   void amdgpu_acpi_fini(struct amdgpu_device *adev)
>   {
>   	unregister_acpi_notifier(&adev->acpi_nb);
> +	amdgpu_acpi_uma_option_fini();
>   }
>   
>   /**
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers
  2025-11-14  8:42 ` [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers Yo-Jung Leo Lin (AMD)
@ 2025-11-17  6:48   ` kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2025-11-17  6:48 UTC (permalink / raw)
  To: Yo-Jung Leo Lin (AMD), Alex Deucher, Christian König,
	David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Jonathan Corbet
  Cc: oe-kbuild-all, amd-gfx, dri-devel, linux-kernel, linux-doc,
	Tsao, Anson, Mario Limonciello (AMD) (kernel.org),
	Yo-Jung Leo Lin (AMD)

Hi Yo-Jung,

kernel test robot noticed the following build errors:

[auto build test ERROR on ac9914fa72a5a917bb61c5e87bee6b8f9b751f33]

url:    https://github.com/intel-lab-lkp/linux/commits/Yo-Jung-Leo-Lin-AMD/drm-amdgpu-parse-UMA-size-getting-setting-bits-in-ATCS-mask/20251114-164505
base:   ac9914fa72a5a917bb61c5e87bee6b8f9b751f33
patch link:    https://lore.kernel.org/r/20251114-vram-carveout-tuning-for-upstream-v2-3-4f6bdd48030d%40amd.com
patch subject: [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers
config: parisc-randconfig-002-20251117 (https://download.01.org/0day-ci/archive/20251117/202511171049.kFPjY5Br-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251117/202511171049.kFPjY5Br-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511171049.kFPjY5Br-lkp@intel.com/

All errors (new ones prefixed by >>):

   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_device.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_kms.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/atombios_crtc.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/atom.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_fence.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_object.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_gart.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_encoders.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_display.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_gem.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ring.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_cs.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_bios.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/atombios_dp.o: in function `amdgpu_acpi_set_uma_allocation_size':
>> (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_afmt.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_trace_points.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/atombios_encoders.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_sa.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/atombios_i2c.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ib.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_pll.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_sync.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_virt.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_sched.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ids.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_mmhub.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_csa.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ras.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_umc.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_rap.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_fw_attestation.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_mca.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_aca.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here
   hppa-linux-ld: drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.o: in function `amdgpu_acpi_set_uma_allocation_size':
   (.text.amdgpu_acpi_set_uma_allocation_size+0x0): multiple definition of `amdgpu_acpi_set_uma_allocation_size'; drivers/gpu/drm/amd/amdgpu/amdgpu_drv.o:(.text.amdgpu_acpi_set_uma_allocation_size+0x0): first defined here

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 2/5] drm/amdgpu: add helper to read UMA carveout info
  2025-11-14  8:42 ` [PATCH v2 2/5] drm/amdgpu: add helper to read UMA carveout info Yo-Jung Leo Lin (AMD)
@ 2025-11-17 19:43   ` Alex Deucher
  0 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2025-11-17 19:43 UTC (permalink / raw)
  To: Yo-Jung Leo Lin (AMD)
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet, amd-gfx, dri-devel, linux-kernel, linux-doc,
	Tsao, Anson, Mario Limonciello (AMD) (kernel.org)

On Fri, Nov 14, 2025 at 3:52 AM Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com> wrote:
>
> Currently, the available UMA allocation configs in the integrated system
> information table have not been parsed. Add a helper function to retrieve
> and store these configs.
>
> Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h              | 32 +++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c         |  2 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 73 ++++++++++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h |  2 +
>  4 files changed, 109 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index a5574e84694b..2c1123291577 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1675,6 +1675,38 @@ struct amdgpu_numa_info {
>         int nid;
>  };
>
> +#define MAX_UMA_OPTION_NAME    28
> +#define MAX_UMA_OPTION_ENTRIES 19
> +
> +#define AMDGPU_UMA_FLAG_AUTO   BIT(1)
> +#define AMDGPU_UMA_FLAG_CUSTOM BIT(0)
> +
> +/**
> + * struct amdgpu_uma_carveut_option - single UMA carveout option
> + * @name: Name of the carveout option
> + * @memory_carved: Amount of memory carved
> + * @flags: ATCS flags supported by this option
> + */
> +struct amdgpu_uma_carveout_option {
> +       char name[MAX_UMA_OPTION_NAME];
> +       uint8_t memory_carved;
> +       uint8_t flags;
> +};
> +
> +/**
> + * struct amdgpu_uma_carveut_info - table of available UMA carveout options
> + * @num_entries: Number of available options
> + * @uma_option_index: The index of the option currently applied
> + * @update_lock: Lock to serialize changes to the option
> + * @entries: The array of carveout options
> + */
> +struct amdgpu_uma_carveout_info {
> +       uint8_t num_entries;
> +       uint8_t uma_option_index;
> +       struct mutex update_lock;
> +       struct amdgpu_uma_carveout_option entries[MAX_UMA_OPTION_ENTRIES];
> +};
> +
>  /* ATCS Device/Driver State */
>  #define AMDGPU_ATCS_PSC_DEV_STATE_D0           0
>  #define AMDGPU_ATCS_PSC_DEV_STATE_D3_HOT       3
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 0743fd8620e4..d442dc442d34 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -38,6 +38,7 @@
>  #include "amdgpu_display.h"
>  #include "amd_acpi.h"
>  #include "atom.h"
> +#include "amdgpu_atomfirmware.h"
>
>  /* Declare GUID for AMD _DSM method for XCCs */
>  static const guid_t amd_xcc_dsm_guid = GUID_INIT(0x8267f5d5, 0xa556, 0x44f2,
> @@ -125,6 +126,7 @@ struct amdgpu_atcs {
>         acpi_handle handle;
>
>         struct amdgpu_atcs_functions functions;
> +       struct amdgpu_uma_carveout_info uma_info;
>  };
>
>  static struct amdgpu_acpi_priv {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> index 636385c80f64..b1463bb594aa 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> @@ -296,6 +296,79 @@ static int convert_atom_mem_type_to_vram_type(struct amdgpu_device *adev,
>         return vram_type;
>  }
>
> +static int amdgpu_atomfirmware_get_uma_carveout_info_v2_3(struct amdgpu_device *adev,
> +                                                         union igp_info *igp_info,
> +                                                         struct amdgpu_uma_carveout_info *uma_info)
> +{
> +       struct uma_carveout_option *opts;
> +       uint8_t nr_uma_options;
> +       int i;
> +
> +       nr_uma_options = igp_info->v23.UMACarveoutIndexMax;
> +
> +       if (!nr_uma_options)
> +               return -ENODEV;
> +
> +       if (nr_uma_options > MAX_UMA_OPTION_ENTRIES) {
> +               drm_dbg(adev_to_drm(adev),
> +                       "Number of UMA options exceeds max table size. Options will not be parsed");
> +               return -EINVAL;
> +       }
> +
> +       uma_info->num_entries = nr_uma_options;
> +       uma_info->uma_option_index = igp_info->v23.UMACarveoutIndex;
> +
> +       opts = igp_info->v23.UMASizeControlOption;
> +
> +       for (i = 0; i < nr_uma_options; i++) {
> +               uma_info->entries[i].memory_carved = opts[i].memoryCarvedGb;
> +               uma_info->entries[i].flags = opts[i].uma_carveout_option_flags.all8;
> +               strscpy(uma_info->entries[i].name, opts[i].optionName, MAX_UMA_OPTION_NAME);
> +       }
> +
> +       return 0;
> +}
> +
> +int amdgpu_atomfirmware_get_uma_carveout_info(struct amdgpu_device *adev,
> +                                             struct amdgpu_uma_carveout_info *uma_info)
> +{
> +       struct amdgpu_mode_info *mode_info = &adev->mode_info;
> +       union igp_info *igp_info;
> +       u16 data_offset, size;
> +       u8 frev, crev;
> +       int index;
> +
> +       if (!(adev->flags & AMD_IS_APU))
> +               return -ENODEV;
> +
> +       index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
> +                                           integratedsysteminfo);
> +
> +       if (!amdgpu_atom_parse_data_header(mode_info->atom_context,
> +                                         index, &size,
> +                                         &frev, &crev, &data_offset)) {
> +               return -EINVAL;
> +       }
> +
> +       igp_info = (union igp_info *)
> +                       (mode_info->atom_context->bios + data_offset);
> +
> +       switch (frev) {
> +       case 2:
> +               switch (crev) {
> +               case 3:
> +                       return amdgpu_atomfirmware_get_uma_carveout_info_v2_3(adev, igp_info, uma_info);
> +               break;
> +               default:
> +                       break;
> +               }
> +               break;
> +       default:
> +               break;
> +       }
> +       return -ENODEV;
> +}
> +
>  int
>  amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
>                                   int *vram_width, int *vram_type,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
> index 649b5530d8ae..67c8d105729b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
> @@ -32,6 +32,8 @@ void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev);
>  int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
>  int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
>         int *vram_width, int *vram_type, int *vram_vendor);
> +int amdgpu_atomfirmware_get_uma_carveout_info(struct amdgpu_device *adev,
> +                                             struct amdgpu_uma_carveout_info *uma_info);
>  int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev);
>  int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev);
>  bool amdgpu_atomfirmware_mem_ecc_supported(struct amdgpu_device *adev);
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
  2025-11-14  8:42 ` [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
  2025-11-14 20:26   ` Mario Limonciello (AMD) (kernel.org)
@ 2025-11-17 19:48   ` Alex Deucher
  2025-11-18 14:22     ` Lin, Leo
  1 sibling, 1 reply; 14+ messages in thread
From: Alex Deucher @ 2025-11-17 19:48 UTC (permalink / raw)
  To: Yo-Jung Leo Lin (AMD)
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Jonathan Corbet, amd-gfx, dri-devel, linux-kernel, linux-doc,
	Tsao, Anson, Mario Limonciello (AMD) (kernel.org)

On Fri, Nov 14, 2025 at 3:52 AM Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com> wrote:
>
> Add two sysfs files as interfaces to inspect or change UMA carveout
> size. These files are:
>
> - uma_carveout_options: a read-only file listing all the available
>   UMA allocation options and their index.
>
> - uma_carveout: a file that is both readable and writable. On read,
>   it shows the index of the current setting. Writing a valid index
>   into this file allows users to change the UMA carveout size to that
>   option on the next boot.

Would it be cleaner to combine these?  Reading the file would show the
indexed list of options with a * next to the currently selected one
and then writing the index to the file would cause the change to take
effect on the next reboot.

Alex

>
> Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 127 +++++++++++++++++++++++++++++++
>  1 file changed, 127 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 444ab4102168..b9378f34eb79 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -30,6 +30,7 @@
>  #include <linux/power_supply.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/suspend.h>
> +#include <linux/device.h>
>  #include <acpi/video.h>
>  #include <acpi/actbl.h>
>
> @@ -1247,6 +1248,125 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
>         return -ENOENT;
>  }
>
> +static ssize_t uma_carveout_options_show(struct device *dev,
> +                                        struct device_attribute *attr,
> +                                        char *buf)
> +{
> +       struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
> +       ssize_t size = 0;
> +
> +       if (!uma_info || !uma_info->num_entries)
> +               return -ENODEV;
> +
> +       for (int i = 0; i < uma_info->num_entries; i++) {
> +               size += sysfs_emit_at(buf, size, "%d: %s (%u GB)\n",
> +                                     i,
> +                                     uma_info->entries[i].name,
> +                                     uma_info->entries[i].memory_carved);
> +       }
> +
> +       return size;
> +}
> +static DEVICE_ATTR_RO(uma_carveout_options);
> +
> +static ssize_t uma_carveout_show(struct device *dev,
> +                                struct device_attribute *attr,
> +                                char *buf)
> +{
> +       return sysfs_emit(buf, "%u\n", amdgpu_acpi_priv.atcs.uma_info.uma_option_index);
> +}
> +
> +static ssize_t uma_carveout_store(struct device *dev,
> +                                 struct device_attribute *attr,
> +                                 const char *buf, size_t count)
> +{
> +       struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
> +       struct drm_device *ddev = dev_get_drvdata(dev);
> +       struct amdgpu_device *adev = drm_to_adev(ddev);
> +       struct amdgpu_uma_carveout_option *opt;
> +       unsigned long val;
> +       uint8_t flags;
> +       int r;
> +
> +       r = kstrtoul(buf, 10, &val);
> +       if (r)
> +               return r;
> +
> +       if (val >= uma_info->num_entries)
> +               return -EINVAL;
> +
> +       opt = &uma_info->entries[val];
> +
> +       if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
> +           !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
> +               drm_err_once(ddev, "Option %ul not supported due to lack of Custom/Auto flag", r);
> +               return -EINVAL;
> +       }
> +
> +       flags = opt->flags;
> +       flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
> +
> +       guard(mutex)(&uma_info->update_lock);
> +
> +       r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
> +       if (r)
> +               return r;
> +
> +       uma_info->uma_option_index = val;
> +
> +       return count;
> +}
> +static DEVICE_ATTR_RW(uma_carveout);
> +
> +static struct attribute *amdgpu_uma_attrs[] = {
> +       &dev_attr_uma_carveout.attr,
> +       &dev_attr_uma_carveout_options.attr,
> +       NULL
> +};
> +
> +const struct attribute_group amdgpu_uma_attr_group = {
> +       .attrs = amdgpu_uma_attrs
> +};
> +
> +static int amdgpu_acpi_uma_option_init(struct amdgpu_device *adev)
> +{
> +       struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
> +       int rc;
> +
> +       if (!atcs->functions.set_uma_allocation_size)
> +               return -ENODEV;
> +
> +       rc = amdgpu_atomfirmware_get_uma_carveout_info(adev, &atcs->uma_info);
> +       if (rc) {
> +               drm_dbg(adev_to_drm(adev),
> +                       "Failed to parse UMA carveout info from VBIOS: %d\n", rc);
> +               goto out_info;
> +       }
> +
> +       mutex_init(&atcs->uma_info.update_lock);
> +
> +       rc = devm_device_add_group(adev->dev, &amdgpu_uma_attr_group);
> +       if (rc) {
> +               drm_dbg(adev_to_drm(adev), "Failed to add UMA carveout sysfs interfaces %d\n", rc);
> +               goto out_attr;
> +       }
> +
> +       return 0;
> +
> +out_attr:
> +       mutex_destroy(&atcs->uma_info.update_lock);
> +out_info:
> +       return rc;
> +}
> +
> +static void amdgpu_acpi_uma_option_fini(void)
> +{
> +       struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
> +
> +       mutex_destroy(&uma_info->update_lock);
> +       uma_info->num_entries = 0;
> +}
> +
>  /**
>   * amdgpu_acpi_event - handle notify events
>   *
> @@ -1291,6 +1411,12 @@ static int amdgpu_acpi_event(struct notifier_block *nb,
>  int amdgpu_acpi_init(struct amdgpu_device *adev)
>  {
>         struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
> +       int rc;
> +
> +       rc = amdgpu_acpi_uma_option_init(adev);
> +
> +       if (rc)
> +               drm_dbg(adev_to_drm(adev), "Not creating uma carveout interfaces: %d", rc);
>
>         if (atif->notifications.brightness_change) {
>                 if (adev->dc_enabled) {
> @@ -1343,6 +1469,7 @@ void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps)
>  void amdgpu_acpi_fini(struct amdgpu_device *adev)
>  {
>         unregister_acpi_notifier(&adev->acpi_nb);
> +       amdgpu_acpi_uma_option_fini();
>  }
>
>  /**
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
  2025-11-17 19:48   ` Alex Deucher
@ 2025-11-18 14:22     ` Lin, Leo
  2025-11-18 14:30       ` Alex Deucher
  0 siblings, 1 reply; 14+ messages in thread
From: Lin, Leo @ 2025-11-18 14:22 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Deucher, Alexander, Koenig, Christian, David Airlie,
	Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Jonathan Corbet, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org)

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Alex Deucher <alexdeucher@gmail.com>
> Sent: Tuesday, November 18, 2025 3:49 AM
> To: Lin, Leo <Leo.Lin@amd.com>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; David Airlie <airlied@gmail.com>; Simona
> Vetter <simona@ffwll.ch>; Maarten Lankhorst
> <maarten.lankhorst@linux.intel.com>; Maxime Ripard
> <mripard@kernel.org>; Thomas Zimmermann <tzimmermann@suse.de>;
> Jonathan Corbet <corbet@lwn.net>; amd-gfx@lists.freedesktop.org; dri-
> devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; linux-
> doc@vger.kernel.org; Tsao, Anson <anson.tsao@amd.com>; Mario
> Limonciello (AMD) (kernel.org) <superm1@kernel.org>
> Subject: Re: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to
> sysfs
>
> On Fri, Nov 14, 2025 at 3:52 AM Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> wrote:
> >
> > Add two sysfs files as interfaces to inspect or change UMA carveout
> > size. These files are:
> >
> > - uma_carveout_options: a read-only file listing all the available
> >   UMA allocation options and their index.
> >
> > - uma_carveout: a file that is both readable and writable. On read,
> >   it shows the index of the current setting. Writing a valid index
> >   into this file allows users to change the UMA carveout size to that
> >   option on the next boot.
>
> Would it be cleaner to combine these?  Reading the file would show the
> indexed list of options with a * next to the currently selected one and then
> writing the index to the file would cause the change to take effect on the next
> reboot.
>
> Alex

My thought is that it'll make it less friendly for processing output with awk/cut/other text processing tools. Also, I feel that the format will be trickier to maintain in the future, considering that it has to stay consistent for potentially new carveout option naming scheme.

(Plus, the general guideline of making a sysfs file content array-ish in the kernel doc.[1])

That being said, it's my personal thought. If you feel cleaner to merge those two interfaces into one, it's definitely possible to do this in the next version and see what people's feedback would be. Let me know if that's what you'd like to see.

[1]  https://docs.kernel.org/filesystems/sysfs.html#attributes

BR,
Leo

>
> >
> > Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 127
> > +++++++++++++++++++++++++++++++
> >  1 file changed, 127 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > index 444ab4102168..b9378f34eb79 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > @@ -30,6 +30,7 @@
> >  #include <linux/power_supply.h>
> >  #include <linux/pm_runtime.h>
> >  #include <linux/suspend.h>
> > +#include <linux/device.h>
> >  #include <acpi/video.h>
> >  #include <acpi/actbl.h>
> >
> > @@ -1247,6 +1248,125 @@ int amdgpu_acpi_get_mem_info(struct
> amdgpu_device *adev, int xcc_id,
> >         return -ENOENT;
> >  }
> >
> > +static ssize_t uma_carveout_options_show(struct device *dev,
> > +                                        struct device_attribute *attr,
> > +                                        char *buf) {
> > +       struct amdgpu_uma_carveout_info *uma_info =
> &amdgpu_acpi_priv.atcs.uma_info;
> > +       ssize_t size = 0;
> > +
> > +       if (!uma_info || !uma_info->num_entries)
> > +               return -ENODEV;
> > +
> > +       for (int i = 0; i < uma_info->num_entries; i++) {
> > +               size += sysfs_emit_at(buf, size, "%d: %s (%u GB)\n",
> > +                                     i,
> > +                                     uma_info->entries[i].name,
> > +                                     uma_info->entries[i].memory_carved);
> > +       }
> > +
> > +       return size;
> > +}
> > +static DEVICE_ATTR_RO(uma_carveout_options);
> > +
> > +static ssize_t uma_carveout_show(struct device *dev,
> > +                                struct device_attribute *attr,
> > +                                char *buf) {
> > +       return sysfs_emit(buf, "%u\n",
> > +amdgpu_acpi_priv.atcs.uma_info.uma_option_index);
> > +}
> > +
> > +static ssize_t uma_carveout_store(struct device *dev,
> > +                                 struct device_attribute *attr,
> > +                                 const char *buf, size_t count) {
> > +       struct amdgpu_uma_carveout_info *uma_info =
> &amdgpu_acpi_priv.atcs.uma_info;
> > +       struct drm_device *ddev = dev_get_drvdata(dev);
> > +       struct amdgpu_device *adev = drm_to_adev(ddev);
> > +       struct amdgpu_uma_carveout_option *opt;
> > +       unsigned long val;
> > +       uint8_t flags;
> > +       int r;
> > +
> > +       r = kstrtoul(buf, 10, &val);
> > +       if (r)
> > +               return r;
> > +
> > +       if (val >= uma_info->num_entries)
> > +               return -EINVAL;
> > +
> > +       opt = &uma_info->entries[val];
> > +
> > +       if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
> > +           !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
> > +               drm_err_once(ddev, "Option %ul not supported due to lack of
> Custom/Auto flag", r);
> > +               return -EINVAL;
> > +       }
> > +
> > +       flags = opt->flags;
> > +       flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
> > +
> > +       guard(mutex)(&uma_info->update_lock);
> > +
> > +       r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
> > +       if (r)
> > +               return r;
> > +
> > +       uma_info->uma_option_index = val;
> > +
> > +       return count;
> > +}
> > +static DEVICE_ATTR_RW(uma_carveout);
> > +
> > +static struct attribute *amdgpu_uma_attrs[] = {
> > +       &dev_attr_uma_carveout.attr,
> > +       &dev_attr_uma_carveout_options.attr,
> > +       NULL
> > +};
> > +
> > +const struct attribute_group amdgpu_uma_attr_group = {
> > +       .attrs = amdgpu_uma_attrs
> > +};
> > +
> > +static int amdgpu_acpi_uma_option_init(struct amdgpu_device *adev) {
> > +       struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
> > +       int rc;
> > +
> > +       if (!atcs->functions.set_uma_allocation_size)
> > +               return -ENODEV;
> > +
> > +       rc = amdgpu_atomfirmware_get_uma_carveout_info(adev, &atcs-
> >uma_info);
> > +       if (rc) {
> > +               drm_dbg(adev_to_drm(adev),
> > +                       "Failed to parse UMA carveout info from VBIOS: %d\n", rc);
> > +               goto out_info;
> > +       }
> > +
> > +       mutex_init(&atcs->uma_info.update_lock);
> > +
> > +       rc = devm_device_add_group(adev->dev, &amdgpu_uma_attr_group);
> > +       if (rc) {
> > +               drm_dbg(adev_to_drm(adev), "Failed to add UMA carveout sysfs
> interfaces %d\n", rc);
> > +               goto out_attr;
> > +       }
> > +
> > +       return 0;
> > +
> > +out_attr:
> > +       mutex_destroy(&atcs->uma_info.update_lock);
> > +out_info:
> > +       return rc;
> > +}
> > +
> > +static void amdgpu_acpi_uma_option_fini(void) {
> > +       struct amdgpu_uma_carveout_info *uma_info =
> > +&amdgpu_acpi_priv.atcs.uma_info;
> > +
> > +       mutex_destroy(&uma_info->update_lock);
> > +       uma_info->num_entries = 0;
> > +}
> > +
> >  /**
> >   * amdgpu_acpi_event - handle notify events
> >   *
> > @@ -1291,6 +1411,12 @@ static int amdgpu_acpi_event(struct
> > notifier_block *nb,  int amdgpu_acpi_init(struct amdgpu_device *adev)
> > {
> >         struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
> > +       int rc;
> > +
> > +       rc = amdgpu_acpi_uma_option_init(adev);
> > +
> > +       if (rc)
> > +               drm_dbg(adev_to_drm(adev), "Not creating uma carveout
> > + interfaces: %d", rc);
> >
> >         if (atif->notifications.brightness_change) {
> >                 if (adev->dc_enabled) { @@ -1343,6 +1469,7 @@ void
> > amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps)
> > void amdgpu_acpi_fini(struct amdgpu_device *adev)  {
> >         unregister_acpi_notifier(&adev->acpi_nb);
> > +       amdgpu_acpi_uma_option_fini();
> >  }
> >
> >  /**
> >
> > --
> > 2.43.0
> >

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
  2025-11-18 14:22     ` Lin, Leo
@ 2025-11-18 14:30       ` Alex Deucher
  0 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2025-11-18 14:30 UTC (permalink / raw)
  To: Lin, Leo
  Cc: Deucher, Alexander, Koenig, Christian, David Airlie,
	Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Jonathan Corbet, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, Tsao, Anson,
	Mario Limonciello (AMD) (kernel.org)

On Tue, Nov 18, 2025 at 9:22 AM Lin, Leo <Leo.Lin@amd.com> wrote:
>
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> > -----Original Message-----
> > From: Alex Deucher <alexdeucher@gmail.com>
> > Sent: Tuesday, November 18, 2025 3:49 AM
> > To: Lin, Leo <Leo.Lin@amd.com>
> > Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> > <Christian.Koenig@amd.com>; David Airlie <airlied@gmail.com>; Simona
> > Vetter <simona@ffwll.ch>; Maarten Lankhorst
> > <maarten.lankhorst@linux.intel.com>; Maxime Ripard
> > <mripard@kernel.org>; Thomas Zimmermann <tzimmermann@suse.de>;
> > Jonathan Corbet <corbet@lwn.net>; amd-gfx@lists.freedesktop.org; dri-
> > devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; linux-
> > doc@vger.kernel.org; Tsao, Anson <anson.tsao@amd.com>; Mario
> > Limonciello (AMD) (kernel.org) <superm1@kernel.org>
> > Subject: Re: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to
> > sysfs
> >
> > On Fri, Nov 14, 2025 at 3:52 AM Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> > wrote:
> > >
> > > Add two sysfs files as interfaces to inspect or change UMA carveout
> > > size. These files are:
> > >
> > > - uma_carveout_options: a read-only file listing all the available
> > >   UMA allocation options and their index.
> > >
> > > - uma_carveout: a file that is both readable and writable. On read,
> > >   it shows the index of the current setting. Writing a valid index
> > >   into this file allows users to change the UMA carveout size to that
> > >   option on the next boot.
> >
> > Would it be cleaner to combine these?  Reading the file would show the
> > indexed list of options with a * next to the currently selected one and then
> > writing the index to the file would cause the change to take effect on the next
> > reboot.
> >
> > Alex
>
> My thought is that it'll make it less friendly for processing output with awk/cut/other text processing tools. Also, I feel that the format will be trickier to maintain in the future, considering that it has to stay consistent for potentially new carveout option naming scheme.
>
> (Plus, the general guideline of making a sysfs file content array-ish in the kernel doc.[1])
>
> That being said, it's my personal thought. If you feel cleaner to merge those two interfaces into one, it's definitely possible to do this in the next version and see what people's feedback would be. Let me know if that's what you'd like to see.
>
> [1]  https://docs.kernel.org/filesystems/sysfs.html#attributes

Most of the other sysfs files work more like what I suggested.  That
said, if you'd prefer the other method, can you group then in a
directory?  E.g.,
uma/carveout_options
uma/carveout

Thanks,

Alex

>
> BR,
> Leo
>
> >
> > >
> > > Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > > Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > > Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 127
> > > +++++++++++++++++++++++++++++++
> > >  1 file changed, 127 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > > index 444ab4102168..b9378f34eb79 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > > @@ -30,6 +30,7 @@
> > >  #include <linux/power_supply.h>
> > >  #include <linux/pm_runtime.h>
> > >  #include <linux/suspend.h>
> > > +#include <linux/device.h>
> > >  #include <acpi/video.h>
> > >  #include <acpi/actbl.h>
> > >
> > > @@ -1247,6 +1248,125 @@ int amdgpu_acpi_get_mem_info(struct
> > amdgpu_device *adev, int xcc_id,
> > >         return -ENOENT;
> > >  }
> > >
> > > +static ssize_t uma_carveout_options_show(struct device *dev,
> > > +                                        struct device_attribute *attr,
> > > +                                        char *buf) {
> > > +       struct amdgpu_uma_carveout_info *uma_info =
> > &amdgpu_acpi_priv.atcs.uma_info;
> > > +       ssize_t size = 0;
> > > +
> > > +       if (!uma_info || !uma_info->num_entries)
> > > +               return -ENODEV;
> > > +
> > > +       for (int i = 0; i < uma_info->num_entries; i++) {
> > > +               size += sysfs_emit_at(buf, size, "%d: %s (%u GB)\n",
> > > +                                     i,
> > > +                                     uma_info->entries[i].name,
> > > +                                     uma_info->entries[i].memory_carved);
> > > +       }
> > > +
> > > +       return size;
> > > +}
> > > +static DEVICE_ATTR_RO(uma_carveout_options);
> > > +
> > > +static ssize_t uma_carveout_show(struct device *dev,
> > > +                                struct device_attribute *attr,
> > > +                                char *buf) {
> > > +       return sysfs_emit(buf, "%u\n",
> > > +amdgpu_acpi_priv.atcs.uma_info.uma_option_index);
> > > +}
> > > +
> > > +static ssize_t uma_carveout_store(struct device *dev,
> > > +                                 struct device_attribute *attr,
> > > +                                 const char *buf, size_t count) {
> > > +       struct amdgpu_uma_carveout_info *uma_info =
> > &amdgpu_acpi_priv.atcs.uma_info;
> > > +       struct drm_device *ddev = dev_get_drvdata(dev);
> > > +       struct amdgpu_device *adev = drm_to_adev(ddev);
> > > +       struct amdgpu_uma_carveout_option *opt;
> > > +       unsigned long val;
> > > +       uint8_t flags;
> > > +       int r;
> > > +
> > > +       r = kstrtoul(buf, 10, &val);
> > > +       if (r)
> > > +               return r;
> > > +
> > > +       if (val >= uma_info->num_entries)
> > > +               return -EINVAL;
> > > +
> > > +       opt = &uma_info->entries[val];
> > > +
> > > +       if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
> > > +           !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
> > > +               drm_err_once(ddev, "Option %ul not supported due to lack of
> > Custom/Auto flag", r);
> > > +               return -EINVAL;
> > > +       }
> > > +
> > > +       flags = opt->flags;
> > > +       flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
> > > +
> > > +       guard(mutex)(&uma_info->update_lock);
> > > +
> > > +       r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
> > > +       if (r)
> > > +               return r;
> > > +
> > > +       uma_info->uma_option_index = val;
> > > +
> > > +       return count;
> > > +}
> > > +static DEVICE_ATTR_RW(uma_carveout);
> > > +
> > > +static struct attribute *amdgpu_uma_attrs[] = {
> > > +       &dev_attr_uma_carveout.attr,
> > > +       &dev_attr_uma_carveout_options.attr,
> > > +       NULL
> > > +};
> > > +
> > > +const struct attribute_group amdgpu_uma_attr_group = {
> > > +       .attrs = amdgpu_uma_attrs
> > > +};
> > > +
> > > +static int amdgpu_acpi_uma_option_init(struct amdgpu_device *adev) {
> > > +       struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
> > > +       int rc;
> > > +
> > > +       if (!atcs->functions.set_uma_allocation_size)
> > > +               return -ENODEV;
> > > +
> > > +       rc = amdgpu_atomfirmware_get_uma_carveout_info(adev, &atcs-
> > >uma_info);
> > > +       if (rc) {
> > > +               drm_dbg(adev_to_drm(adev),
> > > +                       "Failed to parse UMA carveout info from VBIOS: %d\n", rc);
> > > +               goto out_info;
> > > +       }
> > > +
> > > +       mutex_init(&atcs->uma_info.update_lock);
> > > +
> > > +       rc = devm_device_add_group(adev->dev, &amdgpu_uma_attr_group);
> > > +       if (rc) {
> > > +               drm_dbg(adev_to_drm(adev), "Failed to add UMA carveout sysfs
> > interfaces %d\n", rc);
> > > +               goto out_attr;
> > > +       }
> > > +
> > > +       return 0;
> > > +
> > > +out_attr:
> > > +       mutex_destroy(&atcs->uma_info.update_lock);
> > > +out_info:
> > > +       return rc;
> > > +}
> > > +
> > > +static void amdgpu_acpi_uma_option_fini(void) {
> > > +       struct amdgpu_uma_carveout_info *uma_info =
> > > +&amdgpu_acpi_priv.atcs.uma_info;
> > > +
> > > +       mutex_destroy(&uma_info->update_lock);
> > > +       uma_info->num_entries = 0;
> > > +}
> > > +
> > >  /**
> > >   * amdgpu_acpi_event - handle notify events
> > >   *
> > > @@ -1291,6 +1411,12 @@ static int amdgpu_acpi_event(struct
> > > notifier_block *nb,  int amdgpu_acpi_init(struct amdgpu_device *adev)
> > > {
> > >         struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
> > > +       int rc;
> > > +
> > > +       rc = amdgpu_acpi_uma_option_init(adev);
> > > +
> > > +       if (rc)
> > > +               drm_dbg(adev_to_drm(adev), "Not creating uma carveout
> > > + interfaces: %d", rc);
> > >
> > >         if (atif->notifications.brightness_change) {
> > >                 if (adev->dc_enabled) { @@ -1343,6 +1469,7 @@ void
> > > amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps)
> > > void amdgpu_acpi_fini(struct amdgpu_device *adev)  {
> > >         unregister_acpi_notifier(&adev->acpi_nb);
> > > +       amdgpu_acpi_uma_option_fini();
> > >  }
> > >
> > >  /**
> > >
> > > --
> > > 2.43.0
> > >

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
  2025-11-14 20:26   ` Mario Limonciello (AMD) (kernel.org)
@ 2025-11-18 14:32     ` Lin, Leo
  0 siblings, 0 replies; 14+ messages in thread
From: Lin, Leo @ 2025-11-18 14:32 UTC (permalink / raw)
  To: Mario Limonciello (AMD) (kernel.org), Deucher, Alexander,
	Koenig, Christian, David Airlie, Simona Vetter, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, Jonathan Corbet
  Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Tsao, Anson

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Mario Limonciello (AMD) (kernel.org) <superm1@kernel.org>
> Sent: Saturday, November 15, 2025 4:26 AM
> To: Lin, Leo <Leo.Lin@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; David Airlie <airlied@gmail.com>; Simona
> Vetter <simona@ffwll.ch>; Maarten Lankhorst
> <maarten.lankhorst@linux.intel.com>; Maxime Ripard
> <mripard@kernel.org>; Thomas Zimmermann <tzimmermann@suse.de>;
> Jonathan Corbet <corbet@lwn.net>
> Cc: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-
> kernel@vger.kernel.org; linux-doc@vger.kernel.org; Tsao, Anson
> <anson.tsao@amd.com>
> Subject: Re: [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to
> sysfs
>
>
>
> On 11/14/2025 2:42 AM, Yo-Jung Leo Lin (AMD) wrote:
> > Add two sysfs files as interfaces to inspect or change UMA carveout
> > size. These files are:
> >
> > - uma_carveout_options: a read-only file listing all the available
> >    UMA allocation options and their index.
> >
> > - uma_carveout: a file that is both readable and writable. On read,
> >    it shows the index of the current setting. Writing a valid index
> >    into this file allows users to change the UMA carveout size to that
> >    option on the next boot.
> >
> > Co-developed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > Signed-off-by: Yo-Jung Leo Lin (AMD) <Leo.Lin@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 127
> +++++++++++++++++++++++++++++++
> >   1 file changed, 127 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > index 444ab4102168..b9378f34eb79 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > @@ -30,6 +30,7 @@
> >   #include <linux/power_supply.h>
> >   #include <linux/pm_runtime.h>
> >   #include <linux/suspend.h>
> > +#include <linux/device.h>
> >   #include <acpi/video.h>
> >   #include <acpi/actbl.h>
> >
> > @@ -1247,6 +1248,125 @@ int amdgpu_acpi_get_mem_info(struct
> amdgpu_device *adev, int xcc_id,
> >     return -ENOENT;
> >   }
> >
> > +static ssize_t uma_carveout_options_show(struct device *dev,
> > +                                    struct device_attribute *attr,
> > +                                    char *buf)
> > +{
> > +   struct amdgpu_uma_carveout_info *uma_info =
> &amdgpu_acpi_priv.atcs.uma_info;
> > +   ssize_t size = 0;
> > +
> > +   if (!uma_info || !uma_info->num_entries)
> > +           return -ENODEV;
> > +
> > +   for (int i = 0; i < uma_info->num_entries; i++) {
> > +           size += sysfs_emit_at(buf, size, "%d: %s (%u GB)\n",
> > +                                 i,
> > +                                 uma_info->entries[i].name,
> > +                                 uma_info->entries[i].memory_carved);
>
> AFAICT when memory_carved is 0 does this shows as:
>
> 0: Minimum (0 GB)
>
> This is actually 512 MB right?
>
> Could you cross reference what Windows shows in that case?  Do they special
> case it to 512 MB?

Yes, this option is actually 512MB. BIOS menu also shows it that way. Will make it show 512MB in the next version.

BR,
Leo

>
> I'm wondering if maybe that should be special cased here.
> > +   }
> > +
> > +   return size;
> > +}
> > +static DEVICE_ATTR_RO(uma_carveout_options);
> > +
> > +static ssize_t uma_carveout_show(struct device *dev,
> > +                            struct device_attribute *attr,
> > +                            char *buf)
> > +{
> > +   return sysfs_emit(buf, "%u\n",
> > +amdgpu_acpi_priv.atcs.uma_info.uma_option_index);
> > +}
> > +
> > +static ssize_t uma_carveout_store(struct device *dev,
> > +                             struct device_attribute *attr,
> > +                             const char *buf, size_t count)
> > +{
> > +   struct amdgpu_uma_carveout_info *uma_info =
> &amdgpu_acpi_priv.atcs.uma_info;
> > +   struct drm_device *ddev = dev_get_drvdata(dev);
> > +   struct amdgpu_device *adev = drm_to_adev(ddev);
> > +   struct amdgpu_uma_carveout_option *opt;
> > +   unsigned long val;
> > +   uint8_t flags;
> > +   int r;
> > +
> > +   r = kstrtoul(buf, 10, &val);
> > +   if (r)
> > +           return r;
> > +
> > +   if (val >= uma_info->num_entries)
> > +           return -EINVAL;
> > +
> > +   opt = &uma_info->entries[val];
> > +
> > +   if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
> > +       !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
> > +           drm_err_once(ddev, "Option %ul not supported due to lack
> of Custom/Auto flag", r);
> > +           return -EINVAL;
> > +   }
> > +
> > +   flags = opt->flags;
> > +   flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
> > +
> > +   guard(mutex)(&uma_info->update_lock);
> > +
> > +   r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
> > +   if (r)
> > +           return r;
> > +
> > +   uma_info->uma_option_index = val;
> > +
> > +   return count;
> > +}
> > +static DEVICE_ATTR_RW(uma_carveout);
> > +
> > +static struct attribute *amdgpu_uma_attrs[] = {
> > +   &dev_attr_uma_carveout.attr,
> > +   &dev_attr_uma_carveout_options.attr,
> > +   NULL
> > +};
> > +
> > +const struct attribute_group amdgpu_uma_attr_group = {
> > +   .attrs = amdgpu_uma_attrs
> > +};
> > +
> > +static int amdgpu_acpi_uma_option_init(struct amdgpu_device *adev) {
> > +   struct amdgpu_atcs *atcs = &amdgpu_acpi_priv.atcs;
> > +   int rc;
> > +
> > +   if (!atcs->functions.set_uma_allocation_size)
> > +           return -ENODEV;
> > +
> > +   rc = amdgpu_atomfirmware_get_uma_carveout_info(adev, &atcs-
> >uma_info);
> > +   if (rc) {
> > +           drm_dbg(adev_to_drm(adev),
> > +                   "Failed to parse UMA carveout info from VBIOS:
> %d\n", rc);
> > +           goto out_info;
> > +   }
> > +
> > +   mutex_init(&atcs->uma_info.update_lock);
> > +
> > +   rc = devm_device_add_group(adev->dev,
> &amdgpu_uma_attr_group);
> > +   if (rc) {
> > +           drm_dbg(adev_to_drm(adev), "Failed to add UMA carveout
> sysfs interfaces %d\n", rc);
> > +           goto out_attr;
> > +   }
> > +
> > +   return 0;
> > +
> > +out_attr:
> > +   mutex_destroy(&atcs->uma_info.update_lock);
> > +out_info:
> > +   return rc;
> > +}
> > +
> > +static void amdgpu_acpi_uma_option_fini(void) {
> > +   struct amdgpu_uma_carveout_info *uma_info =
> > +&amdgpu_acpi_priv.atcs.uma_info;
> > +
> > +   mutex_destroy(&uma_info->update_lock);
> > +   uma_info->num_entries = 0;
> > +}
> > +
> >   /**
> >    * amdgpu_acpi_event - handle notify events
> >    *
> > @@ -1291,6 +1411,12 @@ static int amdgpu_acpi_event(struct
> notifier_block *nb,
> >   int amdgpu_acpi_init(struct amdgpu_device *adev)
> >   {
> >     struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
> > +   int rc;
> > +
> > +   rc = amdgpu_acpi_uma_option_init(adev);
> > +
> > +   if (rc)
> > +           drm_dbg(adev_to_drm(adev), "Not creating uma carveout
> interfaces:
> > +%d", rc);
> >
> >     if (atif->notifications.brightness_change) {
> >             if (adev->dc_enabled) {
> > @@ -1343,6 +1469,7 @@ void amdgpu_acpi_get_backlight_caps(struct
> amdgpu_dm_backlight_caps *caps)
> >   void amdgpu_acpi_fini(struct amdgpu_device *adev)
> >   {
> >     unregister_acpi_notifier(&adev->acpi_nb);
> > +   amdgpu_acpi_uma_option_fini();
> >   }
> >
> >   /**
> >


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-11-18 14:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14  8:42 [PATCH v2 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
2025-11-14  8:42 ` [PATCH v2 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask Yo-Jung Leo Lin (AMD)
2025-11-14  8:42 ` [PATCH v2 2/5] drm/amdgpu: add helper to read UMA carveout info Yo-Jung Leo Lin (AMD)
2025-11-17 19:43   ` Alex Deucher
2025-11-14  8:42 ` [PATCH v2 3/5] drm/amdgpu: add UMA allocation setting helpers Yo-Jung Leo Lin (AMD)
2025-11-17  6:48   ` kernel test robot
2025-11-14  8:42 ` [PATCH v2 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
2025-11-14 20:26   ` Mario Limonciello (AMD) (kernel.org)
2025-11-18 14:32     ` Lin, Leo
2025-11-17 19:48   ` Alex Deucher
2025-11-18 14:22     ` Lin, Leo
2025-11-18 14:30       ` Alex Deucher
2025-11-14  8:42 ` [PATCH v2 5/5] Documentation/amdgpu: Add UMA carveout details Yo-Jung Leo Lin (AMD)
2025-11-14 20:23   ` Mario Limonciello (AMD) (kernel.org)

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).