public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm•com>
To: andrew.murray@arm•com, mathieu.poirier@linaro•org,
	alexander.shishkin@linux•intel.com
Cc: coresight@lists•linaro.org, Sudeep.Holla@arm•com,
	linux-arm-kernel@lists•infradead.org, mike.leach@linaro•org
Subject: Re: [PATCH v2 5/5] coresight: etm4x: save/restore state across CPU low power states
Date: Mon, 1 Jul 2019 14:15:49 +0100	[thread overview]
Message-ID: <13dde41d-5ef4-e9a0-7310-ed5ead5e8230@arm.com> (raw)
In-Reply-To: <20190627083525.37463-6-andrew.murray@arm.com>



On 27/06/2019 09:35, Andrew Murray wrote:
> Some hardware will ignore bit TRCPDCR.PU which is used to signal
> to hardware that power should not be removed from the trace unit.
> Let's mitigate against this by conditionally saving and restoring
> the trace unit state when the CPU enters low power states.
> 
> This patchset introduces a firmware property named
> 'arm,coresight-needs-save-restore' - when this is present the
> hardware state will be conditionally saved and restored.
> 
> A module parameter 'pm_save_enable' is also introduced which can
> be configured to override the firmware property. This can be set
> to never allow save/restore, to conditionally allow it, or to
> do as the firmware indicates (default).
> 
> The hardware state is only ever saved and restored when the claim
> tags indicate that coresight is in use.
> 

> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
> index 86945f054cf8..eff317cd3a03 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c
> @@ -18,6 +18,7 @@
>   #include <linux/stat.h>
>   #include <linux/clk.h>
>   #include <linux/cpu.h>
> +#include <linux/cpu_pm.h>
>   #include <linux/coresight.h>
>   #include <linux/coresight-pmu.h>
>   #include <linux/pm_wakeup.h>
> @@ -26,6 +27,7 @@
>   #include <linux/uaccess.h>
>   #include <linux/perf_event.h>
>   #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>   #include <asm/sections.h>
>   #include <asm/local.h>
>   #include <asm/virt.h>
> @@ -37,6 +39,16 @@ static int boot_enable;
>   module_param(boot_enable, int, 0444);
>   MODULE_PARM_DESC(boot_enable, "Enable tracing on boot");
>   
> +
> +#define PARAM_PM_SAVE_DISABLE	0
> +#define PARAM_PM_SAVE_ENABLE	1
> +#define PARAM_PM_SAVE_FIRMWARE	2
> +
> +static int pm_save_enable = PARAM_PM_SAVE_FIRMWARE;
> +module_param(pm_save_enable, int, 0644);
> +MODULE_PARM_DESC(pm_save_enable, "Save/restore state on power down: "
> +				  "0 = disabled, 1 = enabled, 2 = firmware");

nit: Please could you add a comment to explain the implications of "firmware"
and how this interacts with "disabled" as it is explained in your thread with
Leo. That will be quite helpful for someone looking to use the parameter.

> +
> +static int etm4_cpu_pm_register(struct etmv4_drvdata *drvdata)
> +{
> +	drvdata->nb.notifier_call = etm4_cpu_pm_notify;
> +	return cpu_pm_register_notifier(&drvdata->nb);
> +}

Do we need to tie the notifer_block to etmv4_drvdata ? We could simply
use a static one for the entire driver, given we don't rely on the
"drvdata". Also, we register for only one ETM device at the moment, which
is problematic if that CPU goes down and we decide to unregister the ETM
device (in the future).

> +
> +static void etm4_cpu_pm_unregister(struct etmv4_drvdata *drvdata)
> +{
> +	if (drvdata->nb.notifier_call)
> +		cpu_pm_unregister_notifier(&drvdata->nb);
> +}
> +#else
> +static int etm4_cpu_pm_register(struct etmv4_drvdata *drvdata) { return 0; }
> +static void etm4_cpu_pm_unregister(struct etmv4_drvdata *drvdata) { }
> +#endif
> +
> +static inline bool etm4_needs_save_restore(struct device *dev)
> +{
> +	return fwnode_property_present(dev->fwnode,
> +				       "arm,coresight-needs-save-restore");
> +}
> +
>   static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
>   {
>   	int ret;
> @@ -1095,6 +1386,8 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
>   
>   	dev_set_drvdata(dev, drvdata);
>   
> +	drvdata->pm_save_enable = etm4_needs_save_restore(dev);
> +
>   	/* Validity for the resource is already checked by the AMBA core */
>   	base = devm_ioremap_resource(dev, res);
>   	if (IS_ERR(base))
> @@ -1126,6 +1419,10 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
>   		if (ret < 0)
>   			goto err_arch_supported;
>   		hp_online = ret;
> +
> +		ret = etm4_cpu_pm_register(drvdata);
> +		if (ret)
> +			goto err_arch_supported;
>   	}

>   /**
>    * struct etm4_drvdata - specifics associated to an ETM component
>    * @base:       Memory mapped base address for this component.
> @@ -336,6 +396,8 @@ struct etmv4_config {
>    * @atbtrig:	If the implementation can support ATB triggers
>    * @lpoverride:	If the implementation can support low-power state over.
>    * @config:	structure holding configuration parameters.
> + * @save_state:	State to be preserved across power loss
> + * @nb:		CPU PM notifier
>    */
>   struct etmv4_drvdata {
>   	void __iomem			*base;
> @@ -367,6 +429,7 @@ struct etmv4_drvdata {
>   	u8				q_support;
>   	bool				sticky_enable;
>   	bool				boot_enable;
> +	bool				pm_save_enable;
>   	bool				os_unlock;
>   	bool				instrp0;
>   	bool				trcbb;
> @@ -381,6 +444,9 @@ struct etmv4_drvdata {
>   	bool				atbtrig;
>   	bool				lpoverride;
>   	struct etmv4_config		config;
> +	struct etmv4_save_state		save_state;

We may potentially reduce the memory usage by dynamically allocating this
structure the variable below. So you may make this a ptr instead.

> +	bool				state_needs_restore;

Rest looks good to me.

Suzuki

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

  parent reply	other threads:[~2019-07-01 13:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27  8:35 [PATCH v2 0/5] coresight: etm4x: save/restore ETMv4 context across CPU low power states Andrew Murray
2019-06-27  8:35 ` [PATCH v2 1/5] coresight: etm4x: remove superfluous setting of os_unlock Andrew Murray
2019-06-27  8:35 ` [PATCH v2 2/5] coresight: etm4x: use explicit barriers on enable/disable Andrew Murray
2019-06-27  9:16   ` Suzuki K Poulose
2019-06-27 11:41     ` Andrew Murray
2019-06-28  2:45   ` Leo Yan
2019-06-28  8:35     ` Andrew Murray
2019-06-28  8:51       ` Leo Yan
2019-06-28  9:00         ` Andrew Murray
2019-06-28  9:41           ` Leo Yan
2019-07-01  8:58             ` Suzuki K Poulose
2019-07-01  9:59               ` Leo Yan
2019-06-27  8:35 ` [PATCH v2 3/5] coresight: etm4x: use module_param instead of module_param_named Andrew Murray
2019-06-27  8:35 ` [PATCH v2 4/5] coresight: etm4x: improve clarity of etm4_os_unlock comment Andrew Murray
2019-06-27  8:35 ` [PATCH v2 5/5] coresight: etm4x: save/restore state across CPU low power states Andrew Murray
2019-06-27 14:25   ` Mike Leach
2019-06-27 14:55     ` Andrew Murray
2019-06-27 16:01       ` Suzuki K Poulose
2019-07-08 14:35         ` Andrew Murray
2019-06-28  8:07   ` Leo Yan
2019-06-28  8:53     ` Andrew Murray
2019-06-28  9:12       ` Leo Yan
2019-06-28  9:22         ` Andrew Murray
2019-07-01  2:07           ` Leo Yan
2019-07-01  9:34             ` Andrew Murray
2019-07-01  9:48               ` Leo Yan
2019-07-01  9:54                 ` Andrew Murray
2019-07-01 10:14                   ` Leo Yan
2019-07-04 10:21                     ` Andrew Murray
2019-07-04 14:27                       ` Mathieu Poirier
2019-07-05  1:52                         ` Leo Yan
2019-07-01 13:15   ` Suzuki K Poulose [this message]
2019-07-04  9:59     ` Andrew Murray
2019-07-03 21:21   ` Mathieu Poirier
2019-07-04 10:06     ` Andrew Murray

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=13dde41d-5ef4-e9a0-7310-ed5ead5e8230@arm.com \
    --to=suzuki.poulose@arm$(echo .)com \
    --cc=Sudeep.Holla@arm$(echo .)com \
    --cc=alexander.shishkin@linux$(echo .)intel.com \
    --cc=andrew.murray@arm$(echo .)com \
    --cc=coresight@lists$(echo .)linaro.org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=mathieu.poirier@linaro$(echo .)org \
    --cc=mike.leach@linaro$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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