From nobody Tue Jul 26 06:08:09 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 4LsRKj5ZJyz4XFlm; Tue, 26 Jul 2022 06:08:09 +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 4LsRKj56zXz3Qkp; Tue, 26 Jul 2022 06:08:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658815689; 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=7aQE3T2v4AOjTrIGQ0VP6vu+7JR7mJdfBKoCapyqIDo=; b=C5ABu3o89eay4unwa2nejCa5MllnjjYjXgTEhLq0ptgSEmcImnODe2aQC3ywvgxulsWsDf 1IlQqPd50LxBRkJT2WOyFh+H1UJxMcOeivyrUA1eYjskxaQxDZNNiqlmiOXLqHR5bG5Cl2 lMozXHQeTTKy9bmlTdI5X1e+0E47NQ2FlbRwJibSE1F8JL3juRALlsvI8uD5WVPMQLbG7K 27XgHwVjw8dZZ2SF+cpdMuLcNTNC9lot7rvH/JMbY9q4FgHkt6SDotTc1MwdD5GtnyNwS0 FdynP1pZdHC6RC8Z0Zjqm0bJ5Omhex7KUZQsOcBQJejgwYUFFVvjcChzoAAvpw== 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 4LsRKj442BzRB6; Tue, 26 Jul 2022 06:08:09 +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 26Q6896V034676; Tue, 26 Jul 2022 06:08:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26Q689or034675; Tue, 26 Jul 2022 06:08:09 GMT (envelope-from git) Date: Tue, 26 Jul 2022 06:08:09 GMT Message-Id: <202207260608.26Q689or034675@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: c25156347083 - main - x86/iommu: Correct a recent change to iommu_domain_unload_entry() 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: c251563470831c34cf53242936425a0d4d995edf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658815689; 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=7aQE3T2v4AOjTrIGQ0VP6vu+7JR7mJdfBKoCapyqIDo=; b=pyrP9uJCd6A3jSEUMHqY6qqg+l5txl+nOwEgvQY7EmyuovM+8gKJSFj4BA8OF5BH562pWS HtTGvZ53P8UPRzQlqBeGWJfj8XsuJZ1XHaqA433CkUD/lzHq93hIxOfqFtR8ChDwZSVOvm o0zbKAItUEWRw30UDxAOLcN1kvMTIjo/+fusYIIWiSuIGCXYMRzHrF0V4x9JGTYmMKkNa+ I5+CLD+pF8Y9svM488qAmq8Ftg2lYZRJJRlvfrYGoF0vIdNi9nYfhs/k8c1lsfUrlXZ7IB OM3WVOtfPyi9/3wnHmqG1s7B+ttn5zjzwSDz4sNfdClE7w9/zHSBIm/G85c9KA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658815689; a=rsa-sha256; cv=none; b=KA/ZHPc6i4a4M+Kzfp7DsD9PeYokOHroq/rsJjf+mJNkOwCJQOUEWMCnVRetp5EyB9kdm7 4sVNHwhhLvOuoyGa7xn5CmcgnsCVe5SStMQS1A0aTO6Yxptv4K82KgZkeurTABwEd3ZX2+ qHPJtUDV2rL73ssbW7oHrolIwCIhWEWbNH6Ngb3Q+TZzqaQJD0yl27CF+t36uAjsCyZCpB QO/u4XYFvt3oYmG+r2pUbi0TVPP5P4Q4TxnoyuOX+W9hC6ij3RUU5q/4lAzYAkfgf4O6sc vj1LgmWdG4b1QCD9crSA+h1WTEP7NTSJqO2/v/gKFwU/kCsbhQgI+dQW44tPlw== 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=c251563470831c34cf53242936425a0d4d995edf commit c251563470831c34cf53242936425a0d4d995edf Author: Alan Cox AuthorDate: 2022-07-26 04:53:15 +0000 Commit: Alan Cox CommitDate: 2022-07-26 06:07:21 +0000 x86/iommu: Correct a recent change to iommu_domain_unload_entry() Correct 8bc367384745. When iommu_domain_unload_entry() performs a synchronous IOTLB invalidation, it must call dmar_domain_free_entry() to remove the entry from the domain's RB_TREE. Push down the acquisition and release of the DMAR lock into the recently introduced function dmar_qi_invalidate_sync_locked() and remove the _locked suffix. MFC with: 8bc367384745 --- sys/x86/iommu/intel_ctx.c | 7 ++++--- sys/x86/iommu/intel_dmar.h | 4 ++-- sys/x86/iommu/intel_qi.c | 9 ++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index 5e13f020264b..936cf8bb7632 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -883,17 +883,18 @@ iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free, * dmar_qi_task() is finished processing it. */ if (unit->qi_enabled) { - DMAR_LOCK(unit); if (free) { + DMAR_LOCK(unit); dmar_qi_invalidate_locked(domain, entry->start, entry->end - entry->start, &entry->gseq, true); TAILQ_INSERT_TAIL(&unit->tlb_flush_entries, entry, dmamap_link); + DMAR_UNLOCK(unit); } else { - dmar_qi_invalidate_sync_locked(domain, entry->start, + dmar_qi_invalidate_sync(domain, entry->start, entry->end - entry->start, cansleep); + dmar_domain_free_entry(entry, false); } - DMAR_UNLOCK(unit); } else { domain_flush_iotlb_sync(domain, entry->start, entry->end - entry->start); diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h index 0f811d760bb7..06cecdf704ff 100644 --- a/sys/x86/iommu/intel_dmar.h +++ b/sys/x86/iommu/intel_dmar.h @@ -251,8 +251,8 @@ int dmar_init_qi(struct dmar_unit *unit); void dmar_fini_qi(struct dmar_unit *unit); void dmar_qi_invalidate_locked(struct dmar_domain *domain, iommu_gaddr_t start, iommu_gaddr_t size, struct iommu_qi_genseq *psec, bool emit_wait); -void dmar_qi_invalidate_sync_locked(struct dmar_domain *domain, - iommu_gaddr_t start, iommu_gaddr_t size, bool cansleep); +void dmar_qi_invalidate_sync(struct dmar_domain *domain, iommu_gaddr_t start, + iommu_gaddr_t size, bool cansleep); void dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit); void dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit); void dmar_qi_invalidate_iec_glob(struct dmar_unit *unit); diff --git a/sys/x86/iommu/intel_qi.c b/sys/x86/iommu/intel_qi.c index 174cf9ea19a8..32f01a2787b0 100644 --- a/sys/x86/iommu/intel_qi.c +++ b/sys/x86/iommu/intel_qi.c @@ -243,14 +243,17 @@ dmar_qi_invalidate_locked(struct dmar_domain *domain, iommu_gaddr_t base, } void -dmar_qi_invalidate_sync_locked(struct dmar_domain *domain, iommu_gaddr_t base, +dmar_qi_invalidate_sync(struct dmar_domain *domain, iommu_gaddr_t base, iommu_gaddr_t size, bool cansleep) { + struct dmar_unit *unit; struct iommu_qi_genseq gseq; - DMAR_ASSERT_LOCKED(domain->dmar); + unit = domain->dmar; + DMAR_LOCK(unit); dmar_qi_invalidate_locked(domain, base, size, &gseq, true); - dmar_qi_wait_for_seq(domain->dmar, &gseq, !cansleep); + dmar_qi_wait_for_seq(unit, &gseq, !cansleep); + DMAR_UNLOCK(unit); } void