• Sven Peter's avatar
    iommu/dart: Clear sid2group entry when a group is freed · f0b63680
    Sven Peter authored
    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: 46d1fb07 ("iommu/dart: Add DART iommu driver")
    Reported-by: default avatarMarc Zyngier <maz@kernel.org>
    Signed-off-by: default avatarSven Peter <sven@svenpeter.dev>
    Tested-by: default avatarMarc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20210924134502.15589-1-sven@svenpeter.devSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    f0b63680
apple-dart.c 24.5 KB