All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
To: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>,
	mikey@neuling.org, maddy@linux.vnet.ibm.com, acme@kernel.org,
	jolsa@kernel.org, kjain@linux.ibm.com,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH V4 1/4] powerpc/perf: Add support for outputting extended regs in perf intr_regs
Date: Mon, 27 Jul 2020 12:31:14 +0530	[thread overview]
Message-ID: <a6076d4b-ed55-11a9-fa2c-4260edb1ffd6@linux.ibm.com> (raw)
In-Reply-To: <1595774713-1482-2-git-send-email-atrajeev@linux.vnet.ibm.com>

Hi Athira,

> +/* Function to return the extended register values */
> +static u64 get_ext_regs_value(int idx)
> +{
> +	switch (idx) {
> +	case PERF_REG_POWERPC_MMCR0:
> +		return mfspr(SPRN_MMCR0);
> +	case PERF_REG_POWERPC_MMCR1:
> +		return mfspr(SPRN_MMCR1);
> +	case PERF_REG_POWERPC_MMCR2:
> +		return mfspr(SPRN_MMCR2);
> +	default: return 0;
> +	}
> +}
> +
>   u64 perf_reg_value(struct pt_regs *regs, int idx)
>   {
> -	if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))
> -		return 0;
> +	u64 perf_reg_extended_max = 0;

This should be initialized to PERF_REG_POWERPC_MAX. Default to 0 will always
trigger below WARN_ON_ONCE(idx >= perf_reg_extended_max) on non p9/p10 systems.

> +
> +	if (cpu_has_feature(CPU_FTR_ARCH_300))
> +		perf_reg_extended_max = PERF_REG_MAX_ISA_300;
>   
>   	if (idx == PERF_REG_POWERPC_SIER &&
>   	   (IS_ENABLED(CONFIG_FSL_EMB_PERF_EVENT) ||
> @@ -85,6 +103,16 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
>   	    IS_ENABLED(CONFIG_PPC32)))
>   		return 0;
>   
> +	if (idx >= PERF_REG_POWERPC_MAX && idx < perf_reg_extended_max)
> +		return get_ext_regs_value(idx);
> +
> +	/*
> +	 * If the idx is referring to value beyond the
> +	 * supported registers, return 0 with a warning
> +	 */
> +	if (WARN_ON_ONCE(idx >= perf_reg_extended_max))
> +		return 0;
> +
>   	return regs_get_register(regs, pt_regs_offset[idx]);
>   }

Ravi

  reply	other threads:[~2020-07-27  7:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26 14:45 [PATCH V4 0/4] powerpc/perf: Add support for perf extended regs in powerpc Athira Rajeev
2020-07-26 14:45 ` [PATCH V4 1/4] powerpc/perf: Add support for outputting extended regs in perf intr_regs Athira Rajeev
2020-07-27  7:01   ` Ravi Bangoria [this message]
2020-07-26 14:45 ` [PATCH V4 2/4] powerpc/perf: Add extended regs support for power10 platform Athira Rajeev
2020-07-26 14:45 ` [PATCH V4 3/4] tools/perf: Add perf tools support for extended register capability in powerpc Athira Rajeev
2020-07-26 14:45 ` [PATCH V4 4/4] tools/perf: Add perf tools support for extended regs in power10 Athira Rajeev
2020-07-27  7:03 ` [PATCH V4 0/4] powerpc/perf: Add support for perf extended regs in powerpc 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=a6076d4b-ed55-11a9-fa2c-4260edb1ffd6@linux.ibm.com \
    --to=ravi.bangoria@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.vnet.ibm.com \
    --cc=mikey@neuling.org \
    /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 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.