From nobody Sun Sep 18 06:27:10 2022 X-Original-To: dev-commits-src-branches@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 4MVdBl2tY2z4c33F; Sun, 18 Sep 2022 06:27:11 +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 4MVdBl1VS5z3YNg; Sun, 18 Sep 2022 06:27:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663482431; 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=/cANXApBJ92nAw40nh2dnhyhROq9leg+oijfWhRtH8Y=; b=kFN+DOdYWxMe4t9iLNztrSpEAu0d3uZtHjW4PZUydbdzSG3vI+C6jeqjDJg+PLjc8Ytabt qkTKybd6lKSWZxdMB++oP6g8uboskkhkzNsUFBmCudB3yEqFQSX8U80+yZDqDMlfKDMYlw mmxMFXgjOjClYPZTk9FdvxydJcUqY+TT/0pdL0f5LU4mD7t5u7nT/nzUlTtGUuiHK5tVQ2 BXvbhAHY500YsxSJalH0IRpCkIkSV8pLFDLS5L1K/Jo88zZEVGYZhT0hOjo3jyktw/q84g jnpa/IwPFcWs3d1M+qvMh5gTSwbAXDHtxtXHkj0rdPMP36cSIh4dNIFJgGp+QQ== 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 4MVdBl05YzzxYD; Sun, 18 Sep 2022 06:27:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28I6RA0b068041; Sun, 18 Sep 2022 06:27:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28I6RAQF068040; Sun, 18 Sep 2022 06:27:10 GMT (envelope-from git) Date: Sun, 18 Sep 2022 06:27:10 GMT Message-Id: <202209180627.28I6RAQF068040@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 354d310fe987 - stable/12 - arm64: gic: disable the ITS if it's enabled prior to configuration List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 354d310fe9871df0cbc3edfd5c3ef61ad39acfbf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663482431; 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=/cANXApBJ92nAw40nh2dnhyhROq9leg+oijfWhRtH8Y=; b=IpfkRnGD8Bp57+EflPafZLzfnmjCETiAbWzriTmiIwwu00pWNIL3ZFRM9yp5pAxW77CltI qDph6bUQVln4z3P+sQNMLnjdv3q0E4RcOfqmMuJK1EpQuNW2TR/3fTttaELcB6ntH70IoE aAU8agjzibTqns4tr6PVTzR9lrHkiXBOhHefVDKXQyR6Uf6EQfUS/SjMtMwnEvSxR7u3N4 Y7DLttmqI4SPnD4rgiMfzzncpM1p/w0rsxy8udQE5hcZ4LmN5L+eNRHPXQkGgj7esPp8ub KeGZe4FiEtmNwawhDpavtT34DkRbUm0iM+b5svIlusIoKvv+3YrR11n5VmypBQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663482431; a=rsa-sha256; cv=none; b=pSg+f3dnwSDXLeJ6xO03W+eTulRsseH3083435JHkLSLSofodFXGk9XULDodu7kc3597Yx jI0S3zPnUbosY56QhmYPpsVgnIcl47lQ5QjmhgtaUhvEP8NbVQ/PxNwbLi06MCO0P/+Ns5 Xx6gbfgKXlMt5OWvZWnnkTj+qqFH+WIKFE0/nN5XX1BKyAUqKC5c0rc8la2pn09bpCRkrs UfapYCdBYRINWx2nnNEPUnIbeqvM200Aw8uqlu3qFUhsL5rsrejovEEcdLmzDFRsjP2Z5P BFuzWipJrYBTTE2Dxas+HKUnoqIWXIfDSCI77fcvTSYy7sz+dW5I6t63aGaarg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=354d310fe9871df0cbc3edfd5c3ef61ad39acfbf commit 354d310fe9871df0cbc3edfd5c3ef61ad39acfbf Author: Kyle Evans AuthorDate: 2022-03-19 03:03:44 +0000 Commit: Kyle Evans CommitDate: 2022-09-17 19:29:35 +0000 arm64: gic: disable the ITS if it's enabled prior to configuration The ITS is defined to be disabled on a warm reset, but we may be coming in via another kernel/hypervisor type setup where the ITS has been previously configured then relinquished to the next kernel in the chain. If it's enabled, the later configuration of GITS_BASER will almost certainly fail -- clear it to prevent that. Reviewed by: andrew Sponsored by: Ampere Computing Submitted by: Klara, Inc. (cherry picked from commit 1236b04bb7045e541b2343543e356273db20ee56) --- sys/arm64/arm64/gicv3_its.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 6521752b5a62..465d01558ae2 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -784,7 +784,7 @@ gicv3_its_attach(device_t dev) { struct gicv3_its_softc *sc; const char *name; - uint32_t iidr; + uint32_t ctlr, iidr; int domain, err, i, rid; sc = device_get_softc(dev); @@ -813,6 +813,18 @@ gicv3_its_attach(device_t dev) } } + /* + * GIT_CTLR_EN is mandated to reset to 0 on a Warm reset, but we may be + * coming in via, for instance, a kexec/kboot style setup where a + * previous kernel has configured then relinquished control. Clear it + * so that we can reconfigure GITS_BASER*. + */ + ctlr = gic_its_read_4(sc, GITS_CTLR); + if ((ctlr & GITS_CTLR_EN) != 0) { + ctlr &= ~GITS_CTLR_EN; + gic_its_write_4(sc, GITS_CTLR, ctlr); + } + /* Allocate the private tables */ err = gicv3_its_table_init(dev, sc); if (err != 0) @@ -845,8 +857,7 @@ gicv3_its_attach(device_t dev) sc->sc_its_cols[cpu] = NULL; /* Enable the ITS */ - gic_its_write_4(sc, GITS_CTLR, - gic_its_read_4(sc, GITS_CTLR) | GITS_CTLR_EN); + gic_its_write_4(sc, GITS_CTLR, ctlr | GITS_CTLR_EN); /* Create the LPI configuration table */ gicv3_its_conftable_init(sc);