Skip to content

Commit

Permalink
HACK: iommu: apple-dart: workaround broken runtime PM with PCIe devices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jannau authored and marcan committed Apr 24, 2023
1 parent 282ab49 commit 7edfa96
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/iommu/apple-dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,24 @@ static struct iommu_device *apple_dart_probe_device(struct device *dev)
{
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
struct apple_dart_stream_map *stream_map;
u32 dl_flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER;
int i;

if (!cfg)
return ERR_PTR(-ENODEV);

/*
* 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.
*/
if (dev_is_pci(dev))
dl_flags |= DL_FLAG_RPM_ACTIVE;

for_each_stream_map(i, cfg, stream_map)
device_link_add(
dev, stream_map->dart->dev,
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
device_link_add(dev, stream_map->dart->dev, dl_flags);

return &cfg->stream_maps[0].dart->iommu;
}
Expand Down

0 comments on commit 7edfa96

Please sign in to comment.