From: mglocker Date: Mon, 20 May 2024 20:08:04 +0000 (+0000) Subject: Introduce some macros for static intr. aggr. and slot integers, and do X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d0fe8eba4c8cea6bd274710304caad215af48e3d;p=openbsd Introduce some macros for static intr. aggr. and slot integers, and do more strict checking on the slot count. --- diff --git a/sys/dev/ic/ufshci.c b/sys/dev/ic/ufshci.c index f5070210ff4..22aaa9973a4 100644 --- a/sys/dev/ic/ufshci.c +++ b/sys/dev/ic/ufshci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufshci.c,v 1.26 2024/05/20 12:42:45 mglocker Exp $ */ +/* $OpenBSD: ufshci.c,v 1.27 2024/05/20 20:08:04 mglocker Exp $ */ /* * Copyright (c) 2022 Marcus Glocker @@ -181,15 +181,17 @@ ufshci_attach(struct ufshci_softc *sc) 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)); - if (sc->sc_nutrs > 32) { - printf("%s: NUTRS can't be >32 (is %d)!\n", - sc->sc_dev.dv_xname, sc->sc_nutrs); + if (sc->sc_nutrs < UFSHCI_SLOTS_MIN || + sc->sc_nutrs > UFSHCI_SLOTS_MAX) { + printf("%s: Invalid NUTRS value %d (must be %d-%d)!\n", + sc->sc_dev.dv_xname, sc->sc_nutrs, + UFSHCI_SLOTS_MIN, UFSHCI_SLOTS_MAX); return 1; - } else if (sc->sc_nutrs == 1) { - sc->sc_iacth = sc->sc_nutrs; - } else if (sc->sc_nutrs > 1) { - sc->sc_iacth = sc->sc_nutrs - 1; } + if (sc->sc_nutrs == UFSHCI_SLOTS_MAX) + sc->sc_iacth = UFSHCI_INTR_AGGR_COUNT_MAX; + else + sc->sc_iacth = sc->sc_nutrs; DPRINTF(1, "Intr. aggr. counter threshold:\nIACTH=%d\n", sc->sc_iacth); /* diff --git a/sys/dev/ic/ufshcireg.h b/sys/dev/ic/ufshcireg.h index 741ecd1fe12..bb1991ed762 100644 --- a/sys/dev/ic/ufshcireg.h +++ b/sys/dev/ic/ufshcireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ufshcireg.h,v 1.9 2024/05/16 10:52:11 mglocker Exp $ */ +/* $OpenBSD: ufshcireg.h,v 1.10 2024/05/20 20:08:04 mglocker Exp $ */ /* * Copyright (c) 2022 Marcus Glocker @@ -22,7 +22,9 @@ #define UFSHCI_UCD_PRDT_MAX_SEGS 64 #define UFSHCI_UCD_PRDT_MAX_XFER (UFSHCI_UCD_PRDT_MAX_SEGS * PAGE_SIZE) #define UFSHCI_INTR_AGGR_TIMEOUT 0x08 /* 320us (1 unit = 40us) */ -#define UFSHCI_MAX_UNITS 32 +#define UFSHCI_INTR_AGGR_COUNT_MAX 31 +#define UFSHCI_SLOTS_MIN 1 +#define UFSHCI_SLOTS_MAX 32 #define UFSHCI_LBS 4096 /* UFS Logical Block Size: For UFS minimum size shall be 4096 bytes */