In order to keep the current ability for the aim of debugging and avoid
printing the warning message twice, add ASSERT_BUG() macro definition to
harden the callers of division functions.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
drivers/gpu/drm/amd/display/dc/os_types.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h
index f2ba76c1e0c0..932bbe05ee0a 100644
--- a/drivers/gpu/drm/amd/display/dc/os_types.h
+++ b/drivers/gpu/drm/amd/display/dc/os_types.h
@@ -79,6 +79,11 @@
dc_breakpoint(); \
} while (0)
+#define ASSERT_BUG(expr) do { \
+ dc_breakpoint(); \
+ BUG_ON(!(expr)); \
+ } while (0)
+
#define BREAK_TO_DEBUGGER() \
do { \
DRM_DEBUG_DRIVER("%s():%d\n", __func__, __LINE__); \
--
2.42.0
Hi, Tiezhu,
On Tue, Jan 14, 2025 at 2:16 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> In order to keep the current ability for the aim of debugging and avoid
> printing the warning message twice, add ASSERT_BUG() macro definition to
> harden the callers of division functions.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> drivers/gpu/drm/amd/display/dc/os_types.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h
> index f2ba76c1e0c0..932bbe05ee0a 100644
> --- a/drivers/gpu/drm/amd/display/dc/os_types.h
> +++ b/drivers/gpu/drm/amd/display/dc/os_types.h
> @@ -79,6 +79,11 @@
> dc_breakpoint(); \
> } while (0)
>
> +#define ASSERT_BUG(expr) do { \
> + dc_breakpoint(); \
> + BUG_ON(!(expr)); \
> + } while (0)
I don't think this is correct, if KGDB is enabled, then whether expr
is true or false, ASSERT_BUG() will break to KGDB.
Huacai
> +
> #define BREAK_TO_DEBUGGER() \
> do { \
> DRM_DEBUG_DRIVER("%s():%d\n", __func__, __LINE__); \
> --
> 2.42.0
>
>
On 01/14/2025 04:29 PM, Huacai Chen wrote:
> Hi, Tiezhu,
>
> On Tue, Jan 14, 2025 at 2:16 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>> In order to keep the current ability for the aim of debugging and avoid
>> printing the warning message twice, add ASSERT_BUG() macro definition to
>> harden the callers of division functions.
>>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>> drivers/gpu/drm/amd/display/dc/os_types.h | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h
>> index f2ba76c1e0c0..932bbe05ee0a 100644
>> --- a/drivers/gpu/drm/amd/display/dc/os_types.h
>> +++ b/drivers/gpu/drm/amd/display/dc/os_types.h
>> @@ -79,6 +79,11 @@
>> dc_breakpoint(); \
>> } while (0)
>>
>> +#define ASSERT_BUG(expr) do { \
>> + dc_breakpoint(); \
>> + BUG_ON(!(expr)); \
>> + } while (0)
> I don't think this is correct, if KGDB is enabled, then whether expr
> is true or false, ASSERT_BUG() will break to KGDB.
It should check expr first, something like this:
#define ASSERT_BUG(expr) do { \
if (!(expr)) { \
dc_breakpoint(); \
BUG(); \
} \
} while (0)
I will send v4 later.
Thanks,
Tiezhu
© 2016 - 2025 Red Hat, Inc.