Skip to content

Commit 7edfa96

Browse files
jannaumarcan
authored andcommitted
HACK: iommu: apple-dart: workaround broken runtime PM with PCIe devices
Runtime PM behaves strangely with PCIe devices, pm_runtime_enabled() returns true here although the devices do not support runtime PM. This seems to confuse the PM core and DART is runtime suspended while the device is in use. The dart_hw_reset() in the resume path ends up breaking PCIe devices eventually. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 282ab49 commit 7edfa96

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,15 +764,24 @@ static struct iommu_device *apple_dart_probe_device(struct device *dev)
764764
{
765765
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
766766
struct apple_dart_stream_map *stream_map;
767+
u32 dl_flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER;
767768
int i;
768769

769770
if (!cfg)
770771
return ERR_PTR(-ENODEV);
771772

773+
/*
774+
* Runtime PM behaves strangely with PCIe devices, pm_runtime_enabled()
775+
* returns true here although the devices do not support runtime PM.
776+
* This seems to confuse the PM core and DART is runtime suspended while
777+
* the device is in use. The dart_hw_reset() in the resume path ends up
778+
* breaking PCIe devices eventually.
779+
*/
780+
if (dev_is_pci(dev))
781+
dl_flags |= DL_FLAG_RPM_ACTIVE;
782+
772783
for_each_stream_map(i, cfg, stream_map)
773-
device_link_add(
774-
dev, stream_map->dart->dev,
775-
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
784+
device_link_add(dev, stream_map->dart->dev, dl_flags);
776785

777786
return &cfg->stream_maps[0].dart->iommu;
778787
}

0 commit comments

Comments
 (0)