From nobody Wed Sep 04 21:50:42 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 4WzblQ6bMhz5VS2d; Wed, 04 Sep 2024 21:50:42 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WzblQ3wfTz4gkg; Wed, 4 Sep 2024 21:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725486642; 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=iAz0O1Fcn+Nxso0hOeCrilHLxlKXPAyEzD1arNyyb6o=; b=iVKeqt1WoTzrrvGUq3ojZr3wQ7qYxh4FGcI8D8jVbN2YB4BxD3Bnx+9+Pg+aWHV0+uWSJQ eGimNy7Z5Be9kEmB6CxoivV315VTpFlpxymeGYE7n3bui+sV+Bf6yFmvwkQeawR0f8ueZi ZSnmG43BVOQ99iBHrBl+iae+GEOGB6y/S8VbdJGM3vRm9hUs5L8gaxp2H6T4xGKGFoY2zG KVl75WyFef+uCH/du6Laz8W67zQ+2N9sqz50Cidb37eP/Z8MQVrprJTM0AEwZF1WEDZZVv dBOBQEJnp4GXvNj+V23rzdZuGIh9TP8aZU/aaKHou0/wbpFL7NUmRPRQTG2d0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725486642; a=rsa-sha256; cv=none; b=g8NXvz8vKPL77leVx63EHOUVttCxHFyjqBnUp1J5LGE+e22sa38nUPx2/EVvgwvNYYCS8s lNtoX0m3WOawRyFL/JvHj7frh5jf/Lr3JoPkfkNj8KEnY5bkM0dI115pubrP53sa4w4uoL pY+CSenXV9pCFvFpNnCZyZ4o+vE7lN1/V3/CzRCvNfhZnQ5Qpro+sTgR2XKjVUWqZ/uFLI tUP4oCWCac7x/ttZX/p5VRRiKHntOjyKcAWAx9Z4k0/PR511jxI/+WtUD1j+QdcvluwRne N4/aKeYMAI+/FdTwZn3b+tChpbx3owMFvOXh/WfTI9ZD0XwgnxZ3UQ4KEAGLpQ== 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=1725486642; 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=iAz0O1Fcn+Nxso0hOeCrilHLxlKXPAyEzD1arNyyb6o=; b=iIERrrL3kDMs6/jgESxl7bHHdfiDzZ43CcCqOWaEIOnsnYK5tfX7WJdpAxUUyJLmXe5OC0 5dORpMsz8LpjsZsrwvMw3RRuP2ykuUll1EEgcfp2qOwXHjoedwLq98p20qrD9q+danbkgR qL8Pa7Mh82E8ECyOmPUv52/xjxzFh85P898guf5OVXF5ahtHIJfOWRQOyHrzIx5oDt8CN8 jK9eb4/mL6daDEoyoiSkH4+bKRvJjPFgVjE9pAgmxJlzSv5zNc6heKltYfCjkpaNxpddt7 9zjpoEJaQgVidsS7eXstlbz2Vyedj6Rn22tjk1zCN+53FCVg+sX6gpfVg3ANmA== 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 4WzblQ3XsDzhL1; Wed, 4 Sep 2024 21:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 484LogAC031605; Wed, 4 Sep 2024 21:50:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484Log8b031602; Wed, 4 Sep 2024 21:50:42 GMT (envelope-from git) Date: Wed, 4 Sep 2024 21:50:42 GMT Message-Id: <202409042150.484Log8b031602@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f776a2b84972 - main - dmar_qi_XXX_invalidate_glob(): reduce code duplication 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f776a2b849726e7b86735b2930be64f5a2edf731 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f776a2b849726e7b86735b2930be64f5a2edf731 commit f776a2b849726e7b86735b2930be64f5a2edf731 Author: Konstantin Belousov AuthorDate: 2024-06-09 17:24:31 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-04 21:50:18 +0000 dmar_qi_XXX_invalidate_glob(): reduce code duplication Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/x86/iommu/intel_qi.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/sys/x86/iommu/intel_qi.c b/sys/x86/iommu/intel_qi.c index a94fbb54e7f7..b474d695552f 100644 --- a/sys/x86/iommu/intel_qi.c +++ b/sys/x86/iommu/intel_qi.c @@ -195,14 +195,14 @@ dmar_qi_invalidate_emit(struct iommu_domain *idomain, iommu_gaddr_t base, iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), pseq, emit_wait); } -void -dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit) +static void +dmar_qi_invalidate_glob_impl(struct dmar_unit *unit, uint64_t data1) { struct iommu_qi_genseq gseq; DMAR_ASSERT_LOCKED(unit); dmar_qi_ensure(DMAR2IOMMU(unit), 2); - dmar_qi_emit(unit, DMAR_IQ_DESCR_CTX_INV | DMAR_IQ_DESCR_CTX_GLOB, 0); + dmar_qi_emit(unit, data1, 0); iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), &gseq, true); /* See dmar_qi_invalidate_sync(). */ unit->x86c.inv_seq_waiters++; @@ -211,34 +211,24 @@ dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit) } void -dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit) +dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit) { - struct iommu_qi_genseq gseq; + dmar_qi_invalidate_glob_impl(unit, DMAR_IQ_DESCR_CTX_INV | + DMAR_IQ_DESCR_CTX_GLOB); +} - DMAR_ASSERT_LOCKED(unit); - dmar_qi_ensure(DMAR2IOMMU(unit), 2); - dmar_qi_emit(unit, DMAR_IQ_DESCR_IOTLB_INV | DMAR_IQ_DESCR_IOTLB_GLOB | - DMAR_IQ_DESCR_IOTLB_DW | DMAR_IQ_DESCR_IOTLB_DR, 0); - iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), &gseq, true); - /* See dmar_qi_invalidate_sync(). */ - unit->x86c.inv_seq_waiters++; - dmar_qi_advance_tail(DMAR2IOMMU(unit)); - iommu_qi_wait_for_seq(DMAR2IOMMU(unit), &gseq, false); +void +dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit) +{ + dmar_qi_invalidate_glob_impl(unit, DMAR_IQ_DESCR_IOTLB_INV | + DMAR_IQ_DESCR_IOTLB_GLOB | DMAR_IQ_DESCR_IOTLB_DW | + DMAR_IQ_DESCR_IOTLB_DR); } void dmar_qi_invalidate_iec_glob(struct dmar_unit *unit) { - struct iommu_qi_genseq gseq; - - DMAR_ASSERT_LOCKED(unit); - dmar_qi_ensure(DMAR2IOMMU(unit), 2); - dmar_qi_emit(unit, DMAR_IQ_DESCR_IEC_INV, 0); - iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), &gseq, true); - /* See dmar_qi_invalidate_sync(). */ - unit->x86c.inv_seq_waiters++; - dmar_qi_advance_tail(DMAR2IOMMU(unit)); - iommu_qi_wait_for_seq(DMAR2IOMMU(unit), &gseq, false); + dmar_qi_invalidate_glob_impl(unit, DMAR_IQ_DESCR_IEC_INV); } void