aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2016-12-06 21:05:09 -0500
committerAlex Deucher <alexander.deucher@amd.com>2016-12-08 14:12:09 -0500
commit40ee5888faecf4ea5423dbe94c862d03c3e7e12c (patch)
tree2d1754f6b54ae89ee82b2a34a4ce73b523fdfa47
parenta9f5db9ca7a92aa00af82b3d10416e34b31a9493 (diff)
drm/amd/amdgpu: export vbios information (v2)
Allows userspace components to fetch information from the vbios image. v2: agd: fix warning Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christian Koenig <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c26
-rw-r--r--include/uapi/drm/amdgpu_drm.h11
2 files changed, 37 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index d1cf9ac0dff1..9af87eaf8ee3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -544,6 +544,32 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
544 return copy_to_user(out, &vce_clk_table, 544 return copy_to_user(out, &vce_clk_table,
545 min((size_t)size, sizeof(vce_clk_table))) ? -EFAULT : 0; 545 min((size_t)size, sizeof(vce_clk_table))) ? -EFAULT : 0;
546 } 546 }
547 case AMDGPU_INFO_VBIOS: {
548 uint32_t bios_size = adev->bios_size;
549
550 switch (info->vbios_info.type) {
551 case AMDGPU_INFO_VBIOS_SIZE:
552 return copy_to_user(out, &bios_size,
553 min((size_t)size, sizeof(bios_size)))
554 ? -EFAULT : 0;
555 case AMDGPU_INFO_VBIOS_IMAGE: {
556 uint8_t *bios;
557 uint32_t bios_offset = info->vbios_info.offset;
558
559 if (bios_offset >= bios_size)
560 return -EINVAL;
561
562 bios = adev->bios + bios_offset;
563 return copy_to_user(out, bios,
564 min((size_t)size, (size_t)(bios_size - bios_offset)))
565 ? -EFAULT : 0;
566 }
567 default:
568 DRM_DEBUG_KMS("Invalid request %d\n",
569 info->vbios_info.type);
570 return -EINVAL;
571 }
572 }
547 default: 573 default:
548 DRM_DEBUG_KMS("Invalid request %d\n", info->query); 574 DRM_DEBUG_KMS("Invalid request %d\n", info->query);
549 return -EINVAL; 575 return -EINVAL;
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 2191a9e4f3db..396183628f3c 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -522,6 +522,12 @@ struct drm_amdgpu_cs_chunk_data {
522#define AMDGPU_INFO_MEMORY 0x19 522#define AMDGPU_INFO_MEMORY 0x19
523/* Query vce clock table */ 523/* Query vce clock table */
524#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A 524#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
525/* Query vbios related information */
526#define AMDGPU_INFO_VBIOS 0x1B
527 /* Subquery id: Query vbios size */
528 #define AMDGPU_INFO_VBIOS_SIZE 0x1
529 /* Subquery id: Query vbios image */
530 #define AMDGPU_INFO_VBIOS_IMAGE 0x2
525 531
526#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0 532#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
527#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff 533#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -580,6 +586,11 @@ struct drm_amdgpu_info {
580 } read_mmr_reg; 586 } read_mmr_reg;
581 587
582 struct drm_amdgpu_query_fw query_fw; 588 struct drm_amdgpu_query_fw query_fw;
589
590 struct {
591 __u32 type;
592 __u32 offset;
593 } vbios_info;
583 }; 594 };
584}; 595};
585 596