From nobody Wed Aug 23 14:53:51 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RW8Nv6Nq9z4qjmh; Wed, 23 Aug 2023 14:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RW8Nv5jz7z3bpL; Wed, 23 Aug 2023 14:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692802431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LKr1R1R81oZCN3TiIvQIV88F7VIkl3dRTc7CtL2tuDc=; b=I8T4ouZGafs8gyn+x1PpdwkFBDf0A70Y+2+FgzlOWcRH7V5kElK8Uk/rKDLsP8GqB05uRE NtfON4d2DPT+sF4s2gnVWJCN+d6TQbOp7rPS0iPdaHiVso271vjTNKqSBo0jSvAt3fPtEw ramcifs+OJFjpWv/6OdCZdxMGfrKd+ZvFXzOYsYAtJD6IImrvK15PxM7tIK0f1CIx6eyUP nUgYakPqYf0fdA+b1UmkdvvEbx49D1Ovg/AcWZSws+kVd9RoFLtdg2RUhOlqJWLObNhbZ1 vlTjJtSpxWM5cTug6L3mPxACtsgtDn5eOQBphq5XIAqM+LGq8jOplk2MCKOUJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692802431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LKr1R1R81oZCN3TiIvQIV88F7VIkl3dRTc7CtL2tuDc=; b=aVBJOIsp7nVBoxWrv0f3rw4urGuyFU9dlb79V1SR2KSUvqf8VsHaRSTE58GubsOOqgwYLM dPNKcZy/cLG35aLHEpsMAyaDMbNxEIgyF9qb5ongj48PlDOtGILsHTexvvY1jACCeGoTww 17c/qodsXkwM/1ubjoouLEPwaHx9klhV3S1VEQM6k1R4cqBQwxcCKj+4RnCHEq1rVFUwv+ oWG1RxlTKs9Zzob5hdcBACNXEBNqXA+qObJPjqIYN+CYyNL4gm06IWb2RWiCccTnpJkaj2 V/bn8lVaTuoqhV/Bssm4Br7cVUvjfI2O9Ur37iRxRojAO/a2IPFz8KArinkCkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692802431; a=rsa-sha256; cv=none; b=bNZhxhMGotFjlyRXDMyKmBi6P4HvTRQp5EzzZtNzUNjvdJgIb8+txOxOfrJFHhTYxf3cFy ot6ecTkY/fhBv/Xq6X4JJPjn3FRPKOlQBipTGi5m2l5DmiNVESzcJmWU1E6duGm2Qm/HOs 10XboIvBa3/K6NEcJzk0RMPUA1qIvbbxEN8rbQ9pClaVZHkWK2R4ZxAAGd1c28NyoLte0O mIxu1ym9MrFmrX+qXE/hWkRlsGjOm8zVd6G74pCFRZ0FB9x0vp98u0JheHjuZUsDvJCTBQ XfP/JoTM93v6bRfbYpIseNeU7nxVfM7BN4ycd3s//PaVFK9GtyPacl6/izsmGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RW8Nv4n8yzq3c; Wed, 23 Aug 2023 14:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37NErpFq056041; Wed, 23 Aug 2023 14:53:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37NErpkR056038; Wed, 23 Aug 2023 14:53:51 GMT (envelope-from git) Date: Wed, 23 Aug 2023 14:53:51 GMT Message-Id: <202308231453.37NErpkR056038@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 3fc4f7c88085 - main - gicv3: Split out finding the page size List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3fc4f7c88085dc94c88348839074b8db6f19fae1 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=3fc4f7c88085dc94c88348839074b8db6f19fae1 commit 3fc4f7c88085dc94c88348839074b8db6f19fae1 Author: Andrew Turner AuthorDate: 2023-08-22 10:51:26 +0000 Commit: Andrew Turner CommitDate: 2023-08-23 14:29:34 +0000 gicv3: Split out finding the page size When adding indirect (2 level) tabled we will need to know the page size to calculate the size of the level 1 table. To allow for this find the page size before entering the loop to calculate the final register value. Reviewed by: gallatin, imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D41551 --- sys/arm64/arm64/gicv3_its.c | 72 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 0e2ccb5037ce..d67b19e7d345 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -424,6 +424,52 @@ gicv3_its_cmdq_init(struct gicv3_its_softc *sc) gic_its_write_8(sc, GITS_CWRITER, 0x0); } +static int +gicv3_its_table_page_size(struct gicv3_its_softc *sc, int table) +{ + uint64_t reg, tmp; + int page_size; + + page_size = PAGE_SIZE_64K; + reg = gic_its_read_8(sc, GITS_BASER(table)); + + while (1) { + reg &= GITS_BASER_PSZ_MASK; + switch (page_size) { + case PAGE_SIZE_4K: /* 4KB */ + reg |= GITS_BASER_PSZ_4K << GITS_BASER_PSZ_SHIFT; + break; + case PAGE_SIZE_16K: /* 16KB */ + reg |= GITS_BASER_PSZ_16K << GITS_BASER_PSZ_SHIFT; + break; + case PAGE_SIZE_64K: /* 64KB */ + reg |= GITS_BASER_PSZ_64K << GITS_BASER_PSZ_SHIFT; + break; + } + + /* Write the new page size */ + gic_its_write_8(sc, GITS_BASER(table), reg); + + /* Read back to check */ + tmp = gic_its_read_8(sc, GITS_BASER(table)); + + /* The page size is correct */ + if ((tmp & GITS_BASER_PSZ_MASK) == (reg & GITS_BASER_PSZ_MASK)) + return (page_size); + + switch (page_size) { + default: + return (-1); + case PAGE_SIZE_16K: + page_size = PAGE_SIZE_4K; + break; + case PAGE_SIZE_64K: + page_size = PAGE_SIZE_16K; + break; + } + } +} + static int gicv3_its_table_init(device_t dev, struct gicv3_its_softc *sc) { @@ -460,20 +506,30 @@ gicv3_its_table_init(device_t dev, struct gicv3_its_softc *sc) cache = GITS_BASER_CACHE_WAWB; } share = GITS_BASER_SHARE_IS; - page_size = PAGE_SIZE_64K; for (i = 0; i < GITS_BASER_NUM; i++) { reg = gic_its_read_8(sc, GITS_BASER(i)); /* The type of table */ type = GITS_BASER_TYPE(reg); + if (type == GITS_BASER_TYPE_UNIMPL) + continue; + /* The table entry size */ esize = GITS_BASER_ESIZE(reg); + /* Find the tables page size */ + page_size = gicv3_its_table_page_size(sc, i); + if (page_size == -1) { + device_printf(dev, "No valid page size for table %d\n", + i); + return (EINVAL); + } + switch(type) { case GITS_BASER_TYPE_DEV: nidents = (1 << devbits); its_tbl_size = esize * nidents; - its_tbl_size = roundup2(its_tbl_size, PAGE_SIZE_64K); + its_tbl_size = roundup2(its_tbl_size, page_size); break; case GITS_BASER_TYPE_VP: case GITS_BASER_TYPE_PP: /* Undocumented? */ @@ -540,18 +596,6 @@ gicv3_its_table_init(device_t dev, struct gicv3_its_softc *sc) continue; } - if ((tmp & GITS_BASER_PSZ_MASK) != - (reg & GITS_BASER_PSZ_MASK)) { - switch (page_size) { - case PAGE_SIZE_16K: - page_size = PAGE_SIZE_4K; - continue; - case PAGE_SIZE_64K: - page_size = PAGE_SIZE_16K; - continue; - } - } - if (tmp != reg) { device_printf(dev, "GITS_BASER%d: " "unable to be updated: %lx != %lx\n",