
Starting with v2024.10 dev_iommu_dma_unmap calls during device removal trigger a NULL pointer dereference in the Apple dart iommu driver. The iommu device is removed before its user. The sparsely used DM_FLAG_VITAL flag is intended to describe this dependency. Add it to the driver.
Adding this flag is unfortunately not enough since the boot routines except the arm one simply remove all drivers. Add and use a new function which calls dm_remove_devioce_flags(DM_REMOVE_ACTIVE_ALL | DM_REMOVE_NON_VITAL); dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL); to ensure this order dependency is head consistently.
Signed-off-by: Janne Grunau j@jannau.net --- Changes in v2: - added Mark's Ab: for Patch 1 - add dm_remove_device_active() and replace existing dm_remove_device_flags(DM_REMOVE_ACTIVE_ALL) with it (ignoring test code) - Link to v1: https://lore.kernel.org/r/20241031-iommu_apple_dart_ordering-v1-0-8a6877946d...
--- Janne Grunau (2): iommu: apple: Mark device with DM_FLAG_VITAL dm: Add dm_remove_devices_active() for ordered device removal
arch/arm/lib/bootm.c | 7 +++--- arch/riscv/lib/bootm.c | 2 +- arch/x86/lib/bootm.c | 2 +- drivers/core/root.c | 7 ++++++ drivers/iommu/apple_dart.c | 2 +- include/dm/root.h | 10 +++++++++ lib/efi_loader/efi_boottime.c | 2 +- test/dm/core.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 74 insertions(+), 8 deletions(-) --- base-commit: cca05617a8f585f3a98a8fa82f75cc68a530d771 change-id: 20241031-iommu_apple_dart_ordering-558e62671512
Best regards,