Skip to contentSkip to conversation

drm/amdgpu: fix compiler 'side-effect' check issue for RAS_EVENT_LOG()

PATCH In review Yang Wang 2 participants 3 messages May 14, 2024 – May 15, 2024

Subsystems (2)
lore
Share & tools
lore

Yang Wang

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix compiler 'side-effect' check issue for RAS_EVENT_LOG()

create a new helper function to avoid compiler 'side-effect' check about RAS_EVENT_LOG() macro.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 13 ++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +18 -0
index 1dd13ed3b7b5..c04e6ced1af3 100644
@@ -4504,3 +4504,21 @@ int amdgpu_ras_reserve_page(struct amdgpu_device *adev, uint64_t pfn)
 
 	return ret;
 }
+
+void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
+				const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	if (amdgpu_ras_event_id_is_valid(adev, event_id))
+		dev_printk(KERN_INFO, adev->dev, "{%llu}%pV", event_id, &vaf);
+	else
+		dev_printk(KERN_INFO, adev->dev, "%pV", &vaf);
+
+	va_end(args);
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +6 -7
index c8980d5f6540..6a8c7b1609df 100644
@@ -67,13 +67,8 @@ struct amdgpu_iv_entry;
 /* The high three bits indicates socketid */
 #define AMDGPU_RAS_GET_FEATURES(val)  ((val) & ~AMDGPU_RAS_FEATURES_SOCKETID_MASK)
 
-#define RAS_EVENT_LOG(_adev, _id, _fmt, ...)				\
-do {									\
-	if (amdgpu_ras_event_id_is_valid((_adev), (_id)))			\
-	    dev_info((_adev)->dev, "{%llu}" _fmt, (_id), ##__VA_ARGS__);	\
-	else								\
-	    dev_info((_adev)->dev, _fmt, ##__VA_ARGS__);			\
-} while (0)
+#define RAS_EVENT_LOG(adev, id, fmt, ...)	\
+	amdgpu_ras_event_log_print((adev), (id), (fmt), ##__VA_ARGS__);
 
 enum amdgpu_ras_block {
 	AMDGPU_RAS_BLOCK__UMC = 0,
@@ -956,4 +951,8 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
 		enum amdgpu_ras_block block, uint16_t pasid,
 		pasid_notify pasid_fn, void *data, uint32_t reset);
 
+__printf(3, 4)
+void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
+				const char *fmt, ...);
+
 #endif
Signature · 1 line
2.34.1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Ping...

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yang Wang
Sent: Tuesday, May 14, 2024 8:03 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH] drm/amdgpu: fix compiler 'side-effect' check issue for RAS_EVENT_LOG()

create a new helper function to avoid compiler 'side-effect' check about RAS_EVENT_LOG() macro.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 18 ++++++++++++++++++  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 13 ++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +18 -0
index 1dd13ed3b7b5..c04e6ced1af3 100644
@@ -4504,3 +4504,21 @@ int amdgpu_ras_reserve_page(struct amdgpu_device *adev, uint64_t pfn)
 
        return ret;
 }
+
+void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
+                               const char *fmt, ...)
+{
+       struct va_format vaf;
+       va_list args;
+
+       va_start(args, fmt);
+       vaf.fmt = fmt;
+       vaf.va = &args;
+
+       if (amdgpu_ras_event_id_is_valid(adev, event_id))
+               dev_printk(KERN_INFO, adev->dev, "{%llu}%pV", event_id, &vaf);
+       else
+               dev_printk(KERN_INFO, adev->dev, "%pV", &vaf);
+
+       va_end(args);
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +6 -7
index c8980d5f6540..6a8c7b1609df 100644
@@ -67,13 +67,8 @@ struct amdgpu_iv_entry;
 /* The high three bits indicates socketid */  #define AMDGPU_RAS_GET_FEATURES(val)  ((val) & ~AMDGPU_RAS_FEATURES_SOCKETID_MASK)
 
-#define RAS_EVENT_LOG(_adev, _id, _fmt, ...)                           \
-do {                                                                   \
-       if (amdgpu_ras_event_id_is_valid((_adev), (_id)))                       \
-           dev_info((_adev)->dev, "{%llu}" _fmt, (_id), ##__VA_ARGS__);        \
-       else                                                            \
-           dev_info((_adev)->dev, _fmt, ##__VA_ARGS__);                        \
-} while (0)
+#define RAS_EVENT_LOG(adev, id, fmt, ...)      \
+       amdgpu_ras_event_log_print((adev), (id), (fmt), ##__VA_ARGS__);
 
 enum amdgpu_ras_block {
        AMDGPU_RAS_BLOCK__UMC = 0,
@@ -956,4 +951,8 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
                enum amdgpu_ras_block block, uint16_t pasid,
                pasid_notify pasid_fn, void *data, uint32_t reset);
 
+__printf(3, 4)
+void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
+                               const char *fmt, ...);
+
 #endif

--
2.34.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Yang Wang

[AMD Official Use Only - AMD Internal Distribution Only]

Regards,
Hawking
-----Original Message-----
From: Wang, Yang(Kevin) <[email protected]>
Sent: Tuesday, May 14, 2024 08:03
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH] drm/amdgpu: fix compiler 'side-effect' check issue for RAS_EVENT_LOG()

create a new helper function to avoid compiler 'side-effect' check about RAS_EVENT_LOG() macro.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 18 ++++++++++++++++++  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 13 ++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +18 -0
index 1dd13ed3b7b5..c04e6ced1af3 100644
@@ -4504,3 +4504,21 @@ int amdgpu_ras_reserve_page(struct amdgpu_device *adev, uint64_t pfn)
 
        return ret;
 }
+
+void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
+                               const char *fmt, ...)
+{
+       struct va_format vaf;
+       va_list args;
+
+       va_start(args, fmt);
+       vaf.fmt = fmt;
+       vaf.va = &args;
+
+       if (amdgpu_ras_event_id_is_valid(adev, event_id))
+               dev_printk(KERN_INFO, adev->dev, "{%llu}%pV", event_id, &vaf);
+       else
+               dev_printk(KERN_INFO, adev->dev, "%pV", &vaf);
+
+       va_end(args);
+}
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +6 -7
index c8980d5f6540..6a8c7b1609df 100644
@@ -67,13 +67,8 @@ struct amdgpu_iv_entry;
 /* The high three bits indicates socketid */  #define AMDGPU_RAS_GET_FEATURES(val)  ((val) & ~AMDGPU_RAS_FEATURES_SOCKETID_MASK)
 
-#define RAS_EVENT_LOG(_adev, _id, _fmt, ...)                           \
-do {                                                                   \
-       if (amdgpu_ras_event_id_is_valid((_adev), (_id)))                       \
-           dev_info((_adev)->dev, "{%llu}" _fmt, (_id), ##__VA_ARGS__);        \
-       else                                                            \
-           dev_info((_adev)->dev, _fmt, ##__VA_ARGS__);                        \
-} while (0)
+#define RAS_EVENT_LOG(adev, id, fmt, ...)      \
+       amdgpu_ras_event_log_print((adev), (id), (fmt), ##__VA_ARGS__);
 
 enum amdgpu_ras_block {
        AMDGPU_RAS_BLOCK__UMC = 0,
@@ -956,4 +951,8 @@ int amdgpu_ras_put_poison_req(struct amdgpu_device *adev,
                enum amdgpu_ras_block block, uint16_t pasid,
                pasid_notify pasid_fn, void *data, uint32_t reset);
 
+__printf(3, 4)
+void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
+                               const char *fmt, ...);
+
 #endif

--
2.34.1