iommu/amd: WARN when __[attach|detach]_device are called with irqs enabled
authorJoerg Roedel <jroedel@suse.de>
Tue, 20 Oct 2015 15:33:37 +0000 (17:33 +0200)
committerJoerg Roedel <jroedel@suse.de>
Wed, 21 Oct 2015 09:29:27 +0000 (11:29 +0200)
These functions rely on being called with IRQs disabled. Add
a WARN_ON to detect early when its not.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu.c

index 07f491c2dc647064f7232dd4df2ad1b1c1db94c7..f8f54a4b1d8f47ac553d0f5217c241d0fff382f4 100644 (file)
@@ -2030,6 +2030,12 @@ static int __attach_device(struct iommu_dev_data *dev_data,
 {
        int ret;
 
+       /*
+        * Must be called with IRQs disabled. Warn here to detect early
+        * when its not.
+        */
+       WARN_ON(!irqs_disabled());
+
        /* lock domain */
        spin_lock(&domain->lock);
 
@@ -2190,6 +2196,12 @@ static void __detach_device(struct iommu_dev_data *dev_data)
 {
        struct protection_domain *domain;
 
+       /*
+        * Must be called with IRQs disabled. Warn here to detect early
+        * when its not.
+        */
+       WARN_ON(!irqs_disabled());
+
        if (WARN_ON(!dev_data->domain))
                return;