linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: "Yo-Jung Leo Lin (AMD)" <Leo.Lin@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <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>,
	"Mario Limonciello (AMD) (kernel.org)" <superm1@kernel.org>
Subject: Re: [PATCH v4 2/5] drm/amdgpu: add helper to read UMA carveout info
Date: Mon, 1 Dec 2025 20:09:39 +0530	[thread overview]
Message-ID: <a1913f9b-45ee-4e93-8b16-f827ead35f52@amd.com> (raw)
In-Reply-To: <20251201-vram-carveout-tuning-for-upstream-v4-2-9e151363b5ab@amd.com>



On 12/1/2025 4:38 PM, Yo-Jung Leo Lin (AMD) 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>
> 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              | 32 ++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c         |  2 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 77 ++++++++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h |  2 +
>   4 files changed, 113 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 9f9774f58ce1..ca9c2b54045b 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_carveout_option - single UMA carveout option
> + * @name: Name of the carveout option
> + * @memory_carved_mb: Amount of memory carved in MB
> + * @flags: ATCS flags supported by this option
> + */
> +struct amdgpu_uma_carveout_option {
> +	char name[MAX_UMA_OPTION_NAME];
> +	uint32_t memory_carved_mb;
> +	uint8_t flags;
> +};
> +
> +/**
> + * struct amdgpu_uma_carveout_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 610449d73a6c..92070738bd42 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;

Since carveout_info definition is part of amdgpu.h, I think moving this 
to amdgpu_device is better and then keeping the uma/sysfs options 
initialization (patch 4) in amdgpu_device.c. amdgpu_acpi doesn't really 
need to have atomfirmware included.

Thanks,
Lijo

>   };
>   
>   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..7f4751e5caaf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
> @@ -296,6 +296,83 @@ 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++) {
> +		if (!opts[i].memoryCarvedGb)
> +			uma_info->entries[i].memory_carved_mb = 512;
> +		else
> +			uma_info->entries[i].memory_carved_mb = (uint32_t)opts[i].memoryCarvedGb << 10;
> +
> +		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);
> 


  reply	other threads:[~2025-12-01 14:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 11:08 [PATCH v4 0/5] drm/amdgpu: add UMA carveout tuning interfaces Yo-Jung Leo Lin (AMD)
2025-12-01 11:08 ` [PATCH v4 1/5] drm/amdgpu: parse UMA size-getting/setting bits in ATCS mask Yo-Jung Leo Lin (AMD)
2025-12-01 11:08 ` [PATCH v4 2/5] drm/amdgpu: add helper to read UMA carveout info Yo-Jung Leo Lin (AMD)
2025-12-01 14:39   ` Lazar, Lijo [this message]
2025-12-03 15:24     ` Lin, Leo
2025-12-01 11:08 ` [PATCH v4 3/5] drm/amdgpu: add UMA allocation setting helpers Yo-Jung Leo Lin (AMD)
2025-12-01 11:08 ` [PATCH v4 4/5] drm/amdgpu: add UMA allocation interfaces to sysfs Yo-Jung Leo Lin (AMD)
2025-12-01 20:05   ` Alex Deucher
2025-12-01 11:08 ` [PATCH v4 5/5] Documentation/amdgpu: Add UMA carveout details Yo-Jung Leo Lin (AMD)
2025-12-01 20:07   ` Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1913f9b-45ee-4e93-8b16-f827ead35f52@amd.com \
    --to=lijo.lazar@amd.com \
    --cc=Leo.Lin@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=anson.tsao@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=superm1@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).