Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd: Use attribute groups for PSP flashing attributes

Individually creating attributes can be racy, instead make attributes
using attribute groups and control their visibility with an is_visible
callback to only show when using appropriate products.

v2: squash in fix for PSP 13.0.10

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Mario Limonciello and committed by
Alex Deucher
521289d2 3e6a9329

+29 -39
-1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1034 1034 bool has_pr3; 1035 1035 1036 1036 bool ucode_sysfs_en; 1037 - bool psp_sysfs_en; 1038 1037 1039 1038 /* Chip product information */ 1040 1039 char product_number[20];
-10
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 4050 4050 } else 4051 4051 adev->ucode_sysfs_en = true; 4052 4052 4053 - r = amdgpu_psp_sysfs_init(adev); 4054 - if (r) { 4055 - adev->psp_sysfs_en = false; 4056 - if (!amdgpu_sriov_vf(adev)) 4057 - DRM_ERROR("Creating psp sysfs failed\n"); 4058 - } else 4059 - adev->psp_sysfs_en = true; 4060 - 4061 4053 /* 4062 4054 * Register gpu instance before amdgpu_device_enable_mgpu_fan_boost. 4063 4055 * Otherwise the mgpu fan boost feature will be skipped due to the ··· 4199 4207 amdgpu_pm_sysfs_fini(adev); 4200 4208 if (adev->ucode_sysfs_en) 4201 4209 amdgpu_ucode_sysfs_fini(adev); 4202 - if (adev->psp_sysfs_en) 4203 - amdgpu_psp_sysfs_fini(adev); 4204 4210 sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes); 4205 4211 4206 4212 /* disable ras feature must before hw fini */
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 2899 2899 2900 2900 extern const struct attribute_group amdgpu_vram_mgr_attr_group; 2901 2901 extern const struct attribute_group amdgpu_gtt_mgr_attr_group; 2902 + extern const struct attribute_group amdgpu_flash_attr_group; 2902 2903 2903 2904 static const struct attribute_group *amdgpu_sysfs_groups[] = { 2904 2905 &amdgpu_vram_mgr_attr_group, 2905 2906 &amdgpu_gtt_mgr_attr_group, 2907 + &amdgpu_flash_attr_group, 2906 2908 NULL, 2907 2909 }; 2908 2910
+27 -26
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 202 202 case IP_VERSION(13, 0, 3): 203 203 case IP_VERSION(13, 0, 5): 204 204 case IP_VERSION(13, 0, 8): 205 - case IP_VERSION(13, 0, 10): 206 205 case IP_VERSION(13, 0, 11): 207 206 psp_v13_0_set_psp_funcs(psp); 208 207 psp->autoload_supported = true; ··· 214 215 break; 215 216 case IP_VERSION(13, 0, 0): 216 217 case IP_VERSION(13, 0, 7): 218 + case IP_VERSION(13, 0, 10): 217 219 psp_v13_0_set_psp_funcs(psp); 218 220 psp->autoload_supported = true; 219 221 break; ··· 3677 3677 return 0; 3678 3678 } 3679 3679 3680 + static struct bin_attribute psp_vbflash_bin_attr = { 3681 + .attr = {.name = "psp_vbflash", .mode = 0660}, 3682 + .size = 0, 3683 + .write = amdgpu_psp_vbflash_write, 3684 + .read = amdgpu_psp_vbflash_read, 3685 + }; 3686 + 3680 3687 static ssize_t amdgpu_psp_vbflash_status(struct device *dev, 3681 3688 struct device_attribute *attr, 3682 3689 char *buf) ··· 3700 3693 3701 3694 return sysfs_emit(buf, "0x%x\n", vbflash_status); 3702 3695 } 3703 - 3704 - static const struct bin_attribute psp_vbflash_bin_attr = { 3705 - .attr = {.name = "psp_vbflash", .mode = 0660}, 3706 - .size = 0, 3707 - .write = amdgpu_psp_vbflash_write, 3708 - .read = amdgpu_psp_vbflash_read, 3709 - }; 3710 - 3711 3696 static DEVICE_ATTR(psp_vbflash_status, 0440, amdgpu_psp_vbflash_status, NULL); 3712 3697 3713 - int amdgpu_psp_sysfs_init(struct amdgpu_device *adev) 3698 + static struct attribute *flash_attrs[] = { 3699 + &dev_attr_psp_vbflash_status.attr, 3700 + &psp_vbflash_bin_attr.attr, 3701 + NULL 3702 + }; 3703 + 3704 + static umode_t amdgpu_flash_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx) 3714 3705 { 3715 - int ret = 0; 3706 + struct device *dev = kobj_to_dev(kobj); 3707 + struct drm_device *ddev = dev_get_drvdata(dev); 3708 + struct amdgpu_device *adev = drm_to_adev(ddev); 3716 3709 3717 3710 if (amdgpu_sriov_vf(adev)) 3718 - return -EINVAL; 3711 + return 0; 3719 3712 3720 3713 switch (adev->ip_versions[MP0_HWIP][0]) { 3721 3714 case IP_VERSION(13, 0, 0): 3722 3715 case IP_VERSION(13, 0, 7): 3723 - case IP_VERSION(13, 0, 10): 3724 - ret = sysfs_create_bin_file(&adev->dev->kobj, &psp_vbflash_bin_attr); 3725 - if (ret) 3726 - dev_err(adev->dev, "Failed to create device file psp_vbflash"); 3727 - ret = device_create_file(adev->dev, &dev_attr_psp_vbflash_status); 3728 - if (ret) 3729 - dev_err(adev->dev, "Failed to create device file psp_vbflash_status"); 3730 - return ret; 3716 + if (attr == &psp_vbflash_bin_attr.attr) 3717 + return 0660; 3718 + return 0440; 3731 3719 default: 3732 3720 return 0; 3733 3721 } 3734 3722 } 3723 + 3724 + const struct attribute_group amdgpu_flash_attr_group = { 3725 + .attrs = flash_attrs, 3726 + .is_visible = amdgpu_flash_attr_is_visible, 3727 + }; 3735 3728 3736 3729 const struct amd_ip_funcs psp_ip_funcs = { 3737 3730 .name = "psp", ··· 3759 3752 DRM_ERROR("Failed to create USBC PD FW control file!"); 3760 3753 3761 3754 return ret; 3762 - } 3763 - 3764 - void amdgpu_psp_sysfs_fini(struct amdgpu_device *adev) 3765 - { 3766 - sysfs_remove_bin_file(&adev->dev->kobj, &psp_vbflash_bin_attr); 3767 - device_remove_file(adev->dev, &dev_attr_psp_vbflash_status); 3768 3755 } 3769 3756 3770 3757 static void psp_sysfs_fini(struct amdgpu_device *adev)
-2
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
··· 525 525 526 526 int is_psp_fw_valid(struct psp_bin_desc bin); 527 527 528 - int amdgpu_psp_sysfs_init(struct amdgpu_device *adev); 529 - void amdgpu_psp_sysfs_fini(struct amdgpu_device *adev); 530 528 #endif