)]}'
{
  "commit": "1a577f9402c1780cc1e663f48d5dd54c02051b09",
  "tree": "ec07f5e0779ca3184d1a21f95ccf54836582f88e",
  "parents": [
    "92368f4fb8ff40b87faa4acf1775720ffaf5749d"
  ],
  "author": {
    "name": "Zenghui Yu (Huawei)",
    "email": "zenghui.yu@linux.dev",
    "time": "Thu Oct 29 20:16:48 2026 +0800"
  },
  "committer": {
    "name": "Michael S. Tsirkin",
    "email": "mst@redhat.com",
    "time": "Tue Nov 03 07:32:14 2026 -0500"
  },
  "message": "virtio_pci: don\u0027t take the MSI mutex under cpu_hotplug_lock\n\nLockdep reports the following circular locking dependency when a virtio-net\ndevice is probed with lockdep enabled on a system whose devices sit behind\nan IOMMU:\n\n    \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n    WARNING: possible circular locking dependency detected\n    7.3.0-rc1+ #84 Not tainted\n    ------------------------------------------------------\n    kworker/u34:0/57 is trying to acquire lock:\n    ffff800104f83ee8 (\u0026md-\u003emutex){+.+.}-{4:4}, at: msi_domain_get_virq+0xf0/0x118\n\n    but task is already holding lock:\n    ffffc00081edd930 (cpu_hotplug_lock){++++}-{0:0}, at: cpus_read_lock+0x10/0x1c\n\n    which lock already depends on the new lock.\n\n    Chain exists of:\n      \u0026md-\u003emutex --\u003e \u0026group-\u003emutex --\u003e cpu_hotplug_lock\n\nThe cycle is composed of three dependencies:\n\n* cpu_hotplug_lock -\u003e \u0026md-\u003emutex (which triggers the splat). virtio_net\u0027s\n  init_vqs() calls cpus_read_lock() around virtnet_set_affinity(), which\n  reaches vp_set_vq_affinity(). That calls pci_irq_vector(), which takes\n  the per-device MSI mutex (\u0026dev-\u003emsi.data-\u003emutex) via\n  msi_domain_get_virq().\n\n* \u0026md-\u003emutex -\u003e \u0026domain-\u003emutex -\u003e \u0026group-\u003emutex.  MSI-X allocation of any\n  device behind the IOMMU holds the MSI mutex while allocating interrupts\n  through the IRQ domain hierarchy. The MSI parent domain (GICv2m, or ITS\n  likewise) calls iommu_dma_prepare_msi() from its .alloc() to map the MSI\n  doorbell, which takes the IOMMU group mutex.\n\n* \u0026group-\u003emutex -\u003e cpu_hotplug_lock. bus_iommu_probe() calls\n  iommu_setup_dma_ops() under the group mutex; initializing the IOVA\n  rcaches registers a cpuhp instance, which takes cpu_hotplug_lock.\n\nThe cycle only became complete since commit 288683c92b1a (\"iommu: Make\niommu_dma_prepare_msi() into a generic operation\"), where\niommu_dma_prepare_msi() switched to use the group mutex.\n\npci_irq_vector() is a pure lookup of a vector that is bound to the\nqueue for the whole lifetime of the queue, so there is no reason to\ntake the MSI mutex for it from cpu hotplug locked contexts.\n\nCache the IRQ number in virtio_pci_vq_info {} at vector binding time and\nmake vp_set_vq_affinity() use the cached value.\n\nThis also covers the CPU hotplug callbacks\n(virtnet_cpu_online/virtnet_cpu_dead), which call virtnet_set_affinity()\nwith cpu_hotplug_lock already held.\n\nSigned-off-by: Zenghui Yu (Huawei) \u003czenghui.yu@linux.dev\u003e\nSigned-off-by: Michael S. Tsirkin \u003cmst@redhat.com\u003e\nMessage-ID: \u003c20261029121648.22155-1-zenghui.yu@linux.dev\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "284daff7ece6f9536fca8d10626608f6ae5e4e8c",
      "old_mode": 33188,
      "old_path": "drivers/virtio/virtio_pci_common.c",
      "new_id": "79d3395f370501844240d7a4bba9e9b7ce37a260",
      "new_mode": 33188,
      "new_path": "drivers/virtio/virtio_pci_common.c"
    },
    {
      "type": "modify",
      "old_id": "18b6dbdfd1e55c1bac90674c7e32fd353da38cfc",
      "old_mode": 33188,
      "old_path": "drivers/virtio/virtio_pci_common.h",
      "new_id": "4ce903e7d3a99b71db022ce09338509771df8982",
      "new_mode": 33188,
      "new_path": "drivers/virtio/virtio_pci_common.h"
    }
  ]
}
