]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
iommu/dart: Clear sid2group entry when a group is freed
authorSven Peter <sven@svenpeter.dev>
Fri, 24 Sep 2021 13:45:02 +0000 (15:45 +0200)
committerJoerg Roedel <jroedel@suse.de>
Tue, 28 Sep 2021 09:47:24 +0000 (11:47 +0200)
commitf0b636804c7c4c564efbca5981e3c56b5c6fe0c5
tree97123a6b7f6e9592f417d0146fc61d5c795fa702
parent0b482d0c75bf321b2fd87d215c3d6df095a601d1
iommu/dart: Clear sid2group entry when a group is freed

sid2groups keeps track of which stream id combinations belong to a
iommu_group to assign those correctly to devices.
When a iommu_group is freed a stale pointer will however remain in
sid2groups. This prevents devices with the same stream id combination
to ever be attached again (see below).
Fix that by creating a shadow copy of the stream id configuration
when a group is allocated for the first time and clear the sid2group
entry when that group is freed.

  # echo 1 >/sys/bus/pci/devices/0000\:03\:00.0/remove
  pci 0000:03:00.0: Removing from iommu group 1
  # echo 1 >/sys/bus/pci/rescan
  [...]
  pci 0000:03:00.0: BAR 0: assigned [mem 0x6a0000000-0x6a000ffff 64bit pref]
  pci 0000:03:00.0: BAR 2: assigned [mem 0x6a0010000-0x6a001ffff 64bit pref]
  pci 0000:03:00.0: BAR 6: assigned [mem 0x6c0100000-0x6c01007ff pref]
  tg3 0000:03:00.0: Failed to add to iommu group 1: -2
  [...]

Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver")
Reported-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Tested-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210924134502.15589-1-sven@svenpeter.dev
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/apple-dart.c