Linux-Doc Archive on lore.kernel.org
 help / color / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Mike Leach <mike.leach@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org,
	linux-doc@vger.kernel.org, suzuki.poulose@arm.com
Subject: Re: [PATCH v4 5/6] coresight: cti: Add in sysfs links to other coresight devices.
Date: Fri, 14 Feb 2020 15:58:39 -0700
Message-ID: <20200214225839.GB20024@xps15> (raw)
In-Reply-To: <20200211105808.27884-6-mike.leach@linaro.org>

On Tue, Feb 11, 2020 at 10:58:07AM +0000, Mike Leach wrote:
> Adds in sysfs links for connections where the connected device is another
> coresight device. This allows examination of the coresight topology.
> 
> Non-coresight connections remain just as a reference name.
> 
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
>  drivers/hwtracing/coresight/coresight-cti.c | 41 ++++++++++++++++++++-
>  1 file changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
> index 9e18e176831c..f620e9460e7d 100644
> --- a/drivers/hwtracing/coresight/coresight-cti.c
> +++ b/drivers/hwtracing/coresight/coresight-cti.c
> @@ -441,6 +441,37 @@ int cti_channel_setop(struct device *dev, enum cti_chan_set_op op,
>  	return err;
>  }
>  
> +static void cti_add_sysfs_link(struct cti_drvdata *drvdata,
> +			       struct cti_trig_con *tc)
> +{
> +	struct coresight_sysfs_link link_info;
> +
> +	link_info.orig = drvdata->csdev;
> +	link_info.orig_name = tc->con_dev_name;
> +	link_info.target = tc->con_dev;
> +	link_info.target_name = dev_name(&drvdata->csdev->dev);
> +	coresight_add_sysfs_link(&link_info);

I understand there isn't much to do if a problem occurs so just catch the error
and add a comment to assert you're doing this on purpose.

> +}
> +
> +static void cti_remove_all_sysfs_links(struct cti_drvdata *drvdata)
> +{
> +	struct cti_trig_con *tc;
> +	struct cti_device *ctidev = &drvdata->ctidev;
> +	struct coresight_sysfs_link link_info;
> +
> +	/* origin device and target link name constant for this cti */
> +	link_info.orig = drvdata->csdev;
> +	link_info.target_name = dev_name(&drvdata->csdev->dev);
> +
> +	list_for_each_entry(tc, &ctidev->trig_cons, node) {
> +		if (tc->con_dev) {
> +			link_info.target = tc->con_dev;
> +			link_info.orig_name = tc->con_dev_name;
> +			coresight_remove_sysfs_link(&link_info);
> +		}
> +	}
> +}
> +
>  /*
>   * Look for a matching connection device name in the list of connections.
>   * If found then swap in the csdev name, set trig con association pointer
> @@ -452,6 +483,8 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name,
>  {
>  	struct cti_trig_con *tc;
>  	const char *csdev_name;
> +	struct cti_drvdata *drvdata = container_of(ctidev, struct cti_drvdata,
> +						   ctidev);
>  
>  	list_for_each_entry(tc, &ctidev->trig_cons, node) {
>  		if (tc->con_dev_name) {
> @@ -462,6 +495,7 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name,
>  					devm_kstrdup(&csdev->dev, csdev_name,
>  						     GFP_KERNEL);
>  				tc->con_dev = csdev;
> +				cti_add_sysfs_link(drvdata, tc);
>  				return true;
>  			}
>  		}
> @@ -546,10 +580,12 @@ static void cti_update_conn_xrefs(struct cti_drvdata *drvdata)
>  	struct cti_device *ctidev = &drvdata->ctidev;
>  
>  	list_for_each_entry(tc, &ctidev->trig_cons, node) {
> -		if (tc->con_dev)
> +		if (tc->con_dev) {
>  			/* set tc->con_dev->ect_dev */
>  			coresight_set_assoc_ectdev_mutex(tc->con_dev,
>  							 drvdata->csdev);
> +			cti_add_sysfs_link(drvdata, tc);
> +		}
>  	}
>  }
>  
> @@ -602,6 +638,9 @@ static void cti_device_release(struct device *dev)
>  	mutex_lock(&ect_mutex);
>  	cti_remove_conn_xrefs(drvdata);
>  
> +	/* clear the dynamic sysfs associate with connections */

s/associate/associated

> +	cti_remove_all_sysfs_links(drvdata);
> +
>  	/* remove from the list */
>  	list_for_each_entry_safe(ect_item, ect_tmp, &ect_net, node) {
>  		if (ect_item == drvdata) {

With the above:

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

> -- 
> 2.17.1
> 

  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 10:58 [PATCH v4 0/6] Describe CoreSight topology using sysfs links Mike Leach
2020-02-11 10:58 ` [PATCH v4 1/6] coresight: Pass coresight_device for coresight_release_platform_data Mike Leach
2020-02-11 10:58 ` [PATCH v4 2/6] coresight: add return value for fixup connections Mike Leach
2020-02-11 10:58 ` [PATCH v4 3/6] coresight: Add generic sysfs link creation functions Mike Leach
2020-02-14 23:17   ` Mathieu Poirier
2020-02-11 10:58 ` [PATCH v4 4/6] coresight: Expose device connections via sysfs Mike Leach
2020-02-14 22:31   ` Mathieu Poirier
2020-02-11 10:58 ` [PATCH v4 5/6] coresight: cti: Add in sysfs links to other coresight devices Mike Leach
2020-02-14 22:58   ` Mathieu Poirier [this message]
2020-02-11 10:58 ` [PATCH v4 6/6] coresight: docs: Add information about the topology representations Mike Leach
2020-02-14 23:10   ` Mathieu Poirier

Reply instructions:

You may reply publically 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=20200214225839.GB20024@xps15 \
    --to=mathieu.poirier@linaro.org \
    --cc=coresight@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=suzuki.poulose@arm.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

Linux-Doc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-doc/0 linux-doc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-doc linux-doc/ https://lore.kernel.org/linux-doc \
		linux-doc@vger.kernel.org
	public-inbox-index linux-doc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-doc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git