linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Ravi Bangoria <ravi.bangoria@linux.ibm.com>, mpe@ellerman.id.au
Cc: mikey@neuling.org, linux-kernel@vger.kernel.org,
	npiggin@gmail.com, paulus@samba.org,
	naveen.n.rao@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 4/5] Powerpc/hw-breakpoint: Optimize disable path
Date: Tue, 18 Jun 2019 08:31:57 +0200	[thread overview]
Message-ID: <6e7c6054-b152-40db-c7d3-89901949460f@c-s.fr> (raw)
In-Reply-To: <20190618042732.5582-5-ravi.bangoria@linux.ibm.com>



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.bangoria@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

  parent reply	other threads:[~2019-06-18  6:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18  4:27 [PATCH 0/5] Powerpc/hw-breakpoint: Fixes plus Code refactor Ravi Bangoria
2019-06-18  4:27 ` [PATCH 1/5] Powerpc/hw-breakpoint: Replace stale do_dabr() with do_break() Ravi Bangoria
2019-06-18  6:02   ` Michael Neuling
2019-06-18  6:14   ` Christophe Leroy
2019-06-18  4:27 ` [PATCH 2/5] Powerpc/hw-breakpoint: Refactor hw_breakpoint_arch_parse() Ravi Bangoria
2019-06-18  6:21   ` Christophe Leroy
2019-06-18  7:10     ` Ravi Bangoria
2019-06-18  4:27 ` [PATCH 3/5] Powerpc/hw-breakpoint: Refactor set_dawr() Ravi Bangoria
2019-06-18  6:11   ` Michael Neuling
2019-06-18  7:13     ` Ravi Bangoria
2019-06-18  6:24   ` Christophe Leroy
2019-06-18  4:27 ` [PATCH 4/5] Powerpc/hw-breakpoint: Optimize disable path Ravi Bangoria
2019-06-18  6:15   ` Michael Neuling
2019-06-19  6:02     ` Ravi Bangoria
2019-06-18  6:31   ` Christophe Leroy [this message]
2019-06-19  6:14     ` Ravi Bangoria
2019-06-18  4:27 ` [PATCH 5/5] Powerpc/Watchpoint: Fix length calculation for unaligned target Ravi Bangoria
2019-06-18  6:46   ` Christophe Leroy
2019-06-19  6:51     ` Ravi Bangoria
2019-06-18 13:32   ` Michael Neuling
2019-06-19  7:45     ` Ravi Bangoria
2019-06-18  6:01 ` [PATCH 0/5] Powerpc/hw-breakpoint: Fixes plus Code refactor Christophe Leroy
2019-06-18  6:17   ` Michael Neuling
2019-06-19  7:47     ` Ravi Bangoria

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e7c6054-b152-40db-c7d3-89901949460f@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.org \
    --cc=ravi.bangoria@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).