git: c5041b4ee8c3 - main - mpr/mps: Add comment explaining state transition
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 28 Apr 2022 17:21:02 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=c5041b4ee8c3385cec03e6ccf73af78cadfe8d90
commit c5041b4ee8c3385cec03e6ccf73af78cadfe8d90
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-04-28 17:13:58 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-04-28 17:19:39 +0000
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
---
sys/dev/mpr/mpr.c | 6 ++++++
sys/dev/mps/mps.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c
index 0f4c5c906216..b4d3f3269dba 100644
--- a/sys/dev/mpr/mpr.c
+++ b/sys/dev/mpr/mpr.c
@@ -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;
diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c
index 5021acf930a3..b3f470bf5a39 100644
--- a/sys/dev/mps/mps.c
+++ b/sys/dev/mps/mps.c
@@ -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;