Skip to contentSkip to conversation

drm/radeon: add a GPU reset counter queryable by userspace

PATCH Applied Marek Olšák 3 participants 4 messages Apr 29, 2015 – May 11, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: add a GPU reset counter queryable by userspace

From: Marek Olšák <[email protected]>

Userspace will be able to tell whether a GPU reset occured by comparing an old referece value of the counter with a new value.

---
 drivers/gpu/drm/radeon/radeon.h        | 1 +
 drivers/gpu/drm/radeon/radeon_device.c | 2 ++
 drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
 drivers/gpu/drm/radeon/radeon_kms.c    | 3 +++
 include/uapi/drm/radeon_drm.h          | 1 +
 5 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
index d2abe48..c2b345a 100644
@@ -2436,6 +2436,7 @@ struct radeon_device {
 	atomic64_t			vram_usage;
 	atomic64_t			gtt_usage;
 	atomic64_t			num_bytes_moved;
+	atomic_t			gpu_reset_counter;
 	/* ACPI interface */
 	struct radeon_atif		atif;
 	struct radeon_atcs		atcs;
drivers/gpu/drm/radeon/radeon_device.c +2 -0
index b7ca4c5..13e207e 100644
@@ -1725,6 +1725,8 @@ int radeon_gpu_reset(struct radeon_device *rdev)
 		return 0;
 	}
 
+	atomic_inc(&rdev->gpu_reset_counter);
+
 	radeon_save_bios_scratch_regs(rdev);
 	/* block TTM */
 	resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
drivers/gpu/drm/radeon/radeon_drv.c +2 -1
index 7d620d4..5751446 100644
@@ -90,9 +90,10 @@
  *            CS to GPU on >= r600
  *   2.41.0 - evergreen/cayman: Add SET_BASE/DRAW_INDIRECT command parsing support
  *   2.42.0 - Add VCE/VUI (Video Usability Information) support
+ *   2.43.0 - RADEON_INFO_GPU_RESET_COUNTER
  */
 #define KMS_DRIVER_MAJOR	2
-#define KMS_DRIVER_MINOR	42
+#define KMS_DRIVER_MINOR	43
 #define KMS_DRIVER_PATCHLEVEL	0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
index 7b2a733..9632e88 100644
@@ -576,6 +576,9 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 		if (radeon_get_allowed_info_register(rdev, *value, value))
 			return -EINVAL;
 		break;
+	case RADEON_INFO_GPU_RESET_COUNTER:
+		*value = atomic_read(&rdev->gpu_reset_counter);
+		break;
 	default:
 		DRM_DEBUG_KMS("Invalid request %d\n", info->request);
 		return -EINVAL;
include/uapi/drm/radeon_drm.h +1 -0
index 871e73f..573cb86 100644
@@ -1038,6 +1038,7 @@ struct drm_radeon_cs {
 #define RADEON_INFO_CURRENT_GPU_SCLK	0x22
 #define RADEON_INFO_CURRENT_GPU_MCLK	0x23
 #define RADEON_INFO_READ_REG		0x24
+#define RADEON_INFO_GPU_RESET_COUNTER	0x25
 
 struct drm_radeon_info {
 	uint32_t		request;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Ping

Quoted 82 lines · Marek Olšák

From: Marek Olšák <[email protected]>

Userspace will be able to tell whether a GPU reset occured by comparing an old referece value of the counter with a new value.

---
 drivers/gpu/drm/radeon/radeon.h        | 1 +
 drivers/gpu/drm/radeon/radeon_device.c | 2 ++
 drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
 drivers/gpu/drm/radeon/radeon_kms.c    | 3 +++
 include/uapi/drm/radeon_drm.h          | 1 +
 5 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
index d2abe48..c2b345a 100644
@@ -2436,6 +2436,7 @@ struct radeon_device {
        atomic64_t                      vram_usage;
        atomic64_t                      gtt_usage;
        atomic64_t                      num_bytes_moved;
+       atomic_t                        gpu_reset_counter;
        /* ACPI interface */
        struct radeon_atif              atif;
        struct radeon_atcs              atcs;
drivers/gpu/drm/radeon/radeon_device.c +2 -0
index b7ca4c5..13e207e 100644
@@ -1725,6 +1725,8 @@ int radeon_gpu_reset(struct radeon_device *rdev)
                return 0;
        }
 
+       atomic_inc(&rdev->gpu_reset_counter);
+
        radeon_save_bios_scratch_regs(rdev);
        /* block TTM */
        resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
drivers/gpu/drm/radeon/radeon_drv.c +2 -1
index 7d620d4..5751446 100644
@@ -90,9 +90,10 @@
  *            CS to GPU on >= r600
  *   2.41.0 - evergreen/cayman: Add SET_BASE/DRAW_INDIRECT command parsing support
  *   2.42.0 - Add VCE/VUI (Video Usability Information) support
+ *   2.43.0 - RADEON_INFO_GPU_RESET_COUNTER
  */
 #define KMS_DRIVER_MAJOR       2
-#define KMS_DRIVER_MINOR       42
+#define KMS_DRIVER_MINOR       43
 #define KMS_DRIVER_PATCHLEVEL  0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
index 7b2a733..9632e88 100644
@@ -576,6 +576,9 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                if (radeon_get_allowed_info_register(rdev, *value, value))
                        return -EINVAL;
                break;
+       case RADEON_INFO_GPU_RESET_COUNTER:
+               *value = atomic_read(&rdev->gpu_reset_counter);
+               break;
        default:
                DRM_DEBUG_KMS("Invalid request %d\n", info->request);
                return -EINVAL;
include/uapi/drm/radeon_drm.h +1 -1
index 871e73f..573cb86 100644
@@ -1038,6 +1038,7 @@ struct drm_radeon_cs {
 #define RADEON_INFO_CURRENT_GPU_SCLK   0x22
 #define RADEON_INFO_CURRENT_GPU_MCLK   0x23
 #define RADEON_INFO_READ_REG           0x24
+#define RADEON_INFO_GPU_RESET_COUNTER  0x25
 
 struct drm_radeon_info {
        uint32_t                request;
--
Quoted 2 lines

2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by
#2 lore raw
Quoted 9 lines · Marek Olšák

Ping

Quoted 6 lines · Marek Olšák

From: Marek Olšák <[email protected]>

Userspace will be able to tell whether a GPU reset occured by comparing an old referece value of the counter with a new value.

Quoted 73 lines
Quoted 73 lines
---
  drivers/gpu/drm/radeon/radeon.h        | 1 +
  drivers/gpu/drm/radeon/radeon_device.c | 2 ++
  drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
  drivers/gpu/drm/radeon/radeon_kms.c    | 3 +++
  include/uapi/drm/radeon_drm.h          | 1 +
  5 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
index d2abe48..c2b345a 100644
@@ -2436,6 +2436,7 @@ struct radeon_device {
         atomic64_t                      vram_usage;
         atomic64_t                      gtt_usage;
         atomic64_t                      num_bytes_moved;
+       atomic_t                        gpu_reset_counter;
         /* ACPI interface */
         struct radeon_atif              atif;
         struct radeon_atcs              atcs;
drivers/gpu/drm/radeon/radeon_device.c +2 -0
index b7ca4c5..13e207e 100644
@@ -1725,6 +1725,8 @@ int radeon_gpu_reset(struct radeon_device *rdev)
                 return 0;
         }
 
+       atomic_inc(&rdev->gpu_reset_counter);
+
         radeon_save_bios_scratch_regs(rdev);
         /* block TTM */
         resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
drivers/gpu/drm/radeon/radeon_drv.c +2 -1
index 7d620d4..5751446 100644
@@ -90,9 +90,10 @@
   *            CS to GPU on >= r600
   *   2.41.0 - evergreen/cayman: Add SET_BASE/DRAW_INDIRECT command parsing support
   *   2.42.0 - Add VCE/VUI (Video Usability Information) support
+ *   2.43.0 - RADEON_INFO_GPU_RESET_COUNTER
   */
  #define KMS_DRIVER_MAJOR       2
-#define KMS_DRIVER_MINOR       42
+#define KMS_DRIVER_MINOR       43
  #define KMS_DRIVER_PATCHLEVEL  0
  int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
  int radeon_driver_unload_kms(struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
index 7b2a733..9632e88 100644
@@ -576,6 +576,9 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                 if (radeon_get_allowed_info_register(rdev, *value, value))
                         return -EINVAL;
                 break;
+       case RADEON_INFO_GPU_RESET_COUNTER:
+               *value = atomic_read(&rdev->gpu_reset_counter);
+               break;
         default:
                 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
                 return -EINVAL;
include/uapi/drm/radeon_drm.h +1 -0
index 871e73f..573cb86 100644
@@ -1038,6 +1038,7 @@ struct drm_radeon_cs {
  #define RADEON_INFO_CURRENT_GPU_SCLK   0x22
  #define RADEON_INFO_CURRENT_GPU_MCLK   0x23
  #define RADEON_INFO_READ_REG           0x24
+#define RADEON_INFO_GPU_RESET_COUNTER  0x25
 
Quoted 9 lines
Quoted 5 lines
include/uapi/drm/radeon_drm.h +0 -1
  struct drm_radeon_info {
         uint32_t                request;
--

2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Applied
#3 lore raw
Quoted 8 lines · Christian König
Quoted 7 lines · Marek Olšák

Ping

Quoted 3 lines · Marek Olšák

From: Marek Olšák <[email protected]>

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

Userspace will be able to tell whether a GPU reset occured by comparing an old referece value of the counter with a new value.

Applied to my drm-next tree. Thanks!

Alex

Quoted 94 lines
Quoted 83 lines
Quoted 83 lines
---
  drivers/gpu/drm/radeon/radeon.h        | 1 +
  drivers/gpu/drm/radeon/radeon_device.c | 2 ++
  drivers/gpu/drm/radeon/radeon_drv.c    | 3 ++-
  drivers/gpu/drm/radeon/radeon_kms.c    | 3 +++
  include/uapi/drm/radeon_drm.h          | 1 +
  5 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
index d2abe48..c2b345a 100644
@@ -2436,6 +2436,7 @@ struct radeon_device {
         atomic64_t                      vram_usage;
         atomic64_t                      gtt_usage;
         atomic64_t                      num_bytes_moved;
+       atomic_t                        gpu_reset_counter;
         /* ACPI interface */
         struct radeon_atif              atif;
         struct radeon_atcs              atcs;
drivers/gpu/drm/radeon/radeon_device.c +2 -0
index b7ca4c5..13e207e 100644
@@ -1725,6 +1725,8 @@ int radeon_gpu_reset(struct radeon_device *rdev)
                 return 0;
         }
 
+       atomic_inc(&rdev->gpu_reset_counter);
+
         radeon_save_bios_scratch_regs(rdev);
         /* block TTM */
         resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
drivers/gpu/drm/radeon/radeon_drv.c +0 -0
index 7d620d4..5751446 100644
@@ -90,9 +90,10 @@
   *            CS to GPU on >= r600
   *   2.41.0 - evergreen/cayman: Add SET_BASE/DRAW_INDIRECT command

parsing support
* 2.42.0 - Add VCE/VUI (Video Usability Information) support
+ * 2.43.0 - RADEON_INFO_GPU_RESET_COUNTER
*/
#define KMS_DRIVER_MAJOR 2

drivers/gpu/drm/radeon/radeon_drv.c +1 -1
-#define KMS_DRIVER_MINOR       42
+#define KMS_DRIVER_MINOR       43
  #define KMS_DRIVER_PATCHLEVEL  0
  int radeon_driver_load_kms(struct drm_device *dev, unsigned long

flags);
int radeon_driver_unload_kms(struct drm_device *dev);

drivers/gpu/drm/radeon/radeon_kms.c +0 -0
index 7b2a733..9632e88 100644
@@ -576,6 +576,9 @@ static int radeon_info_ioctl(struct drm_device *dev,

void *data, struct drm_file
if (radeon_get_allowed_info_register(rdev, *value,
value))

                         return -EINVAL;
                 break;
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
+       case RADEON_INFO_GPU_RESET_COUNTER:
+               *value = atomic_read(&rdev->gpu_reset_counter);
+               break;
         default:
                 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
                 return -EINVAL;
include/uapi/drm/radeon_drm.h +1 -0
index 871e73f..573cb86 100644
@@ -1038,6 +1038,7 @@ struct drm_radeon_cs {
  #define RADEON_INFO_CURRENT_GPU_SCLK   0x22
  #define RADEON_INFO_CURRENT_GPU_MCLK   0x23
  #define RADEON_INFO_READ_REG           0x24
+#define RADEON_INFO_GPU_RESET_COUNTER  0x25
 
Quoted 9 lines
Quoted 5 lines
include/uapi/drm/radeon_drm.h +0 -1
  struct drm_radeon_info {
         uint32_t                request;
--

2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel