All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: frank.li@nxp.com, will@kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/3] perf/imx_ddr: speed up overflow frequency of cycle counter
Date: Fri, 28 Jul 2023 14:33:34 +0100	[thread overview]
Message-ID: <ZMPDru_CUHz4iVoL@FVFF77S0Q05N> (raw)
In-Reply-To: <20230713103758.2627269-1-xu.yang_2@nxp.com>

On Thu, Jul 13, 2023 at 06:37:56PM +0800, Xu Yang wrote:
> For i.MX8MP, we cannot ensure that cycle counter overflow occurs at least
> 4 times as often as other events. Due to byte counters will count for any
> event configured, it will overflow more often. And if byte counters
> overflow that related counters would stop since they share the COUNTER_CNTL
> We can speed up cycle counter overflow frequency by setting counter
> parameter (CP) field of cycle counter. In this way, we can avoid stop
> counting byte counters when interrupt didn't come and the byte counters
> can be fetched or updated from each cycle counter overflow interrupt.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> 
> ---
> Changes in v2:
>  - improve if condition
> ---
>  drivers/perf/fsl_imx8_ddr_perf.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
> index 5222ba1e79d0..039069756bbc 100644
> --- a/drivers/perf/fsl_imx8_ddr_perf.c
> +++ b/drivers/perf/fsl_imx8_ddr_perf.c
> @@ -28,6 +28,8 @@
>  #define CNTL_CLEAR_MASK		0xFFFFFFFD
>  #define CNTL_OVER_MASK		0xFFFFFFFE
>  
> +#define CNTL_CP_SHIFT		16
> +#define CNTL_CP_MASK		(0xFF << CNTL_CP_SHIFT)
>  #define CNTL_CSV_SHIFT		24
>  #define CNTL_CSV_MASK		(0xFFU << CNTL_CSV_SHIFT)
>  
> @@ -427,6 +429,19 @@ static void ddr_perf_counter_enable(struct ddr_pmu *pmu, int config,
>  		writel(0, pmu->base + reg);
>  		val = CNTL_EN | CNTL_CLEAR;
>  		val |= FIELD_PREP(CNTL_CSV_MASK, config);
> +
> +		/*
> +		 * Workaround for i.MX8MP:
> +		 * Common counters and byte counters share the same COUNTER_CNTL,
> +		 * and byte counters could overflow before cycle counter. Need set
> +		 * counter parameter(CP) of cycle counter to give it initial value
> +		 * which can speed up cycle counter overflow frequency.
> +		 */

From the comments on path 2, it sounds like this "counter parameter" sets bits
[31..28] of the counter value, is that correct?

Assuming so, could we please update this comment to say:

	/*
	 * On i.MX8MP we need to bias the cycle counter to overflow more often.
	 * We do this by initializing bits [31:28] of the counter value via the
	 * COUNTER_CTRL Counter Parameter (CP) field.
	 *
	 * See ddr_perf_counter_enable() for more details.
	 */

Thanks,
Mark.

> +		if (pmu->devtype_data->quirks & DDR_CAP_AXI_ID_FILTER_ENHANCED) {
> +			if (counter == EVENT_CYCLES_COUNTER)
> +				val |= FIELD_PREP(CNTL_CP_MASK, 0xf0);
> +		}
> +
>  		writel(val, pmu->base + reg);
>  	} else {
>  		/* Disable counter */
> -- 
> 2.34.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-07-28 13:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 10:37 [PATCH v2 1/3] perf/imx_ddr: speed up overflow frequency of cycle counter Xu Yang
2023-07-13 10:37 ` [PATCH v2 2/3] perf/imx_ddr: adjust counter result after read " Xu Yang
2023-07-13 15:36   ` Frank Li
2023-07-14  1:44     ` Xu Yang
2023-07-28 13:36   ` Mark Rutland
2023-07-29  2:08     ` [EXT] " Xu Yang
2023-07-13 10:37 ` [PATCH v2 3/3] perf/imx_ddr: don't enable counter0 if none of 4 counters are used Xu Yang
2023-07-28 13:38   ` Mark Rutland
2023-07-28 13:33 ` Mark Rutland [this message]
2023-07-29  2:02   ` [EXT] Re: [PATCH v2 1/3] perf/imx_ddr: speed up overflow frequency of cycle counter Xu Yang

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=ZMPDru_CUHz4iVoL@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=frank.li@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=will@kernel.org \
    --cc=xu.yang_2@nxp.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 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.