From nobody Wed Sep 11 08:44:34 2024 X-Original-To: dev-commits-src-all@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 4X3Yz71SmYz5W7q1; Wed, 11 Sep 2024 08:44:35 +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 4X3Yz70nCxz41rB; Wed, 11 Sep 2024 08:44:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726044275; 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=JcfyYemWPZeCDLon+VT0Jpf16eg4nB5N2d+1h1PNjBo=; b=rEWTmcAXTwPhDTqUbBtq5dj9tNRf4RKvLFTulNC2A5EtNp0AuupK6QfIw9Q+mgHCOmjczo 2Wh8WKiTIQE3JeY7WrTr76RSQZD9z/2tvRfvN9mYFkWO8CUL8fvOZ1MEJiSMuB2FZgtvgV vBRdaoxsnE4n73I79qbe2AaZdq57ae3dqebBJ9Or8OsUWtG3qfxyiphzjZJxYVYPXw+iZ4 GDJ5s4BviUTasOGcZVXCosQP/qoM3chYClluiOZgOHiatPaTbnS/7BfV9mFPunjLbzXuzn QiFM4FOA1yB1OilhXQAyfGHm5AVWgbxREGl4clYzGEvwbnB/9oNyfTQu1j7mDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726044275; a=rsa-sha256; cv=none; b=Fy3fFQQe9KMWyn7GLd/SATNfRXZ67h9HGEEvSA0GNohlIZORZFAI8a23GyF+n7jK7BS5ne ZtTgMbQg2I/mBO61vNFK0XpgOVUO4LIPVK3KDIh8P7KxAL8r/U9hVo4NdGYD/eNOpKwYFw d5iMCSHQRsGj1/VsZzh+gAs9AnGkJ/AMQL2Xm7po3NnmwU5r/mTGHXwzpA6ZgHzeyWNMyi JUONqEK2m+htxhlTre4+WwL/Nzx2sy/TKdkbhcsXwTsyEAv4FDNjaycCHovKficCK4bVGK BFMa+eUIAiRhW+T/CHZeveps7fpaMpBuad0AidetZy1ONmWsY8CXlczYZHWyxA== 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=1726044275; 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=JcfyYemWPZeCDLon+VT0Jpf16eg4nB5N2d+1h1PNjBo=; b=rZO6llcYxia8FH9tOK6aE4ap78vUGSQ7zPrxfboN3IqikFRcHMi+nUnaga1/fl8e1lyOxL JprJ8RNjCMBDT/BzBc7ZTeqxdPTT2VYJpuv76wXjv6LEhH9UQG5Z64LiWfpjWpMvn/t3x0 Z+g1AG35FQrQn8LeA4nGK5VAE/ck/xL4HxLclxGrbn5qHQq76gw6b7SRwiKhbjBKy2g8gI LZeE5+hmcGt162204rifKQRTWAoV9iEWfqq643/xZAf7HZzyeorLH5eSCFaIVyiUwDwwkZ MxfXT+R6aaBwKRYu7pSSbeZbUKVl/MO0yn7mYP6i6BfF1Hnwg4j3XuBpOoak8g== 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 4X3Yz705XMzP9l; Wed, 11 Sep 2024 08:44:35 +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 48B8iYqh007990; Wed, 11 Sep 2024 08:44:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48B8iY79007987; Wed, 11 Sep 2024 08:44:34 GMT (envelope-from git) Date: Wed, 11 Sep 2024 08:44:34 GMT Message-Id: <202409110844.48B8iY79007987@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1dfa8765409b - stable/14 - busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 1dfa8765409b1f1424c66ec9584768033a97ef19 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1dfa8765409b1f1424c66ec9584768033a97ef19 commit 1dfa8765409b1f1424c66ec9584768033a97ef19 Author: Konstantin Belousov AuthorDate: 2024-07-27 16:28:01 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-11 08:44:00 +0000 busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx() (cherry picked from commit ba33e74c7d48479784896807eb8a1c2e1012d163) --- sys/arm64/iommu/iommu.c | 5 +++++ sys/dev/iommu/busdma_iommu.c | 6 +----- sys/dev/iommu/iommu.h | 1 + sys/x86/iommu/intel_drv.c | 8 ++++++++ sys/x86/iommu/iommu_utils.c | 6 ++++++ sys/x86/iommu/x86_iommu.h | 1 + 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index 331553a93623..d876d443ffa0 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -503,6 +503,11 @@ iommu_find(device_t dev, bool verbose) return (NULL); } +void +iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ +} + void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free, bool cansleep __unused) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 565067488435..0d86ff0d4468 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -279,11 +279,7 @@ iommu_get_dev_ctx(device_t dev) if (!unit->dma_enabled) return (NULL); -#if defined(__amd64__) || defined(__i386__) - dmar_quirks_pre_use(unit); - dmar_instantiate_rmrr_ctxs(unit); -#endif - + iommu_unit_pre_instantiate_ctx(unit); return (iommu_instantiate_ctx(unit, dev, false)); } diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h index 157f4c62423f..9845b09e8732 100644 --- a/sys/dev/iommu/iommu.h +++ b/sys/dev/iommu/iommu.h @@ -158,6 +158,7 @@ void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free, void iommu_domain_unload(struct iommu_domain *domain, struct iommu_map_entries_tailq *entries, bool cansleep); +void iommu_unit_pre_instantiate_ctx(struct iommu_unit *iommu); struct iommu_ctx *iommu_instantiate_ctx(struct iommu_unit *iommu, device_t dev, bool rmrr); device_t iommu_get_requester(device_t dev, uint16_t *rid); diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 2439ef9e4ef5..05fb49538add 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -1310,8 +1310,16 @@ dmar_get_x86_common(struct iommu_unit *unit) return (&dmar->x86c); } +static void +dmar_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ + dmar_quirks_pre_use(unit); + dmar_instantiate_rmrr_ctxs(unit); +} + static struct x86_iommu dmar_x86_iommu = { .get_x86_common = dmar_get_x86_common, + .unit_pre_instantiate_ctx = dmar_unit_pre_instantiate_ctx, .domain_unload_entry = dmar_domain_unload_entry, .domain_unload = dmar_domain_unload, .get_ctx = dmar_get_ctx, diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index 5d22c6584ab7..2c647fd21c67 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -278,6 +278,12 @@ iommu_unmap_ioapic_intr(u_int ioapic_id, u_int *cookie) return (x86_iommu->unmap_ioapic_intr(ioapic_id, cookie)); } +void +iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ + x86_iommu->unit_pre_instantiate_ctx(unit); +} + #define IOMMU2X86C(iommu) (x86_iommu->get_x86_common(iommu)) static bool diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h index 210ce82c8f6d..a1ed5c71c513 100644 --- a/sys/x86/iommu/x86_iommu.h +++ b/sys/x86/iommu/x86_iommu.h @@ -64,6 +64,7 @@ struct x86_unit_common; struct x86_iommu { struct x86_unit_common *(*get_x86_common)(struct iommu_unit *iommu); + void (*unit_pre_instantiate_ctx)(struct iommu_unit *iommu); void (*qi_ensure)(struct iommu_unit *unit, int descr_count); void (*qi_emit_wait_descr)(struct iommu_unit *unit, uint32_t seq, bool, bool, bool);