powerpc/watchpoint: Provide DAWR number to set_dawr

Introduce new parameter 'nr' to set_dawr() which indicates which DAWR
should be programed.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Michael Neuling <mikey@neuling.org>
Link: https://lore.kernel.org/r/20200514111741.97993-6-ravi.bangoria@linux.ibm.com
This commit is contained in:
Ravi Bangoria 2020-05-14 16:47:30 +05:30 committed by Michael Ellerman
parent 45093b382e
commit a18b834625
3 changed files with 13 additions and 8 deletions

View File

@ -104,10 +104,10 @@ static inline bool dawr_enabled(void)
{ {
return dawr_force_enable; return dawr_force_enable;
} }
int set_dawr(struct arch_hw_breakpoint *brk); int set_dawr(int nr, struct arch_hw_breakpoint *brk);
#else #else
static inline bool dawr_enabled(void) { return false; } 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(int nr, struct arch_hw_breakpoint *brk) { return -1; }
#endif #endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */

View File

@ -16,7 +16,7 @@
bool dawr_force_enable; bool dawr_force_enable;
EXPORT_SYMBOL_GPL(dawr_force_enable); EXPORT_SYMBOL_GPL(dawr_force_enable);
int set_dawr(struct arch_hw_breakpoint *brk) int set_dawr(int nr, struct arch_hw_breakpoint *brk)
{ {
unsigned long dawr, dawrx, mrd; unsigned long dawr, dawrx, mrd;
@ -39,15 +39,20 @@ int set_dawr(struct arch_hw_breakpoint *brk)
if (ppc_md.set_dawr) if (ppc_md.set_dawr)
return ppc_md.set_dawr(dawr, dawrx); return ppc_md.set_dawr(dawr, dawrx);
mtspr(SPRN_DAWR0, dawr); if (nr == 0) {
mtspr(SPRN_DAWRX0, dawrx); mtspr(SPRN_DAWR0, dawr);
mtspr(SPRN_DAWRX0, dawrx);
} else {
mtspr(SPRN_DAWR1, dawr);
mtspr(SPRN_DAWRX1, dawrx);
}
return 0; return 0;
} }
static void set_dawr_cb(void *info) static void set_dawr_cb(void *info)
{ {
set_dawr(info); set_dawr(0, info);
} }
static ssize_t dawr_write_file_bool(struct file *file, 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 */ /* Send error to user if they hypervisor won't allow us to write DAWR */
if (!dawr_force_enable && if (!dawr_force_enable &&
firmware_has_feature(FW_FEATURE_LPAR) && firmware_has_feature(FW_FEATURE_LPAR) &&
set_dawr(&null_brk) != H_SUCCESS) set_dawr(0, &null_brk) != H_SUCCESS)
return -ENODEV; return -ENODEV;
rc = debugfs_write_file_bool(file, user_buf, count, ppos); rc = debugfs_write_file_bool(file, user_buf, count, ppos);

View File

@ -806,7 +806,7 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
if (dawr_enabled()) if (dawr_enabled())
// Power8 or later // Power8 or later
set_dawr(brk); set_dawr(0, brk);
else if (IS_ENABLED(CONFIG_PPC_8xx)) else if (IS_ENABLED(CONFIG_PPC_8xx))
set_breakpoint_8xx(brk); set_breakpoint_8xx(brk);
else if (!cpu_has_feature(CPU_FTR_ARCH_207S)) else if (!cpu_has_feature(CPU_FTR_ARCH_207S))