[Intel-xe] [PATCH 0/1] Remove uses of BUG_ON

Matthew Brost matthew.brost at intel.com
Fri Jul 21 15:50:42 UTC 2023


On Fri, Jul 21, 2023 at 01:20:29PM +0000, Francois Dugast wrote:
> This is a first pass on removing BUG_ON. It is replaced with a call to
> drm_err() and a return. Feedback on this is welcome before removing
> remaining uses of BUG_ON, which will require more manual and specific
> work.
> 

Personally I don't like this at all, agree the BUG_ON should be removed
but IMO we just replace these with a XE_WARN_ON that gets compiled out
of non-debug builds. I like WARN/BUG as they act more like a self
documenting assert of the codes usage plus if they get trigger we get
the call stack which usuaully help diagnosis the issue and disappear in
non-debug builds.

Let's see if the team agrees.

Matt

> For this pass, most of the changes were automated with coccinelle using:
> 
> 	@notpossible@
> 	@@
> 
> 	- XE_BUG_ON("NOT POSSIBLE");
> 	+ drm_err(&vm->xe->drm, "NOT POSSIBLE");
> 	+ return -EINVAL;
> 
> 	@e@
> 	identifier macro =~ "^XE_BUG_ON$";
> 	expression cond;
> 	@@
> 	macro(cond)
> 
> 	@script : python q@
> 	cond << e.cond;
> 	cond_expr;
> 	@@
> 	coccinelle.cond_expr = cocci.make_expr("\""+cond.replace(" ", "")+"\"");
> 
> 	@replace_in_func_return_struct@
> 	identifier e.macro;
> 	expression e.cond;
> 	expression q.cond_expr;
> 	identifier func;
> 	identifier a;
> 	@@
> 
> 	struct a *func(...) {
> 	...
> 	- macro(cond);
> 	+ if (cond) {
> 	+ drm_err(&xe->drm, cond_expr);
> 	+ return NULL;
> 	+ }
> 	...
> 	}
> 
> 	@replace_in_func_return_void@
> 	identifier e.macro;
> 	expression e.cond;
> 	expression q.cond_expr;
> 	identifier func;
> 	@@
> 
> 	void func(...) {
> 	...
> 	- macro(cond);
> 	+ if (cond) {
> 	+ drm_err(&xe->drm, cond_expr);
> 	+ return;
> 	+ }
> 	...
> 	}
> 
> 	@replace_in_func_return_other@
> 	identifier e.macro;
> 	expression e.cond;
> 	expression q.cond_expr;
> 	@@
> 
> 	- macro(cond);
> 	+ if (cond) {
> 	+ drm_err(&xe->drm, cond_expr);
> 	+ return -EINVAL;
> 	+ }
> 
> Francois Dugast (1):
>   drm/xe: Remove uses of BUG_ON
> 
>  drivers/gpu/drm/xe/xe_bo.c                  | 105 ++++++++++++----
>  drivers/gpu/drm/xe/xe_bo_evict.c            |  10 +-
>  drivers/gpu/drm/xe/xe_execlist.c            |  22 +++-
>  drivers/gpu/drm/xe/xe_force_wake.c          |  10 +-
>  drivers/gpu/drm/xe/xe_gt_clock.c            |   5 +-
>  drivers/gpu/drm/xe/xe_gt_debugfs.c          |   5 +-
>  drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c |  31 ++++-
>  drivers/gpu/drm/xe/xe_guc.c                 |  32 +++--
>  drivers/gpu/drm/xe/xe_guc_ads.c             |  35 ++++--
>  drivers/gpu/drm/xe/xe_guc_hwconfig.c        |   5 +-
>  drivers/gpu/drm/xe/xe_guc_submit.c          |  95 +++++++++++----
>  drivers/gpu/drm/xe/xe_huc.c                 |   5 +-
>  drivers/gpu/drm/xe/xe_migrate.c             |  61 ++++++++--
>  drivers/gpu/drm/xe/xe_sched_job.c           |   9 +-
>  drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c      |  10 +-
>  drivers/gpu/drm/xe/xe_vm.c                  | 125 +++++++++++++++-----
>  drivers/gpu/drm/xe/xe_wopcm.c               |  45 +++++--
>  17 files changed, 482 insertions(+), 128 deletions(-)
> 
> -- 
> 2.34.1
> 


More information about the Intel-xe mailing list