Page MenuHomeFreeBSD

D61111.1793789521.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D61111.1793789521.diff

diff --git a/sys/dev/ufshci/ufshci_private.h b/sys/dev/ufshci/ufshci_private.h
--- a/sys/dev/ufshci/ufshci_private.h
+++ b/sys/dev/ufshci/ufshci_private.h
@@ -133,7 +133,7 @@
struct ufshci_tracker **tr);
void (*ring_doorbell)(struct ufshci_controller *ctrlr,
struct ufshci_tracker *tr);
- bool (*is_doorbell_cleared)(struct ufshci_controller *ctrlr,
+ bool (*is_completed)(struct ufshci_controller *ctrlr,
uint8_t slot);
void (*clear_cpl_ntf)(struct ufshci_controller *ctrlr,
struct ufshci_tracker *tr);
@@ -532,9 +532,9 @@
struct ufshci_tracker *tr);
void ufshci_req_sdb_utr_ring_doorbell(struct ufshci_controller *ctrlr,
struct ufshci_tracker *tr);
-bool ufshci_req_sdb_utmr_is_doorbell_cleared(struct ufshci_controller *ctrlr,
+bool ufshci_req_sdb_utmr_is_completed(struct ufshci_controller *ctrlr,
uint8_t slot);
-bool ufshci_req_sdb_utr_is_doorbell_cleared(struct ufshci_controller *ctrlr,
+bool ufshci_req_sdb_utr_is_completed(struct ufshci_controller *ctrlr,
uint8_t slot);
void ufshci_req_sdb_utmr_clear_cpl_ntf(struct ufshci_controller *ctrlr,
struct ufshci_tracker *tr);
diff --git a/sys/dev/ufshci/ufshci_req_queue.c b/sys/dev/ufshci/ufshci_req_queue.c
--- a/sys/dev/ufshci/ufshci_req_queue.c
+++ b/sys/dev/ufshci/ufshci_req_queue.c
@@ -28,7 +28,7 @@
.reserve_slot = ufshci_req_sdb_reserve_slot,
.reserve_admin_slot = ufshci_req_sdb_reserve_slot,
.ring_doorbell = ufshci_req_sdb_utmr_ring_doorbell,
- .is_doorbell_cleared = ufshci_req_sdb_utmr_is_doorbell_cleared,
+ .is_completed = ufshci_req_sdb_utmr_is_completed,
.clear_cpl_ntf = ufshci_req_sdb_utmr_clear_cpl_ntf,
.process_cpl = ufshci_req_sdb_process_cpl,
.get_inflight_io = ufshci_req_sdb_get_inflight_io,
@@ -43,7 +43,7 @@
.reserve_slot = ufshci_req_sdb_reserve_slot,
.reserve_admin_slot = ufshci_req_sdb_reserve_slot,
.ring_doorbell = ufshci_req_sdb_utr_ring_doorbell,
- .is_doorbell_cleared = ufshci_req_sdb_utr_is_doorbell_cleared,
+ .is_completed = ufshci_req_sdb_utr_is_completed,
.clear_cpl_ntf = ufshci_req_sdb_utr_clear_cpl_ntf,
.process_cpl = ufshci_req_sdb_process_cpl,
.get_inflight_io = ufshci_req_sdb_get_inflight_io,
diff --git a/sys/dev/ufshci/ufshci_req_sdb.c b/sys/dev/ufshci/ufshci_req_sdb.c
--- a/sys/dev/ufshci/ufshci_req_sdb.c
+++ b/sys/dev/ufshci/ufshci_req_sdb.c
@@ -551,21 +551,31 @@
}
bool
-ufshci_req_sdb_utmr_is_doorbell_cleared(struct ufshci_controller *ctrlr,
+ufshci_req_sdb_utmr_is_completed(struct ufshci_controller *ctrlr,
uint8_t slot)
{
uint32_t utmrldbr;
+ /* The task management list has no completion notification. */
utmrldbr = ufshci_mmio_read_4(ctrlr, utmrldbr);
return (!(utmrldbr & (1 << slot)));
}
bool
-ufshci_req_sdb_utr_is_doorbell_cleared(struct ufshci_controller *ctrlr,
+ufshci_req_sdb_utr_is_completed(struct ufshci_controller *ctrlr,
uint8_t slot)
{
- uint32_t utrldbr;
+ uint32_t utrlcnr, utrldbr;
+ /*
+ * Since UFSHCI 3.0 the controller sets a notification bit when it
+ * completes a request. Before that, a cleared doorbell bit was the
+ * only sign, and a slot that was never rung looks the same.
+ */
+ if (ctrlr->major_version >= 3) {
+ utrlcnr = ufshci_mmio_read_4(ctrlr, utrlcnr);
+ return ((utrlcnr & (1 << slot)) != 0);
+ }
utrldbr = ufshci_mmio_read_4(ctrlr, utrldbr);
return (!(utrldbr & (1 << slot)));
}
@@ -592,15 +602,13 @@
KASSERT(tr, ("there is no tracker assigned to the slot"));
/*
- * When the response is delivered from the device, the doorbell
- * is cleared. Check it under qlock so that a slot whose
+ * Check the completion under qlock so that a slot whose
* doorbell write is still in flight in the submit path is not
* mistaken for a completed one.
*/
mtx_lock(&hwq->qlock);
completed = tr->slot_state == UFSHCI_SLOT_STATE_SCHEDULED &&
- req_queue->qops.is_doorbell_cleared(req_queue->ctrlr,
- slot);
+ req_queue->qops.is_completed(req_queue->ctrlr, slot);
mtx_unlock(&hwq->qlock);
if (completed) {
ufshci_req_queue_complete_tracker(tr);

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 4, 10:52 AM (6 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41360974
Default Alt Text
D61111.1793789521.diff (3 KB)

Event Timeline