Skip to contentSkip to conversation

drm/amd/amdgpu: Add helper to get ip block valid

PATCH New Asad Kamal 1 participant 1 message Sep 11, 2024

Subsystems (2)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Add helper to get ip block valid

Add helper function to check if ip block is enabled

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index c6cdabd60a4f..e21122dac1db 100644
@@ -367,6 +367,8 @@ int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev,
 				   enum amd_ip_block_type block_type);
 bool amdgpu_device_ip_is_idle(struct amdgpu_device *adev,
 			      enum amd_ip_block_type block_type);
+bool amdgpu_device_ip_is_valid(struct amdgpu_device *adev,
+			      enum amd_ip_block_type block_type);
 
 #define AMDGPU_MAX_IP_NUM 16
 
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -0
index 61a189e30bcd..22585f970f43 100644
@@ -2193,6 +2193,28 @@ bool amdgpu_device_ip_is_idle(struct amdgpu_device *adev,
 
 }
 
+/**
+ * amdgpu_device_ip_is_valid - is the hardware IP enabled
+ *
+ * @adev: amdgpu_device pointer
+ * @block_type: Type of hardware IP (SMU, GFX, UVD, etc.)
+ *
+ * Check if the hardware IP is enable or not.
+ * Returns true if it the IP is enable, false if not.
+ */
+bool amdgpu_device_ip_is_valid(struct amdgpu_device *adev,
+			       enum amd_ip_block_type block_type)
+{
+	int i;
+
+	for (i = 0; i < adev->num_ip_blocks; i++) {
+		if (adev->ip_blocks[i].version->type == block_type)
+			return adev->ip_blocks[i].status.valid;
+	}
+	return false;
+
+}
+
 /**
  * amdgpu_device_ip_get_ip_block - get a hw IP pointer
  *
Signature · 1 line
2.46.0