From nobody Tue Jul 19 03:25:58 2022 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 4Ln43q1G1Zz4Wncr; Tue, 19 Jul 2022 03:25:59 +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 4Ln43q0gmNz3Stb; Tue, 19 Jul 2022 03:25:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658201159; 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=jmw1KQPyamgCpr0ZZdklJ3F9wN19sQpR+IQxm/Ukqxc=; b=WX74+iJ+CVA1fDmTRZ466FMYvkxRyNmX+ih2Qqw45+Y1kmH2ivyw428CxdUqL5+3qWEIeX FlZMCVEhfQVy5WetF0MfbXKmSep1BHkp2L7wo7H4G4/ZUEOeZIEMyOCcCirKsQNVXksJqA 3pAITpMJ9NCV+xvqAyQ/p6Pw5l/VRGZI9wxDImwNJlyxEieJnuzkbrJvDbUJ+pOx6LdxQi y/UympraX85QipbAAJOel/30K97Yez2QFQzn6ypyeBXmGel6QAVk1rnLjKXxajBofPvVpY 9o/gxmv2HMElZ4pL+NYSRABJhxgDC81bL/4rrdX0p/5xr1JmRQPFS1yjz7THkA== 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 4Ln43p6pRLz13wk; Tue, 19 Jul 2022 03:25:58 +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 26J3PwcO083213; Tue, 19 Jul 2022 03:25:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26J3Pwe6083212; Tue, 19 Jul 2022 03:25:58 GMT (envelope-from git) Date: Tue, 19 Jul 2022 03:25:58 GMT Message-Id: <202207190325.26J3Pwe6083212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Cox Subject: git: 4eaaacc75535 - main - x86/iommu: Shrink the critical section in dmar_qi_task() 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: alc X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4eaaacc75535befdb9894cca4e0d8da376328fa4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658201159; 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=jmw1KQPyamgCpr0ZZdklJ3F9wN19sQpR+IQxm/Ukqxc=; b=rRWXxYVzBS8n2TBqMWmO41cAp2CR9gSGo8Sda+k1rxW0gKJd2RV9kk6PbOJUqVkxWciFha YgLVbI7Q08VoZm7ZhpC9XkW93UrohLmVvBLskjsXsdcIPW7gjNzsXr3wuZ9g7XeSfH73hI bjguWQTkg4Byut4BxLKGYkQoT38zPon2+ZDZsGp2DbXfgBOyWG+4crwfzcn4SFlGaAI9fk 7dXvRPT0j4cqFNBZnvY8PA+303KL/CtYZNH/zHElvF5HqbaiKqrKKy9d3/EKxDU14qMLm2 PTxiFDqYNEg4EjM9YwSl+4B1DbsinxVaaeuWCtInlJyGcsJtdueLjIbMmJiZTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658201159; a=rsa-sha256; cv=none; b=PQhO7HPbAovQ6WtfUNREKI8MHUtxt8ug6g82norzpjOtsYctPN4f4AJAWpQMiuY5FJ/yKP 20idAbrSuEXoSOdiqPQ01R7LQCRfj5iRiOObl3FXJSJaj2qfK81s6Zntg0zw+XBqoxeiPx 3XacadSCgdtFHMyA16aeC1vNFDC7NAFPrrQfZOj4LkLApTYoDqWAlBKutgzABIrDvR4Lwa 0srmxRnqm+96ddcArpFLffQbA2+e+BrlOiuTTZoa/pmvCqmwrBTsuR0zsMsfj31Ft/clI4 e6+jrqKSbuJB2wcN6htuYNhuydVaZVp2M9Otv7BSJWH36VLAHdMRUw90vOmuuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=4eaaacc75535befdb9894cca4e0d8da376328fa4 commit 4eaaacc75535befdb9894cca4e0d8da376328fa4 Author: Alan Cox AuthorDate: 2022-07-18 00:56:39 +0000 Commit: Alan Cox CommitDate: 2022-07-19 03:23:13 +0000 x86/iommu: Shrink the critical section in dmar_qi_task() It is safe to test and clear the Invalidation Wait Descriptor Complete flag before acquiring the DMAR lock in dmar_qi_task(), rather than waiting until the lock is held. Reviewed by: kib MFC after: 2 weeks --- sys/x86/iommu/intel_qi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/x86/iommu/intel_qi.c b/sys/x86/iommu/intel_qi.c index 894e3d537ac7..ca58715a227c 100644 --- a/sys/x86/iommu/intel_qi.c +++ b/sys/x86/iommu/intel_qi.c @@ -343,6 +343,16 @@ dmar_qi_task(void *arg, int pending __unused) unit = arg; + /* + * Request an interrupt on the completion of the next invalidation + * wait descriptor with the IF field set. + */ + ics = dmar_read4(unit, DMAR_ICS_REG); + if ((ics & DMAR_ICS_IWC) != 0) { + ics = DMAR_ICS_IWC; + dmar_write4(unit, DMAR_ICS_REG, ics); + } + DMAR_LOCK(unit); for (;;) { entry = TAILQ_FIRST(&unit->tlb_flush_entries); @@ -356,11 +366,6 @@ dmar_qi_task(void *arg, int pending __unused) IOMMU_MAP_ENTRY_QI_NF) == 0); DMAR_LOCK(unit); } - ics = dmar_read4(unit, DMAR_ICS_REG); - if ((ics & DMAR_ICS_IWC) != 0) { - ics = DMAR_ICS_IWC; - dmar_write4(unit, DMAR_ICS_REG, ics); - } if (unit->inv_seq_waiters > 0) wakeup(&unit->inv_seq_waiters); DMAR_UNLOCK(unit);