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

Francois Dugast francois.dugast at intel.com
Fri Jul 21 13:20:29 UTC 2023


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.

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