From nobody Sat Nov 09 22:32:56 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 4Xm9Yh5K1xz5cldx; Sat, 09 Nov 2024 22:32:56 +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 4Xm9Yh4Ht6z4tCc; Sat, 9 Nov 2024 22:32:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731191576; 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=RiOBtoY1a3WJB7fa4dNeAJj/MAVafVsZCIojJyzWquo=; b=w5+L1QR3Gsyjsi0sv48ZcSRAO7K2l8pcvXj7PpGT7c4w4nH6wx+RHGXZefhLS7DdtGFvc/ 0wJ7f0FSBrIhd1G/MgNTyrWlFpNYMU7YZnBhR+cAUnyFcqrbp6B9GsG0SYlSxqGbGmHQc8 PV+SBRRTi+CYQfAuHzDgjEuzUQqoH5AH3Ds5eQ1LTaPvlv0DyPBqWlrENjsYfKwh1Z32xq HBKtHRzfJxfoW0c/HMK+JQt5ihQOgVPB8CGbUF0G4qAmTvQcTK+69LCJpkMemLW3JS37tE MYRtfUz64RdB6ZWrxSWeADl6b/ChOU1aJGj0RBcUJ8jVD6SJ1rx1tma8PyA13A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731191576; 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=RiOBtoY1a3WJB7fa4dNeAJj/MAVafVsZCIojJyzWquo=; b=qDTIIXMnE3B8Y28BVlpKiIbc4HMJasDJfMH+zM6dsalQd7hPYK9agxMZilo6AaWdQQOMCT lSnQSP20HkGKqH67nsiw+67qWVoHP9Kt/Fgi16eqRctUZURPhmLlJarMQKJ2YMtCpMy+Zb C0c91AU6vEI2FdgIv5zVSja2udoZKrmr2YE4S4o+ca8yNs90QE/B4IXNwPNKHBwkZn1OGz bp0ocr2lp52X9m1QucBwlK8cUE/yV/aaQu2lm0AqBrDN0yjq/m9Yz4GHPfzyhWFUBcH7zw 4EXcAeeRyrAc+y/y9eefs0dN1xXuTBmO+pCEGhdEtnbdS+gcFOpjbr96CP5HWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731191576; a=rsa-sha256; cv=none; b=tXLBKTt79+vnkrwLelkFDg0oIOefIWRvMfOrasU3X/vGJn6o60aEaTqU6TdKMzFyC7jinE DK1VDTvYG5xESpgWC4Z6azPMewk+N5fi4Ea8w6TITYrNWVucPO1qYM3TvRGWn9HdC1FlFb CaWFnYx2nZodV3HMDeyOv8n/k9utIgIK0rZu3GimAKzppHA5JaDT+rZYCp8UuhoRYdVm4D hTEcLvUhXJSjPUWLw0J73zpB37yrRdfNIY43sDjtErs4yKDQ1pRx5Q8mi54QadCqV9fGvf KKzz61+TeoE4WfM+ep2ARaOXIBIdCErsrilnSlOkoz5Z73IWgsicGSor0MAzow== 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 4Xm9Yh3vZgzG8j; Sat, 9 Nov 2024 22:32:56 +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 4A9MWu7m091024; Sat, 9 Nov 2024 22:32:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A9MWubs091021; Sat, 9 Nov 2024 22:32:56 GMT (envelope-from git) Date: Sat, 9 Nov 2024 22:32:56 GMT Message-Id: <202411092232.4A9MWubs091021@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: 9805e5b071a1 - main - amdiommu: short-circuit all amdiommu_find_unit() functions 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/main X-Git-Reftype: branch X-Git-Commit: 9805e5b071a10711cfcd3c7a750ac4a4d14b6e3f Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9805e5b071a10711cfcd3c7a750ac4a4d14b6e3f commit 9805e5b071a10711cfcd3c7a750ac4a4d14b6e3f Author: Konstantin Belousov AuthorDate: 2024-11-09 22:29:20 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-09 22:32:37 +0000 amdiommu: short-circuit all amdiommu_find_unit() functions for the case where amdiommu is not enabled. In this case, it does not matter if IVHD does not describe some device. Similarly, no unit can be found for a device, because units are not instantiated, but it does not matter. Reported by: mav Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 3 days --- 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 d8f3c25fcae0..d35c6c8dddc8 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);