From nobody Tue Nov 26 22:00:35 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 4Xyc2X1mx5z5f4tB; Tue, 26 Nov 2024 22:00:36 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xyc2W6TkBz4GRg; Tue, 26 Nov 2024 22:00:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732658435; 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=Zl8sms29TEcYQZSeZSMrErGF4thlYRdUIiKoYdoV5K4=; b=nn0q5zCJFu13yaKvil28QYLDNnZuR0miOqC7ZaInuD64p8NDYdcxvMQVCybHqeu6WAlKGL EqD6jcfVD2y/1X5bGD5Yt9oV2u+QEwnGTpRPybNg518omo29y1aCjXLFsq1mDL7UKRYWE5 PBE82BuojNIJntsFNvVb9fraODldxThAfwZg/9dbqrvaLBWgJDW69pXcmzNo99V+xIZI7K 6QQz1x5tdKe8MkYHZA0aVEy7mNr5Ghwrai3eaPhW4qVdsoSheSMom69v92f8jbuKQUNqlf d63N1l6THmdYm5hYanxEYNt3jcn2cJMBfjhIxqC3xars/RWHMBKsIEnY1EwKuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732658435; 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=Zl8sms29TEcYQZSeZSMrErGF4thlYRdUIiKoYdoV5K4=; b=Vel0wpJsA3s+w0Cj9oaGVq1fq/dPtcVpJr1ht+seHxtsmT5lAuQvuF+fFrauac0ZyFiKJS QZPMSM36ha194sr4oXM+gdkOrYKHjWmxlMvzxEoJCLZAfjjKa9a2H5nb4/Rur1HlQXQisE tuOuDuPDKqTHIBUvRy3nlx/H6KgfOSvwTq6OUhPZAAOK2Dt7f8MDyGNmnimJoGoPqKp/XY 53DGSSt+Ew3u9w68kg5q8EBRsq0w3zjyEpqXrdqPy9QdrubtlEIMDRc1iGFi68mUQ1Jx5l c2YIiDkvO19sh7WP5MsIExWDpVzZx0+Ote0J7pCNxZ1bsq+eiIWxeF2FUrWMGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732658435; a=rsa-sha256; cv=none; b=VmY5ktAi2O5xUOTVkHM9N+euiD6f9VJmhzSvQWsoBrPc5disNMq1if5JnN03n8t5XyGDLf eu/tbL3ju+R+R9D7Kj9IrffX0y/x7StAGSaYMY0W30H+boDNotWG0wbIEnIl1AUq/MVBF9 uL3IW2BdgfamefvmO/TwGo87jJ4ALGtpNsv/645cPZPG26GXvJpPp8kIFT2RUMHZab2BvX MghOeGLqv4vRlhhKXVMGSRbudy1nOyt3nv+oyA4QyKjRwub/jgTAZ1K4wslKxcsxNs6L7j Tqik3L5KsYtSDuqd/BsuqaeZ6NHbfCYxpk9m1BSwfuu4a/ujogf6YEtpyFqBng== 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 4Xyc2W62ZBzjJT; Tue, 26 Nov 2024 22:00: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 4AQM0ZEL095324; Tue, 26 Nov 2024 22:00:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AQM0ZDl095321; Tue, 26 Nov 2024 22:00:35 GMT (envelope-from git) Date: Tue, 26 Nov 2024 22:00:35 GMT Message-Id: <202411262200.4AQM0ZDl095321@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: 3f0289ea7f66 - main - dmar: set acpi ivar domain on identify() 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: 3f0289ea7f66c82656a43edf6527055fd27d225d Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3f0289ea7f66c82656a43edf6527055fd27d225d commit 3f0289ea7f66c82656a43edf6527055fd27d225d Author: Konstantin Belousov AuthorDate: 2024-10-25 05:38:25 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-26 21:56:45 +0000 dmar: set acpi ivar domain on identify() Reviewed by: jhb Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47291 --- sys/x86/iommu/intel_drv.c | 60 ++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index b21c8460e830..dd2a3d1a631f 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -160,6 +160,27 @@ dmar_count_iter(ACPI_DMAR_HEADER *dmarh, void *arg) return (1); } +/* Remapping Hardware Static Affinity Structure lookup */ +struct rhsa_iter_arg { + uint64_t base; + u_int proxim_dom; +}; + +static int +dmar_rhsa_iter(ACPI_DMAR_HEADER *dmarh, void *arg) +{ + struct rhsa_iter_arg *ria; + ACPI_DMAR_RHSA *adr; + + if (dmarh->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) { + ria = arg; + adr = (ACPI_DMAR_RHSA *)dmarh; + if (adr->BaseAddress == ria->base) + ria->proxim_dom = adr->ProximityDomain; + } + return (1); +} + int dmar_rmrr_enable = 1; static int dmar_enable = 0; @@ -168,6 +189,7 @@ dmar_identify(driver_t *driver, device_t parent) { ACPI_TABLE_DMAR *dmartbl; ACPI_DMAR_HARDWARE_UNIT *dmarh; + struct rhsa_iter_arg ria; ACPI_STATUS status; int i, error; @@ -217,7 +239,15 @@ dmar_identify(driver_t *driver, device_t parent) i, (uintmax_t)dmarh->Address, error); device_delete_child(parent, dmar_devs[i]); dmar_devs[i] = NULL; + continue; } + + ria.base = dmarh->Address; + ria.proxim_dom = -1; + dmar_iterate_tbl(dmar_rhsa_iter, &ria); + acpi_set_domain(dmar_devs[i], ria.proxim_dom == -1 ? + ACPI_DEV_DOMAIN_UNKNOWN : + acpi_map_pxm_to_vm_domainid(ria.proxim_dom)); } } @@ -326,34 +356,12 @@ dmar_print_caps(device_t dev, struct dmar_unit *unit, DMAR_ECAP_IRO(unit->hw_ecap)); } -/* Remapping Hardware Static Affinity Structure lookup */ -struct rhsa_iter_arg { - uint64_t base; - u_int proxim_dom; -}; - -static int -dmar_rhsa_iter(ACPI_DMAR_HEADER *dmarh, void *arg) -{ - struct rhsa_iter_arg *ria; - ACPI_DMAR_RHSA *adr; - - if (dmarh->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) { - ria = arg; - adr = (ACPI_DMAR_RHSA *)dmarh; - if (adr->BaseAddress == ria->base) - ria->proxim_dom = adr->ProximityDomain; - } - return (1); -} - static int dmar_attach(device_t dev) { struct dmar_unit *unit; ACPI_DMAR_HARDWARE_UNIT *dmaru; struct iommu_msi_data *dmd; - struct rhsa_iter_arg ria; uint64_t timeout; int disable_pmr; int i, error; @@ -381,13 +389,7 @@ dmar_attach(device_t dev) if (bootverbose) dmar_print_caps(dev, unit, dmaru); dmar_quirks_post_ident(unit); - unit->memdomain = -1; - ria.base = unit->base; - ria.proxim_dom = -1; - dmar_iterate_tbl(dmar_rhsa_iter, &ria); - if (ria.proxim_dom != -1) - unit->memdomain = acpi_map_pxm_to_vm_domainid(ria.proxim_dom); - + unit->memdomain = acpi_get_domain(dev); timeout = dmar_get_timeout(); TUNABLE_UINT64_FETCH("hw.iommu.dmar.timeout", &timeout); dmar_update_timeout(timeout);