From: Mathieu Poirier <mathieu.poirier@linaro.org> To: Mike Leach <mike.leach@linaro.org> Cc: linux-arm-kernel <linux-arm-kernel@lists.infradead.org>, Coresight ML <coresight@lists.linaro.org>, "Suzuki K. Poulose" <suzuki.poulose@arm.com>, Yabin Cui <yabinc@google.com>, Leo Yan <leo.yan@linaro.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Tingwei Zhang <tingwei@codeaurora.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: Re: [PATCH v9 05/10] coresight: syscfg: Add API to activate and enable configurations Date: Thu, 29 Jul 2021 10:14:43 -0600 [thread overview] Message-ID: <CANLsYkwZfLM2qbaPkWnAKZHWrF0UgY_ApDT6yjJ=HAadA2azsQ@mail.gmail.com> (raw) In-Reply-To: <CAJ9a7ViN9hS6Z+MH2Z1s-KgDBPeiDZ260FfMd23OG9MzZc4mTQ@mail.gmail.com> [...] > > > + > > > +/** > > > + * cscfg_csdev_enable_active_config - Enable matching active configuration for device. > > > + * > > > + * Enables the configuration selected by @cfg_hash if the configuration is supported > > > + * on the device and has been activated. > > > + * > > > + * If active and supported the CoreSight device @csdev will be programmed with the > > > + * configuration, using @preset parameters. > > > + * > > > + * Should be called before driver hardware enable for the requested device, prior to > > > + * programming and enabling the physical hardware. > > > + * > > > + * @csdev: CoreSight device to program. > > > + * @cfg_hash: Selector for the configuration. > > > + * @preset: Preset parameter values to use, 0 for current / default values. > > > + */ > > > +int cscfg_csdev_enable_active_config(struct coresight_device *csdev, > > > + unsigned long cfg_hash, int preset) > > > +{ > > > + struct cscfg_config_csdev *config_csdev_active = NULL, *config_csdev_item; > > > + const struct cscfg_config_desc *config_desc; > > > + unsigned long flags; > > > + int err = 0; > > > + > > > + /* quickly check global count */ > > > + if (!atomic_read(&cscfg_mgr->sys_active_cnt)) > > > + return 0; > > > + > > > + /* look for matching config - set in_enable flag if found */ > > > > The second part of this comment no longer applies. > > > > You are right - sorry missed that! > > > > + spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags); > > > + list_for_each_entry(config_csdev_item, &csdev->config_csdev_list, node) { > > > + config_desc = config_csdev_item->config_desc; > > > + if ((atomic_read(&config_desc->active_cnt)) && > > > + ((unsigned long)config_desc->event_ea->var == cfg_hash)) { > > > + config_csdev_active = config_csdev_item; > > > + csdev->active_cscfg_ctxt = (void *)config_csdev_active; > > > + break; > > > + } > > > + } > > > + spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags); > > > + > > > + /* > > > + * If found, attempt to enable > > > + */ > > > + if (config_csdev_active) { > > > + /* > > > + * Call the generic routine that will program up the internal > > > + * driver structures prior to programming up the hardware. > > > + * This routine takes the driver spinlock saved in the configs. > > > + */ > > > + err = cscfg_csdev_enable_config(config_csdev_active, preset); > > > + if (!err) { > > > + /* > > > + * Successful programming. Check the active_cscfg_ctxt > > > + * pointer to ensure no pre-emption disabled it via > > > + * cscfg_csdev_disable_active_config() before > > > + * we could start. > > > + * > > > + * Set enabled if OK, err if not. > > > + */ > > > + spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags); > > > + if (csdev->active_cscfg_ctxt) > > > + config_csdev_active->enabled = true; > > > + else > > > + err = -EBUSY; > > > + spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags); > > > + } > > > > This is much better. I spent some time trying to break the heuristic and I > > can't. I intend to re-apply this set to give it as much exposure as possible but > > want to see the above comment fixed. I will do that locally though to avoid > > having to deal with another revision. What do you think of: > > > > /* > > * Look for a matching configuration - set the active configuration > > * context if found. > > */ > > > > That looks fin to me > > Thanks I have applied this set. > > Mike > > > > Thanks, > > Mathieu > > > > > + } > > > + return err; > > > +} > > > +EXPORT_SYMBOL_GPL(cscfg_csdev_enable_active_config); > > > + > > > +/** > > > + * cscfg_csdev_disable_active_config - disable an active config on the device. > > > + * > > > + * Disables the active configuration on the CoreSight device @csdev. > > > + * Disable will save the values of any registers marked in the configurations > > > + * as save on disable. > > > + * > > > + * Should be called after driver hardware disable for the requested device, > > > + * after disabling the physical hardware and reading back registers. > > > + * > > > + * @csdev: The CoreSight device. > > > + */ > > > +void cscfg_csdev_disable_active_config(struct coresight_device *csdev) > > > +{ > > > + struct cscfg_config_csdev *config_csdev; > > > + unsigned long flags; > > > + > > > + /* > > > + * Check if we have an active config, and that it was successfully enabled. > > > + * If it was not enabled, we have no work to do, otherwise mark as disabled. > > > + * Clear the active config pointer. > > > + */ > > > + spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags); > > > + config_csdev = (struct cscfg_config_csdev *)csdev->active_cscfg_ctxt; > > > + if (config_csdev) { > > > + if (!config_csdev->enabled) > > > + config_csdev = NULL; > > > + else > > > + config_csdev->enabled = false; > > > + } > > > + csdev->active_cscfg_ctxt = NULL; > > > + spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags); > > > + > > > + /* true if there was an enabled active config */ > > > + if (config_csdev) > > > + cscfg_csdev_disable_config(config_csdev); > > > +} > > > +EXPORT_SYMBOL_GPL(cscfg_csdev_disable_active_config); > > > + > > > /* Initialise system configuration management device. */ > > > > > > struct device *cscfg_device(void) > > > @@ -536,6 +747,7 @@ int __init cscfg_init(void) > > > INIT_LIST_HEAD(&cscfg_mgr->csdev_desc_list); > > > INIT_LIST_HEAD(&cscfg_mgr->feat_desc_list); > > > INIT_LIST_HEAD(&cscfg_mgr->config_desc_list); > > > + atomic_set(&cscfg_mgr->sys_active_cnt, 0); > > > > > > dev_info(cscfg_device(), "CoreSight Configuration manager initialised"); > > > return 0; > > > diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h > > > index 5bcae3b374c6..a52775890670 100644 > > > --- a/drivers/hwtracing/coresight/coresight-syscfg.h > > > +++ b/drivers/hwtracing/coresight/coresight-syscfg.h > > > @@ -24,12 +24,14 @@ > > > * @csdev_desc_list: List of coresight devices registered with the configuration manager. > > > * @feat_desc_list: List of feature descriptors to load into registered devices. > > > * @config_desc_list: List of system configuration descriptors to load into registered devices. > > > + * @sys_active_cnt: Total number of active config descriptor references. > > > */ > > > struct cscfg_manager { > > > struct device dev; > > > struct list_head csdev_desc_list; > > > struct list_head feat_desc_list; > > > struct list_head config_desc_list; > > > + atomic_t sys_active_cnt; > > > }; > > > > > > /* get reference to dev in cscfg_manager */ > > > @@ -61,5 +63,11 @@ int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs, > > > int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags, > > > struct cscfg_csdev_feat_ops *ops); > > > void cscfg_unregister_csdev(struct coresight_device *csdev); > > > +int cscfg_activate_config(unsigned long cfg_hash); > > > +void cscfg_deactivate_config(unsigned long cfg_hash); > > > +void cscfg_csdev_reset_feats(struct coresight_device *csdev); > > > +int cscfg_csdev_enable_active_config(struct coresight_device *csdev, > > > + unsigned long cfg_hash, int preset); > > > +void cscfg_csdev_disable_active_config(struct coresight_device *csdev); > > > > > > #endif /* CORESIGHT_SYSCFG_H */ > > > diff --git a/include/linux/coresight.h b/include/linux/coresight.h > > > index 16544ae2b532..93a2922b7653 100644 > > > --- a/include/linux/coresight.h > > > +++ b/include/linux/coresight.h > > > @@ -223,6 +223,7 @@ struct coresight_sysfs_link { > > > * @feature_csdev_list: List of complex feature programming added to the device. > > > * @config_csdev_list: List of system configurations added to the device. > > > * @cscfg_csdev_lock: Protect the lists of configurations and features. > > > + * @active_cscfg_ctxt: Context information for current active system configuration. > > > */ > > > struct coresight_device { > > > struct coresight_platform_data *pdata; > > > @@ -248,6 +249,7 @@ struct coresight_device { > > > struct list_head feature_csdev_list; > > > struct list_head config_csdev_list; > > > spinlock_t cscfg_csdev_lock; > > > + void *active_cscfg_ctxt; > > > }; > > > > > > /* > > > -- > > > 2.17.1 > > > > > > > -- > Mike Leach > Principal Engineer, ARM Ltd. > Manchester Design Centre. UK
next prev parent reply other threads:[~2021-07-29 16:14 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-23 16:54 [PATCH v9 00/10] CoreSight configuration management; ETM strobing Mike Leach 2021-07-23 16:54 ` [PATCH v9 01/10] coresight: syscfg: Initial coresight system configuration Mike Leach 2021-07-23 16:54 ` [PATCH v9 02/10] coresight: syscfg: Add registration and feature loading for cs devices Mike Leach 2021-07-23 16:54 ` [PATCH v9 03/10] coresight: config: Add configuration and feature generic functions Mike Leach 2021-07-23 16:54 ` [PATCH v9 04/10] coresight: etm-perf: update to handle configuration selection Mike Leach 2021-07-23 16:54 ` [PATCH v9 05/10] coresight: syscfg: Add API to activate and enable configurations Mike Leach 2021-07-28 16:24 ` Mathieu Poirier 2021-07-28 16:41 ` Mike Leach 2021-07-29 16:14 ` Mathieu Poirier [this message] 2021-07-23 16:54 ` [PATCH v9 06/10] coresight: etm-perf: Update to activate selected configuration Mike Leach 2021-07-23 16:54 ` [PATCH v9 07/10] coresight: etm4x: Add complex configuration handlers to etmv4 Mike Leach 2021-07-23 16:54 ` [PATCH v9 08/10] coresight: config: Add preloaded configurations Mike Leach 2021-07-23 16:54 ` [PATCH v9 09/10] coresight: syscfg: Add initial configfs support Mike Leach 2021-07-23 16:54 ` [PATCH v9 10/10] Documentation: coresight: Add documentation for CoreSight config Mike Leach
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='CANLsYkwZfLM2qbaPkWnAKZHWrF0UgY_ApDT6yjJ=HAadA2azsQ@mail.gmail.com' \ --to=mathieu.poirier@linaro.org \ --cc=alexander.shishkin@linux.intel.com \ --cc=coresight@lists.linaro.org \ --cc=gregkh@linuxfoundation.org \ --cc=leo.yan@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mike.leach@linaro.org \ --cc=suzuki.poulose@arm.com \ --cc=tingwei@codeaurora.org \ --cc=yabinc@google.com \ --subject='Re: [PATCH v9 05/10] coresight: syscfg: Add API to activate and enable configurations' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).