Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5962862ybp; Tue, 8 Oct 2019 10:50:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzR0g9mycBuAL8/nualNl2K9BNqq8Vj+UfmQu1lu+PK8h7xrSJBrkLjq1JybpKXYvLs5bI X-Received: by 2002:a05:6402:750:: with SMTP id p16mr35475276edy.188.1570557009682; Tue, 08 Oct 2019 10:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570557009; cv=none; d=google.com; s=arc-20160816; b=fiAEVk/2QzWqPUi0QLfNs+AMsb9k229h+S4yfLE6qVKJf15mlLkqtBUf4SOAXtAO8O sjEZWSAg4BI2Lhre7Cd1TQrYDjGLzldR+YfF/QI67Q3Iyl+Y81po5NRX2WvbLSD8z8JE pwgqYtuQa4H+s4wIfVC0ZPLdmlZKasnVeajNT4beg1yhKqlw/3BcQpDeQQcuhAHOZYvZ uWHXx1cmbrMg1xZhWaUDsJxC9oMEzR2L/+B8NU0yK8/qBJDKs5Nx22mcD8Uv0ZE+7fiS 4VcvRuW6/ylmZj1mjBSWpRTPDRfdUvJ34KF0svC9ZBqC65dGgrs3qZ3lGa5zsqgmLKYv i/vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=x/lkpIj/2xYb2Ets/AmbxlIgxRR/5zYpb4Zq2VW265Y=; b=zOsNLVIvn4ufz/7p7tzy0WtbWiCrGf08JFGnQE9sOXddQaptZiK1cDJcduCZ2alN9G LrL+FhlIkfKgu/aTAWlo52Bf5Cbv8UjWCtd1tRUeF1TuOujo8UcpCXZ0K/971Y4eQ0qr 3QoajutMcZQO26doG8lO+6Ou8hVr5Mf5jDKu1Ah05bpatbevvrSa/090J0s1y5fR6hoz AzBweTdWz33i5UtfKS995g26zKGZ12yLsAabCA2Kgq4dqRrlmhvMW5kE3PLq/B01QFh5 BtIk0FoXQghznzSzUT+/5YLRDcIYVJ3AE7Re9f8u+XT06GwLWZKPDzuvBhyJ9BoaO91r qeFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=VEO1J0fH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w30si11023723edd.137.2019.10.08.10.49.45; Tue, 08 Oct 2019 10:50:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=VEO1J0fH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfJHRr5 (ORCPT + 99 others); Tue, 8 Oct 2019 13:47:57 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:37441 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfJHRr4 (ORCPT ); Tue, 8 Oct 2019 13:47:56 -0400 Received: by mail-yb1-f194.google.com with SMTP id z125so6206119ybc.4 for ; Tue, 08 Oct 2019 10:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=x/lkpIj/2xYb2Ets/AmbxlIgxRR/5zYpb4Zq2VW265Y=; b=VEO1J0fHbr5YZ64cx9iNONBB/RbjNEHNF81sZuVrfzgwpgfM5wn/Aq/YpvWDWwQmI7 e97bleMB5sVfaIglyn+RI/xrFBkvvrZhcUgxioe2FKUObrC6KqvpqTDgmssVPeNW5J8C 1AjOapwOziiaYPQ36bl/VJFU7O3k1VUcOx7N4jdqQ8qQ9hZoD4iCK7ZHxybAnRUI513u 3ekrGql9AWKcdY7eMi/l0+l/OFBl3tXpgYpQfUta1djE7G/yBLsUiKOXhIT/yI0+qPC5 0kYGNuLsebLLL2e+LgzP03yApbbrHk2w1RGB2LOtDQsGVJqu9P+DWjb/fzWcUwbv0l+F EQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x/lkpIj/2xYb2Ets/AmbxlIgxRR/5zYpb4Zq2VW265Y=; b=paMU6ZKEN5pL3hfrQLM588fMcJ0UprXCCnY0uY8XzEZWgLDlPu6fGjHapQKoz96HNk lbo7dswpBeOLDIZdWsKII4Ys+O1HfMfQ/h5rgagQ6H4nmzjYF00Vh2HEI/lmu0L0XYai jBSVj3VNWiurc+MU5zG2dYmakWtV26peN+LHNShCMEHxQfFnKI1GRmVJNmIne5SHtYPY dlR1JmdpfiJCAkgXeEiqXUZI88ZeiUWZZMY8y6cTe9ZJIDn0G3p4LGeaKmfBU1oXHlfN BagsdNWLE6Zv8cvNrj/y6N3RO7RNjDoLsKeK7ht/YmrvaLsDJa3QOM40Bdve3vl+er7c gb4w== X-Gm-Message-State: APjAAAU7m8r4lpJL4oZAbwuBZKBPZqO8Zo25ktOclN3guUad8xKt2wjC 1Rn1nJeR+LeOUVFNNnbQOBj7Hw== X-Received: by 2002:a25:3287:: with SMTP id y129mr16402593yby.339.1570556874742; Tue, 08 Oct 2019 10:47:54 -0700 (PDT) Received: from localhost ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id p10sm4719432ywc.19.2019.10.08.10.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 10:47:53 -0700 (PDT) Date: Tue, 8 Oct 2019 13:47:53 -0400 From: Sean Paul To: "Lowry Li (Arm Technology China)" Cc: Liviu Dudau , "james qian wang (Arm Technology China)" , "maarten.lankhorst@linux.intel.com" , "seanpaul@chromium.org" , "airlied@linux.ie" , Brian Starkey , Mihail Atanassov , Ayan Halder , "Jonathan Chai (Arm Technology China)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin (Arm Technology China)" , nd Subject: Re: [PATCH] drm/komeda: Adds power management support Message-ID: <20191008174753.GC85762@art_vandelay> References: <20190923015908.26627-1-lowry.li@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190923015908.26627-1-lowry.li@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 23, 2019 at 01:59:25AM +0000, Lowry Li (Arm Technology China) wrote: > From: "Lowry Li (Arm Technology China)" > > Adds system power management support in KMS kernel driver. > > Depends on: > https://patchwork.freedesktop.org/series/62377/ > > Changes since v1: > Since we have unified mclk/pclk/pipeline->aclk to one mclk, which will > be turned on/off when crtc atomic enable/disable, removed runtime power > management. > Removes run time get/put related flow. > Adds to disable the aclk when register access finished. > > Changes since v2: > Rebases to the drm-misc-next branch. > > Signed-off-by: Lowry Li (Arm Technology China) > --- > .../gpu/drm/arm/display/komeda/komeda_crtc.c | 1 - > .../gpu/drm/arm/display/komeda/komeda_dev.c | 65 +++++++++++++++++-- > .../gpu/drm/arm/display/komeda/komeda_dev.h | 3 + > .../gpu/drm/arm/display/komeda/komeda_drv.c | 30 ++++++++- > 4 files changed, 91 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c > index 38d5cb20e908..b47c0dabd0d1 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c > @@ -5,7 +5,6 @@ > * > */ > #include > -#include > #include > > #include > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c > index bee4633cdd9f..8a03324f02a5 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c > @@ -258,7 +258,7 @@ struct komeda_dev *komeda_dev_create(struct device *dev) > product->product_id, > MALIDP_CORE_ID_PRODUCT_ID(mdev->chip.core_id)); > err = -ENODEV; > - goto err_cleanup; > + goto disable_clk; > } > > DRM_INFO("Found ARM Mali-D%x version r%dp%d\n", > @@ -271,19 +271,19 @@ struct komeda_dev *komeda_dev_create(struct device *dev) > err = mdev->funcs->enum_resources(mdev); > if (err) { > DRM_ERROR("enumerate display resource failed.\n"); > - goto err_cleanup; > + goto disable_clk; > } > > err = komeda_parse_dt(dev, mdev); > if (err) { > DRM_ERROR("parse device tree failed.\n"); > - goto err_cleanup; > + goto disable_clk; > } > > err = komeda_assemble_pipelines(mdev); > if (err) { > DRM_ERROR("assemble display pipelines failed.\n"); > - goto err_cleanup; > + goto disable_clk; > } > > dev->dma_parms = &mdev->dma_parms; > @@ -296,11 +296,14 @@ struct komeda_dev *komeda_dev_create(struct device *dev) > if (mdev->iommu && mdev->funcs->connect_iommu) { > err = mdev->funcs->connect_iommu(mdev); > if (err) { > + DRM_ERROR("connect iommu failed.\n"); > mdev->iommu = NULL; > - goto err_cleanup; > + goto disable_clk; > } > } > > + clk_disable_unprepare(mdev->aclk); > + > err = sysfs_create_group(&dev->kobj, &komeda_sysfs_attr_group); > if (err) { > DRM_ERROR("create sysfs group failed.\n"); > @@ -313,6 +316,8 @@ struct komeda_dev *komeda_dev_create(struct device *dev) > > return mdev; > > +disable_clk: > + clk_disable_unprepare(mdev->aclk); > err_cleanup: > komeda_dev_destroy(mdev); > return ERR_PTR(err); > @@ -330,8 +335,12 @@ void komeda_dev_destroy(struct komeda_dev *mdev) > debugfs_remove_recursive(mdev->debugfs_root); > #endif > > + if (mdev->aclk) > + clk_prepare_enable(mdev->aclk); > + > if (mdev->iommu && mdev->funcs->disconnect_iommu) > - mdev->funcs->disconnect_iommu(mdev); > + if (mdev->funcs->disconnect_iommu(mdev)) > + DRM_ERROR("disconnect iommu failed.\n"); > mdev->iommu = NULL; > > for (i = 0; i < mdev->n_pipelines; i++) { > @@ -359,3 +368,47 @@ void komeda_dev_destroy(struct komeda_dev *mdev) > > devm_kfree(dev, mdev); > } > + > +int komeda_dev_resume(struct komeda_dev *mdev) > +{ > + int ret = 0; > + > + clk_prepare_enable(mdev->aclk); > + > + if (mdev->iommu && mdev->funcs->connect_iommu) { > + ret = mdev->funcs->connect_iommu(mdev); > + if (ret < 0) { > + DRM_ERROR("connect iommu failed.\n"); > + goto disable_clk; > + } > + } > + > + ret = mdev->funcs->enable_irq(mdev); > + > +disable_clk: > + clk_disable_unprepare(mdev->aclk); > + > + return ret; > +} > + > +int komeda_dev_suspend(struct komeda_dev *mdev) > +{ > + int ret = 0; > + > + clk_prepare_enable(mdev->aclk); > + > + if (mdev->iommu && mdev->funcs->disconnect_iommu) { > + ret = mdev->funcs->disconnect_iommu(mdev); > + if (ret < 0) { > + DRM_ERROR("disconnect iommu failed.\n"); > + goto disable_clk; > + } > + } > + > + ret = mdev->funcs->disable_irq(mdev); > + > +disable_clk: > + clk_disable_unprepare(mdev->aclk); > + > + return ret; > +} > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h > index 8acf8c0601cc..414200233b64 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h > @@ -224,4 +224,7 @@ void komeda_print_events(struct komeda_events *evts); > static inline void komeda_print_events(struct komeda_events *evts) {} > #endif > > +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 69ace6f9055d..d6c2222c5d33 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 > #include > #include > +#include > #include > #include "komeda_dev.h" > #include "komeda_kms.h" > @@ -136,13 +137,40 @@ static const struct of_device_id komeda_of_match[] = { > > MODULE_DEVICE_TABLE(of, komeda_of_match); > > +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; > + > + res = drm_mode_config_helper_suspend(drm); Just noticed this while prepping the -misc pull request. You should use the atomic helpers instead, drm_atomic_helper_suspend and drm_atomic_helper_resume. > + > + 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; > + > + 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) > +}; > + > 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, > }, > }; > > -- > 2.17.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Sean Paul, Software Engineer, Google / Chromium OS