mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-18 14:43:42 -04:00
drm/amdgpu: Add helpers to set/get unique ids
Add a struct to store unique id information for each type. Add helper to fetch the unique id. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Asad Kamal <asad.kamal@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -2675,6 +2675,24 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static void amdgpu_uid_init(struct amdgpu_device *adev)
|
||||
{
|
||||
/* Initialize the UID for the device */
|
||||
adev->uid_info = kzalloc(sizeof(struct amdgpu_uid), GFP_KERNEL);
|
||||
if (!adev->uid_info) {
|
||||
dev_warn(adev->dev, "Failed to allocate memory for UID\n");
|
||||
return;
|
||||
}
|
||||
adev->uid_info->adev = adev;
|
||||
}
|
||||
|
||||
static void amdgpu_uid_fini(struct amdgpu_device *adev)
|
||||
{
|
||||
/* Free the UID memory */
|
||||
kfree(adev->uid_info);
|
||||
adev->uid_info = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_device_ip_early_init - run early init for hardware IPs
|
||||
*
|
||||
@@ -2858,6 +2876,8 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
|
||||
if (adev->gmc.xgmi.supported)
|
||||
amdgpu_xgmi_early_init(adev);
|
||||
|
||||
if (amdgpu_is_multi_aid(adev))
|
||||
amdgpu_uid_init(adev);
|
||||
ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);
|
||||
if (ip_block->status.valid != false)
|
||||
amdgpu_amdkfd_device_probe(adev);
|
||||
@@ -3648,6 +3668,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
|
||||
}
|
||||
|
||||
amdgpu_ras_fini(adev);
|
||||
amdgpu_uid_fini(adev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -7486,3 +7507,53 @@ ssize_t amdgpu_show_reset_mask(char *buf, uint32_t supported_reset)
|
||||
size += sysfs_emit_at(buf, size, "\n");
|
||||
return size;
|
||||
}
|
||||
|
||||
void amdgpu_device_set_uid(struct amdgpu_uid *uid_info,
|
||||
enum amdgpu_uid_type type, uint8_t inst,
|
||||
uint64_t uid)
|
||||
{
|
||||
if (!uid_info)
|
||||
return;
|
||||
|
||||
if (type >= AMDGPU_UID_TYPE_MAX) {
|
||||
dev_err_once(uid_info->adev->dev, "Invalid UID type %d\n",
|
||||
type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inst >= AMDGPU_UID_INST_MAX) {
|
||||
dev_err_once(uid_info->adev->dev, "Invalid UID instance %d\n",
|
||||
inst);
|
||||
return;
|
||||
}
|
||||
|
||||
if (uid_info->uid[type][inst] != 0) {
|
||||
dev_warn_once(
|
||||
uid_info->adev->dev,
|
||||
"Overwriting existing UID %llu for type %d instance %d\n",
|
||||
uid_info->uid[type][inst], type, inst);
|
||||
}
|
||||
|
||||
uid_info->uid[type][inst] = uid;
|
||||
}
|
||||
|
||||
u64 amdgpu_device_get_uid(struct amdgpu_uid *uid_info,
|
||||
enum amdgpu_uid_type type, uint8_t inst)
|
||||
{
|
||||
if (!uid_info)
|
||||
return 0;
|
||||
|
||||
if (type >= AMDGPU_UID_TYPE_MAX) {
|
||||
dev_err_once(uid_info->adev->dev, "Invalid UID type %d\n",
|
||||
type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (inst >= AMDGPU_UID_INST_MAX) {
|
||||
dev_err_once(uid_info->adev->dev, "Invalid UID instance %d\n",
|
||||
inst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return uid_info->uid[type][inst];
|
||||
}
|
||||
Reference in New Issue
Block a user