drm/radeon: add support for read reg query from radeon info ioctl
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Oct 2014 15:26:50 +0000 (11:26 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 Mar 2015 16:26:42 +0000 (12:26 -0400)
This allows us to query certain registers from userspace
for profiling and harvest configuration.  E.g., it can
be used by the GALLIUM_HUD for profiling the status of
various gfx blocks.

Tested-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_kms.c
include/uapi/drm/radeon_drm.h

index cf7e54e9b0d164eb4d44bb3fc87788228c9c6b85..7b2a7335cc5d557eafa6864d50cb6ebc9cdfb5ff 100644 (file)
@@ -568,6 +568,14 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                else
                        *value = rdev->pm.current_mclk / 100;
                break;
+       case RADEON_INFO_READ_REG:
+               if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
+                       DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
+                       return -EFAULT;
+               }
+               if (radeon_get_allowed_info_register(rdev, *value, value))
+                       return -EINVAL;
+               break;
        default:
                DRM_DEBUG_KMS("Invalid request %d\n", info->request);
                return -EINVAL;
index de7ee21efea22f6d148652b7f79d2febed5d0f63..871e73f99a4d7aa13b4cd6f5bc8969421c2a9301 100644 (file)
@@ -1037,6 +1037,7 @@ struct drm_radeon_cs {
 #define RADEON_INFO_CURRENT_GPU_TEMP   0x21
 #define RADEON_INFO_CURRENT_GPU_SCLK   0x22
 #define RADEON_INFO_CURRENT_GPU_MCLK   0x23
+#define RADEON_INFO_READ_REG           0x24
 
 struct drm_radeon_info {
        uint32_t                request;