Le 18/06/2019 à 06:27, Ravi Bangoria a écrit :
Directly setting dawr and dawrx with 0 should be enough to
disable watchpoint. No need to reset individual bits in
variable and then set in hw.

Signed-off-by: Ravi Bangoria <ravi.bango...@linux.ibm.com>
---
  arch/powerpc/include/asm/hw_breakpoint.h |  3 ++-
  arch/powerpc/kernel/process.c            | 12 ++++++++++++
  2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/hw_breakpoint.h 
b/arch/powerpc/include/asm/hw_breakpoint.h
index 78202d5fb13a..8acbbdd4a2d5 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -19,6 +19,7 @@ struct arch_hw_breakpoint {
  /* Note: Don't change the the first 6 bits below as they are in the same order
   * as the dabr and dabrx.
   */
+#define HW_BRK_TYPE_DISABLE            0x00

I'd rather call it HW_BRK_TYPE_NONE

  #define HW_BRK_TYPE_READ              0x01
  #define HW_BRK_TYPE_WRITE             0x02
  #define HW_BRK_TYPE_TRANSLATE         0x04
@@ -68,7 +69,7 @@ static inline void hw_breakpoint_disable(void)
        struct arch_hw_breakpoint brk;
brk.address = 0;
-       brk.type = 0;
+       brk.type = HW_BRK_TYPE_DISABLE;
        brk.len = 0;
        if (ppc_breakpoint_available())
                __set_breakpoint(&brk);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index f002d2ffff86..265fac9fb3a4 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -793,10 +793,22 @@ static inline int set_dabr(struct arch_hw_breakpoint *brk)
        return __set_dabr(dabr, dabrx);
  }
+static int disable_dawr(void)
+{
+       if (ppc_md.set_dawr)
+               return ppc_md.set_dawr(0, 0);
+
+       mtspr(SPRN_DAWRX, 0);

And SPRN_DAWR ?

The above code looks pretty similar to the one at the end of set_dawr(). You should factorise it, for instance

static int __set_dawr(int dawr, int dawrx)
{
        if (ppc_md.set_dawr)
                return ppc_md.set_dawr(dawr, dawrx);
        mtspr(SPRN_DAWR, dawr);
        mtspr(SPRN_DAWRX, dawrx);
        return 0;
}

+       return 0;
+}
+
  int set_dawr(struct arch_hw_breakpoint *brk)
  {
        unsigned long dawr, dawrx, mrd;
+ if (brk->type == HW_BRK_TYPE_DISABLE)
+               return disable_dawr();

Then replace by __set_dawr(0, 0);

+
        dawr = brk->address;
dawrx = (brk->type & HW_BRK_TYPE_RDWR) << (63 - 58);


And use the new helper at the end of the function too.

Christophe

Reply via email to