drm/komeda: Adds error event print functionality
Subsystems (4)
PATCH 1/1 drm/komeda: Adds error event print functionality
Adds to print the event message when error happens and the same event will not be printed until next vsync.
--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.c
drivers/gpu/drm/arm/display/komeda/Makefile +1 -0
@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \
drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13 -0
@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,
@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +144 -0
144 lines not on this page · raw message
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +2 -0
@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts); +/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 221 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +144
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ; + } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +} + +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} + +void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ; + +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ]; +struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +2
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts); +/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1
Looks good to me.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerQuoted 101 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +40
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ;
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+ } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}
Why do we need this wrapper?
Quoted 58 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +58
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} +
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;
When does en_print ever get false?
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +8
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];
I've counted about 27 evt_sprintf() calls in evt_str() function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0
drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);
Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the evts->global and evts->pipes[] as integers and decode that in userspace or as a debugfs entry.
Best regards,
Liviu
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 1 line · Liviu Dudau
On Thu, Jun 27, 2019 at 04:10:36AM +0100, Lowry Li (Arm Technology China) wrote:
/snip
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts);
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 1 line
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.
Alternatively, consider using kernel trace events. They allow you to selectively turn on/off certain events and also allow you to customize which data is recorded and how it's formatted. Seems like a good fit from the quick scan I've done.
Sean
Quoted 21 lines
Best regards,
LiviuQuoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Hi Sean,
Quoted 21 lines · Sean Paul
Quoted 1 line · Liviu Dudau
On Thu, Jun 27, 2019 at 04:10:36AM +0100, Lowry Li (Arm Technology China) wrote:
/snip
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts);Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 1 line
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.
Quoted 7 lines
Alternatively, consider using kernel trace events. They allow you to selectively turn on/off certain events and also allow you to customize which data is recorded and how it's formatted. Seems like a good fit from the quick scan I've done.
Sean
Yes, finially we want to get both way, using kernel trace events and meanwhile printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware.Like intel did, in intel_cpu_fifo_underrun_irq_handler().
Thanks a lot.
Best Regards,
Lowry
Quoted 24 lines
Quoted 21 lines
Best regards,
LiviuQuoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 6 lines
Regards, Lowry _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Liviu,
Quoted 106 lines · Liviu Dudau
Quoted 105 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +44
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ; + } + +return err; +}
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 6 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +6
-0+ +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
The komeda_sprintf is a generic function and will be used by other places, while evt_sprintf is working for the detail event msg.
Quoted 62 lines
Quoted 62 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +62
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} + +void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true;
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 6 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +6
-0+ +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?
Once the events printed, it will be set false (pls find at the last line of this function).
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +4
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif
Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +4
-0+ +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf() will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.
Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.
Quoted 2 lines
Best regards,
Liviu
The name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
Best regards,
Lowry
Quoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Signature · 6 lines
Regards, Lowry _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]@arm.com
Liviu Dudau
maintainerQuoted 117 lines · Lowry Li (Arm Technology China)
Hi Liviu,
Quoted 106 lines · Liviu Dudau
Quoted 105 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +44
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ; + } + +return err; +}Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 6 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +6
-0+ +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
Quoted 2 lines
The
komeda_sprintfis a generic function and will be used by other places, whileevt_sprintfis working for the detail event msg.
Yeah, I'm not buying this argument any more. We should not create new functions just because we want to save typing one if () condition. evt_sprintf does nothing with the extra evt argument other than checking that it is not zero.
Quoted 71 lines
Quoted 63 lines
Quoted 63 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +62
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} + +void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true;Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 6 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +6
-0+ +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?
Quoted 2 lines
Once the events printed, it will be set false (pls find at the last line of this function).
What is the point of making en_print a static variable? We print all the time when we have a global event anyway.
Quoted 50 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +4
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif Quoted 8 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +4
-0+ +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf()will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.
Quoted 8 lines
Quoted 2 lines
Best regards,
LiviuThe name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
We should probably just collect the global and pipes values and expose them to userspace so that the printing and decoding of the messages happens there.
Best regards,
Liviu
Quoted 25 lines
Best regards,
LowryQuoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, Lowry
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 118 lines · Liviu Dudau
Quoted 117 lines · Lowry Li (Arm Technology China)
Hi Liviu,
Quoted 114 lines · Liviu Dudau
Quoted 101 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +40
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ;drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+ } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
Quoted 6 lines
Quoted 2 lines
The
komeda_sprintfis a generic function and will be used by other places, whileevt_sprintfis working for the detail event msg.Yeah, I'm not buying this argument any more. We should not create new functions just because we want to save typing one if () condition.
evt_sprintfdoes nothing with the extra evt argument other than checking that it is not zero.
Hi Liviu
But I think we'd better to have this function which can remove many duplicate if () checks, and makes the code elegant and easy to read. and I think that why the concept of function has been introduced.
And in linux we can see lot of functions or MACRO that just for save one word like:
static inline void *kzalloc(size_t size, gfp_t flags)
{
return kmalloc(size, flags | __GFP_ZERO);}
And for this "if () check" specific, I think this is also very popular in linux like:
static inline void __rcu_read_lock(void)
{
if (IS_ENABLED(CONFIG_PREEMPT_COUNT))
preempt_disable();
}
static inline void __rcu_read_unlock(void)
{
if (IS_ENABLED(CONFIG_PREEMPT_COUNT))
preempt_enable();}
thanks
James
Quoted 71 lines
Quoted 71 lines
Quoted 71 lines
Quoted 59 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +58
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} +drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?
Quoted 5 lines
Quoted 2 lines
Once the events printed, it will be set false (pls find at the last line of this function).
What is the point of making
en_printa static variable? We print all the time when we have a global event anyway.
Hi Liviu:
| why make en_print a static.
Consider you commit a scene which may leads a UNDERUN. and it will trigger HW UNDERRUN in every vsync peroid untill this sceen have been replace by another scene. for a scene it will trigger same error again and again. we don't need print them all for a scene one msg is enough.
| we print all the time when we have a global event.
Since we only reduce the duplicate error, but want print all different error. And per our HW design, the event reported by different component. this global for collect the GCU error. the pipeline_event is for LPU/CU/DOU. like UNDERUN which is only DOU error.
and current GCU only have one error type: opmode change error which only can be happened on when we call change_opmode in crtc_enable/disable.
So don't worry, globl event which can not make en_print has been set to true in every irq handling.
Thanks
James
Quoted 60 lines
Quoted 51 lines
Quoted 13 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 9 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +8
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf()will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.Quoted 8 lines
Quoted 2 lines
Best regards,
LiviuThe name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
Quoted 6 lines
We should probably just collect the global and pipes values and expose them to userspace so that the printing and decoding of the messages happens there.
Best regards,
Liviu
Hi Liviu:
Any special resons.
Since such error print is not only wanted by us, mostly it is required and used by our customer to easily capture the problem.
If no special reasons, I want to keep it for avoiding the complaint from our customer.
Thanks
James
Quoted 23 lines
Quoted 23 lines
Best regards,
LowryQuoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Quoted 13 lines
Quoted 3 lines
Signature · 2 lines
Regards, LowrySignature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Liviu Dudau
maintainerQuoted 133 lines · james qian wang (Arm Technology China)
Quoted 118 lines · Liviu Dudau
Quoted 117 lines · Lowry Li (Arm Technology China)
Hi Liviu,
Quoted 114 lines · Liviu Dudau
Quoted 101 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +40
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ;drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+ } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
Quoted 6 lines
Quoted 2 lines
The
komeda_sprintfis a generic function and will be used by other places, whileevt_sprintfis working for the detail event msg.Yeah, I'm not buying this argument any more. We should not create new functions just because we want to save typing one if () condition.
evt_sprintfdoes nothing with the extra evt argument other than checking that it is not zero.Hi Liviu
But I think we'd better to have this function which can remove many duplicate if () checks, and makes the code elegant and easy to read. and I think that why the concept of function has been introduced.
Quoted 7 lines
And in linux we can see lot of functions or MACRO that just for save one word like:
static inline void *kzalloc(size_t size,
gfp_tflags){ return kmalloc(size, flags | __GFP_ZERO);}
This is a different (and valid use) of creating macros. kzalloc() does something specific (initialises allocated memory with zeros) by using the generic kmalloc() function. The added __GFP_ZERO has a specific outcome to the invocation of the wrapped function. evt_sprintf() does nothing of this sort and it is arguably wrong, as it drops any possibility of passing arguments to the format string that komeda_sprintf() allows.
Quoted 7 lines
And for this "if () check" specific, I think this is also very popular in linux like:
static inline void
__rcu_read_lock(void)
{
if (IS_ENABLED(CONFIG_PREEMPT_COUNT))
Quoted 8 lines
preempt_disable();}
static inline void
__rcu_read_unlock(void){ if (IS_ENABLED(CONFIG_PREEMPT_COUNT)) preempt_enable();}
These are inline functions wrapping around the fact that a config option might be disabled. Not really the same thing with what we are talking here.
Quoted 81 lines
thanks
JamesQuoted 71 lines
Quoted 71 lines
Quoted 71 lines
Quoted 59 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +58
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} +drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?Quoted 5 lines
Quoted 2 lines
Once the events printed, it will be set false (pls find at the last line of this function).
What is the point of making
en_printa static variable? We print all the time when we have a global event anyway.
Quoted 8 lines
Hi Liviu:
| why make
en_printa static.Consider you commit a scene which may leads a UNDERUN. and it will trigger HW UNDERRUN in every vsync peroid untill this sceen have been replace by another scene. for a scene it will trigger same error again and again. we don't need print them all for a scene one msg is enough.
The same can be achieved by removing en_print entirely and inverting the top condition:
if (!evts->global && !is_new_frame(evts)) return;
Quoted 7 lines
| we print all the time when we have a global event.
Since we only reduce the duplicate error, but want print all different error. And per our HW design, the event reported by different component. this global for collect the GCU error. thepipeline_eventis for LPU/CU/DOU. like UNDERUN which is only DOU error.
Quoted 5 lines
and current GCU only have one error type: opmode change error which only can be happened on when we call
change_opmodein crtc_enable/disable.So don't worry, globl event which can not make
en_printhas been set to true in every irq handling.
And that's the reason I'm asking why make en_print static if we reset it in every irq_handling (i.e. when we actually want to print). Does it really need to be static when we don't actually use the stored state?
Best regards,
Liviu
Quoted 118 lines
Thanks
JamesQuoted 60 lines
Quoted 51 lines
Quoted 13 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 9 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +8
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf()will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.Quoted 8 lines
Quoted 2 lines
Best regards,
LiviuThe name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
Quoted 6 lines
We should probably just collect the global and pipes values and expose them to userspace so that the printing and decoding of the messages happens there.
Best regards,
LiviuHi Liviu:
Any special resons.
Since such error print is not only wanted by us, mostly it is required and used by our customer to easily capture the problem.
If no special reasons, I want to keep it for avoiding the complaint from our customer.Thanks
JamesQuoted 36 lines
Quoted 26 lines
Best regards,
LowryQuoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, LowrySignature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 142 lines · Liviu Dudau
Quoted 133 lines · james qian wang (Arm Technology China)
Quoted 118 lines · Liviu Dudau
Quoted 117 lines · Lowry Li (Arm Technology China)
Hi Liviu,
Quoted 114 lines · Liviu Dudau
Quoted 101 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +40
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ;drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+ } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
Quoted 6 lines
Quoted 2 lines
The
komeda_sprintfis a generic function and will be used by other places, whileevt_sprintfis working for the detail event msg.Yeah, I'm not buying this argument any more. We should not create new functions just because we want to save typing one if () condition.
evt_sprintfdoes nothing with the extra evt argument other than checking that it is not zero.Hi Liviu
But I think we'd better to have this function which can remove many duplicate if () checks, and makes the code elegant and easy to read. and I think that why the concept of function has been introduced.
Quoted 7 lines
And in linux we can see lot of functions or MACRO that just for save one word like:
static inline void *kzalloc(size_t size,
gfp_tflags){ return kmalloc(size, flags | __GFP_ZERO);}
Quoted 6 lines
This is a different (and valid use) of creating macros.
kzalloc()does something specific (initialises allocated memory with zeros) by using the generickmalloc()function. The added__GFP_ZEROhas a specific outcome to the invocation of the wrapped function.evt_sprintf()does nothing of this sort and it is arguably wrong, as it drops any possibility of passing arguments to the format string thatkomeda_sprintf()allows.
komeda_sprintf(struct komeda_str *str, const char *fmt, ...), will be treated as a generic function, which may be called from other places, with the possiblity support of passing arguments to the format string of it.
evt_sprintf(struct komeda_str *str, u64 evt, const char *msg), is a wrapper aim to to remove so many duplicate if() checks and make the code elegant and easy to read.
About "drops any possibility of passing arguments to the format string that komeda_sprintf() allows". In this wrapper, the 2nd parameter *msg is already be set and no possible to be a format string, even it calls komeda_sprintf, which supports passing arguments to the format string.
There are 27 places need check before calling into komeda_sprintf(). So I still think this wrapper is reasonable. It can make the code elegant and easy to read. May I give another example:
void drm_property_blob_put(struct drm_property_blob *blob)
{
if (!blob)
return;
drm_mode_object_put(&blob->base);
}Best regards,
Lowry
Quoted 109 lines
Quoted 7 lines
And for this "if () check" specific, I think this is also very popular in linux like:
static inline void
__rcu_read_lock(void)
{
if (IS_ENABLED(CONFIG_PREEMPT_COUNT))Quoted 8 lines
preempt_disable();}
static inline void
__rcu_read_unlock(void){ if (IS_ENABLED(CONFIG_PREEMPT_COUNT)) preempt_enable();}
These are inline functions wrapping around the fact that a config option might be disabled. Not really the same thing with what we are talking here.
Quoted 81 lines
thanks
JamesQuoted 71 lines
Quoted 71 lines
Quoted 71 lines
Quoted 59 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +58
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} +drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?Quoted 5 lines
Quoted 2 lines
Once the events printed, it will be set false (pls find at the last line of this function).
What is the point of making
en_printa static variable? We print all the time when we have a global event anyway.Quoted 8 lines
Hi Liviu:
| why make
en_printa static.Consider you commit a scene which may leads a UNDERUN. and it will trigger HW UNDERRUN in every vsync peroid untill this sceen have been replace by another scene. for a scene it will trigger same error again and again. we don't need print them all for a scene one msg is enough.
Quoted 5 lines
The same can be achieved by removing
en_printentirely and inverting the top condition:if (!evts->global && !is_new_frame(evts)) return;
It looks better and will change to this. Thanks a lot for this.
Quoted 149 lines
Quoted 7 lines
| we print all the time when we have a global event.
Since we only reduce the duplicate error, but want print all different error. And per our HW design, the event reported by different component. this global for collect the GCU error. thepipeline_eventis for LPU/CU/DOU. like UNDERUN which is only DOU error.Quoted 5 lines
and current GCU only have one error type: opmode change error which only can be happened on when we call
change_opmodein crtc_enable/disable.So don't worry, globl event which can not make
en_printhas been set to true in every irq handling.And that's the reason I'm asking why make
en_printstatic if we reset it in everyirq_handling(i.e. when we actually want to print). Does it really need to be static when we don't actually use the stored state?Best regards,
LiviuQuoted 118 lines
Thanks
JamesQuoted 60 lines
Quoted 51 lines
Quoted 13 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 9 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +8
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf()will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.Quoted 8 lines
Quoted 2 lines
Best regards,
LiviuThe name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
Quoted 6 lines
We should probably just collect the global and pipes values and expose them to userspace so that the printing and decoding of the messages happens there.
Best regards,
LiviuHi Liviu:
Any special resons.
Since such error print is not only wanted by us, mostly it is required and used by our customer to easily capture the problem.
If no special reasons, I want to keep it for avoiding the complaint from our customer.Thanks
JamesQuoted 36 lines
Quoted 26 lines
Best regards,
LowryQuoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, LowrySignature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Signature · 6 lines
Regards, Lowry _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]@arm.com
Liviu Dudau
maintainerQuoted 155 lines · Lowry Li (Arm Technology China)
Quoted 142 lines · Liviu Dudau
Quoted 133 lines · james qian wang (Arm Technology China)
Quoted 118 lines · Liviu Dudau
Quoted 117 lines · Lowry Li (Arm Technology China)
Hi Liviu,
Quoted 114 lines · Liviu Dudau
Quoted 101 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +40
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ;drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+ } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
Quoted 6 lines
Quoted 2 lines
The
komeda_sprintfis a generic function and will be used by other places, whileevt_sprintfis working for the detail event msg.Yeah, I'm not buying this argument any more. We should not create new functions just because we want to save typing one if () condition.
evt_sprintfdoes nothing with the extra evt argument other than checking that it is not zero.Hi Liviu
But I think we'd better to have this function which can remove many duplicate if () checks, and makes the code elegant and easy to read. and I think that why the concept of function has been introduced.
Quoted 7 lines
And in linux we can see lot of functions or MACRO that just for save one word like:
static inline void *kzalloc(size_t size,
gfp_tflags){ return kmalloc(size, flags | __GFP_ZERO);}
Quoted 6 lines
This is a different (and valid use) of creating macros.
kzalloc()does something specific (initialises allocated memory with zeros) by using the generickmalloc()function. The added__GFP_ZEROhas a specific outcome to the invocation of the wrapped function.evt_sprintf()does nothing of this sort and it is arguably wrong, as it drops any possibility of passing arguments to the format string thatkomeda_sprintf()allows.
komeda_sprintf(struct komeda_str *str, const char *fmt, ...), will be treated as a generic function, which may be called from other places, with the possiblity support of passing arguments to the format string of it.
Quoted 8 lines
evt_sprintf(struct komeda_str *str, u64 evt, const char *msg), is a wrapper aim to to remove so many duplicateif()checks and make the code elegant and easy to read.About "drops any possibility of passing arguments to the format string that
komeda_sprintf()allows". In this wrapper, the 2nd parameter *msg is already be set and no possible to be a format string, even it callskomeda_sprintf, which supports passing arguments to the format string.
Should this not be documented above the function?
Anyway, I think we are getting side-tracked. My main argument is that we don't need this function and evt_str() function *at all*. We should just expose the events value into debugfs and let userspace decode the bit values.
Quoted 4 lines
There are 27 places need check before calling into
komeda_sprintf(). So I still think this wrapper is reasonable. It can make the code elegant and easy to read. May I give another example:
Those 27 calls are also made in an interrupt handler.
Best regards,
Liviu
Quoted 281 lines
void
drm_property_blob_put(struct drm_property_blob *blob){ if (!blob) return; drm_mode_object_put(&blob->base); }Best regards,
LowryQuoted 109 lines
Quoted 7 lines
And for this "if () check" specific, I think this is also very popular in linux like:
static inline void
__rcu_read_lock(void)
{
if (IS_ENABLED(CONFIG_PREEMPT_COUNT))Quoted 8 lines
preempt_disable();}
static inline void
__rcu_read_unlock(void){ if (IS_ENABLED(CONFIG_PREEMPT_COUNT)) preempt_enable();}
These are inline functions wrapping around the fact that a config option might be disabled. Not really the same thing with what we are talking here.
Quoted 81 lines
thanks
JamesQuoted 71 lines
Quoted 71 lines
Quoted 71 lines
Quoted 59 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +58
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} +drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?Quoted 5 lines
Quoted 2 lines
Once the events printed, it will be set false (pls find at the last line of this function).
What is the point of making
en_printa static variable? We print all the time when we have a global event anyway.Quoted 8 lines
Hi Liviu:
| why make
en_printa static.Consider you commit a scene which may leads a UNDERUN. and it will trigger HW UNDERRUN in every vsync peroid untill this sceen have been replace by another scene. for a scene it will trigger same error again and again. we don't need print them all for a scene one msg is enough.
Quoted 5 lines
The same can be achieved by removing
en_printentirely and inverting the top condition:if (!evts->global && !is_new_frame(evts)) return;It looks better and will change to this. Thanks a lot for this.
Quoted 149 lines
Quoted 7 lines
| we print all the time when we have a global event.
Since we only reduce the duplicate error, but want print all different error. And per our HW design, the event reported by different component. this global for collect the GCU error. thepipeline_eventis for LPU/CU/DOU. like UNDERUN which is only DOU error.Quoted 5 lines
and current GCU only have one error type: opmode change error which only can be happened on when we call
change_opmodein crtc_enable/disable.So don't worry, globl event which can not make
en_printhas been set to true in every irq handling.And that's the reason I'm asking why make
en_printstatic if we reset it in everyirq_handling(i.e. when we actually want to print). Does it really need to be static when we don't actually use the stored state?Best regards,
LiviuQuoted 118 lines
Thanks
JamesQuoted 60 lines
Quoted 51 lines
Quoted 13 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 9 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +8
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf()will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.Quoted 8 lines
Quoted 2 lines
Best regards,
LiviuThe name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
Quoted 6 lines
We should probably just collect the global and pipes values and expose them to userspace so that the printing and decoding of the messages happens there.
Best regards,
LiviuHi Liviu:
Any special resons.
Since such error print is not only wanted by us, mostly it is required and used by our customer to easily capture the problem.
If no special reasons, I want to keep it for avoiding the complaint from our customer.Thanks
JamesQuoted 36 lines
Quoted 26 lines
Best regards,
LowryQuoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, LowrySignature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, Lowry
Signature · 12 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develQuoted 165 lines · Liviu Dudau
Quoted 155 lines · Lowry Li (Arm Technology China)
Quoted 142 lines · Liviu Dudau
Quoted 133 lines · james qian wang (Arm Technology China)
Quoted 118 lines · Liviu Dudau
Quoted 117 lines · Lowry Li (Arm Technology China)
Hi Liviu,
Quoted 114 lines · Liviu Dudau
Quoted 101 lines · Lowry Li (Arm Technology China)
Adds to print the event message when error happens and the same event will not be printed until next vsync.
Signed-off-by Lowry Li (Arm Technology China) <[email protected]>--- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + drivers/gpu/drm/arm/display/komeda/komeda_dev.h | 13 ++ drivers/gpu/drm/arm/display/komeda/komeda_event.c | 144 ++++++++++++++++++++++ drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 + 4 files changed, 160 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_event.cdrivers/gpu/drm/arm/display/komeda/Makefile +1
-0@@ -7,6 +7,7 @@ ccflags-y := \ komeda-y := \ komeda_drv.o \ komeda_dev.o \ + komeda_event.o \ komeda_format_caps.o \ komeda_coeffs.o \ komeda_color_mgmt.o \drivers/gpu/drm/arm/display/komeda/komeda_dev.h +13
-0@@ -40,6 +40,17 @@#define KOMEDA_ERR_TTNG BIT_ULL(30)#define KOMEDA_ERR_TTF BIT_ULL(31) +#define KOMEDA_ERR_EVENTS \ + (KOMEDA_EVENT_URUN | KOMEDA_EVENT_IBSY | KOMEDA_EVENT_OVR |\ + KOMEDA_ERR_TETO | KOMEDA_ERR_TEMR | KOMEDA_ERR_TITR |\ + KOMEDA_ERR_CPE | KOMEDA_ERR_CFGE | KOMEDA_ERR_AXIE |\ + KOMEDA_ERR_ACE0 | KOMEDA_ERR_ACE1 | KOMEDA_ERR_ACE2 |\ + KOMEDA_ERR_ACE3 | KOMEDA_ERR_DRIFTTO | KOMEDA_ERR_FRAMETO |\ + KOMEDA_ERR_ZME | KOMEDA_ERR_MERR | KOMEDA_ERR_TCF |\ + KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF) + +#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE +/* malidp device id */ enum {MALI_D71 =0 ,@@ -207,6 +218,8 @@ struct komeda_dev {struct komeda_dev *dev_to_mdev (struct device *dev); +void komeda_print_events (struct komeda_events *evts); +int komeda_dev_resume (struct komeda_dev *mdev);int komeda_dev_suspend (struct komeda_dev *mdev);#endif /*_KOMEDA_DEV_H_*/ drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +40
-0@@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) COPYRIGHT 2019 ARM Limited. All rights reserved. +* Author: James.Qian.Wang <[email protected]> +* +*/ +#include <drm/drm_print.h> + +#include "komeda_dev.h" + +struct komeda_str { +char *str; +u32 sz; +u32 len; +}; + +/* return 0 on success, < 0 on no space. +*/ +static int komeda_sprintf (struct komeda_str *str,const char *fmt, ...) +{ +va_list args; +int num, free_sz; +int err; + + free_sz = str->sz - str->len; +if (free_sz <=0 ) +return -ENOSPC ; + +va_start (args, fmt); + + num =vsnprintf (str->str + str->len, free_sz, fmt, args); + +va_end (args); + +if (num <= free_sz) { + str->len += num; + err =0 ; + }else { + str->len = str->sz; + err = -ENOSPC ;drivers/gpu/drm/arm/display/komeda/komeda_event.c line 50
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+ } + +return err; +} + +static void evt_sprintf (struct komeda_str *str,u64 evt,const char *msg) +{ +if (evt) +komeda_sprintf (str, msg); +}Why do we need this wrapper?
Quoted 6 lines
Quoted 2 lines
The
komeda_sprintfis a generic function and will be used by other places, whileevt_sprintfis working for the detail event msg.Yeah, I'm not buying this argument any more. We should not create new functions just because we want to save typing one if () condition.
evt_sprintfdoes nothing with the extra evt argument other than checking that it is not zero.Hi Liviu
But I think we'd better to have this function which can remove many duplicate if () checks, and makes the code elegant and easy to read. and I think that why the concept of function has been introduced.
Quoted 7 lines
And in linux we can see lot of functions or MACRO that just for save one word like:
static inline void *kzalloc(size_t size,
gfp_tflags){ return kmalloc(size, flags | __GFP_ZERO);}
Quoted 6 lines
This is a different (and valid use) of creating macros.
kzalloc()does something specific (initialises allocated memory with zeros) by using the generickmalloc()function. The added__GFP_ZEROhas a specific outcome to the invocation of the wrapped function.evt_sprintf()does nothing of this sort and it is arguably wrong, as it drops any possibility of passing arguments to the format string thatkomeda_sprintf()allows.
komeda_sprintf(struct komeda_str *str, const char *fmt, ...), will be treated as a generic function, which may be called from other places, with the possiblity support of passing arguments to the format string of it.Quoted 8 lines
evt_sprintf(struct komeda_str *str, u64 evt, const char *msg), is a wrapper aim to to remove so many duplicateif()checks and make the code elegant and easy to read.About "drops any possibility of passing arguments to the format string that
komeda_sprintf()allows". In this wrapper, the 2nd parameter *msg is already be set and no possible to be a format string, even it callskomeda_sprintf, which supports passing arguments to the format string.
Quoted 5 lines
Should this not be documented above the function?
Anyway, I think we are getting side-tracked. My main argument is that we don't need this function and
evt_str()function *at all*. We should just expose the events value into debugfs and let userspace decode the bit values.
Hi Liviu,
Thanks a lot for your reply. We are glad to accept your suggestion to remove this. But about this, James also had another concern in his previous reply.
| "Since such error print is not only wanted by us, mostly it is | required and used by our customer to easily capture the problem. | If no special reasons, I want to keep it for avoiding the complaint | from our customer."
Could you please share your concern.
Best regards,
Lowry
Quoted 301 lines
Quoted 4 lines
There are 27 places need check before calling into
komeda_sprintf(). So I still think this wrapper is reasonable. It can make the code elegant and easy to read. May I give another example:Those 27 calls are also made in an interrupt handler.
Best regards,
LiviuQuoted 281 lines
void
drm_property_blob_put(struct drm_property_blob *blob){ if (!blob) return; drm_mode_object_put(&blob->base); }Best regards,
LowryQuoted 109 lines
Quoted 7 lines
And for this "if () check" specific, I think this is also very popular in linux like:
static inline void
__rcu_read_lock(void)
{
if (IS_ENABLED(CONFIG_PREEMPT_COUNT))Quoted 8 lines
preempt_disable();}
static inline void
__rcu_read_unlock(void){ if (IS_ENABLED(CONFIG_PREEMPT_COUNT)) preempt_enable();}
These are inline functions wrapping around the fact that a config option might be disabled. Not really the same thing with what we are talking here.
Quoted 81 lines
thanks
JamesQuoted 71 lines
Quoted 71 lines
Quoted 71 lines
Quoted 59 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +58
-0+ +static void evt_str (struct komeda_str *str,u64 events) +{ +if (events ==0ULL ) { +evt_sprintf (str,1 ,"None" ); +return ; + } + +evt_sprintf (str, events &KOMEDA_EVENT_VSYNC ,"VSYNC|" ); +evt_sprintf (str, events &KOMEDA_EVENT_FLIP ,"FLIP|" ); +evt_sprintf (str, events &KOMEDA_EVENT_EOW ,"EOW|" ); +evt_sprintf (str, events &KOMEDA_EVENT_MODE ,"OP-MODE|" ); + +evt_sprintf (str, events &KOMEDA_EVENT_URUN ,"UNDERRUN|" ); +evt_sprintf (str, events &KOMEDA_EVENT_OVR ,"OVERRUN|" ); + +/* GLB error */ +evt_sprintf (str, events &KOMEDA_ERR_MERR ,"MERR|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); + +/* DOU error */ +evt_sprintf (str, events &KOMEDA_ERR_DRIFTTO ,"DRIFTTO|" ); +evt_sprintf (str, events &KOMEDA_ERR_FRAMETO ,"FRAMETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_TETO ,"TETO|" ); +evt_sprintf (str, events &KOMEDA_ERR_CSCE ,"CSCE|" ); + +/* LPU errors or events */ +evt_sprintf (str, events &KOMEDA_EVENT_IBSY ,"IBSY|" ); +evt_sprintf (str, events &KOMEDA_ERR_AXIE ,"AXIE|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE0 ,"ACE0|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE1 ,"ACE1|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE2 ,"ACE2|" ); +evt_sprintf (str, events &KOMEDA_ERR_ACE3 ,"ACE3|" ); + +/* LPU TBU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_TCF ,"TCF|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTNG ,"TTNG|" ); +evt_sprintf (str, events &KOMEDA_ERR_TITR ,"TITR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); +evt_sprintf (str, events &KOMEDA_ERR_TTF ,"TTF|" ); + +/* CU errors*/ +evt_sprintf (str, events &KOMEDA_ERR_CPE ,"COPROC|" ); +evt_sprintf (str, events &KOMEDA_ERR_ZME ,"ZME|" ); +evt_sprintf (str, events &KOMEDA_ERR_CFGE ,"CFGE|" ); +evt_sprintf (str, events &KOMEDA_ERR_TEMR ,"TEMR|" ); + +if (str->len >0 && (str->str[str->len -1 ] =='|' )) { + str->str[str->len -1 ] =0 ; + str->len--; + } +} + +static bool is_new_frame (struct komeda_events *a) +{ +return (a->pipes[0 ] | a->pipes[1 ]) &KOMEDA_EVENT_FLIP ; +} +drivers/gpu/drm/arm/display/komeda/komeda_event.c line 118
Quoted 10 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +10
-0+void komeda_print_events (struct komeda_events *evts) +{ +u64 print_evts =KOMEDA_ERR_EVENTS ; +static bool en_print = true; + +/* reduce the same msg print, only print the first evt for one frame */ +if (evts->global ||is_new_frame (evts)) + en_print = true; +if (!en_print) +return ;When does
en_printever get false?Quoted 5 lines
Quoted 2 lines
Once the events printed, it will be set false (pls find at the last line of this function).
What is the point of making
en_printa static variable? We print all the time when we have a global event anyway.Quoted 8 lines
Hi Liviu:
| why make
en_printa static.Consider you commit a scene which may leads a UNDERUN. and it will trigger HW UNDERRUN in every vsync peroid untill this sceen have been replace by another scene. for a scene it will trigger same error again and again. we don't need print them all for a scene one msg is enough.
Quoted 5 lines
The same can be achieved by removing
en_printentirely and inverting the top condition:if (!evts->global && !is_new_frame(evts)) return;It looks better and will change to this. Thanks a lot for this.
Quoted 149 lines
Quoted 7 lines
| we print all the time when we have a global event.
Since we only reduce the duplicate error, but want print all different error. And per our HW design, the event reported by different component. this global for collect the GCU error. thepipeline_eventis for LPU/CU/DOU. like UNDERUN which is only DOU error.Quoted 5 lines
and current GCU only have one error type: opmode change error which only can be happened on when we call
change_opmodein crtc_enable/disable.So don't worry, globl event which can not make
en_printhas been set to true in every irq handling.And that's the reason I'm asking why make
en_printstatic if we reset it in everyirq_handling(i.e. when we actually want to print). Does it really need to be static when we don't actually use the stored state?Best regards,
LiviuQuoted 118 lines
Thanks
JamesQuoted 60 lines
Quoted 51 lines
Quoted 13 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c line 126
Quoted 9 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +8
-0+ +#ifdef DEBUG + print_evts |=KOMEDA_WARN_EVENTS ; +#endif + +if ((evts->global | evts->pipes[0 ] | evts->pipes[1 ]) & print_evts) { +#define STR_SZ 128 +char msg[STR_SZ ];I've counted about 27
evt_sprintf()calls inevt_str()function, with an average of 5 characters each, so thats 135 characters printed into a buffer that is only 128 bytes. Please don't do this!
komeda_sprintf()will check the size and also I thought those evt will not populat together. But yes, I'd better change this to 256. Will change this.Quoted 34 lines
Quoted 23 lines
drivers/gpu/drm/arm/display/komeda/komeda_event.c new file +18
-0+struct komeda_str str; + + str.str = msg; + str.sz =STR_SZ ; + str.len =0 ; + +komeda_sprintf (&str,"gcu: " ); +evt_str (&str, evts->global); +komeda_sprintf (&str,", pipes[0]: " ); +evt_str (&str, evts->pipes[0 ]); +komeda_sprintf (&str,", pipes[1]: " ); +evt_str (&str, evts->pipes[1 ]); + +DRM_ERROR ("err detect: %s\n" , msg); + + en_print = false; + } +}drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0drivers/gpu/drm/arm/display/komeda/komeda_kms.c static irqreturn_t komeda_kms_irq_handler(int irq, void *data) · line 50
Quoted 4 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -47,6 +47,8 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)memset (&evts,0 ,sizeof (evts)); status = mdev->funcs->irq_handler (mdev, &evts); +komeda_print_events (&evts);Calling this function from the IRQ handler is a bad idea. We should use debugfs if you really want to have a trace of the events, but I personally don't see value in having this functionality in the kernel at all. You can expose the value of the
evts->globaland evts->pipes[] as integers and decode that in userspace or as a debugfs entry.Quoted 8 lines
Quoted 2 lines
Best regards,
LiviuThe name of this function is misleading, but this is printing out the hardware detected errors, from which we can know directly once the errors happened on the hardware. Like if the driver code was at bring-up stage, the logs from this layer is helpful. So can we keep this?
Quoted 6 lines
We should probably just collect the global and pipes values and expose them to userspace so that the printing and decoding of the messages happens there.
Best regards,
LiviuHi Liviu:
Any special resons.
Since such error print is not only wanted by us, mostly it is required and used by our customer to easily capture the problem.
If no special reasons, I want to keep it for avoiding the complaint from our customer.Thanks
JamesQuoted 36 lines
Quoted 26 lines
Best regards,
LowryQuoted 17 lines
Quoted 7 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0+/* Notify the crtc to handle the events */ for (i =0 ; i < kms->n_crtcs; i++)komeda_crtc_handle_event (&kms->crtcs[i], &evts);Signature · 1 line
1.9.1Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, LowrySignature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯Signature · 2 lines
Regards, LowrySignature · 8 lines
==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Signature · 6 lines
Regards, Lowry _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel