From nobody Wed Feb 28 14:10:44 2024 X-Original-To: dev-commits-src-main@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 4TlGTw5CKvz5BfSn; Wed, 28 Feb 2024 14:10:44 +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 4TlGTw2RD9z4fgW; Wed, 28 Feb 2024 14:10:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709129444; 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=uZABjtx+ikSrt4hFBymsOvrZUlEFk/TafnuHCIntJwk=; b=f1ZgHLzhmhiIv/aqFpBrJNH44qW1gG2kri25t5AyaLMsepiOiAJc2+6CzCi3h/8KWGcFNU xHpK9yJn2yH1LSw0Z7KPrWfey68pv7SYRY5CdyGNrdKCYsq3zf1zcDBFAtEdnYya5bLfFH LO/vyck+UqTMNBq063H5cduRtEt91SGpcLu9Pjd3+ErzQ2RTJOMbUk1JMKHkmVXKTRn0u1 gUdM5SbEtefH6LGT64adqFTX4JPdrOGIJSfdijm5qO5QD2S0xlFenUhmHDsvf2XddT5mgk DSV3N2NCf5kVP540eMLtflRSCGjQM1dgT8OnLS4RYNWbvguGsACnLzjjTmia7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709129444; a=rsa-sha256; cv=none; b=R2MqVh8NzK5wKj5/3S+8n5nMLrB8CGhcKWO47oywgDCJa+q8rysQD9V9ZGXTODIOiz5fpw 0JYJ5H7hDqlNkt1vefw66Bj3Zf4zFPWjBYtDipGE+byvxRQpLG9aQKpNPzk0Yw+hUwYMB2 t/J3Lt+muvOYvFRzdajB0DgyENijXh8oGECrLJfyYvm7Ef/dHouKtq6sq97+Z8ptR6hLLu Mm7fjaeuaDVb/9IqbEeVBDcn7EDqNbH1t+Q3jI1tbjjYXCK0NhG00UJNjEE5CX5Y+b+A5W Qo0KRByGfHRqKe0rWgKqf0EH71ZnKwTL0Yfbh7LZGGA/NLu0sMZkQMNp3dqz2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709129444; 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=uZABjtx+ikSrt4hFBymsOvrZUlEFk/TafnuHCIntJwk=; b=hxvBsjqMoOchhSqLXc5cPbD+kAffkzoLgCg9Me9RW1YAlMweU8wRHnsNfQj8IA1k9/FMgm RkVTqOZEwX5l1HPsSQyXxfYBX83tU2sUFkjZMU/6e7jmJapBJdUF7i/zIyAl3BvVOalPKz 1L/NZEG1M5RkXZsX2Ctiui299lThIHh6FEmkouHmYfpEBURsgk9tduaxrgEIvLMVUWZfy3 px5RyTYNP7K2DitGVTf61d5mV2MhcKx2M818f/uEPMjS23aJpyqF5uiEIe7Jd0r15Vdful qbB15+MdOe87tXh5nMD+0hofSRnJNzV8w0shqAuCZREaeubmB50EfKVodrFddQ== 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 4TlGTw1PxRz113R; Wed, 28 Feb 2024 14:10:44 +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 41SEAiFk058230; Wed, 28 Feb 2024 14:10:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41SEAiIS058227; Wed, 28 Feb 2024 14:10:44 GMT (envelope-from git) Date: Wed, 28 Feb 2024 14:10:44 GMT Message-Id: <202402281410.41SEAiIS058227@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: ae84491a3594 - main - gicv3: Only set the redistributor base if we're not prealloced List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae84491a3594c542f2aedc9340581cbb30386c1e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ae84491a3594c542f2aedc9340581cbb30386c1e commit ae84491a3594c542f2aedc9340581cbb30386c1e Author: Warner Losh AuthorDate: 2024-02-28 14:08:39 +0000 Commit: Warner Losh CommitDate: 2024-02-28 14:09:42 +0000 gicv3: Only set the redistributor base if we're not prealloced Only set the redistributor base if we're not reallocated. If we are preallocated, leave it all alone. Sponsored by: Netflix Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D44035 --- sys/arm64/arm64/gicv3_its.c | 134 +++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 63 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index c7e9ef7a3733..74d6f617bbba 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -745,81 +745,89 @@ static void its_init_cpu_lpi(device_t dev, struct gicv3_its_softc *sc) { device_t gicv3; - uint64_t xbaser, tmp; + uint64_t xbaser, tmp, size; uint32_t ctlr; u_int cpuid; gicv3 = device_get_parent(dev); cpuid = PCPU_GET(cpuid); - /* Disable LPIs */ - ctlr = gic_r_read_4(gicv3, GICR_CTLR); - ctlr &= ~GICR_CTLR_LPI_ENABLE; - gic_r_write_4(gicv3, GICR_CTLR, ctlr); - - /* Make sure changes are observable my the GIC */ - dsb(sy); - /* - * Set the redistributor base + * Set the redistributor base. If we're reusing what we found on boot + * since the gic was already running, then don't touch it here. We also + * don't need to disable / enable LPI if we're not changing PROPBASER, + * so only do that if we're not prealloced. */ - xbaser = vtophys(sc->sc_conf_base) | - (GICR_PROPBASER_SHARE_IS << GICR_PROPBASER_SHARE_SHIFT) | - (GICR_PROPBASER_CACHE_NIWAWB << GICR_PROPBASER_CACHE_SHIFT) | - (flsl(LPI_CONFTAB_SIZE | GIC_FIRST_LPI) - 1); - gic_r_write_8(gicv3, GICR_PROPBASER, xbaser); - - /* Check the cache attributes we set */ - tmp = gic_r_read_8(gicv3, GICR_PROPBASER); - - if ((tmp & GICR_PROPBASER_SHARE_MASK) != - (xbaser & GICR_PROPBASER_SHARE_MASK)) { - if ((tmp & GICR_PROPBASER_SHARE_MASK) == - (GICR_PROPBASER_SHARE_NS << GICR_PROPBASER_SHARE_SHIFT)) { - /* We need to mark as non-cacheable */ - xbaser &= ~(GICR_PROPBASER_SHARE_MASK | - GICR_PROPBASER_CACHE_MASK); - /* Non-cacheable */ - xbaser |= GICR_PROPBASER_CACHE_NIN << - GICR_PROPBASER_CACHE_SHIFT; - /* Non-shareable */ - xbaser |= GICR_PROPBASER_SHARE_NS << - GICR_PROPBASER_SHARE_SHIFT; - gic_r_write_8(gicv3, GICR_PROPBASER, xbaser); + if ((sc->sc_its_flags & ITS_FLAGS_LPI_PREALLOC) == 0) { + /* Disable LPIs */ + ctlr = gic_r_read_4(gicv3, GICR_CTLR); + ctlr &= ~GICR_CTLR_LPI_ENABLE; + gic_r_write_4(gicv3, GICR_CTLR, ctlr); + + /* Make sure changes are observable my the GIC */ + dsb(sy); + + size = (flsl(LPI_CONFTAB_SIZE | GIC_FIRST_LPI) - 1); + + xbaser = vtophys(sc->sc_conf_base) | + (GICR_PROPBASER_SHARE_IS << GICR_PROPBASER_SHARE_SHIFT) | + (GICR_PROPBASER_CACHE_NIWAWB << GICR_PROPBASER_CACHE_SHIFT) | + size; + + gic_r_write_8(gicv3, GICR_PROPBASER, xbaser); + + /* Check the cache attributes we set */ + tmp = gic_r_read_8(gicv3, GICR_PROPBASER); + + if ((tmp & GICR_PROPBASER_SHARE_MASK) != + (xbaser & GICR_PROPBASER_SHARE_MASK)) { + if ((tmp & GICR_PROPBASER_SHARE_MASK) == + (GICR_PROPBASER_SHARE_NS << GICR_PROPBASER_SHARE_SHIFT)) { + /* We need to mark as non-cacheable */ + xbaser &= ~(GICR_PROPBASER_SHARE_MASK | + GICR_PROPBASER_CACHE_MASK); + /* Non-cacheable */ + xbaser |= GICR_PROPBASER_CACHE_NIN << + GICR_PROPBASER_CACHE_SHIFT; + /* Non-shareable */ + xbaser |= GICR_PROPBASER_SHARE_NS << + GICR_PROPBASER_SHARE_SHIFT; + gic_r_write_8(gicv3, GICR_PROPBASER, xbaser); + } + sc->sc_its_flags |= ITS_FLAGS_LPI_CONF_FLUSH; } - sc->sc_its_flags |= ITS_FLAGS_LPI_CONF_FLUSH; - } - /* - * Set the LPI pending table base - */ - xbaser = vtophys(sc->sc_pend_base[cpuid]) | - (GICR_PENDBASER_CACHE_NIWAWB << GICR_PENDBASER_CACHE_SHIFT) | - (GICR_PENDBASER_SHARE_IS << GICR_PENDBASER_SHARE_SHIFT); - - gic_r_write_8(gicv3, GICR_PENDBASER, xbaser); - - tmp = gic_r_read_8(gicv3, GICR_PENDBASER); - - if ((tmp & GICR_PENDBASER_SHARE_MASK) == - (GICR_PENDBASER_SHARE_NS << GICR_PENDBASER_SHARE_SHIFT)) { - /* Clear the cahce and shareability bits */ - xbaser &= ~(GICR_PENDBASER_CACHE_MASK | - GICR_PENDBASER_SHARE_MASK); - /* Mark as non-shareable */ - xbaser |= GICR_PENDBASER_SHARE_NS << GICR_PENDBASER_SHARE_SHIFT; - /* And non-cacheable */ - xbaser |= GICR_PENDBASER_CACHE_NIN << - GICR_PENDBASER_CACHE_SHIFT; - } + /* + * Set the LPI pending table base + */ + xbaser = vtophys(sc->sc_pend_base[cpuid]) | + (GICR_PENDBASER_CACHE_NIWAWB << GICR_PENDBASER_CACHE_SHIFT) | + (GICR_PENDBASER_SHARE_IS << GICR_PENDBASER_SHARE_SHIFT); + + gic_r_write_8(gicv3, GICR_PENDBASER, xbaser); + + tmp = gic_r_read_8(gicv3, GICR_PENDBASER); + + if ((tmp & GICR_PENDBASER_SHARE_MASK) == + (GICR_PENDBASER_SHARE_NS << GICR_PENDBASER_SHARE_SHIFT)) { + /* Clear the cahce and shareability bits */ + xbaser &= ~(GICR_PENDBASER_CACHE_MASK | + GICR_PENDBASER_SHARE_MASK); + /* Mark as non-shareable */ + xbaser |= GICR_PENDBASER_SHARE_NS << GICR_PENDBASER_SHARE_SHIFT; + /* And non-cacheable */ + xbaser |= GICR_PENDBASER_CACHE_NIN << + GICR_PENDBASER_CACHE_SHIFT; + } - /* Enable LPIs */ - ctlr = gic_r_read_4(gicv3, GICR_CTLR); - ctlr |= GICR_CTLR_LPI_ENABLE; - gic_r_write_4(gicv3, GICR_CTLR, ctlr); + /* Enable LPIs */ + ctlr = gic_r_read_4(gicv3, GICR_CTLR); + ctlr |= GICR_CTLR_LPI_ENABLE; + gic_r_write_4(gicv3, GICR_CTLR, ctlr); - /* Make sure the GIC has seen everything */ - dsb(sy); + /* Make sure the GIC has seen everything */ + dsb(sy); + } } static int