mpr/mps: Add comment explaining state transition

When we can't load a request due to a shortage of chains, we complete
the command's cm. However, to avoid an assert in mp?_complete_command,
we transition its state to INQUEUE. This transition is legitimate
because this is the only error path that terminates a cm before it's
enqueued and the only other alternative would be an additional transient
state that would add complexity w/o adding value. Add a comment
explainging all this because otherwise the transition can look a bit
weird.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-04-28 11:13:58 -06:00
parent 65c87a6c81
commit c5041b4ee8
2 changed files with 12 additions and 0 deletions

View File

@ -3704,6 +3704,12 @@ mpr_data_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
mpr_dprint(sc, MPR_INFO, "Out of chain frames, "
"consider increasing hw.mpr.max_chains.\n");
cm->cm_flags |= MPR_CM_FLAGS_CHAIN_FAILED;
/*
* mpr_complete_command can only be called on commands
* that are in the queue. Since this is an error path
* which gets called before we enqueue, update the state
* to meet this requirement before we complete it.
*/
cm->cm_state = MPR_CM_STATE_INQUEUE;
mpr_complete_command(sc, cm);
return;

View File

@ -2983,6 +2983,12 @@ mps_data_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
mps_dprint(sc, MPS_INFO, "Out of chain frames, "
"consider increasing hw.mps.max_chains.\n");
cm->cm_flags |= MPS_CM_FLAGS_CHAIN_FAILED;
/*
* mpr_complete_command can only be called on commands
* that are in the queue. Since this is an error path
* which gets called before we enqueue, update the state
* to meet this requirement before we complete it.
*/
cm->cm_state = MPS_CM_STATE_INQUEUE;
mps_complete_command(sc, cm);
return;