All of lore.kernel.org
 help / color / mirror / Atom feed
From: shawnguo@kernel.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] ARM: imx: mmdc perf function support i.MX6QP
Date: Sat, 5 Nov 2016 15:31:38 +0800	[thread overview]
Message-ID: <20161105073137.GC5597@dragon> (raw)
In-Reply-To: <1478109604-18323-1-git-send-email-Frank.Li@nxp.com>

On Wed, Nov 02, 2016 at 01:00:03PM -0500, Frank Li wrote:
> i.MX6QP added new reigster bit PROFILE_SEL in MADPCR0.

s/reigster/register

> need set it at perf start.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>

We probably need a 'for' in patch subject after 'support'?

> ---
> V1 to V2: remove fsl_mmdc_devtype
> 
>  arch/arm/mach-imx/mmdc.c | 38 ++++++++++++++++++++++++++++++++------
>  1 file changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c
> index d82d14c..032cbe0 100644
> --- a/arch/arm/mach-imx/mmdc.c
> +++ b/arch/arm/mach-imx/mmdc.c
> @@ -44,6 +44,7 @@
>  #define DBG_RST			0x2
>  #define PRF_FRZ			0x4
>  #define CYC_OVF			0x8
> +#define PROFILE_SEL		0x10
>  
>  #define MMDC_MADPCR0	0x410
>  #define MMDC_MADPSR0	0x418
> @@ -55,10 +56,29 @@
>  
>  #define MMDC_NUM_COUNTERS	6
>  
> +#define FSL_MMDC_QUIRK_PROFILE_SEL	0x1
> +

What about naming it MMDC_FLAG_PROFILE_SEL?

>  #define to_mmdc_pmu(p) container_of(p, struct mmdc_pmu, pmu)
>  
>  static int ddr_type;
>  
> +struct fsl_mmdc_devtype_data {
> +	int driver_data;
> +};

What about the following?

struct imx_mmdc_data {
	unsigned int flags;
};

> +
> +static struct fsl_mmdc_devtype_data imx6q_data = {
> +};
> +
> +static struct fsl_mmdc_devtype_data imx6qp_data = {
> +	.driver_data = FSL_MMDC_QUIRK_PROFILE_SEL,
> +};

Have a const for better?

> +
> +static const struct of_device_id imx_mmdc_dt_ids[] = {
> +	{ .compatible = "fsl,imx6q-mmdc", .data = (void *)&imx6q_data},
> +	{ .compatible = "fsl,imx6qp-mmdc", .data = (void *)&imx6qp_data},
> +	{ /* sentinel */ }
> +};
> +
>  #ifdef CONFIG_PERF_EVENTS
>  
>  static DEFINE_IDA(mmdc_ida);
> @@ -83,6 +103,7 @@ struct mmdc_pmu {
>  	struct device *dev;
>  	struct perf_event *mmdc_events[MMDC_NUM_COUNTERS];
>  	struct hlist_node node;
> +	struct fsl_mmdc_devtype_data *devtype_data;

mmdc_data

>  };
>  
>  /*
> @@ -307,6 +328,7 @@ static void mmdc_pmu_event_start(struct perf_event *event, int flags)
>  	struct mmdc_pmu *pmu_mmdc = to_mmdc_pmu(event->pmu);
>  	struct hw_perf_event *hwc = &event->hw;
>  	void __iomem *mmdc_base, *reg;
> +	int val;

Shouldn't it be u32 for better?

Shawn

>  
>  	mmdc_base = pmu_mmdc->mmdc_base;
>  	reg = mmdc_base + MMDC_MADPCR0;
> @@ -321,7 +343,12 @@ static void mmdc_pmu_event_start(struct perf_event *event, int flags)
>  	local64_set(&hwc->prev_count, 0);
>  
>  	writel(DBG_RST, reg);
> -	writel(DBG_EN, reg);
> +
> +	val = DBG_EN;
> +	if (pmu_mmdc->devtype_data->driver_data & FSL_MMDC_QUIRK_PROFILE_SEL)
> +		val |= PROFILE_SEL;
> +
> +	writel(val, reg);
>  }
>  
>  static int mmdc_pmu_event_add(struct perf_event *event, int flags)
> @@ -436,6 +463,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
>  	char *name;
>  	int mmdc_num;
>  	int ret;
> +	const struct of_device_id *of_id =
> +		of_match_device(imx_mmdc_dt_ids, &pdev->dev);
>  
>  	pmu_mmdc = kzalloc(sizeof(*pmu_mmdc), GFP_KERNEL);
>  	if (!pmu_mmdc) {
> @@ -450,6 +479,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
>  		name = devm_kasprintf(&pdev->dev,
>  				GFP_KERNEL, "mmdc%d", mmdc_num);
>  
> +	pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data;
> +
>  	hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC,
>  			HRTIMER_MODE_REL);
>  	pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler;
> @@ -524,11 +555,6 @@ int imx_mmdc_get_ddr_type(void)
>  	return ddr_type;
>  }
>  
> -static const struct of_device_id imx_mmdc_dt_ids[] = {
> -	{ .compatible = "fsl,imx6q-mmdc", },
> -	{ /* sentinel */ }
> -};
> -
>  static struct platform_driver imx_mmdc_driver = {
>  	.driver		= {
>  		.name	= "imx-mmdc",
> -- 
> 2.5.2
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Shawn Guo <shawnguo@kernel.org>
To: Frank Li <Frank.Li@nxp.com>
Cc: mark.rutland@arm.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org, acme@kernel.org,
	alexander.shishkin@linux.intel.com, mingo@redhat.com,
	lznuaa@gmail.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/2] ARM: imx: mmdc perf function support i.MX6QP
Date: Sat, 5 Nov 2016 15:31:38 +0800	[thread overview]
Message-ID: <20161105073137.GC5597@dragon> (raw)
In-Reply-To: <1478109604-18323-1-git-send-email-Frank.Li@nxp.com>

On Wed, Nov 02, 2016 at 01:00:03PM -0500, Frank Li wrote:
> i.MX6QP added new reigster bit PROFILE_SEL in MADPCR0.

s/reigster/register

> need set it at perf start.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>

We probably need a 'for' in patch subject after 'support'?

> ---
> V1 to V2: remove fsl_mmdc_devtype
> 
>  arch/arm/mach-imx/mmdc.c | 38 ++++++++++++++++++++++++++++++++------
>  1 file changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c
> index d82d14c..032cbe0 100644
> --- a/arch/arm/mach-imx/mmdc.c
> +++ b/arch/arm/mach-imx/mmdc.c
> @@ -44,6 +44,7 @@
>  #define DBG_RST			0x2
>  #define PRF_FRZ			0x4
>  #define CYC_OVF			0x8
> +#define PROFILE_SEL		0x10
>  
>  #define MMDC_MADPCR0	0x410
>  #define MMDC_MADPSR0	0x418
> @@ -55,10 +56,29 @@
>  
>  #define MMDC_NUM_COUNTERS	6
>  
> +#define FSL_MMDC_QUIRK_PROFILE_SEL	0x1
> +

What about naming it MMDC_FLAG_PROFILE_SEL?

>  #define to_mmdc_pmu(p) container_of(p, struct mmdc_pmu, pmu)
>  
>  static int ddr_type;
>  
> +struct fsl_mmdc_devtype_data {
> +	int driver_data;
> +};

What about the following?

struct imx_mmdc_data {
	unsigned int flags;
};

> +
> +static struct fsl_mmdc_devtype_data imx6q_data = {
> +};
> +
> +static struct fsl_mmdc_devtype_data imx6qp_data = {
> +	.driver_data = FSL_MMDC_QUIRK_PROFILE_SEL,
> +};

Have a const for better?

> +
> +static const struct of_device_id imx_mmdc_dt_ids[] = {
> +	{ .compatible = "fsl,imx6q-mmdc", .data = (void *)&imx6q_data},
> +	{ .compatible = "fsl,imx6qp-mmdc", .data = (void *)&imx6qp_data},
> +	{ /* sentinel */ }
> +};
> +
>  #ifdef CONFIG_PERF_EVENTS
>  
>  static DEFINE_IDA(mmdc_ida);
> @@ -83,6 +103,7 @@ struct mmdc_pmu {
>  	struct device *dev;
>  	struct perf_event *mmdc_events[MMDC_NUM_COUNTERS];
>  	struct hlist_node node;
> +	struct fsl_mmdc_devtype_data *devtype_data;

mmdc_data

>  };
>  
>  /*
> @@ -307,6 +328,7 @@ static void mmdc_pmu_event_start(struct perf_event *event, int flags)
>  	struct mmdc_pmu *pmu_mmdc = to_mmdc_pmu(event->pmu);
>  	struct hw_perf_event *hwc = &event->hw;
>  	void __iomem *mmdc_base, *reg;
> +	int val;

Shouldn't it be u32 for better?

Shawn

>  
>  	mmdc_base = pmu_mmdc->mmdc_base;
>  	reg = mmdc_base + MMDC_MADPCR0;
> @@ -321,7 +343,12 @@ static void mmdc_pmu_event_start(struct perf_event *event, int flags)
>  	local64_set(&hwc->prev_count, 0);
>  
>  	writel(DBG_RST, reg);
> -	writel(DBG_EN, reg);
> +
> +	val = DBG_EN;
> +	if (pmu_mmdc->devtype_data->driver_data & FSL_MMDC_QUIRK_PROFILE_SEL)
> +		val |= PROFILE_SEL;
> +
> +	writel(val, reg);
>  }
>  
>  static int mmdc_pmu_event_add(struct perf_event *event, int flags)
> @@ -436,6 +463,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
>  	char *name;
>  	int mmdc_num;
>  	int ret;
> +	const struct of_device_id *of_id =
> +		of_match_device(imx_mmdc_dt_ids, &pdev->dev);
>  
>  	pmu_mmdc = kzalloc(sizeof(*pmu_mmdc), GFP_KERNEL);
>  	if (!pmu_mmdc) {
> @@ -450,6 +479,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
>  		name = devm_kasprintf(&pdev->dev,
>  				GFP_KERNEL, "mmdc%d", mmdc_num);
>  
> +	pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data;
> +
>  	hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC,
>  			HRTIMER_MODE_REL);
>  	pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler;
> @@ -524,11 +555,6 @@ int imx_mmdc_get_ddr_type(void)
>  	return ddr_type;
>  }
>  
> -static const struct of_device_id imx_mmdc_dt_ids[] = {
> -	{ .compatible = "fsl,imx6q-mmdc", },
> -	{ /* sentinel */ }
> -};
> -
>  static struct platform_driver imx_mmdc_driver = {
>  	.driver		= {
>  		.name	= "imx-mmdc",
> -- 
> 2.5.2
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2016-11-05  7:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 18:00 [PATCH v2 1/2] ARM: imx: mmdc perf function support i.MX6QP Frank Li
2016-11-02 18:00 ` Frank Li
2016-11-02 18:00 ` [PATCH V2 2/2] ARM: dts: add new compatible stream for i.MX6QP mmdc Frank Li
2016-11-02 18:00   ` Frank Li
2016-11-05  7:43   ` Shawn Guo
2016-11-05  7:43     ` Shawn Guo
2016-11-05  7:31 ` Shawn Guo [this message]
2016-11-05  7:31   ` [PATCH v2 1/2] ARM: imx: mmdc perf function support i.MX6QP Shawn Guo

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=20161105073137.GC5597@dragon \
    --to=shawnguo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.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.