All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8]
@ 2021-02-05 12:53 Patrick Delaunay
  2021-02-05 12:53 ` [PATCH 1/8] stm32mp: update MMU config before the relocation Patrick Delaunay
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Serie proposed after analysis in [1], to correctly handle Domain Access
Control Register (DACR) and activate the domain checking in MMU against
the permission bits in the translation tables and avoids prefetching issue
on ARMv7, as indicated in [1].

I propose a clean and general solution for ARMv7, when the LPAE is not
activated; after this update, I revert the correction done for OMAP
by the commit de63ac278cba ("ARM: mmu: Set domain permissions to client
access")

Tests on ARMv7 platform is requested before integration,
so I think the target can be v2021.07 (next).

The 2 first patch of the serie solve issues for stm32mp platform
when dcache is activate in pre-reloc or in SPL.

See also correction for LPAE mode in commit 06d43c808d61 ("arm: Set TTB
XN bit in case DCACHE_OFF for LPAE mode")


[1] [PATCH 0/7] arm: cache: cp15: don't map reserved region with no-map
    property
http://u-boot.10912.n7.nabble.com/PATCH-0-7-arm-cache-cp15-don-t-map-reserved-region-with-no-map-property-tt428715.html



Patrick Delaunay (8):
  stm32mp: update MMU config before the relocation
  stm32mp: update the mmu configuration for SPL and prereloc
  arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH
  arm: cosmetic: align TTB_SECT define value
  arm: cp15: update DACR value to activate access control
  arm: omap2: remove arm_init_domains
  arm: cp15: remove weak function arm_init_domains
  arm: remove set_dacr/get_dacr functions

 arch/arm/cpu/armv7/cache_v7.c     |  3 ---
 arch/arm/include/asm/cache.h      |  1 -
 arch/arm/include/asm/system.h     | 18 ++------------
 arch/arm/lib/cache-cp15.c         | 13 ++++------
 arch/arm/mach-omap2/omap-cache.c  | 17 -------------
 arch/arm/mach-stm32mp/cpu.c       | 40 +++++++++++++++++++++++--------
 arch/arm/mach-stm32mp/dram_init.c | 13 ++++++----
 7 files changed, 46 insertions(+), 59 deletions(-)

-- 
2.17.1

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

* [PATCH 1/8] stm32mp: update MMU config before the relocation
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:08   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 2/8] stm32mp: update the mmu configuration for SPL and prereloc Patrick Delaunay
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Mark the top of ram, used for relocated U-Boot as a normal memory
(cacheable and executable) to avoid permission access issue when
U-Boot jumps to this relocated code.

When MMU is activated in pre-reloc stage; only the beginning of
DDR is marked executable.

This patch avoids access issue when DACR is correctly managed.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-stm32mp/dram_init.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
index 32b177bb79..5fc8c6e15d 100644
--- a/arch/arm/mach-stm32mp/dram_init.c
+++ b/arch/arm/mach-stm32mp/dram_init.c
@@ -12,6 +12,7 @@
 #include <lmb.h>
 #include <log.h>
 #include <ram.h>
+#include <asm/system.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -40,6 +41,7 @@ int dram_init(void)
 
 ulong board_get_usable_ram_top(ulong total_size)
 {
+	phys_size_t size;
 	phys_addr_t reg;
 	struct lmb lmb;
 
@@ -47,10 +49,13 @@ ulong board_get_usable_ram_top(ulong total_size)
 	lmb_init(&lmb);
 	lmb_add(&lmb, gd->ram_base, gd->ram_size);
 	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
-	reg = lmb_alloc(&lmb, CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
+	size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE),
+	reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
 
-	if (reg)
-		return ALIGN(reg + CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K);
+	if (!reg)
+		reg = gd->ram_top - size;
 
-	return gd->ram_top;
+	mmu_set_region_dcache_behaviour(reg, size, DCACHE_DEFAULT_OPTION);
+
+	return reg + size;
 }
-- 
2.17.1

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

* [PATCH 2/8] stm32mp: update the mmu configuration for SPL and prereloc
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
  2021-02-05 12:53 ` [PATCH 1/8] stm32mp: update MMU config before the relocation Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:08   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 3/8] arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH Patrick Delaunay
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Overidde the weak function dram_bank_mmu_setup() to set the DDR
(preloc case) or the SYSRAM (in SPL case) executable before to enable
the MMU and configure DACR.

This weak function is called in dcache_enable/mmu_setup.

This patchs avoids a permission access issue when the DDR is marked
executable (by calling mmu_set_region_dcache_behaviour with
DCACHE_DEFAULT_OPTION) after MMU setup and domain access permission
activation with DACR in dcache_enable.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-stm32mp/cpu.c | 40 +++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index 717f80e9ff..030066dc7c 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -210,6 +210,35 @@ u32 get_bootmode(void)
 		    TAMP_BOOT_MODE_SHIFT;
 }
 
+/*
+ * weak function overidde: set the DDR/SYSRAM executable before to enable the
+ * MMU and configure DACR, for early early_enable_caches (SPL or pre-reloc)
+ */
+void dram_bank_mmu_setup(int bank)
+{
+	struct bd_info *bd = gd->bd;
+	int	i;
+	phys_addr_t start;
+	phys_size_t size;
+
+	if (IS_ENABLED(CONFIG_SPL_BUILD)) {
+		start = ALIGN_DOWN(STM32_SYSRAM_BASE, MMU_SECTION_SIZE);
+		size = ALIGN(STM32_SYSRAM_SIZE, MMU_SECTION_SIZE);
+	} else if (gd->flags & GD_FLG_RELOC) {
+		/* bd->bi_dram is available only after relocation */
+		start = bd->bi_dram[bank].start;
+		size =  bd->bi_dram[bank].size;
+	} else {
+		/* mark cacheable and executable the beggining of the DDR */
+		start = STM32_DDR_BASE;
+		size = CONFIG_DDR_CACHEABLE_SIZE;
+	}
+
+	for (i = start >> MMU_SECTION_SHIFT;
+	     i < (start >> MMU_SECTION_SHIFT) + (size >> MMU_SECTION_SHIFT);
+	     i++)
+		set_section_dcache(i, DCACHE_DEFAULT_OPTION);
+}
 /*
  * initialize the MMU and activate cache in SPL or in U-Boot pre-reloc stage
  * MMU/TLB is updated in enable_caches() for U-Boot after relocation
@@ -225,17 +254,8 @@ static void early_enable_caches(void)
 	gd->arch.tlb_size = PGTABLE_SIZE;
 	gd->arch.tlb_addr = (unsigned long)&early_tlb;
 
+	/* enable MMU (default configuration) */
 	dcache_enable();
-
-	if (IS_ENABLED(CONFIG_SPL_BUILD))
-		mmu_set_region_dcache_behaviour(
-			ALIGN_DOWN(STM32_SYSRAM_BASE, MMU_SECTION_SIZE),
-			ALIGN(STM32_SYSRAM_SIZE, MMU_SECTION_SIZE),
-			DCACHE_DEFAULT_OPTION);
-	else
-		mmu_set_region_dcache_behaviour(STM32_DDR_BASE,
-						CONFIG_DDR_CACHEABLE_SIZE,
-						DCACHE_DEFAULT_OPTION);
 }
 
 /*
-- 
2.17.1

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

* [PATCH 3/8] arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
  2021-02-05 12:53 ` [PATCH 1/8] stm32mp: update MMU config before the relocation Patrick Delaunay
  2021-02-05 12:53 ` [PATCH 2/8] stm32mp: update the mmu configuration for SPL and prereloc Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:08   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 4/8] arm: cosmetic: align TTB_SECT define value Patrick Delaunay
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

The normal memory (other that DCACHE_OFF) should be executable by default,
only the device memory (DCACHE_OFF) used for peripheral access should have
the bit execute never (TTB_SECT_XN_MASK).

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/include/asm/system.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 5fe83699f4..9db64dd69d 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -489,7 +489,7 @@ enum dcache_option {
  */
 enum dcache_option {
 	DCACHE_OFF = TTB_SECT_DOMAIN(0) | TTB_SECT_XN_MASK | TTB_SECT,
-	DCACHE_WRITETHROUGH = DCACHE_OFF | TTB_SECT_C_MASK,
+	DCACHE_WRITETHROUGH = TTB_SECT_DOMAIN(0) | TTB_SECT | TTB_SECT_C_MASK,
 	DCACHE_WRITEBACK = DCACHE_WRITETHROUGH | TTB_SECT_B_MASK,
 	DCACHE_WRITEALLOC = DCACHE_WRITEBACK | TTB_SECT_TEX(1),
 };
-- 
2.17.1

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

* [PATCH 4/8] arm: cosmetic: align TTB_SECT define value
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
                   ` (2 preceding siblings ...)
  2021-02-05 12:53 ` [PATCH 3/8] arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:09   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 5/8] arm: cp15: update DACR value to activate access control Patrick Delaunay
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Align TTB_SECT define value with previous value.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/include/asm/system.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 9db64dd69d..289b820a6d 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -475,7 +475,7 @@ enum dcache_option {
 #define TTB_SECT_XN_MASK	(1 << 4)
 #define TTB_SECT_C_MASK		(1 << 3)
 #define TTB_SECT_B_MASK		(1 << 2)
-#define TTB_SECT			(2 << 0)
+#define TTB_SECT		(2 << 0)
 
 /*
  * Short-descriptor format memory region attributes, without TEX remap
-- 
2.17.1

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

* [PATCH 5/8] arm: cp15: update DACR value to activate access control
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
                   ` (3 preceding siblings ...)
  2021-02-05 12:53 ` [PATCH 4/8] arm: cosmetic: align TTB_SECT define value Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:09   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 6/8] arm: omap2: remove arm_init_domains Patrick Delaunay
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Update the initial value of Domain Access Control Register (DACR)
and set by default the access permission to client (DACR_Dn_CLIENT = 1U)
for each of the 16 domains and no more to all-supervisor
(DACR_Dn_MANAGER = 3U).

This patch allows to activate the domain checking in MMU against the
permission bits in the translation tables and avoids prefetching issue
on ARMv7 [1].

Today it was already done for OMAP2 architecture
./arch/arm/mach-omap2/omap-cache.c::arm_init_domains
introduced by commit de63ac278cba ("ARM: mmu: Set domain permissions
to client access") which fixes lot of speculative prefetch aborts seen
on OMAP5 secure devices.

[1] https://developer.arm.com/documentation/ddi0406/b/System-Level-Architecture/Virtual-Memory-System-Architecture--VMSA-/Memory-access-control/The-Execute-Never--XN--attribute-and-instruction-prefetching

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reported-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/lib/cache-cp15.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index abd81d21c7..f78ce33b18 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -202,9 +202,12 @@ static inline void mmu_setup(void)
 	asm volatile("mcr p15, 0, %0, c2, c0, 0"
 		     : : "r" (gd->arch.tlb_addr) : "memory");
 #endif
-	/* Set the access control to all-supervisor */
+	/*
+	 * initial value of Domain Access Control Register (DACR)
+	 * Set the access control to client (1U) for each of the 16 domains
+	 */
 	asm volatile("mcr p15, 0, %0, c3, c0, 0"
-		     : : "r" (~0));
+		     : : "r" (0x55555555));
 
 	arm_init_domains();
 
-- 
2.17.1

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

* [PATCH 6/8] arm: omap2: remove arm_init_domains
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
                   ` (4 preceding siblings ...)
  2021-02-05 12:53 ` [PATCH 5/8] arm: cp15: update DACR value to activate access control Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:09   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 7/8] arm: cp15: remove weak function arm_init_domains Patrick Delaunay
  2021-02-05 12:53 ` [PATCH 8/8] arm: remove set_dacr/get_dacr functions Patrick Delaunay
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Remove the arm_init_domains and the DACR update, as it is now done
in ARMv7 CP15 level.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-omap2/omap-cache.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-cache.c b/arch/arm/mach-omap2/omap-cache.c
index 502ea6987a..451d8e4542 100644
--- a/arch/arm/mach-omap2/omap-cache.c
+++ b/arch/arm/mach-omap2/omap-cache.c
@@ -40,9 +40,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ARMV7_DCACHE_POLICY	DCACHE_WRITEBACK & ~TTB_SECT_XN_MASK
 #endif
 
-#define ARMV7_DOMAIN_CLIENT	1
-#define ARMV7_DOMAIN_MASK	(0x3 << 0)
-
 void enable_caches(void)
 {
 
@@ -66,17 +63,3 @@ void dram_bank_mmu_setup(int bank)
 	for (i = start; i < end; i++)
 		set_section_dcache(i, ARMV7_DCACHE_POLICY);
 }
-
-void arm_init_domains(void)
-{
-	u32 reg;
-
-	reg = get_dacr();
-	/*
-	* Set DOMAIN to client access so that all permissions
-	* set in pagetables are validated by the mmu.
-	*/
-	reg &= ~ARMV7_DOMAIN_MASK;
-	reg |= ARMV7_DOMAIN_CLIENT;
-	set_dacr(reg);
-}
-- 
2.17.1

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

* [PATCH 7/8] arm: cp15: remove weak function arm_init_domains
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
                   ` (5 preceding siblings ...)
  2021-02-05 12:53 ` [PATCH 6/8] arm: omap2: remove arm_init_domains Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:09   ` Tom Rini
  2021-02-05 12:53 ` [PATCH 8/8] arm: remove set_dacr/get_dacr functions Patrick Delaunay
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Remove the unused weak function arm_init_domains used to change the
DACR value.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/cpu/armv7/cache_v7.c | 3 ---
 arch/arm/include/asm/cache.h  | 1 -
 arch/arm/lib/cache-cp15.c     | 6 ------
 3 files changed, 10 deletions(-)

diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
index 146cf52608..19ff432352 100644
--- a/arch/arm/cpu/armv7/cache_v7.c
+++ b/arch/arm/cpu/armv7/cache_v7.c
@@ -176,9 +176,6 @@ void mmu_page_table_flush(unsigned long start, unsigned long stop)
 {
 }
 
-void arm_init_domains(void)
-{
-}
 #endif /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
 
 #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
index c20e05ec7f..b10edf805b 100644
--- a/arch/arm/include/asm/cache.h
+++ b/arch/arm/include/asm/cache.h
@@ -35,7 +35,6 @@ void l2_cache_disable(void);
 void set_section_dcache(int section, enum dcache_option option);
 
 void arm_init_before_mmu(void);
-void arm_init_domains(void);
 void cpu_cache_initialization(void);
 void dram_bank_mmu_setup(int bank);
 
diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index f78ce33b18..8a49e5217c 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -21,10 +21,6 @@ __weak void arm_init_before_mmu(void)
 {
 }
 
-__weak void arm_init_domains(void)
-{
-}
-
 static void set_section_phys(int section, phys_addr_t phys,
 			     enum dcache_option option)
 {
@@ -209,8 +205,6 @@ static inline void mmu_setup(void)
 	asm volatile("mcr p15, 0, %0, c3, c0, 0"
 		     : : "r" (0x55555555));
 
-	arm_init_domains();
-
 	/* and enable the mmu */
 	reg = get_cr();	/* get control reg. */
 	set_cr(reg | CR_M);
-- 
2.17.1

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

* [PATCH 8/8] arm: remove set_dacr/get_dacr functions
  2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
                   ` (6 preceding siblings ...)
  2021-02-05 12:53 ` [PATCH 7/8] arm: cp15: remove weak function arm_init_domains Patrick Delaunay
@ 2021-02-05 12:53 ` Patrick Delaunay
  2021-03-03 19:09   ` Tom Rini
  7 siblings, 1 reply; 22+ messages in thread
From: Patrick Delaunay @ 2021-02-05 12:53 UTC (permalink / raw)
  To: u-boot

Remove the unused function set_dacr/get_dacr

Serie-cc: Ard Biesheuvel <ardb@kernel.org>
Serie-cc: R Sricharan <r.sricharan@ti.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/include/asm/system.h | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 289b820a6d..11fceec4d2 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -397,20 +397,6 @@ static inline void set_cr(unsigned int val)
 	isb();
 }
 
-static inline unsigned int get_dacr(void)
-{
-	unsigned int val;
-	asm("mrc p15, 0, %0, c3, c0, 0	@ get DACR" : "=r" (val) : : "cc");
-	return val;
-}
-
-static inline void set_dacr(unsigned int val)
-{
-	asm volatile("mcr p15, 0, %0, c3, c0, 0	@ set DACR"
-	  : : "r" (val) : "cc");
-	isb();
-}
-
 #ifdef CONFIG_ARMV7_LPAE
 /* Long-Descriptor Translation Table Level 1/2 Bits */
 #define TTB_SECT_XN_MASK	(1ULL << 54)
-- 
2.17.1

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

* [PATCH 1/8] stm32mp: update MMU config before the relocation
  2021-02-05 12:53 ` [PATCH 1/8] stm32mp: update MMU config before the relocation Patrick Delaunay
@ 2021-03-03 19:08   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:08 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:32PM +0100, Patrick Delaunay wrote:

> Mark the top of ram, used for relocated U-Boot as a normal memory
> (cacheable and executable) to avoid permission access issue when
> U-Boot jumps to this relocated code.
> 
> When MMU is activated in pre-reloc stage; only the beginning of
> DDR is marked executable.
> 
> This patch avoids access issue when DACR is correctly managed.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/10ecb907/attachment.sig>

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

* [PATCH 2/8] stm32mp: update the mmu configuration for SPL and prereloc
  2021-02-05 12:53 ` [PATCH 2/8] stm32mp: update the mmu configuration for SPL and prereloc Patrick Delaunay
@ 2021-03-03 19:08   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:08 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:33PM +0100, Patrick Delaunay wrote:

> Overidde the weak function dram_bank_mmu_setup() to set the DDR
> (preloc case) or the SYSRAM (in SPL case) executable before to enable
> the MMU and configure DACR.
> 
> This weak function is called in dcache_enable/mmu_setup.
> 
> This patchs avoids a permission access issue when the DDR is marked
> executable (by calling mmu_set_region_dcache_behaviour with
> DCACHE_DEFAULT_OPTION) after MMU setup and domain access permission
> activation with DACR in dcache_enable.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/8fb111a9/attachment.sig>

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

* [PATCH 3/8] arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH
  2021-02-05 12:53 ` [PATCH 3/8] arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH Patrick Delaunay
@ 2021-03-03 19:08   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:08 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:34PM +0100, Patrick Delaunay wrote:

> The normal memory (other that DCACHE_OFF) should be executable by default,
> only the device memory (DCACHE_OFF) used for peripheral access should have
> the bit execute never (TTB_SECT_XN_MASK).
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/3d62db45/attachment.sig>

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

* [PATCH 4/8] arm: cosmetic: align TTB_SECT define value
  2021-02-05 12:53 ` [PATCH 4/8] arm: cosmetic: align TTB_SECT define value Patrick Delaunay
@ 2021-03-03 19:09   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:09 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:35PM +0100, Patrick Delaunay wrote:

> Align TTB_SECT define value with previous value.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/40c25fbe/attachment.sig>

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

* [PATCH 5/8] arm: cp15: update DACR value to activate access control
  2021-02-05 12:53 ` [PATCH 5/8] arm: cp15: update DACR value to activate access control Patrick Delaunay
@ 2021-03-03 19:09   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:09 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:36PM +0100, Patrick Delaunay wrote:

> Update the initial value of Domain Access Control Register (DACR)
> and set by default the access permission to client (DACR_Dn_CLIENT = 1U)
> for each of the 16 domains and no more to all-supervisor
> (DACR_Dn_MANAGER = 3U).
> 
> This patch allows to activate the domain checking in MMU against the
> permission bits in the translation tables and avoids prefetching issue
> on ARMv7 [1].
> 
> Today it was already done for OMAP2 architecture
> ./arch/arm/mach-omap2/omap-cache.c::arm_init_domains
> introduced by commit de63ac278cba ("ARM: mmu: Set domain permissions
> to client access") which fixes lot of speculative prefetch aborts seen
> on OMAP5 secure devices.
> 
> [1] https://developer.arm.com/documentation/ddi0406/b/System-Level-Architecture/Virtual-Memory-System-Architecture--VMSA-/Memory-access-control/The-Execute-Never--XN--attribute-and-instruction-prefetching
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> Reported-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/229398d9/attachment.sig>

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

* [PATCH 6/8] arm: omap2: remove arm_init_domains
  2021-02-05 12:53 ` [PATCH 6/8] arm: omap2: remove arm_init_domains Patrick Delaunay
@ 2021-03-03 19:09   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:09 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:37PM +0100, Patrick Delaunay wrote:

> Remove the arm_init_domains and the DACR update, as it is now done
> in ARMv7 CP15 level.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/8b210d24/attachment.sig>

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

* [PATCH 7/8] arm: cp15: remove weak function arm_init_domains
  2021-02-05 12:53 ` [PATCH 7/8] arm: cp15: remove weak function arm_init_domains Patrick Delaunay
@ 2021-03-03 19:09   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:09 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:38PM +0100, Patrick Delaunay wrote:

> Remove the unused weak function arm_init_domains used to change the
> DACR value.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/aa106af3/attachment.sig>

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

* [PATCH 8/8] arm: remove set_dacr/get_dacr functions
  2021-02-05 12:53 ` [PATCH 8/8] arm: remove set_dacr/get_dacr functions Patrick Delaunay
@ 2021-03-03 19:09   ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2021-03-03 19:09 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 01:53:39PM +0100, Patrick Delaunay wrote:

> Remove the unused function set_dacr/get_dacr
> 
> Serie-cc: Ard Biesheuvel <ardb@kernel.org>
> Serie-cc: R Sricharan <r.sricharan@ti.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210303/81760aa1/attachment.sig>

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

* Re: [PATCH 0/8]
  2019-04-15  3:41   ` Sam Bobroff
@ 2019-04-19 22:36     ` Tyrel Datwyler
  0 siblings, 0 replies; 22+ messages in thread
From: Tyrel Datwyler @ 2019-04-19 22:36 UTC (permalink / raw)
  To: Sam Bobroff, Tyrel Datwyler; +Cc: linuxppc-dev

On 04/14/2019 08:41 PM, Sam Bobroff wrote:
> On Thu, Apr 11, 2019 at 05:55:33PM -0700, Tyrel Datwyler wrote:
>> On 03/19/2019 07:58 PM, Sam Bobroff wrote:
>>> Hi all,
>>>
>>> This patch set adds support for EEH recovery of hot plugged devices on pSeries
>>> machines. Specifically, devices discovered by PCI rescanning using
>>> /sys/bus/pci/rescan, which includes devices hotplugged by QEMU's device_add
>>> command. (pSeries doesn't currently use slot power control for hotplugging.)
>>
>> Slight nit that its not that pSeries doesn't support slot power control
>> hotplugging, its that QEMU pSeries guests don't support it. We most definitely
>> use the slot power control for hotplugging in PowerVM pSeries Linux guests. More
> 
> Ah, I think I see what you mean: pSeries can (and does!) use slot power
> control for hotplugging, it's just that Linux doesn't. Right :-) I'll
> change it to "Linux on pSeries doesn't...." for the next version.

Not quite. A pSeries Linux PowerVM LPAR does use the slot power hotplugging. It
is only the pSeries Linux qemu guest that doesn't. The way that hotplug is
initiated is different for PowerVM and qemu. On PowerVM the command is sent from
the HMC down the RSCT stack which calls drmgr whereas with qemu hotplug
generates an interrupt which logs an event that is picked up by rtas_errd which
then calls drmgr with the "-V" flag. That flag was a special case that we added
to drmgr to work around the slot power hotplugging with rpaphp not working
correctly with qemu guests.

> 
>> specifically we had to work around short comings in the rpaphp driver when
>> dealing with QEMU. This being that while at initial glance the design implies
>> that it had multiple devices per PHB in mind, it didn't, and only actually
>> supported a single slot per PHB. Further, when we developed the QEMU pci hotplug
>> feature we had to deal with only having a single PHB per QEMU guest and as a
>> result needed a way to plug multiple pci devices into a single PHB. Hence, came
>> the pci rescan work around in drmgr.
>>
>> Mike Roth and I have had discussions over the years to get the slot power
>> control hotplugging working properly with QEMU, and while I did get the RPA
>> hotplug driver fixed to register all available slots associated with a PHB, EEH
>> remained an issue. So, I'm very happy to see this patchset get that working with
>> the rescan work around.
>>
>>>
>>> As a side effect this also provides EEH support for devices removed by
>>> /sys/bus/pci/devices/*/remove and re-discovered by writing to /sys/bus/pci/rescan,
>>> on all platforms.
>>
>> +1, this seems like icing on the cake. ;)
> 
> Yes :-)
> 
> Although maybe I should mention that we can't really benefit from this
> on PowerNV *yet* because there seem to be some other problems with
> removing and re-scanning devices: in my tests devices are often unusable
> after being rediscovered.
> 
> (I'm hoping to take a look at that soon.)

Interesting.

> 
>>>
>>> The approach I've taken is to use the fact that the existing
>>> pcibios_bus_add_device() platform hooks (which are used to set up EEH on
>>> Virtual Function devices (VFs)) are actually called for all devices, so I've
>>> widened their scope and made other adjustments necessary to allow them to work
>>> for hotplugged and boot-time devices as well.
>>>
>>> Because some of the changes are in generic PowerPC code, it's
>>> possible that I've disturbed something for another PowerPC platform. I've tried
>>> to minimize this by leaving that code alone as much as possible and so there
>>> are a few cases where eeh_add_device_{early,late}() or eeh_add_sysfs_files() is
>>> called more than once. I think these can be looked at later, as duplicate calls
>>> are not harmful.
>>>
>>> The patch "Convert PNV_PHB_FLAG_EEH" isn't strictly necessary and I'm not sure
>>> if it's better to keep it, because it simplifies the code or drop it, because
>>> we may need a separate flag per PHB later on. Thoughts anyone?
>>>
>>> The first patch is a rework of the pcibios_init reordering patch I posted
>>> earlier, which I've included here because it's necessary for this set.
>>>
>>> I have done some testing for PowerNV on Power9 using a modified pnv_php module
>>> and some testing on pSeries with slot power control using a modified rpaphp
>>> module, and the EEH-related parts seem to work.
>>
>> I'm interested in what modifications with rpaphp. Its unclear if you are saying
>> rpaphp modified so that slot power hotplug works with a QEMU pSeries guest? If
>> thats the case it would be optimal to get that upstream and remove the work
>> rescan workaround for guests that don't need it.
> 
> Unfortunately no, I didn't do enough work to really get it working.  I
> just wanted to get an idea of how that code path interacted with the EEH
> code I was changing, so that hopefully when we get to fixing it, the EEH
> part will be easier to do.
> 
> The hack I tested with was:
> 
> - rtas_errd changed so that it doesn't pass -V to drmgr (-V seems to
>   trigger drmgr to use the PCI rescan system rather that slot power
>   control).

Correct, as I mentioned above we did that on purpose to basically hack around
rpaphp not working with qemu guests.

-Tyrel

> - of_pci_parse_addrs() changed so that if the assigned-addresses node
>   is missing (which it is when the guest is running under QEMU/KVM) we
>   call pci_setup_device() to configure the BARs.
> 
> It did look pretty good -- the EEH part may actually work fine once we get
> the rest sorted out.
> 
>>
>> -Tyrel
>>
>>>
>>> Cheers,
>>> Sam.
>>>
>>> Sam Bobroff (8):
>>>   powerpc/64: Adjust order in pcibios_init()
>>>   powerpc/eeh: Clear stale EEH_DEV_NO_HANDLER flag
>>>   powerpc/eeh: Convert PNV_PHB_FLAG_EEH to global flag
>>>   powerpc/eeh: Improve debug messages around device addition
>>>   powerpc/eeh: Add eeh_show_enabled()
>>>   powerpc/eeh: Initialize EEH address cache earlier
>>>   powerpc/eeh: EEH for pSeries hot plug
>>>   powerpc/eeh: Remove eeh_probe_devices() and eeh_addr_cache_build()
>>>
>>>  arch/powerpc/include/asm/eeh.h               | 19 +++--
>>>  arch/powerpc/kernel/eeh.c                    | 33 ++++-----
>>>  arch/powerpc/kernel/eeh_cache.c              | 29 +-------
>>>  arch/powerpc/kernel/eeh_driver.c             |  4 ++
>>>  arch/powerpc/kernel/of_platform.c            |  3 +-
>>>  arch/powerpc/kernel/pci-common.c             |  4 --
>>>  arch/powerpc/kernel/pci_32.c                 |  4 ++
>>>  arch/powerpc/kernel/pci_64.c                 | 12 +++-
>>>  arch/powerpc/platforms/powernv/eeh-powernv.c | 41 +++++------
>>>  arch/powerpc/platforms/powernv/pci.c         |  7 +-
>>>  arch/powerpc/platforms/powernv/pci.h         |  2 -
>>>  arch/powerpc/platforms/pseries/eeh_pseries.c | 75 +++++++++++---------
>>>  arch/powerpc/platforms/pseries/pci.c         |  7 +-
>>>  13 files changed, 122 insertions(+), 118 deletions(-)
>>>
>>


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

* Re: [PATCH 0/8]
  2019-04-12  0:55 ` Tyrel Datwyler
@ 2019-04-15  3:41   ` Sam Bobroff
  2019-04-19 22:36     ` Tyrel Datwyler
  0 siblings, 1 reply; 22+ messages in thread
From: Sam Bobroff @ 2019-04-15  3:41 UTC (permalink / raw)
  To: Tyrel Datwyler; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 6202 bytes --]

On Thu, Apr 11, 2019 at 05:55:33PM -0700, Tyrel Datwyler wrote:
> On 03/19/2019 07:58 PM, Sam Bobroff wrote:
> > Hi all,
> > 
> > This patch set adds support for EEH recovery of hot plugged devices on pSeries
> > machines. Specifically, devices discovered by PCI rescanning using
> > /sys/bus/pci/rescan, which includes devices hotplugged by QEMU's device_add
> > command. (pSeries doesn't currently use slot power control for hotplugging.)
> 
> Slight nit that its not that pSeries doesn't support slot power control
> hotplugging, its that QEMU pSeries guests don't support it. We most definitely
> use the slot power control for hotplugging in PowerVM pSeries Linux guests. More

Ah, I think I see what you mean: pSeries can (and does!) use slot power
control for hotplugging, it's just that Linux doesn't. Right :-) I'll
change it to "Linux on pSeries doesn't...." for the next version.

> specifically we had to work around short comings in the rpaphp driver when
> dealing with QEMU. This being that while at initial glance the design implies
> that it had multiple devices per PHB in mind, it didn't, and only actually
> supported a single slot per PHB. Further, when we developed the QEMU pci hotplug
> feature we had to deal with only having a single PHB per QEMU guest and as a
> result needed a way to plug multiple pci devices into a single PHB. Hence, came
> the pci rescan work around in drmgr.
> 
> Mike Roth and I have had discussions over the years to get the slot power
> control hotplugging working properly with QEMU, and while I did get the RPA
> hotplug driver fixed to register all available slots associated with a PHB, EEH
> remained an issue. So, I'm very happy to see this patchset get that working with
> the rescan work around.
> 
> > 
> > As a side effect this also provides EEH support for devices removed by
> > /sys/bus/pci/devices/*/remove and re-discovered by writing to /sys/bus/pci/rescan,
> > on all platforms.
> 
> +1, this seems like icing on the cake. ;)

Yes :-)

Although maybe I should mention that we can't really benefit from this
on PowerNV *yet* because there seem to be some other problems with
removing and re-scanning devices: in my tests devices are often unusable
after being rediscovered.

(I'm hoping to take a look at that soon.)

> > 
> > The approach I've taken is to use the fact that the existing
> > pcibios_bus_add_device() platform hooks (which are used to set up EEH on
> > Virtual Function devices (VFs)) are actually called for all devices, so I've
> > widened their scope and made other adjustments necessary to allow them to work
> > for hotplugged and boot-time devices as well.
> > 
> > Because some of the changes are in generic PowerPC code, it's
> > possible that I've disturbed something for another PowerPC platform. I've tried
> > to minimize this by leaving that code alone as much as possible and so there
> > are a few cases where eeh_add_device_{early,late}() or eeh_add_sysfs_files() is
> > called more than once. I think these can be looked at later, as duplicate calls
> > are not harmful.
> > 
> > The patch "Convert PNV_PHB_FLAG_EEH" isn't strictly necessary and I'm not sure
> > if it's better to keep it, because it simplifies the code or drop it, because
> > we may need a separate flag per PHB later on. Thoughts anyone?
> > 
> > The first patch is a rework of the pcibios_init reordering patch I posted
> > earlier, which I've included here because it's necessary for this set.
> > 
> > I have done some testing for PowerNV on Power9 using a modified pnv_php module
> > and some testing on pSeries with slot power control using a modified rpaphp
> > module, and the EEH-related parts seem to work.
> 
> I'm interested in what modifications with rpaphp. Its unclear if you are saying
> rpaphp modified so that slot power hotplug works with a QEMU pSeries guest? If
> thats the case it would be optimal to get that upstream and remove the work
> rescan workaround for guests that don't need it.

Unfortunately no, I didn't do enough work to really get it working.  I
just wanted to get an idea of how that code path interacted with the EEH
code I was changing, so that hopefully when we get to fixing it, the EEH
part will be easier to do.

The hack I tested with was:

- rtas_errd changed so that it doesn't pass -V to drmgr (-V seems to
  trigger drmgr to use the PCI rescan system rather that slot power
  control).
- of_pci_parse_addrs() changed so that if the assigned-addresses node
  is missing (which it is when the guest is running under QEMU/KVM) we
  call pci_setup_device() to configure the BARs.

It did look pretty good -- the EEH part may actually work fine once we get
the rest sorted out.

> 
> -Tyrel
> 
> > 
> > Cheers,
> > Sam.
> > 
> > Sam Bobroff (8):
> >   powerpc/64: Adjust order in pcibios_init()
> >   powerpc/eeh: Clear stale EEH_DEV_NO_HANDLER flag
> >   powerpc/eeh: Convert PNV_PHB_FLAG_EEH to global flag
> >   powerpc/eeh: Improve debug messages around device addition
> >   powerpc/eeh: Add eeh_show_enabled()
> >   powerpc/eeh: Initialize EEH address cache earlier
> >   powerpc/eeh: EEH for pSeries hot plug
> >   powerpc/eeh: Remove eeh_probe_devices() and eeh_addr_cache_build()
> > 
> >  arch/powerpc/include/asm/eeh.h               | 19 +++--
> >  arch/powerpc/kernel/eeh.c                    | 33 ++++-----
> >  arch/powerpc/kernel/eeh_cache.c              | 29 +-------
> >  arch/powerpc/kernel/eeh_driver.c             |  4 ++
> >  arch/powerpc/kernel/of_platform.c            |  3 +-
> >  arch/powerpc/kernel/pci-common.c             |  4 --
> >  arch/powerpc/kernel/pci_32.c                 |  4 ++
> >  arch/powerpc/kernel/pci_64.c                 | 12 +++-
> >  arch/powerpc/platforms/powernv/eeh-powernv.c | 41 +++++------
> >  arch/powerpc/platforms/powernv/pci.c         |  7 +-
> >  arch/powerpc/platforms/powernv/pci.h         |  2 -
> >  arch/powerpc/platforms/pseries/eeh_pseries.c | 75 +++++++++++---------
> >  arch/powerpc/platforms/pseries/pci.c         |  7 +-
> >  13 files changed, 122 insertions(+), 118 deletions(-)
> > 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/8]
  2019-03-20  2:58 [PATCH 0/8] Sam Bobroff
@ 2019-04-12  0:55 ` Tyrel Datwyler
  2019-04-15  3:41   ` Sam Bobroff
  0 siblings, 1 reply; 22+ messages in thread
From: Tyrel Datwyler @ 2019-04-12  0:55 UTC (permalink / raw)
  To: Sam Bobroff, linuxppc-dev

On 03/19/2019 07:58 PM, Sam Bobroff wrote:
> Hi all,
> 
> This patch set adds support for EEH recovery of hot plugged devices on pSeries
> machines. Specifically, devices discovered by PCI rescanning using
> /sys/bus/pci/rescan, which includes devices hotplugged by QEMU's device_add
> command. (pSeries doesn't currently use slot power control for hotplugging.)

Slight nit that its not that pSeries doesn't support slot power control
hotplugging, its that QEMU pSeries guests don't support it. We most definitely
use the slot power control for hotplugging in PowerVM pSeries Linux guests. More
specifically we had to work around short comings in the rpaphp driver when
dealing with QEMU. This being that while at initial glance the design implies
that it had multiple devices per PHB in mind, it didn't, and only actually
supported a single slot per PHB. Further, when we developed the QEMU pci hotplug
feature we had to deal with only having a single PHB per QEMU guest and as a
result needed a way to plug multiple pci devices into a single PHB. Hence, came
the pci rescan work around in drmgr.

Mike Roth and I have had discussions over the years to get the slot power
control hotplugging working properly with QEMU, and while I did get the RPA
hotplug driver fixed to register all available slots associated with a PHB, EEH
remained an issue. So, I'm very happy to see this patchset get that working with
the rescan work around.

> 
> As a side effect this also provides EEH support for devices removed by
> /sys/bus/pci/devices/*/remove and re-discovered by writing to /sys/bus/pci/rescan,
> on all platforms.

+1, this seems like icing on the cake. ;)

> 
> The approach I've taken is to use the fact that the existing
> pcibios_bus_add_device() platform hooks (which are used to set up EEH on
> Virtual Function devices (VFs)) are actually called for all devices, so I've
> widened their scope and made other adjustments necessary to allow them to work
> for hotplugged and boot-time devices as well.
> 
> Because some of the changes are in generic PowerPC code, it's
> possible that I've disturbed something for another PowerPC platform. I've tried
> to minimize this by leaving that code alone as much as possible and so there
> are a few cases where eeh_add_device_{early,late}() or eeh_add_sysfs_files() is
> called more than once. I think these can be looked at later, as duplicate calls
> are not harmful.
> 
> The patch "Convert PNV_PHB_FLAG_EEH" isn't strictly necessary and I'm not sure
> if it's better to keep it, because it simplifies the code or drop it, because
> we may need a separate flag per PHB later on. Thoughts anyone?
> 
> The first patch is a rework of the pcibios_init reordering patch I posted
> earlier, which I've included here because it's necessary for this set.
> 
> I have done some testing for PowerNV on Power9 using a modified pnv_php module
> and some testing on pSeries with slot power control using a modified rpaphp
> module, and the EEH-related parts seem to work.

I'm interested in what modifications with rpaphp. Its unclear if you are saying
rpaphp modified so that slot power hotplug works with a QEMU pSeries guest? If
thats the case it would be optimal to get that upstream and remove the work
rescan workaround for guests that don't need it.

-Tyrel

> 
> Cheers,
> Sam.
> 
> Sam Bobroff (8):
>   powerpc/64: Adjust order in pcibios_init()
>   powerpc/eeh: Clear stale EEH_DEV_NO_HANDLER flag
>   powerpc/eeh: Convert PNV_PHB_FLAG_EEH to global flag
>   powerpc/eeh: Improve debug messages around device addition
>   powerpc/eeh: Add eeh_show_enabled()
>   powerpc/eeh: Initialize EEH address cache earlier
>   powerpc/eeh: EEH for pSeries hot plug
>   powerpc/eeh: Remove eeh_probe_devices() and eeh_addr_cache_build()
> 
>  arch/powerpc/include/asm/eeh.h               | 19 +++--
>  arch/powerpc/kernel/eeh.c                    | 33 ++++-----
>  arch/powerpc/kernel/eeh_cache.c              | 29 +-------
>  arch/powerpc/kernel/eeh_driver.c             |  4 ++
>  arch/powerpc/kernel/of_platform.c            |  3 +-
>  arch/powerpc/kernel/pci-common.c             |  4 --
>  arch/powerpc/kernel/pci_32.c                 |  4 ++
>  arch/powerpc/kernel/pci_64.c                 | 12 +++-
>  arch/powerpc/platforms/powernv/eeh-powernv.c | 41 +++++------
>  arch/powerpc/platforms/powernv/pci.c         |  7 +-
>  arch/powerpc/platforms/powernv/pci.h         |  2 -
>  arch/powerpc/platforms/pseries/eeh_pseries.c | 75 +++++++++++---------
>  arch/powerpc/platforms/pseries/pci.c         |  7 +-
>  13 files changed, 122 insertions(+), 118 deletions(-)
> 


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

* [PATCH 0/8]
@ 2019-03-20  2:58 Sam Bobroff
  2019-04-12  0:55 ` Tyrel Datwyler
  0 siblings, 1 reply; 22+ messages in thread
From: Sam Bobroff @ 2019-03-20  2:58 UTC (permalink / raw)
  To: linuxppc-dev

Hi all,

This patch set adds support for EEH recovery of hot plugged devices on pSeries
machines. Specifically, devices discovered by PCI rescanning using
/sys/bus/pci/rescan, which includes devices hotplugged by QEMU's device_add
command. (pSeries doesn't currently use slot power control for hotplugging.)

As a side effect this also provides EEH support for devices removed by
/sys/bus/pci/devices/*/remove and re-discovered by writing to /sys/bus/pci/rescan,
on all platforms.

The approach I've taken is to use the fact that the existing
pcibios_bus_add_device() platform hooks (which are used to set up EEH on
Virtual Function devices (VFs)) are actually called for all devices, so I've
widened their scope and made other adjustments necessary to allow them to work
for hotplugged and boot-time devices as well.

Because some of the changes are in generic PowerPC code, it's
possible that I've disturbed something for another PowerPC platform. I've tried
to minimize this by leaving that code alone as much as possible and so there
are a few cases where eeh_add_device_{early,late}() or eeh_add_sysfs_files() is
called more than once. I think these can be looked at later, as duplicate calls
are not harmful.

The patch "Convert PNV_PHB_FLAG_EEH" isn't strictly necessary and I'm not sure
if it's better to keep it, because it simplifies the code or drop it, because
we may need a separate flag per PHB later on. Thoughts anyone?

The first patch is a rework of the pcibios_init reordering patch I posted
earlier, which I've included here because it's necessary for this set.

I have done some testing for PowerNV on Power9 using a modified pnv_php module
and some testing on pSeries with slot power control using a modified rpaphp
module, and the EEH-related parts seem to work.

Cheers,
Sam.

Sam Bobroff (8):
  powerpc/64: Adjust order in pcibios_init()
  powerpc/eeh: Clear stale EEH_DEV_NO_HANDLER flag
  powerpc/eeh: Convert PNV_PHB_FLAG_EEH to global flag
  powerpc/eeh: Improve debug messages around device addition
  powerpc/eeh: Add eeh_show_enabled()
  powerpc/eeh: Initialize EEH address cache earlier
  powerpc/eeh: EEH for pSeries hot plug
  powerpc/eeh: Remove eeh_probe_devices() and eeh_addr_cache_build()

 arch/powerpc/include/asm/eeh.h               | 19 +++--
 arch/powerpc/kernel/eeh.c                    | 33 ++++-----
 arch/powerpc/kernel/eeh_cache.c              | 29 +-------
 arch/powerpc/kernel/eeh_driver.c             |  4 ++
 arch/powerpc/kernel/of_platform.c            |  3 +-
 arch/powerpc/kernel/pci-common.c             |  4 --
 arch/powerpc/kernel/pci_32.c                 |  4 ++
 arch/powerpc/kernel/pci_64.c                 | 12 +++-
 arch/powerpc/platforms/powernv/eeh-powernv.c | 41 +++++------
 arch/powerpc/platforms/powernv/pci.c         |  7 +-
 arch/powerpc/platforms/powernv/pci.h         |  2 -
 arch/powerpc/platforms/pseries/eeh_pseries.c | 75 +++++++++++---------
 arch/powerpc/platforms/pseries/pci.c         |  7 +-
 13 files changed, 122 insertions(+), 118 deletions(-)

-- 
2.19.0.2.gcad72f5712


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

* [PATCH 0/8]
@ 2016-09-16 16:22 Michael Wood
  0 siblings, 0 replies; 22+ messages in thread
From: Michael Wood @ 2016-09-16 16:22 UTC (permalink / raw)
  To: bitbake-devel

Series to improve process handling of runbuilds and one additional patch for fixing checking out HEAD as a reference. Changes reviewed on toaster mailing list.

Copy of process handling patchset cover letter:

This patchset introduced a bit lighter way of handling builds.
Instead of polling database every second we process builds only when runbuilds
receives SIGUSR1. The signal is sent when build is either scheduled, canceled or
finished. A little bit of code cleanup is also included into this patchset.

Test instructions:
 - Create multiple builds in UI. Check if they'll be built sequentially
 - Create multiple builds in UI, cancel one. Check if the next one starts building.
 - Repeat first two test cases when command line build is run. Only one UI build
   should be run in parallel with command line build.
 - Test any other combinations of running and cancelling builds to make sure
   there are no regressions.



Ed Bartosh (8):
  toaster: fix checking of repository url
  toaster: implement signal_runbuilds function
  toaster: notify runbuilds when build status changes
  runbuilds: process builds on SIGUSR1
  runbuilds: process builds on start
  runbuilds: code cleanup - whitespaces, long lines
  runbuilds: code cleanup - remove unused imports
  toaster: unlock BuildEnvirnoment when build is done

 lib/bb/ui/buildinfohelper.py                       | 12 ++++--
 lib/toaster/bldcontrol/localhostbecontroller.py    |  2 +-
 .../bldcontrol/management/commands/runbuilds.py    | 49 ++++++++++------------
 lib/toaster/orm/models.py                          | 10 ++++-
 4 files changed, 42 insertions(+), 31 deletions(-)

-- 
2.7.4



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

end of thread, other threads:[~2021-03-03 19:09 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 12:53 [PATCH 0/8] Patrick Delaunay
2021-02-05 12:53 ` [PATCH 1/8] stm32mp: update MMU config before the relocation Patrick Delaunay
2021-03-03 19:08   ` Tom Rini
2021-02-05 12:53 ` [PATCH 2/8] stm32mp: update the mmu configuration for SPL and prereloc Patrick Delaunay
2021-03-03 19:08   ` Tom Rini
2021-02-05 12:53 ` [PATCH 3/8] arm: remove TTB_SECT_XN_MASK in DCACHE_WRITETHROUGH Patrick Delaunay
2021-03-03 19:08   ` Tom Rini
2021-02-05 12:53 ` [PATCH 4/8] arm: cosmetic: align TTB_SECT define value Patrick Delaunay
2021-03-03 19:09   ` Tom Rini
2021-02-05 12:53 ` [PATCH 5/8] arm: cp15: update DACR value to activate access control Patrick Delaunay
2021-03-03 19:09   ` Tom Rini
2021-02-05 12:53 ` [PATCH 6/8] arm: omap2: remove arm_init_domains Patrick Delaunay
2021-03-03 19:09   ` Tom Rini
2021-02-05 12:53 ` [PATCH 7/8] arm: cp15: remove weak function arm_init_domains Patrick Delaunay
2021-03-03 19:09   ` Tom Rini
2021-02-05 12:53 ` [PATCH 8/8] arm: remove set_dacr/get_dacr functions Patrick Delaunay
2021-03-03 19:09   ` Tom Rini
  -- strict thread matches above, loose matches on Subject: below --
2019-03-20  2:58 [PATCH 0/8] Sam Bobroff
2019-04-12  0:55 ` Tyrel Datwyler
2019-04-15  3:41   ` Sam Bobroff
2019-04-19 22:36     ` Tyrel Datwyler
2016-09-16 16:22 Michael Wood

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.