diff options
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index da0a667a911b..1c5c44acaad2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -66,7 +66,6 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); | |||
66 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); | 66 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); |
67 | static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev); | 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); | 68 | static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev); |
69 | static int amdgpu_debugfs_vbios_version_init(struct amdgpu_device *adev); | ||
70 | 69 | ||
71 | static const char *amdgpu_asic_name[] = { | 70 | static const char *amdgpu_asic_name[] = { |
72 | "TAHITI", | 71 | "TAHITI", |
@@ -889,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg) | |||
889 | return r; | 888 | return r; |
890 | } | 889 | } |
891 | 890 | ||
891 | static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev, | ||
892 | struct device_attribute *attr, | ||
893 | char *buf) | ||
894 | { | ||
895 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
896 | struct amdgpu_device *adev = ddev->dev_private; | ||
897 | struct atom_context *ctx = adev->mode_info.atom_context; | ||
898 | |||
899 | return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); | ||
900 | } | ||
901 | |||
902 | static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, | ||
903 | NULL); | ||
904 | |||
892 | /** | 905 | /** |
893 | * amdgpu_atombios_fini - free the driver info and callbacks for atombios | 906 | * amdgpu_atombios_fini - free the driver info and callbacks for atombios |
894 | * | 907 | * |
@@ -908,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev) | |||
908 | adev->mode_info.atom_context = NULL; | 921 | adev->mode_info.atom_context = NULL; |
909 | kfree(adev->mode_info.atom_card_info); | 922 | kfree(adev->mode_info.atom_card_info); |
910 | adev->mode_info.atom_card_info = NULL; | 923 | adev->mode_info.atom_card_info = NULL; |
924 | device_remove_file(adev->dev, &dev_attr_vbios_version); | ||
911 | } | 925 | } |
912 | 926 | ||
913 | /** | 927 | /** |
@@ -924,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev) | |||
924 | { | 938 | { |
925 | struct card_info *atom_card_info = | 939 | struct card_info *atom_card_info = |
926 | kzalloc(sizeof(struct card_info), GFP_KERNEL); | 940 | kzalloc(sizeof(struct card_info), GFP_KERNEL); |
941 | int ret; | ||
927 | 942 | ||
928 | if (!atom_card_info) | 943 | if (!atom_card_info) |
929 | return -ENOMEM; | 944 | return -ENOMEM; |
@@ -960,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev) | |||
960 | amdgpu_atombios_scratch_regs_init(adev); | 975 | amdgpu_atombios_scratch_regs_init(adev); |
961 | amdgpu_atombios_allocate_fb_scratch(adev); | 976 | amdgpu_atombios_allocate_fb_scratch(adev); |
962 | } | 977 | } |
978 | |||
979 | ret = device_create_file(adev->dev, &dev_attr_vbios_version); | ||
980 | if (ret) { | ||
981 | DRM_ERROR("Failed to create device file for VBIOS version\n"); | ||
982 | return ret; | ||
983 | } | ||
984 | |||
963 | return 0; | 985 | return 0; |
964 | } | 986 | } |
965 | 987 | ||
@@ -2207,10 +2229,6 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2207 | if (r) | 2229 | if (r) |
2208 | DRM_ERROR("Creating vbios dump debugfs failed (%d).\n", r); | 2230 | DRM_ERROR("Creating vbios dump debugfs failed (%d).\n", r); |
2209 | 2231 | ||
2210 | r = amdgpu_debugfs_vbios_version_init(adev); | ||
2211 | if (r) | ||
2212 | DRM_ERROR("Creating vbios version debugfs failed (%d).\n", r); | ||
2213 | |||
2214 | if ((amdgpu_testing & 1)) { | 2232 | if ((amdgpu_testing & 1)) { |
2215 | if (adev->accel_working) | 2233 | if (adev->accel_working) |
2216 | amdgpu_test_moves(adev); | 2234 | amdgpu_test_moves(adev); |
@@ -3775,39 +3793,17 @@ static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data) | |||
3775 | return 0; | 3793 | return 0; |
3776 | } | 3794 | } |
3777 | 3795 | ||
3778 | static int amdgpu_debugfs_get_vbios_version(struct seq_file *m, void *data) | ||
3779 | { | ||
3780 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
3781 | struct drm_device *dev = node->minor->dev; | ||
3782 | struct amdgpu_device *adev = dev->dev_private; | ||
3783 | struct atom_context *ctx = adev->mode_info.atom_context; | ||
3784 | |||
3785 | seq_printf(m, "%s\n", ctx->vbios_version); | ||
3786 | return 0; | ||
3787 | } | ||
3788 | |||
3789 | static const struct drm_info_list amdgpu_vbios_dump_list[] = { | 3796 | static const struct drm_info_list amdgpu_vbios_dump_list[] = { |
3790 | {"amdgpu_vbios", | 3797 | {"amdgpu_vbios", |
3791 | amdgpu_debugfs_get_vbios_dump, | 3798 | amdgpu_debugfs_get_vbios_dump, |
3792 | 0, NULL}, | 3799 | 0, NULL}, |
3793 | }; | 3800 | }; |
3794 | 3801 | ||
3795 | static const struct drm_info_list amdgpu_vbios_version_list[] = { | ||
3796 | {"amdgpu_vbios_version", | ||
3797 | amdgpu_debugfs_get_vbios_version, | ||
3798 | 0, NULL}, | ||
3799 | }; | ||
3800 | |||
3801 | static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) | 3802 | static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) |
3802 | { | 3803 | { |
3803 | return amdgpu_debugfs_add_files(adev, | 3804 | return amdgpu_debugfs_add_files(adev, |
3804 | amdgpu_vbios_dump_list, 1); | 3805 | amdgpu_vbios_dump_list, 1); |
3805 | } | 3806 | } |
3806 | static int amdgpu_debugfs_vbios_version_init(struct amdgpu_device *adev) | ||
3807 | { | ||
3808 | return amdgpu_debugfs_add_files(adev, | ||
3809 | amdgpu_vbios_version_list, 1); | ||
3810 | } | ||
3811 | #else | 3807 | #else |
3812 | static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev) | 3808 | static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev) |
3813 | { | 3809 | { |
@@ -3821,9 +3817,5 @@ static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) | |||
3821 | { | 3817 | { |
3822 | return 0; | 3818 | return 0; |
3823 | } | 3819 | } |
3824 | static int amdgpu_debugfs_vbios_version_init(struct amdgpu_device *adev) | ||
3825 | { | ||
3826 | return 0; | ||
3827 | } | ||
3828 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev) { } | 3820 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev) { } |
3829 | #endif | 3821 | #endif |