All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Varka Bhadram <varkabhadram@gmail.com>
Cc: myungjoo.ham@samsung.com, kgene.kim@samsung.com,
	Kyungmin Park <kyungmin.park@samsung.com>,
	rafael.j.wysocki@intel.com, Mark Rutland <mark.rutland@arm.com>,
	a.kesavan@samsung.com, tomasz.figa@gmail.com,
	k.kozlowski@samsung.com, inki.dae@samsung.com,
	linux-pm@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCHv5 3/9] devfreq: event: Add exynos-ppmu devfreq-event driver
Date: Tue, 23 Dec 2014 13:35:00 +0900	[thread overview]
Message-ID: <5498F0F4.7020700@samsung.com> (raw)
In-Reply-To: <CAEUmHyYnb8_HNnuz8BLhMOh01+gpXfTv63P-ubYE1DK9uptonA@mail.gmail.com>

On 12/23/2014 12:40 PM, Varka Bhadram wrote:
> On Tue, Dec 23, 2014 at 8:48 AM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
>> This patch adds exynos-ppmu devfreq-event driver to get performance data
>> of each IP for Samsung Exynos SoC. These event from Exynos PPMU provide
>> useful information about the behavior of the SoC that you can use when
>> analyzing system performance, and made visible and can be counted using
>> logic in each IP.
>>
>> This patch is based on existing drivers/devfreq/exynos/exynos-ppmu.c
>>
>> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
>> Cc: Kyungmin Park <kyungmin.park@samsung.com>
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> 
> (...)
>> +static int exynos_ppmu_parse_dt(struct exynos_ppmu_data *data)
>> +{
>> +       struct device *dev = data->dev;
>> +       struct device_node *np = dev->of_node;
>> +       int ret = 0;
>> +
>> +       if (!np) {
>> +               dev_err(dev, "failed to find devicetree node\n");
>> +               return -EINVAL;
>> +       }
>> +
>> +       /* Maps the memory mapped IO to control PPMU register */
>> +       data->ppmu.base = of_iomap(np, 0);
>> +       if (IS_ERR_OR_NULL(data->ppmu.base)) {
>> +               dev_err(dev, "failed to map memory region\n");
>> +               return -EINVAL;
> -ENOMEM or -ENXIO is the proper error return value..?

OK. I'll return -ENOMEM value.

> 
>> +       }
>> +
>> +       data->clk_ppmu = devm_clk_get(dev, "ppmu");
>> +       if (IS_ERR(data->clk_ppmu)) {
>> +               data->clk_ppmu = NULL;
>> +               dev_warn(dev, "failed to get PPMU clock\n");
>> +       }
> If PPMU clk get fails..?  return PTR_ERR(data->clk_ppmu)

If Exynos SoC don't register the clock to clock tree, the clock remains on state.
So, I print just warning message.

But, It is not proper. I'll fix it.

>> +
>> +       ret = of_get_devfreq_events(np, data);
>> +       if (ret < 0) {
>> +               dev_err(dev, "failed to parse exynos ppmu dt node\n");
>> +               goto err;
>> +       }
>> +
>> +       return 0;
>> +
>> +err:
>> +       iounmap(data->ppmu.base);
>> +
>> +       return ret;
>> +}
>> +
>> +static int exynos_ppmu_probe(struct platform_device *pdev)
>> +{
>> +       struct exynos_ppmu_data *data;
>> +       struct devfreq_event_dev **edev;
>> +       struct devfreq_event_desc *desc;
>> +       int i, ret = 0, size;
>> +
>> +       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
>> +       if (!data)
>> +               return -ENOMEM;
>> +
>> +       mutex_init(&data->lock);
>> +       data->dev = &pdev->dev;
>> +
>> +       /* Parse dt data to get resource */
>> +       ret = exynos_ppmu_parse_dt(data);
>> +       if (ret < 0) {
>> +               dev_err(&pdev->dev,
>> +                       "failed to parse devicetree for resource\n");
>> +               return ret;
>> +       }
>> +       desc = data->desc;
>> +
>> +       size = sizeof(struct devfreq_event_dev *) * data->num_events;
>> +       data->edev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
>> +       if (!data->edev) {
>> +               dev_err(&pdev->dev,
>> +                       "failed to allocate memory devfreq-event devices\n");
>> +               return -ENOMEM;
>> +       }
>> +       edev = data->edev;
>> +       platform_set_drvdata(pdev, data);
>> +
>> +       for (i = 0; i < data->num_events; i++) {
>> +               edev[i] = devfreq_event_add_edev(&pdev->dev, &desc[i]);
>> +               if (IS_ERR(edev)) {
>> +                       ret = PTR_ERR(edev);
>> +                       dev_err(&pdev->dev,
>> +                               "failed to add devfreq-event device\n");
>> +                       goto err;
>> +               }
>> +       }
>> +
>> +       clk_prepare_enable(data->clk_ppmu);
>> +
>> +       return 0;
>> +err:
>> +       iounmap(data->ppmu.base);
>> +
>> +       return ret;
>> +}
>> +
>> +static int exynos_ppmu_remove(struct platform_device *pdev)
>> +{
>> +       struct exynos_ppmu_data *data = platform_get_drvdata(pdev);
>> +       int i, ret = 0;
>> +
>> +       for (i = 0; i < data->num_events; i++) {
>> +               ret = devfreq_event_remove_edev(data->edev[i]);
>> +               if (ret < 0) {
>> +                       dev_err(&pdev->dev,
>> +                               "failed to remove devfreq-event device\n");
>> +                       goto err;
>> +               }
>> +       }
>> +
>> +err:
>> +       clk_disable_unprepare(data->clk_ppmu);
>> +       iounmap(data->ppmu.base);
>> +
>> +       return ret;
>> +}
>> +
>> +static struct of_device_id exynos_ppmu_id_match[] = {
>> +       { .compatible = "samsung,exynos-ppmu", },
>> +       { /* sentinel */ },
>> +};
>> +
>> +static struct platform_driver exynos_ppmu_driver = {
>> +       .probe  = exynos_ppmu_probe,
>> +       .remove = exynos_ppmu_remove,
>> +       .driver = {
>> +               .name   = "exynos-ppmu",
>> +               .owner  = THIS_MODULE,
> remove owner field. It will be populate by driver core.

OK. I'll remove it.

Thanks for your review.

Best Regards,
Chanwoo Choi

WARNING: multiple messages have this Message-ID (diff)
From: cw00.choi@samsung.com (Chanwoo Choi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5 3/9] devfreq: event: Add exynos-ppmu devfreq-event driver
Date: Tue, 23 Dec 2014 13:35:00 +0900	[thread overview]
Message-ID: <5498F0F4.7020700@samsung.com> (raw)
In-Reply-To: <CAEUmHyYnb8_HNnuz8BLhMOh01+gpXfTv63P-ubYE1DK9uptonA@mail.gmail.com>

On 12/23/2014 12:40 PM, Varka Bhadram wrote:
> On Tue, Dec 23, 2014 at 8:48 AM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
>> This patch adds exynos-ppmu devfreq-event driver to get performance data
>> of each IP for Samsung Exynos SoC. These event from Exynos PPMU provide
>> useful information about the behavior of the SoC that you can use when
>> analyzing system performance, and made visible and can be counted using
>> logic in each IP.
>>
>> This patch is based on existing drivers/devfreq/exynos/exynos-ppmu.c
>>
>> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
>> Cc: Kyungmin Park <kyungmin.park@samsung.com>
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> 
> (...)
>> +static int exynos_ppmu_parse_dt(struct exynos_ppmu_data *data)
>> +{
>> +       struct device *dev = data->dev;
>> +       struct device_node *np = dev->of_node;
>> +       int ret = 0;
>> +
>> +       if (!np) {
>> +               dev_err(dev, "failed to find devicetree node\n");
>> +               return -EINVAL;
>> +       }
>> +
>> +       /* Maps the memory mapped IO to control PPMU register */
>> +       data->ppmu.base = of_iomap(np, 0);
>> +       if (IS_ERR_OR_NULL(data->ppmu.base)) {
>> +               dev_err(dev, "failed to map memory region\n");
>> +               return -EINVAL;
> -ENOMEM or -ENXIO is the proper error return value..?

OK. I'll return -ENOMEM value.

> 
>> +       }
>> +
>> +       data->clk_ppmu = devm_clk_get(dev, "ppmu");
>> +       if (IS_ERR(data->clk_ppmu)) {
>> +               data->clk_ppmu = NULL;
>> +               dev_warn(dev, "failed to get PPMU clock\n");
>> +       }
> If PPMU clk get fails..?  return PTR_ERR(data->clk_ppmu)

If Exynos SoC don't register the clock to clock tree, the clock remains on state.
So, I print just warning message.

But, It is not proper. I'll fix it.

>> +
>> +       ret = of_get_devfreq_events(np, data);
>> +       if (ret < 0) {
>> +               dev_err(dev, "failed to parse exynos ppmu dt node\n");
>> +               goto err;
>> +       }
>> +
>> +       return 0;
>> +
>> +err:
>> +       iounmap(data->ppmu.base);
>> +
>> +       return ret;
>> +}
>> +
>> +static int exynos_ppmu_probe(struct platform_device *pdev)
>> +{
>> +       struct exynos_ppmu_data *data;
>> +       struct devfreq_event_dev **edev;
>> +       struct devfreq_event_desc *desc;
>> +       int i, ret = 0, size;
>> +
>> +       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
>> +       if (!data)
>> +               return -ENOMEM;
>> +
>> +       mutex_init(&data->lock);
>> +       data->dev = &pdev->dev;
>> +
>> +       /* Parse dt data to get resource */
>> +       ret = exynos_ppmu_parse_dt(data);
>> +       if (ret < 0) {
>> +               dev_err(&pdev->dev,
>> +                       "failed to parse devicetree for resource\n");
>> +               return ret;
>> +       }
>> +       desc = data->desc;
>> +
>> +       size = sizeof(struct devfreq_event_dev *) * data->num_events;
>> +       data->edev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
>> +       if (!data->edev) {
>> +               dev_err(&pdev->dev,
>> +                       "failed to allocate memory devfreq-event devices\n");
>> +               return -ENOMEM;
>> +       }
>> +       edev = data->edev;
>> +       platform_set_drvdata(pdev, data);
>> +
>> +       for (i = 0; i < data->num_events; i++) {
>> +               edev[i] = devfreq_event_add_edev(&pdev->dev, &desc[i]);
>> +               if (IS_ERR(edev)) {
>> +                       ret = PTR_ERR(edev);
>> +                       dev_err(&pdev->dev,
>> +                               "failed to add devfreq-event device\n");
>> +                       goto err;
>> +               }
>> +       }
>> +
>> +       clk_prepare_enable(data->clk_ppmu);
>> +
>> +       return 0;
>> +err:
>> +       iounmap(data->ppmu.base);
>> +
>> +       return ret;
>> +}
>> +
>> +static int exynos_ppmu_remove(struct platform_device *pdev)
>> +{
>> +       struct exynos_ppmu_data *data = platform_get_drvdata(pdev);
>> +       int i, ret = 0;
>> +
>> +       for (i = 0; i < data->num_events; i++) {
>> +               ret = devfreq_event_remove_edev(data->edev[i]);
>> +               if (ret < 0) {
>> +                       dev_err(&pdev->dev,
>> +                               "failed to remove devfreq-event device\n");
>> +                       goto err;
>> +               }
>> +       }
>> +
>> +err:
>> +       clk_disable_unprepare(data->clk_ppmu);
>> +       iounmap(data->ppmu.base);
>> +
>> +       return ret;
>> +}
>> +
>> +static struct of_device_id exynos_ppmu_id_match[] = {
>> +       { .compatible = "samsung,exynos-ppmu", },
>> +       { /* sentinel */ },
>> +};
>> +
>> +static struct platform_driver exynos_ppmu_driver = {
>> +       .probe  = exynos_ppmu_probe,
>> +       .remove = exynos_ppmu_remove,
>> +       .driver = {
>> +               .name   = "exynos-ppmu",
>> +               .owner  = THIS_MODULE,
> remove owner field. It will be populate by driver core.

OK. I'll remove it.

Thanks for your review.

Best Regards,
Chanwoo Choi

  reply	other threads:[~2014-12-23  4:35 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23  3:18 [PATCHv5 0/9] devfreq: Add devfreq-event class to provide raw data for devfreq device Chanwoo Choi
2014-12-23  3:18 ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 1/9] devfreq: event: Add new devfreq_event class to provide basic data for devfreq governor Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 2/9] devfreq: event: Add the list of supported devfreq-event type Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 3/9] devfreq: event: Add exynos-ppmu devfreq-event driver Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:40   ` Varka Bhadram
2014-12-23  3:40     ` Varka Bhadram
2014-12-23  4:35     ` Chanwoo Choi [this message]
2014-12-23  4:35       ` Chanwoo Choi
2014-12-23  6:35       ` Chanwoo Choi
2014-12-23  6:35         ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 4/9] devfreq: event: Add documentation for " Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
     [not found] ` <1419304697-14789-1-git-send-email-cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-12-23  3:18   ` [PATCHv5 5/9] ARM: dts: Add PPMU dt node for Exynos3250 SoC Chanwoo Choi
2014-12-23  3:18     ` Chanwoo Choi
2014-12-23  3:18     ` Chanwoo Choi
2014-12-23  3:18   ` [PATCHv5 6/9] ARM: dts: Add PPMU dt node for Exynos4 SoCs Chanwoo Choi
2014-12-23  3:18     ` Chanwoo Choi
2014-12-23  3:18     ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 7/9] ARM: dts: Add PPMU dt node for Exynos5260 SoC Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 8/9] ARM: dts: exynos: Add PPMU node to Exynos3250-based Rinato board Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi
2014-12-23  3:18 ` [PATCHv5 9/9] ARM: dts: exynos: Add PPMU_CPU/DMC0/DMC1 node for Exynos4412-based TRATS2 board Chanwoo Choi
2014-12-23  3:18   ` Chanwoo Choi

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=5498F0F4.7020700@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=a.kesavan@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=inki.dae@samsung.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tomasz.figa@gmail.com \
    --cc=varkabhadram@gmail.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.