mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liviu Dudau <Liviu.Dudau@arm.com>
To: "Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>
Cc: "james qian wang (Arm Technology China)"
	<james.qian.wang@arm.com>,
	"maarten.lankhorst@linux.intel.com" 
	<maarten.lankhorst@linux.intel.com>,
	"seanpaul@chromium.org" <seanpaul@chromium.org>,
	"airlied@linux.ie" <airlied@linux.ie>,
	Brian Starkey <Brian.Starkey@arm.com>,
	"Julien Yin (Arm Technology China)" <Julien.Yin@arm.com>,
	"Jonathan Chai (Arm Technology China)" <Jonathan.Chai@arm.com>,
	Ayan Halder <Ayan.Halder@arm.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH] drm/komeda: Adds power management support
Date: Wed, 19 Jun 2019 17:15:21 +0100	[thread overview]
Message-ID: <20190619161521.GD17204@e110455-lin.cambridge.arm.com> (raw)
In-Reply-To: <1560750919-32255-1-git-send-email-lowry.li@arm.com>

Hi Lowry,

On Mon, Jun 17, 2019 at 06:55:49AM +0100, Lowry Li (Arm Technology China) wrote:
> Adds runtime and system power management support in KMS kernel driver.
> 
> Depends on:
> - https://patchwork.freedesktop.org/series/61650/
> - https://patchwork.freedesktop.org/series/60083/
> 
> Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_crtc.c |  2 +
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.c  | 30 +++++++++++++
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.h  |  2 +
>  drivers/gpu/drm/arm/display/komeda/komeda_drv.c  | 54 ++++++++++++++++++++++--
>  4 files changed, 85 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 66c5e0d..1b4ea8a 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -257,6 +257,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
>  komeda_crtc_atomic_enable(struct drm_crtc *crtc,
>  			  struct drm_crtc_state *old)
>  {
> +	pm_runtime_get_sync(crtc->dev->dev);
>  	komeda_crtc_prepare(to_kcrtc(crtc));
>  	drm_crtc_vblank_on(crtc);
>  	komeda_crtc_do_flush(crtc, old);
> @@ -330,6 +331,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
>  
>  	drm_crtc_vblank_off(crtc);
>  	komeda_crtc_unprepare(kcrtc);
> +	pm_runtime_put(crtc->dev->dev);
>  }
>  
>  static void
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 405c64d..edd0943 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -308,3 +308,33 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
>  
>  	devm_kfree(dev, mdev);
>  }
> +
> +int komeda_dev_resume(struct komeda_dev *mdev)
> +{
> +	int ret = 0;
> +
> +	if (mdev->iommu && mdev->funcs->connect_iommu) {
> +		ret = mdev->funcs->connect_iommu(mdev);
> +		if (ret < 0) {
> +			DRM_ERROR("connect iommu failed.\n");
> +			return ret;
> +		}
> +	}
> +
> +	return mdev->funcs->enable_irq(mdev);
> +}
> +
> +int komeda_dev_suspend(struct komeda_dev *mdev)
> +{
> +	int ret = 0;
> +
> +	if (mdev->iommu && mdev->funcs->disconnect_iommu) {
> +		ret = mdev->funcs->disconnect_iommu(mdev);
> +		if (ret < 0) {
> +			DRM_ERROR("disconnect iommu failed.\n");
> +			return ret;
> +		}
> +	}
> +
> +	return mdev->funcs->disable_irq(mdev);
> +}
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
> index d1c86b6..096f9f7 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
> @@ -207,4 +207,6 @@ struct komeda_dev {
>  
>  struct komeda_dev *dev_to_mdev(struct device *dev);
>  
> +int komeda_dev_resume(struct komeda_dev *mdev);
> +int komeda_dev_suspend(struct komeda_dev *mdev);
>  #endif /*_KOMEDA_DEV_H_*/
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
> index cfa5068..aa4cef1 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
> @@ -8,6 +8,7 @@
>  #include <linux/kernel.h>
>  #include <linux/platform_device.h>
>  #include <linux/component.h>
> +#include <linux/pm_runtime.h>
>  #include <drm/drm_of.h>
>  #include "komeda_dev.h"
>  #include "komeda_kms.h"
> @@ -32,6 +33,9 @@ static void komeda_unbind(struct device *dev)
>  		return;
>  
>  	komeda_kms_detach(mdrv->kms);
> +
> +	pm_runtime_disable(dev);
> +
>  	komeda_dev_destroy(mdrv->mdev);
>  
>  	dev_set_drvdata(dev, NULL);
> @@ -52,6 +56,9 @@ static int komeda_bind(struct device *dev)
>  		err = PTR_ERR(mdrv->mdev);
>  		goto free_mdrv;
>  	}
> +	dev_set_drvdata(dev, mdrv);
> +
> +	pm_runtime_enable(dev);
>  
>  	mdrv->kms = komeda_kms_attach(mdrv->mdev);
>  	if (IS_ERR(mdrv->kms)) {
> @@ -59,11 +66,10 @@ static int komeda_bind(struct device *dev)
>  		goto destroy_mdev;
>  	}
>  
> -	dev_set_drvdata(dev, mdrv);
> -
>  	return 0;
>  
>  destroy_mdev:
> +	pm_runtime_disable(dev);
>  	komeda_dev_destroy(mdrv->mdev);
>  
>  free_mdrv:
> @@ -134,13 +140,55 @@ static int komeda_platform_remove(struct platform_device *pdev)
>  
>  MODULE_DEVICE_TABLE(of, komeda_of_match);
>  
> +static int komeda_rt_pm_suspend(struct device *dev)
> +{
> +	dev_info(dev, "%s\n", __func__);
> +	return 0;
> +}
> +
> +static int komeda_rt_pm_resume(struct device *dev)
> +{
> +	dev_info(dev, "%s\n", __func__);
> +	return 0;
> +}


Useful only for debugging? I think you've missed an opportunity here to turn
off clocks and disable interrupts.

> +
> +static int __maybe_unused komeda_pm_suspend(struct device *dev)
> +{
> +	struct komeda_drv *mdrv = dev_get_drvdata(dev);
> +	struct drm_device *drm = &mdrv->kms->base;
> +	int res;
> +
> +	dev_info(dev, "%s\n", __func__);
> +	res = drm_mode_config_helper_suspend(drm);
> +
> +	komeda_dev_suspend(mdrv->mdev);
> +
> +	return res;
> +}
> +
> +static int __maybe_unused komeda_pm_resume(struct device *dev)
> +{
> +	struct komeda_drv *mdrv = dev_get_drvdata(dev);
> +	struct drm_device *drm = &mdrv->kms->base;
> +
> +	dev_info(dev, "%s\n", __func__);

I don't see the point of printing all these message on suspend/resume. Please
convert them to DRM_DEBUG() if you want to have some sort of notices in the
kernel log, otherwise please remove them.

Best regards,
Liviu


> +	komeda_dev_resume(mdrv->mdev);
> +
> +	return drm_mode_config_helper_resume(drm);
> +}
> +
> +static const struct dev_pm_ops komeda_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(komeda_pm_suspend, komeda_pm_resume)
> +	SET_RUNTIME_PM_OPS(komeda_rt_pm_suspend, komeda_rt_pm_resume, NULL)
> +};
> +
>  static struct platform_driver komeda_platform_driver = {
>  	.probe	= komeda_platform_probe,
>  	.remove	= komeda_platform_remove,
>  	.driver	= {
>  		.name = "komeda",
>  		.of_match_table	= komeda_of_match,
> -		.pm = NULL,
> +		.pm = &komeda_pm_ops,
>  	},
>  };
>  
> -- 
> 1.9.1
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

  reply	other threads:[~2019-06-19 16:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17  5:55 Lowry Li (Arm Technology China)
2019-06-19 16:15 ` Liviu Dudau [this message]
2019-07-01  6:45 Lowry Li (Arm Technology China)
2019-09-23  1:59 Lowry Li (Arm Technology China)
2019-10-08 17:47 ` Sean Paul
2019-10-08 18:13   ` Sean Paul

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=20190619161521.GD17204@e110455-lin.cambridge.arm.com \
    --to=liviu.dudau@arm.com \
    --cc=Ayan.Halder@arm.com \
    --cc=Brian.Starkey@arm.com \
    --cc=Jonathan.Chai@arm.com \
    --cc=Julien.Yin@arm.com \
    --cc=Lowry.Li@arm.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=james.qian.wang@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=nd@arm.com \
    --cc=seanpaul@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®