The handling of NULL values is half-baked.
In my opinion, you should define if drm_sched_pick_best() may put a
NULL into
rq. If your answer is yes, it might put a NULL there; then, there
should be a
BUG_ON(!entity->rq) after the invocation of
drm_sched_entity_select_rq().
If your answer is no, the BUG_ON() should be in
drm_sched_pick_best().
Yeah good point.
We might not want a BUG_ON(), that is only justified when we prevent
further damage (e.g. random data corruption or similar).
I suggest using a WARN(!shed, "Submission without activated
sheduler!").
This way the system has at least a chance of survival should the
scheduler become ready later on.
On the other hand the BUG_ON() or the NULL pointer deref should only
kill the application thread which is submitting something before the
driver is resumed. So that might help to pinpoint where the actually
issue is.