* [PATCH v3 1/5] arm64: barriers: make use of barrier options with explicit barriers
@ 2014-02-19 12:28 Will Deacon
2014-02-19 12:28 ` [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq Will Deacon
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Will Deacon @ 2014-02-19 12:28 UTC (permalink / raw)
To: linux-arm-kernel
When calling our low-level barrier macros directly, we can often suffice
with more relaxed behaviour than the default "all accesses, full system"
option.
This patch updates the users of dsb() to specify the option which they
actually require.
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/barrier.h | 2 +-
arch/arm64/include/asm/cacheflush.h | 2 +-
arch/arm64/include/asm/pgtable.h | 4 ++--
arch/arm64/include/asm/tlbflush.h | 14 +++++++-------
arch/arm64/kernel/process.c | 2 +-
arch/arm64/kvm/sys_regs.c | 4 ++--
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
index 409ca370cfe2..5c436e3457dd 100644
--- a/arch/arm64/include/asm/barrier.h
+++ b/arch/arm64/include/asm/barrier.h
@@ -27,7 +27,7 @@
#define isb() asm volatile("isb" : : : "memory")
#define dsb(opt) asm volatile("dsb sy" : : : "memory")
-#define mb() dsb()
+#define mb() dsb(sy)
#define rmb() asm volatile("dsb ld" : : : "memory")
#define wmb() asm volatile("dsb st" : : : "memory")
diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
index 889324981aa4..2a365a9e36c0 100644
--- a/arch/arm64/include/asm/cacheflush.h
+++ b/arch/arm64/include/asm/cacheflush.h
@@ -143,7 +143,7 @@ static inline void flush_cache_vmap(unsigned long start, unsigned long end)
* set_pte_at() called from vmap_pte_range() does not
* have a DSB after cleaning the cache line.
*/
- dsb();
+ dsb(ishst);
}
static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index b524dcd17243..54aa68f61008 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -310,7 +310,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
{
*pmdp = pmd;
- dsb();
+ dsb(ishst);
}
static inline void pmd_clear(pmd_t *pmdp)
@@ -340,7 +340,7 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
static inline void set_pud(pud_t *pudp, pud_t pud)
{
*pudp = pud;
- dsb();
+ dsb(ishst);
}
static inline void pud_clear(pud_t *pudp)
diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
index 8b482035cfc2..3083a08f9622 100644
--- a/arch/arm64/include/asm/tlbflush.h
+++ b/arch/arm64/include/asm/tlbflush.h
@@ -72,9 +72,9 @@ extern struct cpu_tlb_fns cpu_tlb;
*/
static inline void flush_tlb_all(void)
{
- dsb();
+ dsb(ishst);
asm("tlbi vmalle1is");
- dsb();
+ dsb(ish);
isb();
}
@@ -82,9 +82,9 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
{
unsigned long asid = (unsigned long)ASID(mm) << 48;
- dsb();
+ dsb(ishst);
asm("tlbi aside1is, %0" : : "r" (asid));
- dsb();
+ dsb(ish);
}
static inline void flush_tlb_page(struct vm_area_struct *vma,
@@ -93,9 +93,9 @@ static inline void flush_tlb_page(struct vm_area_struct *vma,
unsigned long addr = uaddr >> 12 |
((unsigned long)ASID(vma->vm_mm) << 48);
- dsb();
+ dsb(ishst);
asm("tlbi vae1is, %0" : : "r" (addr));
- dsb();
+ dsb(ish);
}
/*
@@ -114,7 +114,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
* set_pte() does not have a DSB, so make sure that the page table
* write is visible.
*/
- dsb();
+ dsb(ishst);
}
#define update_mmu_cache_pmd(vma, address, pmd) do { } while (0)
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 1c0a9be2ffa8..8e78cb238376 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -294,7 +294,7 @@ struct task_struct *__switch_to(struct task_struct *prev,
* Complete any pending TLB or cache maintenance on this CPU in case
* the thread migrates to a different CPU.
*/
- dsb();
+ dsb(ish);
/* the actual thread switch */
last = cpu_switch_to(prev, next);
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 02e9d09e1d80..bbaaabe8e899 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -70,13 +70,13 @@ static u32 get_ccsidr(u32 csselr)
static void do_dc_cisw(u32 val)
{
asm volatile("dc cisw, %x0" : : "r" (val));
- dsb();
+ dsb(ishst);
}
static void do_dc_csw(u32 val)
{
asm volatile("dc csw, %x0" : : "r" (val));
- dsb();
+ dsb(ishst);
}
/* See note@ARM ARM B1.14.4 */
--
1.8.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq
2014-02-19 12:28 [PATCH v3 1/5] arm64: barriers: make use of barrier options with explicit barriers Will Deacon
@ 2014-02-19 12:28 ` Will Deacon
2014-02-19 12:32 ` Catalin Marinas
2014-02-19 13:21 ` Marc Zyngier
2014-02-19 12:28 ` [PATCH v3 3/5] iommu/arm-smmu: provide option to dsb macro when publishing tables Will Deacon
` (2 subsequent siblings)
3 siblings, 2 replies; 7+ messages in thread
From: Will Deacon @ 2014-02-19 12:28 UTC (permalink / raw)
To: linux-arm-kernel
When sending an SGI to another CPU, we require a barrier to ensure that
any pending stores to normal memory are made visible to the recipient
before the interrupt arrives.
Rather than use a vanilla dsb() (which will soon cause an assembly error
on arm64) before the writel_relaxed, we can instead use dsb(ishst),
since we just need to ensure that any pending normal writes are visible
within the inner-shareable domain before we poke the GIC.
With this observation, we can then further weaken the barrier to a
dmb(ishst), since other CPUs in the inner-shareable domain must observe
the write to the distributor before the SGI is generated.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
drivers/irqchip/irq-gic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 341c6016812d..500e533b9648 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -661,9 +661,9 @@ void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)
/*
* Ensure that stores to Normal memory are visible to the
- * other CPUs before issuing the IPI.
+ * other CPUs before they observe us issuing the IPI.
*/
- dsb();
+ dmb(ishst);
/* this always happens on GIC0 */
writel_relaxed(map << 16 | irq, gic_data_dist_base(&gic_data[0]) + GIC_DIST_SOFTINT);
--
1.8.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/5] iommu/arm-smmu: provide option to dsb macro when publishing tables
2014-02-19 12:28 [PATCH v3 1/5] arm64: barriers: make use of barrier options with explicit barriers Will Deacon
2014-02-19 12:28 ` [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq Will Deacon
@ 2014-02-19 12:28 ` Will Deacon
2014-02-19 12:28 ` [PATCH v3 4/5] arm64: barriers: wire up new barrier options Will Deacon
2014-02-19 12:28 ` [PATCH v3 5/5] arm64: barriers: use barrier() instead of smp_mb() when !SMP Will Deacon
3 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2014-02-19 12:28 UTC (permalink / raw)
To: linux-arm-kernel
On coherent systems, publishing new page tables to the SMMU walker is
achieved with a dsb instruction. In fact, this can be a dsb(ishst) which
also provides the mandatory barrier option for arm64.
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
drivers/iommu/arm-smmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 8911850c9444..8f6fee54f3b1 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1417,7 +1417,7 @@ out_unlock:
/* Ensure new page tables are visible to the hardware walker */
if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)
- dsb();
+ dsb(ishst);
return ret;
}
--
1.8.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/5] arm64: barriers: wire up new barrier options
2014-02-19 12:28 [PATCH v3 1/5] arm64: barriers: make use of barrier options with explicit barriers Will Deacon
2014-02-19 12:28 ` [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq Will Deacon
2014-02-19 12:28 ` [PATCH v3 3/5] iommu/arm-smmu: provide option to dsb macro when publishing tables Will Deacon
@ 2014-02-19 12:28 ` Will Deacon
2014-02-19 12:28 ` [PATCH v3 5/5] arm64: barriers: use barrier() instead of smp_mb() when !SMP Will Deacon
3 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2014-02-19 12:28 UTC (permalink / raw)
To: linux-arm-kernel
Now that all callers of the barrier macros are updated to pass the
mandatory options, update the macros so the option is actually used.
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/barrier.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
index 5c436e3457dd..71a42d6599fb 100644
--- a/arch/arm64/include/asm/barrier.h
+++ b/arch/arm64/include/asm/barrier.h
@@ -25,11 +25,12 @@
#define wfi() asm volatile("wfi" : : : "memory")
#define isb() asm volatile("isb" : : : "memory")
-#define dsb(opt) asm volatile("dsb sy" : : : "memory")
+#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
+#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
#define mb() dsb(sy)
-#define rmb() asm volatile("dsb ld" : : : "memory")
-#define wmb() asm volatile("dsb st" : : : "memory")
+#define rmb() dsb(ld)
+#define wmb() dsb(st)
#ifndef CONFIG_SMP
#define smp_mb() barrier()
@@ -53,9 +54,9 @@ do { \
#else
-#define smp_mb() asm volatile("dmb ish" : : : "memory")
-#define smp_rmb() asm volatile("dmb ishld" : : : "memory")
-#define smp_wmb() asm volatile("dmb ishst" : : : "memory")
+#define smp_mb() dmb(ish)
+#define smp_rmb() dmb(ishld)
+#define smp_wmb() dmb(ishst)
#define smp_store_release(p, v) \
do { \
--
1.8.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/5] arm64: barriers: use barrier() instead of smp_mb() when !SMP
2014-02-19 12:28 [PATCH v3 1/5] arm64: barriers: make use of barrier options with explicit barriers Will Deacon
` (2 preceding siblings ...)
2014-02-19 12:28 ` [PATCH v3 4/5] arm64: barriers: wire up new barrier options Will Deacon
@ 2014-02-19 12:28 ` Will Deacon
3 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2014-02-19 12:28 UTC (permalink / raw)
To: linux-arm-kernel
The recently introduced acquire/release accessors refer to smp_mb()
in the !CONFIG_SMP case. This is confusing when reading the code, so use
barrier() directly when we know we're UP.
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/barrier.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
index 71a42d6599fb..709f1f6d6bbd 100644
--- a/arch/arm64/include/asm/barrier.h
+++ b/arch/arm64/include/asm/barrier.h
@@ -40,7 +40,7 @@
#define smp_store_release(p, v) \
do { \
compiletime_assert_atomic_type(*p); \
- smp_mb(); \
+ barrier(); \
ACCESS_ONCE(*p) = (v); \
} while (0)
@@ -48,7 +48,7 @@ do { \
({ \
typeof(*p) ___p1 = ACCESS_ONCE(*p); \
compiletime_assert_atomic_type(*p); \
- smp_mb(); \
+ barrier(); \
___p1; \
})
--
1.8.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq
2014-02-19 12:28 ` [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq Will Deacon
@ 2014-02-19 12:32 ` Catalin Marinas
2014-02-19 13:21 ` Marc Zyngier
1 sibling, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2014-02-19 12:32 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Feb 19, 2014 at 12:28:34PM +0000, Will Deacon wrote:
> When sending an SGI to another CPU, we require a barrier to ensure that
> any pending stores to normal memory are made visible to the recipient
> before the interrupt arrives.
>
> Rather than use a vanilla dsb() (which will soon cause an assembly error
> on arm64) before the writel_relaxed, we can instead use dsb(ishst),
> since we just need to ensure that any pending normal writes are visible
> within the inner-shareable domain before we poke the GIC.
>
> With this observation, we can then further weaken the barrier to a
> dmb(ishst), since other CPUs in the inner-shareable domain must observe
> the write to the distributor before the SGI is generated.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
> drivers/irqchip/irq-gic.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 341c6016812d..500e533b9648 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -661,9 +661,9 @@ void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)
>
> /*
> * Ensure that stores to Normal memory are visible to the
> - * other CPUs before issuing the IPI.
> + * other CPUs before they observe us issuing the IPI.
> */
> - dsb();
> + dmb(ishst);
Oh well ;)
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq
2014-02-19 12:28 ` [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq Will Deacon
2014-02-19 12:32 ` Catalin Marinas
@ 2014-02-19 13:21 ` Marc Zyngier
1 sibling, 0 replies; 7+ messages in thread
From: Marc Zyngier @ 2014-02-19 13:21 UTC (permalink / raw)
To: linux-arm-kernel
On 19/02/14 12:28, Will Deacon wrote:
> When sending an SGI to another CPU, we require a barrier to ensure that
> any pending stores to normal memory are made visible to the recipient
> before the interrupt arrives.
>
> Rather than use a vanilla dsb() (which will soon cause an assembly error
> on arm64) before the writel_relaxed, we can instead use dsb(ishst),
> since we just need to ensure that any pending normal writes are visible
> within the inner-shareable domain before we poke the GIC.
>
> With this observation, we can then further weaken the barrier to a
> dmb(ishst), since other CPUs in the inner-shareable domain must observe
> the write to the distributor before the SGI is generated.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
I'll queue a similar fix for the GICv3 code.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-02-19 13:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 12:28 [PATCH v3 1/5] arm64: barriers: make use of barrier options with explicit barriers Will Deacon
2014-02-19 12:28 ` [PATCH v3 2/5] irqchip: gic: use dmb ishst instead of dsb when raising a softirq Will Deacon
2014-02-19 12:32 ` Catalin Marinas
2014-02-19 13:21 ` Marc Zyngier
2014-02-19 12:28 ` [PATCH v3 3/5] iommu/arm-smmu: provide option to dsb macro when publishing tables Will Deacon
2014-02-19 12:28 ` [PATCH v3 4/5] arm64: barriers: wire up new barrier options Will Deacon
2014-02-19 12:28 ` [PATCH v3 5/5] arm64: barriers: use barrier() instead of smp_mb() when !SMP Will Deacon
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).