From nobody Mon Apr 6 19:38:14 2026 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 012A734572F for ; Thu, 19 Mar 2026 06:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773900951; cv=none; b=MuW7C2BiLVTDJk82TalBbb/uULC6t56MKXtwzzQesD3LF84Lgpl3yShjC+5PUpijebGZ12i9Ydbv5fCpRLp+YLrB9dIvNUwpZHo7C667JfWxrLgYWDp83NToQBmBsUky3ZYUpsuO2RJIaXUCmH1HDvY5XviW9XssF4Slq+8EFbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773900951; c=relaxed/simple; bh=2DHIOR/xu0FQ/B1GFdC6D07OnelCvpt03qpXdP8Z//s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GUu7f5zfc7lsUhwNNMMCfEPOQNID8jbDaV9pzEZCxFwXfx+THO3ODnh/lM/naEGljunKP6235KtM52+s7d9uet2rT6VGUeZeXaf13C1SBV0aApJ8FtSZmvBm/dB03bpP97d2/s5hfPtUYF5ZSLED6vfPsR84MXt1xzVnih6anpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RzJYyNmm; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RzJYyNmm" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8297e0b27e5so396314b3a.1 for ; Wed, 18 Mar 2026 23:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773900949; x=1774505749; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NsT73j4cLvpq8BjBjqE6tomVf3siHf2xqAbxNaDSyB0=; b=RzJYyNmmNwZbTIMLVTW+Tc1dmr9HA1SYcrq7xWbrRDAc87z7T3s56PsWh75J0+J59b Ob25zBJi5jjIrutSYjKiBiGTdceODDNrsbYMa9GGzWFt3dg7LUGES6pKXR45sswQEEcN NbiqMu3byVfn+GeqmLT5oytwLT3MzOMQzavEmuzMuP1YgOUqeEWMmZEjs1ios0HTIDPO ey3LjadjbX+SdA0553P7AyZnCxc9Uj98cSNb+jDeEpifg6V1hJnboD/VSUs4xcE9VgEE EQhdZZxtL83mIX0iNq2GbfEd+HCbOfjHgBtXxDaDjt6FuEf43O0ENuON6K4algncVN5K fG2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773900949; x=1774505749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NsT73j4cLvpq8BjBjqE6tomVf3siHf2xqAbxNaDSyB0=; b=Aw4ySzG0C2I5ZhXXtc1qz4u53bcNfwc/cB4Ip5EMv9NDPN77VNMP7wSqLrMNXUjYJi ruHDOfm2W+RWVval0uCWLYiz0oG/V0atG59pbDvb6OxRc25eySqNlTn+lVq6PE2gh2Hk cEqOJpda2UEo2mBey85phFHapBUCh5FYpNwVxZjSSAGZxSyjw4E/PoSBeHIpdJ7a1I5Y votNYkqc9cI9lYplkfRVsnbwjGa5aNise1wAGuh4kXxPsU5NGvpFjlslfR7Oef3Zs+C7 NWfUm5AfSAJUe0bNI7f4e+QNWoSZB+IVz7iaaVEQ1xVqviL/9WZH+A5U0nYGvbeHr+KB aZ3g== X-Forwarded-Encrypted: i=1; AJvYcCUilVdKbuhk+m91N3BqO3df4J6J9XoQ6rBmrz/5jOentY9/oYMgfjj+UEnswJk2B+c7KiPvVXxW7tVRC94=@vger.kernel.org X-Gm-Message-State: AOJu0Yxf6ZzIE8GLwyLzuRUDhvinmpGGmT7gvzpUyhxU76R8r5YwuP4r pWzvf1VtEo+UjEgSnhwJFoE5RiodGpk9NNemuddDNH+KIjc2WF/EM4Ne X-Gm-Gg: ATEYQzz2XPN+KQnj1B2ml/b4JL2Ds3zJKKe9h5bHLw8f0vZ0VQ8/HrRFkolw5uoudth nB4OU72OLB3vsU6Ciqvcznk3mwnlATeWoGqZXQgYBeVjt0vgiauNg6Ng/OczjUvy88qygxZbrDY eFt4BCZsz4Qr49yQ0B+67FGHf5nyNw1AAsMUr5jAmRloadNqdMHJ/mKUgKHg+vFyBoiC/Z0G/1P A98LiDIPJqElZZ3wtWDwWz5hIoQgaCv7yij10I/ScjQN8/g5F1YrOIuQRwlWLnNulS5J9iXjyt5 vS7bWQvRJvLq65IRnD3LwVUKPbCAyGx46wPa/igiBRxotm8pLay48OPuYBoKenXBfw/wqu9Y3ad XH0vcs1BH2KnsnM0bWAoa8QiT2owHDmLQnu2XQcckph4tZb0BBiewMA8HrT2iQmaT/xGBKq2CCJ YK6ZBH1QdDTrW7fesKIWEs7tjb68I2t3j3wDdXZlxmMIyQ+Gyf2g/PcJnPtE0JRDEZMF6E3+qMf 1RQRpUy1T/lnw== X-Received: by 2002:a05:6a00:190b:b0:829:7d31:dd99 with SMTP id d2e1a72fcca58-82a6ae7084fmr5481255b3a.38.1773900949283; Wed, 18 Mar 2026 23:15:49 -0700 (PDT) Received: from AHUANG12-3ZHH9X.lenovo.com (61-221-208-111.hinet-ip.hinet.net. [61.221.208.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a6bef5ed8sm5660824b3a.57.2026.03.18.23.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 23:15:48 -0700 (PDT) From: "Adrian Huang (Lenovo)" To: Joerg Roedel , Suravee Suthikulpanit Cc: Will Deacon , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, ahuang12@lenovo.com, "Adrian Huang (Lenovo)" Subject: [PATCH 2/2] iommu/amd: Register PCI bus notifier when appending amd_iommu=off Date: Thu, 19 Mar 2026 14:15:07 +0800 Message-Id: <20260319061507.541-3-adrianhuang0701@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260319061507.541-1-adrianhuang0701@gmail.com> References: <20260319061507.541-1-adrianhuang0701@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the amd_iommu=3Doff kernel parameter is used, dynamically adding PCI devices (e.g., creating SR-IOV VFs) triggers a call trace and IOMMU fault events. For example, enabling VFs via sysfs: # echo 4 > /sys/class/net/eth1/device/sriov_numvfs It results in an INVALID_DEVICE_REQUEST and a warning in __irq_msi_compose_msg+0xa3/0xb0: pci 0000:41:03.0: [14e4:16c1] type 00 class 0x020000 PCIe Endpoint bnxt_en 0000:41:03.0: enabling device (0000 -> 0002) bnxt_en 0000:41:03.0 eth4: Broadcom NetXtreme-E Ethernet Virtual Function= found at mem 381c7ff40000, node addr 92:42:39:64:ad:24 ... WARNING: arch/x86/kernel/apic/apic.c:2313 at __irq_msi_compose_msg+0xa3/0= xb0, CPU#2: NetworkManager/4268 bnxt_en 0000:41:03.1: enabling device (0000 -> 0002) CPU: 2 UID: 0 PID: 4268 Comm: NetworkManager Kdump: loaded Not tainted 7.= 0.0-rc4+ #23 PREEMPT(lazy) ... RIP: 0010:__irq_msi_compose_msg+0xa3/0xb0 ... Call Trace: irq_chip_compose_msi_msg+0x2e/0x50 msi_domain_activate+0x41/0x90 __irq_domain_activate_irq+0x53/0x90 ? mtree_load+0x26e/0x2b0 irq_domain_activate_irq+0x29/0x40 __setup_irq+0x322/0x790 ? __pfx_bnxt_msix+0x10/0x10 [bnxt_en] request_threaded_irq+0x109/0x1c0 bnxt_request_irq+0xee/0x270 [bnxt_en] ... AMD-Vi: Event logged [INVALID_DEVICE_REQUEST device=3D0000:41:03.0 pasid= =3D0x00000 address=3D0xfffffffdf8220100 flags=3D0x0a00] The root cause is that when IOMMU is disabled via the command line, the PCI bus notifier is not registered. Consequently, the MSI domain for dynamically added devices is not properly associated with the IOMMU interrupt remapping domain. Even when the IOMMU is "off," certain interrupt remapping configurations must still be handled for newly enumerated devices to prevent activation failures. Fix this by ensuring the PCI bus notifier is registered even when amd_iommu=3Doff is set, allowing the IOMMU interrupt remapping domain to be correctly assigned to new PCI devices. Signed-off-by: Adrian Huang (Lenovo) --- drivers/iommu/amd/init.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 0f577534702d..5509ade0cf0d 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -3431,6 +3431,30 @@ static int __init amd_iommu_devices_set_pci_msi_doma= in(void) return ret; } =20 +static int amd_iommu_pci_bus_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct pci_dev *pdev =3D to_pci_dev(data); + + /* We only care about the add event. */ + if (action !=3D BUS_NOTIFY_ADD_DEVICE) + return NOTIFY_DONE; + + amd_iommu_dev_set_pci_msi_domain(&pdev->dev); + + return NOTIFY_OK; +} + +static struct notifier_block amd_iommu_pci_bus_nb =3D { + .notifier_call =3D amd_iommu_pci_bus_notifier, + .priority =3D 1, +}; + +static void __init amd_iommu_register_bus_notifier(void) +{ + bus_register_notifier(&pci_bus_type, &amd_iommu_pci_bus_nb); +} + /*************************************************************************= *** * * AMD IOMMU Initialization State Machine @@ -3462,6 +3486,7 @@ static int __init state_next(void) case IOMMU_ENABLED: if (amd_iommu_disabled) { amd_iommu_devices_set_pci_msi_domain(); + amd_iommu_register_bus_notifier(); init_state =3D IOMMU_CMDLINE_DISABLED; ret =3D -EINVAL; } else { --=20 2.47.3