From nobody Wed Sep 04 21:50:53 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 4Wzblf0rSQz5VS0R; Wed, 04 Sep 2024 21:50:54 +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 4Wzbld60f3z4hdb; Wed, 4 Sep 2024 21:50:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725486653; 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=wgjRc5w1urqs/hyAo6vC0UXLYdh7sxZ3tMC6ou+rzPo=; b=nX9kGZs1xyx7oiDTT1N3n1lOFCZWgnZHvobyk9FAuYbkryiE7XPmTZRkg6MOTksoAi6y17 PCYq/UqTQ6e+FruC3b3u79pKJflu8BAOMEys3C+cF28sau1pdGpud8gE5UkhdwiLi3YGbJ aTdlpqrWVaxNgsRH/Y/VZRlfcz4+FOn6JNl+tyKXdXgeu1bwhwLnvhbqkdvJhAuloztas6 X70zy6lfzqJYuz02pLDduWMdc4flmlAtoDtOcqMo/zSXYFfj9+JpYTAmm+vfBg1c/jYSy5 LVoBpw8aF62sRkpTwymE+dxqUPnQBUhcN1l9fHL9VzN4rLCN7KmVlFo4GLcmww== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725486653; a=rsa-sha256; cv=none; b=r/FRSxcJF137JHsCtaYNHr4B987M+5sqsqZBd+X7ZYDKF59jUKohabVh1dnAE2/fSmFS3H WrxmXeieQwFwZ8fhFiA8J6KxAGkQqA5e/6Ic7CMBkSsio/V3yf6ioRfyE5T2YYoVI+NXz4 Vz9kQZipGLEcaW1BBBBV3MaqSm1kihbVLrwgorzQxokR6MAe7l0CqBHVk5oMkMU5uiKDe3 DrHCfU0XXC0RD/iTRu4DJSWGa/Cuz40ZZVNf2KNyD/6dkgPGnEK28iN6QRvyOxga+xTSwZ oarKp2gOJfIUVdPK9ekJ3r9ImlW1F4esSK9SzBvU5hKhXVm0Yd0SjqMx1RJwhQ== 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=1725486653; 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=wgjRc5w1urqs/hyAo6vC0UXLYdh7sxZ3tMC6ou+rzPo=; b=S3sxMUINg5F0AdxUnksESraOfqDRffWAYL5wS2BIszN8wbPaHRPdEkJicV9lJLxYL8Z/Ef q5xwoPX9WcFqjSFieXKE9SDjjUxTxC+9ZHIRo9A/whoZBJbMYtEyeNzyKj7D4GZ0CaBm8A ZNgkEKav+8yK69rOfGD3Zy+0s/arwmRwfE+axa9o3LjlGoiGxf/7J5bFJtWC9sKUVQe/kR YmDYy0qU6JRGqjz+nSmuWG9KFLL/uz6akr4q4LUXuXHSUZzi3X0cUgkfoX1L5ZKcjyBUQU aXorP39JtWQTY6EchzmbyC3lbZmwSMsOyyLkAvZSmSjt6wWJ0oetXPKTANvbKw== 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 4Wzbld5byyzhFV; Wed, 4 Sep 2024 21:50:53 +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 484Lor6P033056; Wed, 4 Sep 2024 21:50:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484LorVp033053; Wed, 4 Sep 2024 21:50:53 GMT (envelope-from git) Date: Wed, 4 Sep 2024 21:50:53 GMT Message-Id: <202409042150.484LorVp033053@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: ba33e74c7d48 - main - busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx() 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: ba33e74c7d48479784896807eb8a1c2e1012d163 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ba33e74c7d48479784896807eb8a1c2e1012d163 commit ba33e74c7d48479784896807eb8a1c2e1012d163 Author: Konstantin Belousov AuthorDate: 2024-07-27 16:28:01 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-04 21:50:19 +0000 busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx() Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- 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 b765763e3a60..af0edfee70d8 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -501,6 +501,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 3d554249ba3f..bddb466547d1 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -278,11 +278,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);