All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Remove redundant WARN_ON()
@ 2018-07-20  8:45 Anna-Maria Gleixner
       [not found] ` <20180720084545.3284-1-anna-maria-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Anna-Maria Gleixner @ 2018-07-20  8:45 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Anna-Maria Gleixner, tglx-hfZtesqFncYOwBW4kG4KsQ,
	bigeasy-hfZtesqFncYOwBW4kG4KsQ

The WARN_ON() was introduced in commit 272e4f99e966 ("iommu/amd: WARN
when __[attach|detach]_device are called with irqs enabled") to ensure
that the domain->lock is taken in proper irqs disabled context. This
is required, because the domain->lock is taken as well in irq
context.

The proper context check by the WARN_ON() is redundant, because it is
already covered by LOCKDEP. When working with locks and changing
context, a run with LOCKDEP is required anyway and would detect the
wrong lock context.

Furthermore all callers for those functions are within the same file
and all callers acquire another lock which already disables interrupts.

Signed-off-by: Anna-Maria Gleixner <anna-maria-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
 drivers/iommu/amd_iommu.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 596b95c50051..b5f39bffd684 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1944,12 +1944,6 @@ 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);
 
@@ -2115,12 +2109,6 @@ 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());
-
 	domain = dev_data->domain;
 
 	spin_lock(&domain->lock);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/amd: Remove redundant WARN_ON()
       [not found] ` <20180720084545.3284-1-anna-maria-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
@ 2018-07-20 12:36   ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2018-07-20 12:36 UTC (permalink / raw)
  To: Anna-Maria Gleixner
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	tglx-hfZtesqFncYOwBW4kG4KsQ, bigeasy-hfZtesqFncYOwBW4kG4KsQ

On Fri, Jul 20, 2018 at 10:45:45AM +0200, Anna-Maria Gleixner wrote:
> The WARN_ON() was introduced in commit 272e4f99e966 ("iommu/amd: WARN
> when __[attach|detach]_device are called with irqs enabled") to ensure
> that the domain->lock is taken in proper irqs disabled context. This
> is required, because the domain->lock is taken as well in irq
> context.
> 
> The proper context check by the WARN_ON() is redundant, because it is
> already covered by LOCKDEP. When working with locks and changing
> context, a run with LOCKDEP is required anyway and would detect the
> wrong lock context.
> 
> Furthermore all callers for those functions are within the same file
> and all callers acquire another lock which already disables interrupts.
> 
> Signed-off-by: Anna-Maria Gleixner <anna-maria-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> ---
>  drivers/iommu/amd_iommu.c | 12 ------------
>  1 file changed, 12 deletions(-)

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-20 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20  8:45 [PATCH] iommu/amd: Remove redundant WARN_ON() Anna-Maria Gleixner
     [not found] ` <20180720084545.3284-1-anna-maria-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2018-07-20 12:36   ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.