diff mbox series

[v2,05/16] powerpc/watchpoint: Provide DAWR number to set_dawr

Message ID 20200401061309.92442-6-ravi.bangoria@linux.ibm.com (mailing list archive)
State Superseded
Headers show
Series powerpc/watchpoint: Preparation for more than one watchpoint | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (c6624071c338732402e8c726df6a4074473eaa0e)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (7074695ac6fb965d478f373b95bc5c636e9f21b0)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (1a323ea5356edbb3073dc59d51b9e6b86908857d)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (1d0c32ec3b860a32df593a22bad0d1dbc5546a59)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (3eb7cccdb3ae41ebb6a2f5f1ccd2821550c61fe1)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Ravi Bangoria April 1, 2020, 6:12 a.m. UTC
Introduce new parameter 'nr' to set_dawr() which indicates which DAWR
should be programed.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 arch/powerpc/include/asm/hw_breakpoint.h |  4 ++--
 arch/powerpc/kernel/dawr.c               | 15 ++++++++++-----
 arch/powerpc/kernel/process.c            |  2 +-
 3 files changed, 13 insertions(+), 8 deletions(-)

Comments

Christophe Leroy April 1, 2020, 7:03 a.m. UTC | #1
Le 01/04/2020 à 08:12, Ravi Bangoria a écrit :
> Introduce new parameter 'nr' to set_dawr() which indicates which DAWR
> should be programed.
> 
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> ---
>   arch/powerpc/include/asm/hw_breakpoint.h |  4 ++--
>   arch/powerpc/kernel/dawr.c               | 15 ++++++++++-----
>   arch/powerpc/kernel/process.c            |  2 +-
>   3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
> index 518b41eef924..62549007c87a 100644
> --- a/arch/powerpc/include/asm/hw_breakpoint.h
> +++ b/arch/powerpc/include/asm/hw_breakpoint.h
> @@ -104,10 +104,10 @@ static inline bool dawr_enabled(void)
>   {
>   	return dawr_force_enable;
>   }
> -int set_dawr(struct arch_hw_breakpoint *brk);
> +int set_dawr(struct arch_hw_breakpoint *brk, int nr);

Wondering if it wouldn't make more sense to have nr as first argument.

Christophe

>   #else
>   static inline bool dawr_enabled(void) { return false; }
> -static inline int set_dawr(struct arch_hw_breakpoint *brk) { return -1; }
> +static inline int set_dawr(struct arch_hw_breakpoint *brk, int nr) { return -1; }
>   #endif
>   
>   #endif	/* __KERNEL__ */
> diff --git a/arch/powerpc/kernel/dawr.c b/arch/powerpc/kernel/dawr.c
> index e91b613bf137..311e51ee09f4 100644
> --- a/arch/powerpc/kernel/dawr.c
> +++ b/arch/powerpc/kernel/dawr.c
> @@ -16,7 +16,7 @@
>   bool dawr_force_enable;
>   EXPORT_SYMBOL_GPL(dawr_force_enable);
>   
> -int set_dawr(struct arch_hw_breakpoint *brk)
> +int set_dawr(struct arch_hw_breakpoint *brk, int nr)
>   {
>   	unsigned long dawr, dawrx, mrd;
>   
> @@ -39,15 +39,20 @@ int set_dawr(struct arch_hw_breakpoint *brk)
>   	if (ppc_md.set_dawr)
>   		return ppc_md.set_dawr(dawr, dawrx);
>   
> -	mtspr(SPRN_DAWR0, dawr);
> -	mtspr(SPRN_DAWRX0, dawrx);
> +	if (nr == 0) {
> +		mtspr(SPRN_DAWR0, dawr);
> +		mtspr(SPRN_DAWRX0, dawrx);
> +	} else {
> +		mtspr(SPRN_DAWR1, dawr);
> +		mtspr(SPRN_DAWRX1, dawrx);
> +	}
>   
>   	return 0;
>   }
>   
>   static void set_dawr_cb(void *info)
>   {
> -	set_dawr(info);
> +	set_dawr(info, 0);
>   }
>   
>   static ssize_t dawr_write_file_bool(struct file *file,
> @@ -60,7 +65,7 @@ static ssize_t dawr_write_file_bool(struct file *file,
>   	/* Send error to user if they hypervisor won't allow us to write DAWR */
>   	if (!dawr_force_enable &&
>   	    firmware_has_feature(FW_FEATURE_LPAR) &&
> -	    set_dawr(&null_brk) != H_SUCCESS)
> +	    set_dawr(&null_brk, 0) != H_SUCCESS)
>   		return -ENODEV;
>   
>   	rc = debugfs_write_file_bool(file, user_buf, count, ppos);
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index 110db94cdf3c..b548a584e465 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -799,7 +799,7 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
>   
>   	if (dawr_enabled())
>   		// Power8 or later
> -		set_dawr(brk);
> +		set_dawr(brk, 0);
>   	else if (IS_ENABLED(CONFIG_PPC_8xx))
>   		set_breakpoint_8xx(brk);
>   	else if (!cpu_has_feature(CPU_FTR_ARCH_207S))
>
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
index 518b41eef924..62549007c87a 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -104,10 +104,10 @@  static inline bool dawr_enabled(void)
 {
 	return dawr_force_enable;
 }
-int set_dawr(struct arch_hw_breakpoint *brk);
+int set_dawr(struct arch_hw_breakpoint *brk, int nr);
 #else
 static inline bool dawr_enabled(void) { return false; }
-static inline int set_dawr(struct arch_hw_breakpoint *brk) { return -1; }
+static inline int set_dawr(struct arch_hw_breakpoint *brk, int nr) { return -1; }
 #endif
 
 #endif	/* __KERNEL__ */
diff --git a/arch/powerpc/kernel/dawr.c b/arch/powerpc/kernel/dawr.c
index e91b613bf137..311e51ee09f4 100644
--- a/arch/powerpc/kernel/dawr.c
+++ b/arch/powerpc/kernel/dawr.c
@@ -16,7 +16,7 @@ 
 bool dawr_force_enable;
 EXPORT_SYMBOL_GPL(dawr_force_enable);
 
-int set_dawr(struct arch_hw_breakpoint *brk)
+int set_dawr(struct arch_hw_breakpoint *brk, int nr)
 {
 	unsigned long dawr, dawrx, mrd;
 
@@ -39,15 +39,20 @@  int set_dawr(struct arch_hw_breakpoint *brk)
 	if (ppc_md.set_dawr)
 		return ppc_md.set_dawr(dawr, dawrx);
 
-	mtspr(SPRN_DAWR0, dawr);
-	mtspr(SPRN_DAWRX0, dawrx);
+	if (nr == 0) {
+		mtspr(SPRN_DAWR0, dawr);
+		mtspr(SPRN_DAWRX0, dawrx);
+	} else {
+		mtspr(SPRN_DAWR1, dawr);
+		mtspr(SPRN_DAWRX1, dawrx);
+	}
 
 	return 0;
 }
 
 static void set_dawr_cb(void *info)
 {
-	set_dawr(info);
+	set_dawr(info, 0);
 }
 
 static ssize_t dawr_write_file_bool(struct file *file,
@@ -60,7 +65,7 @@  static ssize_t dawr_write_file_bool(struct file *file,
 	/* Send error to user if they hypervisor won't allow us to write DAWR */
 	if (!dawr_force_enable &&
 	    firmware_has_feature(FW_FEATURE_LPAR) &&
-	    set_dawr(&null_brk) != H_SUCCESS)
+	    set_dawr(&null_brk, 0) != H_SUCCESS)
 		return -ENODEV;
 
 	rc = debugfs_write_file_bool(file, user_buf, count, ppos);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 110db94cdf3c..b548a584e465 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -799,7 +799,7 @@  void __set_breakpoint(struct arch_hw_breakpoint *brk)
 
 	if (dawr_enabled())
 		// Power8 or later
-		set_dawr(brk);
+		set_dawr(brk, 0);
 	else if (IS_ENABLED(CONFIG_PPC_8xx))
 		set_breakpoint_8xx(brk);
 	else if (!cpu_has_feature(CPU_FTR_ARCH_207S))