-/* $OpenBSD: ufshci.c,v 1.22 2024/05/15 18:01:10 mglocker Exp $ */
+/* $OpenBSD: ufshci.c,v 1.23 2024/05/15 20:10:27 mglocker Exp $ */
/*
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
DPRINTF(1, " BI=0x%04x\n", UFSHCI_REG_HCMID_BI(sc->sc_hcmid));
DPRINTF(1, " MIC=0x%04x\n", UFSHCI_REG_HCMID_MIC(sc->sc_hcmid));
- /* XXX: Using more than one slot currently causes OCS errors */
- sc->sc_nutrs = 1;
-
if (sc->sc_nutrs > 32) {
printf("%s: NUTRS can't be >32 (is %d)!\n",
sc->sc_dev.dv_xname, sc->sc_nutrs);
ucd->cmd.hdr.tc = UPIU_TC_I2T_NOP_OUT;
ucd->cmd.hdr.flags = 0;
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
else
ucd->cmd.hdr.flags = (1 << 5); /* Bit-5 = Write */
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = 0; /* No data transfer */
ucd->cmd.hdr.lun = 0;
- ucd->cmd.hdr.taskid = 0;
+ ucd->cmd.hdr.task_tag = slot;
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
{
struct ufshci_ccb *ccb;
uint32_t reg;
- int i;
+ int i, timeout;
mtx_enter(&sc->sc_cmd_mtx);
/* Wait for all commands to complete. */
- while ((reg = ufshci_doorbell_read(sc))) {
- DPRINTF(3, "%s: doorbell reg=0x%x\n", __func__, reg);
+ for (timeout = 5000; timeout != 0; timeout--) {
+ reg = ufshci_doorbell_read(sc);
if (reg == 0)
break;
+ delay(10);
}
+ if (timeout == 0)
+ printf("%s: timeout (reg=0x%x)\n", __func__, reg);
for (i = 0; i < sc->sc_nutrs; i++) {
ccb = &sc->sc_ccbs[i];