Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Nov 2024 00:38:20 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 19cefbb3ddb1 - stable/14 - amdiommu: short-circuit all amdiommu_find_unit() functions
Message-ID:  <202411120038.4AC0cKFG061387@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=19cefbb3ddb157dfa3d24be0be7f1990b9567733

commit 19cefbb3ddb157dfa3d24be0be7f1990b9567733
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-11-09 22:29:20 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-11-12 00:27:24 +0000

    amdiommu: short-circuit all amdiommu_find_unit() functions
    
    (cherry picked from commit 9805e5b071a10711cfcd3c7a750ac4a4d14b6e3f)
---
 sys/x86/iommu/amd_drv.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sys/x86/iommu/amd_drv.c b/sys/x86/iommu/amd_drv.c
index f1ee34467f46..4373987ae24a 100644
--- a/sys/x86/iommu/amd_drv.c
+++ b/sys/x86/iommu/amd_drv.c
@@ -879,6 +879,9 @@ amdiommu_find_unit(device_t dev, struct amdiommu_unit **unitp, uint16_t *ridp,
 	int error, flags;
 	bool res;
 
+	if (!amdiommu_enable)
+		return (ENXIO);
+
 	if (device_get_devclass(device_get_parent(dev)) !=
 	    devclass_find("pci"))
 		return (ENXIO);
@@ -943,6 +946,9 @@ amdiommu_find_unit_for_ioapic(int apic_id, struct amdiommu_unit **unitp,
 	device_t apic_dev;
 	bool res;
 
+	if (!amdiommu_enable)
+		return (ENXIO);
+
 	bzero(&ifu, sizeof(ifu));
 	ifu.type = IFU_DEV_IOAPIC;
 	ifu.devno = apic_id;
@@ -992,6 +998,9 @@ amdiommu_find_unit_for_hpet(device_t hpet, struct amdiommu_unit **unitp,
 	int hpet_no;
 	bool res;
 
+	if (!amdiommu_enable)
+		return (ENXIO);
+
 	hpet_no = hpet_get_uid(hpet);
 	bzero(&ifu, sizeof(ifu));
 	ifu.type = IFU_DEV_HPET;
@@ -1042,7 +1051,7 @@ amdiommu_find_method(device_t dev, bool verbose)
 
 	error = amdiommu_find_unit(dev, &unit, &rid, &dte, &edte, verbose);
 	if (error != 0) {
-		if (verbose)
+		if (verbose && amdiommu_enable)
 			device_printf(dev,
 			    "cannot find amdiommu unit, error %d\n",
 			    error);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202411120038.4AC0cKFG061387>