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

drm/amdgpu: Add debugfs file for VBIOS and version

Add 2 debugfs files, one that contains the VBIOS version, and one that
contains the VBIOS itself. These won't change after initialization,
so we can add the VBIOS version when we parse the atombios information.

This ensures that we can find out the VBIOS version, even when the dmesg
buffer fills up, and makes it easier to associate which VBIOS version is
for which GPU on mGPU configurations. Set the size to 20 characters in
case of some weird VBIOS version that exceeds the expected 17 character
format (3-8-3\0). The VBIOS dump also allows for easy debugging

v2: Move to debugfs, clarify commit message, add VBIOS dump file

Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Kent Russell and committed by
Alex Deucher
db95e218 96bec198

+67 -1
+62
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 65 65 static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); 66 66 static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); 67 67 static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev); 68 + static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev); 69 + static int amdgpu_debugfs_vbios_version_init(struct amdgpu_device *adev); 68 70 69 71 static const char *amdgpu_asic_name[] = { 70 72 "TAHITI", ··· 2203 2201 if (r) 2204 2202 DRM_ERROR("registering firmware debugfs failed (%d).\n", r); 2205 2203 2204 + r = amdgpu_debugfs_vbios_dump_init(adev); 2205 + if (r) 2206 + DRM_ERROR("Creating vbios dump debugfs failed (%d).\n", r); 2207 + 2208 + r = amdgpu_debugfs_vbios_version_init(adev); 2209 + if (r) 2210 + DRM_ERROR("Creating vbios version debugfs failed (%d).\n", r); 2211 + 2206 2212 if ((amdgpu_testing & 1)) { 2207 2213 if (adev->accel_working) 2208 2214 amdgpu_test_moves(adev); ··· 3764 3754 { 3765 3755 return 0; 3766 3756 } 3757 + 3758 + static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data) 3759 + { 3760 + struct drm_info_node *node = (struct drm_info_node *) m->private; 3761 + struct drm_device *dev = node->minor->dev; 3762 + struct amdgpu_device *adev = dev->dev_private; 3763 + 3764 + seq_write(m, adev->bios, adev->bios_size); 3765 + return 0; 3766 + } 3767 + 3768 + static int amdgpu_debugfs_get_vbios_version(struct seq_file *m, void *data) 3769 + { 3770 + struct drm_info_node *node = (struct drm_info_node *) m->private; 3771 + struct drm_device *dev = node->minor->dev; 3772 + struct amdgpu_device *adev = dev->dev_private; 3773 + struct atom_context *ctx = adev->mode_info.atom_context; 3774 + 3775 + seq_printf(m, "%s\n", ctx->vbios_version); 3776 + return 0; 3777 + } 3778 + 3779 + static const struct drm_info_list amdgpu_vbios_dump_list[] = { 3780 + {"amdgpu_vbios", 3781 + amdgpu_debugfs_get_vbios_dump, 3782 + 0, NULL}, 3783 + }; 3784 + 3785 + static const struct drm_info_list amdgpu_vbios_version_list[] = { 3786 + {"amdgpu_vbios_version", 3787 + amdgpu_debugfs_get_vbios_version, 3788 + 0, NULL}, 3789 + }; 3790 + 3791 + static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) 3792 + { 3793 + return amdgpu_debugfs_add_files(adev, 3794 + amdgpu_vbios_dump_list, 1); 3795 + } 3796 + static int amdgpu_debugfs_vbios_version_init(struct amdgpu_device *adev) 3797 + { 3798 + return amdgpu_debugfs_add_files(adev, 3799 + amdgpu_vbios_version_list, 1); 3800 + } 3767 3801 #else 3768 3802 static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev) 3769 3803 { 3770 3804 return 0; 3771 3805 } 3772 3806 static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) 3807 + { 3808 + return 0; 3809 + } 3810 + static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) 3811 + { 3812 + return 0; 3813 + } 3814 + static int amdgpu_debugfs_vbios_version_init(struct amdgpu_device *adev) 3773 3815 { 3774 3816 return 0; 3775 3817 }
+4 -1
drivers/gpu/drm/amd/amdgpu/atom.c
··· 1343 1343 idx = 0x80; 1344 1344 1345 1345 str = CSTR(idx); 1346 - if (*str != '\0') 1346 + if (*str != '\0') { 1347 1347 pr_info("ATOM BIOS: %s\n", str); 1348 + strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version)); 1349 + } 1350 + 1348 1351 1349 1352 return ctx; 1350 1353 }
+1
drivers/gpu/drm/amd/amdgpu/atom.h
··· 140 140 int io_mode; 141 141 uint32_t *scratch; 142 142 int scratch_size_bytes; 143 + char vbios_version[20]; 143 144 }; 144 145 145 146 extern int amdgpu_atom_debug;