iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->flush_queue
@ 2017-09-06 10:34 Sebastian Andrzej Siewior
       [not found] ` <20170906103459.oi2nn7jondjqdo5m-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-09-06 10:34 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	vinadhy-Re5JQEeQqe8AvxtiuMwx3w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

get_cpu_ptr() disables preemption and returns the ->flush_queue object
of the current CPU. raw_cpu_ptr() does the same except that it not
disable preemption which means the scheduler can move it to another CPU
after it obtained the per-CPU object.
In this case this is not bad because the data structure itself is
protected with a spin_lock. This change shouldn't matter in general
but on RT it does because the sleeping lock can't be accessed with
disabled preemption.

Cc: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Reported-by: vinadhy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
 drivers/iommu/amd_iommu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 4ad7e5e31943..943efbc08128 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1911,7 +1911,7 @@ static void queue_add(struct dma_ops_domain *dom,
 	pages     = __roundup_pow_of_two(pages);
 	address >>= PAGE_SHIFT;
 
-	queue = get_cpu_ptr(dom->flush_queue);
+	queue = raw_cpu_ptr(dom->flush_queue);
 	spin_lock_irqsave(&queue->lock, flags);
 
 	/*
@@ -1940,8 +1940,6 @@ static void queue_add(struct dma_ops_domain *dom,
 
 	if (atomic_cmpxchg(&dom->flush_timer_on, 0, 1) == 0)
 		mod_timer(&dom->flush_timer, jiffies + msecs_to_jiffies(10));
-
-	put_cpu_ptr(dom->flush_queue);
 }
 
 static void queue_flush_timeout(unsigned long data)
-- 
2.14.1

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

end of thread, other threads:[~2017-11-06 20:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06 10:34 [PATCH] iommu/amd: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->flush_queue Sebastian Andrzej Siewior
     [not found] ` <20170906103459.oi2nn7jondjqdo5m-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2017-09-12  2:22   ` Vinod Adhikary
     [not found]     ` <CABp9dQUcXTAX9ggX+TAMHE2oH0SF8bcu47E=UYG9fgJdKBXEVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-09-21 15:10       ` Sebastian Andrzej Siewior
2017-09-19  9:41   ` Joerg Roedel
2017-09-21 15:21     ` [PATCH v2] iommu/iova: Use raw_cpu_ptr() instead of get_cpu_ptr() for ->fq Sebastian Andrzej Siewior
2017-11-02 17:33       ` Sebastian Andrzej Siewior
     [not found]         ` <20171102173349.btd3b2xfklcfopmz-E0PNVn5OA6ohrxcnuTQ+TQ@public.gmane.org>
2017-11-06 15:43           ` Alex Williamson
     [not found]             ` <20171106084334.639512ea-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2017-11-06 16:45               ` Robin Murphy
     [not found]                 ` <5653117e-7708-de28-f349-ffe5ebf4481d-5wv7dgnIgG8@public.gmane.org>
2017-11-06 20:07                   ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).