All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] drm/amdgpu: add UMA carveout tuning interfaces
@ 2025-11-26  9:05 Yo-Jung Leo Lin (AMD)
  2025-11-26  9:05 ` [PATCH v3 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; 9+ messages in thread
From: Yo-Jung Leo Lin (AMD) @ 2025-11-26  9:05 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 v3:
- Change the unit of memory carved in UMA option entry from GB to MB and use
  uint32_t instead, so that options below 1 GB can be properly recorded.
- Rename the sysfs interfaces from "uma_carveout_options" and "uma_carveout" to
  just "carveout_options" and "carveout", and put them under a new uma/ directory.
- Update docs to reflect the naming/location changes to the said sysfs files.
- Rebase to latest asdn
- Fix LKP build error
- Link to v2: https://lore.kernel.org/r/20251114-vram-carveout-tuning-for-upstream-v2-0-4f6bdd48030d@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         | 215 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c |  77 ++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h |   2 +
 drivers/gpu/drm/amd/include/amd_acpi.h           |  34 +++-
 6 files changed, 392 insertions(+), 1 deletion(-)
---
base-commit: 5de8ce0f3709ad93ca5a579aa45cf1b52d72bc90
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] 9+ messages in thread
* Re: [PATCH v3 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
@ 2025-11-29  8:26 kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-11-29  8:26 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251126-vram-carveout-tuning-for-upstream-v3-4-cf1729c4cb3c@amd.com>
References: <20251126-vram-carveout-tuning-for-upstream-v3-4-cf1729c4cb3c@amd.com>
TO: "Yo-Jung Leo Lin (AMD)" <Leo.Lin@amd.com>
TO: Alex Deucher <alexander.deucher@amd.com>
TO: "Christian König" <christian.koenig@amd.com>
TO: David Airlie <airlied@gmail.com>
TO: Simona Vetter <simona@ffwll.ch>
TO: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
TO: Maxime Ripard <mripard@kernel.org>
TO: Thomas Zimmermann <tzimmermann@suse.de>
TO: Jonathan Corbet <corbet@lwn.net>
CC: amd-gfx@lists.freedesktop.org
CC: dri-devel@lists.freedesktop.org
CC: linux-kernel@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: "Tsao, Anson" <anson.tsao@amd.com>
CC: "Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
CC: "Yo-Jung Leo Lin (AMD)" <Leo.Lin@amd.com>

Hi Yo-Jung,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 5de8ce0f3709ad93ca5a579aa45cf1b52d72bc90]

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/20251126-171047
base:   5de8ce0f3709ad93ca5a579aa45cf1b52d72bc90
patch link:    https://lore.kernel.org/r/20251126-vram-carveout-tuning-for-upstream-v3-4-cf1729c4cb3c%40amd.com
patch subject: [PATCH v3 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-161-20251128 (https://download.01.org/0day-ci/archive/20251129/202511291652.EupyTDzf-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0

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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202511291652.EupyTDzf-lkp@intel.com/

smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:1306 carveout_store() warn: potential spectre issue 'uma_info->entries' [r] (local cap)

vim +1306 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1286) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1287) static ssize_t carveout_store(struct device *dev,
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1288) 			      struct device_attribute *attr,
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1289) 			      const char *buf, size_t count)
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1290) {
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1291) 	struct amdgpu_uma_carveout_info *uma_info = &amdgpu_acpi_priv.atcs.uma_info;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1292) 	struct drm_device *ddev = dev_get_drvdata(dev);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1293) 	struct amdgpu_device *adev = drm_to_adev(ddev);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1294) 	struct amdgpu_uma_carveout_option *opt;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1295) 	unsigned long val;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1296) 	uint8_t flags;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1297) 	int r;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1298) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1299) 	r = kstrtoul(buf, 10, &val);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1300) 	if (r)
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1301) 		return r;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1302) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1303) 	if (val >= uma_info->num_entries)
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1304) 		return -EINVAL;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1305) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26 @1306) 	opt = &uma_info->entries[val];
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1307) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1308) 	if (!(opt->flags & AMDGPU_UMA_FLAG_AUTO) &&
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1309) 	    !(opt->flags & AMDGPU_UMA_FLAG_CUSTOM)) {
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1310) 		drm_err_once(ddev, "Option %ul not supported due to lack of Custom/Auto flag", r);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1311) 		return -EINVAL;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1312) 	}
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1313) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1314) 	flags = opt->flags;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1315) 	flags &= ~((flags & AMDGPU_UMA_FLAG_AUTO) >> 1);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1316) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1317) 	guard(mutex)(&uma_info->update_lock);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1318) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1319) 	r = amdgpu_acpi_set_uma_allocation_size(adev, val, flags);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1320) 	if (r)
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1321) 		return r;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1322) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1323) 	uma_info->uma_option_index = val;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1324) 
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1325) 	return count;
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1326) }
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1327) static DEVICE_ATTR_RW(carveout);
5b31d3313d99634 Yo-Jung Leo Lin (AMD  2025-11-26  1328) 

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

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

end of thread, other threads:[~2025-12-01 13:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26  9:05 [PATCH v3 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
2025-11-26  9:05 ` [PATCH v3 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask Yo-Jung Leo Lin (AMD)
2025-11-26  9:05 ` [PATCH v3 2/5] drm/amdgpu: add helper to read UMA carveout info Yo-Jung Leo Lin (AMD)
2025-12-01  8:30   ` Kuan-Wei Chiu
2025-11-26  9:05 ` [PATCH v3 3/5] drm/amdgpu: add UMA allocation setting helpers Yo-Jung Leo Lin (AMD)
2025-11-26  9:05 ` [PATCH v3 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
2025-12-01  7:53   ` Kuan-Wei Chiu
2025-11-26  9:05 ` [PATCH v3 5/5] Documentation/amdgpu: Add UMA carveout details Yo-Jung Leo Lin (AMD)
  -- strict thread matches above, loose matches on Subject: below --
2025-11-29  8:26 [PATCH v3 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.