Page MenuHomeFreeBSD

D61121.1793787902.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61121.1793787902.diff

diff --git a/sys/dev/ufshci/ufshci_ctrlr.c b/sys/dev/ufshci/ufshci_ctrlr.c
--- a/sys/dev/ufshci/ufshci_ctrlr.c
+++ b/sys/dev/ufshci/ufshci_ctrlr.c
@@ -287,7 +287,7 @@
int
ufshci_ctrlr_enable(struct ufshci_controller *ctrlr)
{
- uint32_t ie, hcs;
+ uint32_t ie, hcs, attempt;
int error;
error = ufshci_ctrlr_enable_host_ctrlr(ctrlr);
@@ -295,18 +295,27 @@
return (error);
/* Send DME_LINKSTARTUP command to start the link startup procedure */
- error = ufshci_uic_send_dme_link_startup(ctrlr);
- if (error)
- return (error);
+ for (attempt = 0; attempt < UFSHCI_MAX_LINK_STARTUP_ATTEMPTS;
+ attempt++) {
+ error = ufshci_uic_send_dme_link_startup(ctrlr);
+ if (error) {
+ ufshci_printf(ctrlr,
+ "DME_LINKSTARTUP attempt %u failed: %d\n",
+ attempt + 1, error);
+ continue;
+ }
- /*
- * The device_present(UFSHCI_HCS_REG_DP) bit becomes true if the host
- * controller has successfully received a Link Startup UIC command
- * response and the UFS device has found a physical link to the
- * controller.
- */
- hcs = ufshci_mmio_read_4(ctrlr, hcs);
- if (!UFSHCIV(UFSHCI_HCS_REG_DP, hcs)) {
+ /*
+ * The device_present(UFSHCI_HCS_REG_DP) bit becomes true if
+ * the host controller has successfully received a Link
+ * Startup UIC command response and the UFS device has found
+ * a physical link to the controller.
+ */
+ hcs = ufshci_mmio_read_4(ctrlr, hcs);
+ if (UFSHCIV(UFSHCI_HCS_REG_DP, hcs))
+ break;
+ }
+ if (attempt == UFSHCI_MAX_LINK_STARTUP_ATTEMPTS) {
ufshci_printf(ctrlr, "UFS device not found\n");
return (ENXIO);
}
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
@@ -47,6 +47,9 @@
#define UFSHCI_DEFAULT_RETRY_COUNT (4)
+/* A device that is still powering on does not answer the first one. */
+#define UFSHCI_MAX_LINK_STARTUP_ATTEMPTS (3)
+
#define UFSHCI_UTR_ENTRIES (32)
#define UFSHCI_UTRM_ENTRIES (8)

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 4, 10:25 AM (44 m, 21 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41360526
Default Alt Text
D61121.1793787902.diff (1 KB)

Event Timeline