From nobody Fri Sep 27 17:34:45 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 4XFczT3ZM9z5YFcv; Fri, 27 Sep 2024 17:34:45 +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 4XFczT2n7wz4Cdx; Fri, 27 Sep 2024 17:34:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727458485; 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=9DZr/eN/bvDK5hIshzm8NBsl2UBf7lMKtVr4tnimpqM=; b=NCXdxeyrF2VOyrcefMmd2Hbtv3nq9qHjAP+Nh7qdH9XqrUG0nMSnT95+c7iWpNAArMTwXJ 8KxMVJg28oCapDhFqXGF1WGBVOqJg8mwQFj0J3byX6YuiwJHOg/ptvUagQ7BBzWU5ulR3R CtNM3CSZ8guoBX9Uzm7iwGneotmMkowKWO3iV3mo5j3+yWx9eS+YpUUYjdLh7xrP6E9z2o BPd7e9L1qG1p3h6MYyEBtk8xQV4kK6JW9RZsX4y9pDuwhApokZlqXikUu1gwmHvLp4QOnC rcWVNMkUeDyDHKbeOTcEqGW+bQeX7WCL0gfXi6fmfMEcqIzNKw3sshdskhvcXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727458485; 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=9DZr/eN/bvDK5hIshzm8NBsl2UBf7lMKtVr4tnimpqM=; b=uHAQOCJavusp1U/IawjaqXwjFp8Lf54TY1eu3CWSKhxY/im8AMFde8Zgc+/Q4kERcIS6B7 xBn5TWYtBKhF9VyhaIpBA3yvs5WZkFRymR7M0gq4wPW0iewggocPqgJG5fCRi9plYiddAN ZO+YuIITzyJv6ymMu0IhRKVbAAkTq5loH51j0O5zcsXxUOUCxsQ9lk6+tF+sTOIj6XvVej JjiZLkestOocWRSOxfltzungsM/w2TE5txn3Mmib0efZgT+DOGtXLk6d0XNfC88RsUEEQL dVV0d0mUaAzw8k0u+1e/Qgdj8wU9KbF3Q67edIuh+THijyvXd18Tcz4k1QV0rw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727458485; a=rsa-sha256; cv=none; b=TsQ+yKQ6qLzVQIhC5iMgg0jd5DlINKIR0Vc5FZIO1sC4CRocD2+JgMppj6HG3DatbbaUKV 9RLERp1Lcxc3XYxMl14a3NnjOu+jr+t50Fp4e1XMkhhyQbtAQ5dJ21cMaHkOzNCKAILt6S s3ELnJzNpujnPV5NxChGs4XcysW+FxRPYKR1LjFgHPpzwx5uYRtTiS8FOhYaNjdcXPV/Jd DZhyZbA++nvNmS2AkKqwXiXcMN4IKvD0g7N6gZ7L4I4QIVs38qAMV56U9V7iz/YFMUiUjr 1TOKw1iUsHffNR9pOcNi7ta+yDVTywh27paMbtxwh1+RpcobmBtMJX0YL4D+kw== 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 4XFczT2PK5zqb4; Fri, 27 Sep 2024 17:34:45 +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 48RHYjNt062678; Fri, 27 Sep 2024 17:34:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48RHYjvi062675; Fri, 27 Sep 2024 17:34:45 GMT (envelope-from git) Date: Fri, 27 Sep 2024 17:34:45 GMT Message-Id: <202409271734.48RHYjvi062675@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: d50403a6919a - main - iommu: add per-unit sysctls reporting the state of DMA and interrupt remapping 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: d50403a6919a641abfb0da4d60eb58ce42302de5 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d50403a6919a641abfb0da4d60eb58ce42302de5 commit d50403a6919a641abfb0da4d60eb58ce42302de5 Author: Konstantin Belousov AuthorDate: 2024-09-27 01:17:57 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-27 17:34:23 +0000 iommu: add per-unit sysctls reporting the state of DMA and interrupt remapping Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/arm64/iommu/iommu.c | 2 ++ sys/dev/iommu/busdma_iommu.c | 4 ++++ sys/dev/iommu/iommu.h | 1 + sys/x86/iommu/intel_drv.c | 2 ++ sys/x86/iommu/intel_intrmap.c | 5 ++++- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index af0edfee70d8..e7b5b2298e26 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -454,6 +454,7 @@ iommu_register(struct iommu_unit *iommu) LIST_INSERT_HEAD(&iommu_list, entry, next); IOMMU_LIST_UNLOCK(); + sysctl_ctx_init(&iommu->sysctl_ctx); iommu_init_busdma(iommu); return (0); @@ -474,6 +475,7 @@ iommu_unregister(struct iommu_unit *iommu) IOMMU_LIST_UNLOCK(); iommu_fini_busdma(iommu); + sysctl_ctx_free(&iommu->sysctl_ctx); mtx_destroy(&iommu->lock); diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index bddb466547d1..7a0ca39172f3 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -963,6 +963,10 @@ iommu_init_busdma(struct iommu_unit *unit) error = TUNABLE_INT_FETCH("hw.iommu.dma", &unit->dma_enabled); if (error == 0) /* compatibility */ TUNABLE_INT_FETCH("hw.dmar.dma", &unit->dma_enabled); + SYSCTL_ADD_INT(&unit->sysctl_ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(unit->dev)), + OID_AUTO, "dma", CTLFLAG_RD, &unit->dma_enabled, 0, + "DMA ops enabled"); TAILQ_INIT(&unit->delayed_maps); TASK_INIT(&unit->dmamap_load_task, 0, iommu_bus_task_dmamap, unit); unit->delayed_taskqueue = taskqueue_create("iommu", M_WAITOK, diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h index 9845b09e8732..957d4e14e8e2 100644 --- a/sys/dev/iommu/iommu.h +++ b/sys/dev/iommu/iommu.h @@ -67,6 +67,7 @@ struct iommu_unit { struct mtx lock; device_t dev; int unit; + struct sysctl_ctx_list sysctl_ctx; int dma_enabled; diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 05fb49538add..cc16759ebe34 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -256,6 +256,7 @@ dmar_release_resources(device_t dev, struct dmar_unit *unit) vm_object_deallocate(unit->ctx_obj); unit->ctx_obj = NULL; } + sysctl_ctx_free(&unit->iommu.sysctl_ctx); } #ifdef DEV_APIC @@ -337,6 +338,7 @@ dmar_attach(device_t dev) unit = device_get_softc(dev); unit->iommu.unit = device_get_unit(dev); unit->iommu.dev = dev; + sysctl_ctx_init(&unit->iommu.sysctl_ctx); dmaru = dmar_find_by_index(unit->iommu.unit); if (dmaru == NULL) return (EINVAL); diff --git a/sys/x86/iommu/intel_intrmap.c b/sys/x86/iommu/intel_intrmap.c index ec3cd35e4f4e..87bb7c791dd0 100644 --- a/sys/x86/iommu/intel_intrmap.c +++ b/sys/x86/iommu/intel_intrmap.c @@ -318,7 +318,10 @@ dmar_ir_free_irte(struct dmar_unit *unit, u_int cookie) int dmar_init_irt(struct dmar_unit *unit) { - + SYSCTL_ADD_INT(&unit->iommu.sysctl_ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(unit->iommu.dev)), + OID_AUTO, "ir", CTLFLAG_RD, &unit->ir_enabled, 0, + "Interrupt remapping ops enabled"); if ((unit->hw_ecap & DMAR_ECAP_IR) == 0) return (0); unit->ir_enabled = 1;