1 // SPDX-License-Identifier: GPL-2.0
3 * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
4 * Author: James.Qian.Wang <james.qian.wang@arm.com>
7 #include <drm/drm_atomic.h>
8 #include <drm/drm_print.h>
10 #include "komeda_dev.h"
18 /* return 0 on success, < 0 on no space.
21 static int komeda_sprintf(struct komeda_str
*str
, const char *fmt
, ...)
27 free_sz
= str
->sz
- str
->len
- 1;
33 num
= vsnprintf(str
->str
+ str
->len
, free_sz
, fmt
, args
);
41 str
->len
= str
->sz
- 1;
48 static void evt_sprintf(struct komeda_str
*str
, u64 evt
, const char *msg
)
51 komeda_sprintf(str
, msg
);
54 static void evt_str(struct komeda_str
*str
, u64 events
)
57 komeda_sprintf(str
, "None");
61 evt_sprintf(str
, events
& KOMEDA_EVENT_VSYNC
, "VSYNC|");
62 evt_sprintf(str
, events
& KOMEDA_EVENT_FLIP
, "FLIP|");
63 evt_sprintf(str
, events
& KOMEDA_EVENT_EOW
, "EOW|");
64 evt_sprintf(str
, events
& KOMEDA_EVENT_MODE
, "OP-MODE|");
66 evt_sprintf(str
, events
& KOMEDA_EVENT_URUN
, "UNDERRUN|");
67 evt_sprintf(str
, events
& KOMEDA_EVENT_OVR
, "OVERRUN|");
70 evt_sprintf(str
, events
& KOMEDA_ERR_MERR
, "MERR|");
71 evt_sprintf(str
, events
& KOMEDA_ERR_FRAMETO
, "FRAMETO|");
74 evt_sprintf(str
, events
& KOMEDA_ERR_DRIFTTO
, "DRIFTTO|");
75 evt_sprintf(str
, events
& KOMEDA_ERR_FRAMETO
, "FRAMETO|");
76 evt_sprintf(str
, events
& KOMEDA_ERR_TETO
, "TETO|");
77 evt_sprintf(str
, events
& KOMEDA_ERR_CSCE
, "CSCE|");
79 /* LPU errors or events */
80 evt_sprintf(str
, events
& KOMEDA_EVENT_IBSY
, "IBSY|");
81 evt_sprintf(str
, events
& KOMEDA_EVENT_EMPTY
, "EMPTY|");
82 evt_sprintf(str
, events
& KOMEDA_EVENT_FULL
, "FULL|");
83 evt_sprintf(str
, events
& KOMEDA_ERR_AXIE
, "AXIE|");
84 evt_sprintf(str
, events
& KOMEDA_ERR_ACE0
, "ACE0|");
85 evt_sprintf(str
, events
& KOMEDA_ERR_ACE1
, "ACE1|");
86 evt_sprintf(str
, events
& KOMEDA_ERR_ACE2
, "ACE2|");
87 evt_sprintf(str
, events
& KOMEDA_ERR_ACE3
, "ACE3|");
90 evt_sprintf(str
, events
& KOMEDA_ERR_TCF
, "TCF|");
91 evt_sprintf(str
, events
& KOMEDA_ERR_TTNG
, "TTNG|");
92 evt_sprintf(str
, events
& KOMEDA_ERR_TITR
, "TITR|");
93 evt_sprintf(str
, events
& KOMEDA_ERR_TEMR
, "TEMR|");
94 evt_sprintf(str
, events
& KOMEDA_ERR_TTF
, "TTF|");
97 evt_sprintf(str
, events
& KOMEDA_ERR_CPE
, "COPROC|");
98 evt_sprintf(str
, events
& KOMEDA_ERR_ZME
, "ZME|");
99 evt_sprintf(str
, events
& KOMEDA_ERR_CFGE
, "CFGE|");
100 evt_sprintf(str
, events
& KOMEDA_ERR_TEMR
, "TEMR|");
102 if (str
->len
> 0 && (str
->str
[str
->len
- 1] == '|')) {
103 str
->str
[str
->len
- 1] = 0;
108 static bool is_new_frame(struct komeda_events
*a
)
110 return (a
->pipes
[0] | a
->pipes
[1]) &
111 (KOMEDA_EVENT_FLIP
| KOMEDA_EVENT_EOW
);
114 void komeda_print_events(struct komeda_events
*evts
, struct drm_device
*dev
)
117 static bool en_print
= true;
118 struct komeda_dev
*mdev
= dev
->dev_private
;
119 u16
const err_verbosity
= mdev
->err_verbosity
;
120 u64 evts_mask
= evts
->global
| evts
->pipes
[0] | evts
->pipes
[1];
122 /* reduce the same msg print, only print the first evt for one frame */
123 if (evts
->global
|| is_new_frame(evts
))
125 if (!(err_verbosity
& KOMEDA_DEV_PRINT_DISABLE_RATELIMIT
) && !en_print
)
128 if (err_verbosity
& KOMEDA_DEV_PRINT_ERR_EVENTS
)
129 print_evts
|= KOMEDA_ERR_EVENTS
;
130 if (err_verbosity
& KOMEDA_DEV_PRINT_WARN_EVENTS
)
131 print_evts
|= KOMEDA_WARN_EVENTS
;
132 if (err_verbosity
& KOMEDA_DEV_PRINT_INFO_EVENTS
)
133 print_evts
|= KOMEDA_INFO_EVENTS
;
135 if (evts_mask
& print_evts
) {
137 struct komeda_str str
;
138 struct drm_printer p
= drm_info_printer(dev
->dev
);
141 str
.sz
= sizeof(msg
);
144 komeda_sprintf(&str
, "gcu: ");
145 evt_str(&str
, evts
->global
);
146 komeda_sprintf(&str
, ", pipes[0]: ");
147 evt_str(&str
, evts
->pipes
[0]);
148 komeda_sprintf(&str
, ", pipes[1]: ");
149 evt_str(&str
, evts
->pipes
[1]);
151 DRM_ERROR("err detect: %s\n", msg
);
152 if ((err_verbosity
& KOMEDA_DEV_PRINT_DUMP_STATE_ON_EVENT
) &&
153 (evts_mask
& (KOMEDA_ERR_EVENTS
| KOMEDA_WARN_EVENTS
)))
154 drm_state_dump(dev
, &p
);