[PATCH 4/6] drm/amdgpu: add macro of umc for each channel

Deucher, Alexander Alexander.Deucher at amd.com
Thu Aug 1 15:29:55 UTC 2019


Please include a patch description.  Explain why you need the new helper function.

Alex
________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Tao Zhou <tao.zhou1 at amd.com>
Sent: Thursday, August 1, 2019 2:43 AM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>; Zhang, Hawking <Hawking.Zhang at amd.com>; Li, Dennis <Dennis.Li at amd.com>; Chen, Guchun <Guchun.Chen at amd.com>; Pan, Xinhui <Xinhui.Pan at amd.com>
Cc: Zhou1, Tao <Tao.Zhou1 at amd.com>
Subject: [PATCH 4/6] drm/amdgpu: add macro of umc for each channel

common function for all umc versions

Signed-off-by: Tao Zhou <tao.zhou1 at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h
index 2604f5076867..9efdd66279e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h
@@ -21,6 +21,29 @@
 #ifndef __AMDGPU_UMC_H__
 #define __AMDGPU_UMC_H__

+/*
+ * void (*func)(struct amdgpu_device *adev, struct ras_err_data *err_data,
+ *                             uint32_t umc_reg_offset, uint32_t channel_index)
+ */
+#define amdgpu_umc_for_each_channel(func)      \
+       struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;        \
+       uint32_t umc_inst, channel_inst, umc_reg_offset, channel_index; \
+       for (umc_inst = 0; umc_inst < adev->umc.umc_inst_num; umc_inst++) {     \
+               /* enable the index mode to query eror count per channel */     \
+               adev->umc.funcs->enable_umc_index_mode(adev, umc_inst); \
+               for (channel_inst = 0;  \
+                       channel_inst < adev->umc.channel_inst_num;      \
+                       channel_inst++) {       \
+                       /* calc the register offset according to channel instance */    \
+                       umc_reg_offset = adev->umc.channel_offs * channel_inst; \
+                       /* get channel index of interleaved memory */   \
+                       channel_index = adev->umc.channel_idx_tbl[      \
+                               umc_inst * adev->umc.channel_inst_num + channel_inst];  \
+                       (func)(adev, err_data, umc_reg_offset, channel_index);  \
+               }       \
+       }       \
+       adev->umc.funcs->disable_umc_index_mode(adev);
+
 struct amdgpu_umc_funcs {
         void (*ras_init)(struct amdgpu_device *adev);
         void (*query_ras_error_count)(struct amdgpu_device *adev,
--
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20190801/73566cd8/attachment.html>


More information about the amd-gfx mailing list