linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, robert.walker@arm.com,
	linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org
Subject: Re: [PATCH 21/25] coresight: Use fwnode handle instead of device names
Date: Thu, 28 Mar 2019 11:42:16 -0600	[thread overview]
Message-ID: <20190328174216.GD778@xps15> (raw)
In-Reply-To: <1553107783-3340-22-git-send-email-suzuki.poulose@arm.com>

On Wed, Mar 20, 2019 at 06:49:38PM +0000, Suzuki K Poulose wrote:
> We rely on the device names to find a CoreSight device on the
> coresight bus. The device name however is obtained from the platform,
> which is bound to the real platform/amba device. As we are about
> to use different naming scheme for the coresight devices, we can't
> rely on the platform device name to find the corresponding
> coresight device. Instead we use the platform agnostic
> "fwnode handle" of the parent device to find the devices.
> We also reuse the same fwnode as the parent for the Coresight
> device we create.
> 
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/hwtracing/coresight/coresight-platform.c | 10 ++++------
>  drivers/hwtracing/coresight/coresight-priv.h     |  2 ++
>  drivers/hwtracing/coresight/coresight.c          | 19 +++++++++++--------
>  include/linux/coresight.h                        |  4 ++--
>  4 files changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
> index 877ed2b..5eee987 100644
> --- a/drivers/hwtracing/coresight/coresight-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-platform.c
> @@ -31,7 +31,7 @@ static int coresight_alloc_conns(struct device *dev,
>  	return 0;
>  }
>  
> -static int coresight_fwnode_handle_match(struct device *dev, void *data)
> +int coresight_match_fwnode_handle(struct device *dev, void *data)
>  {
>  	return dev_fwnode(dev) == data;
>  }
> @@ -46,7 +46,7 @@ coresight_find_device_by_fwnode(struct fwnode_handle *fwnode)
>  	 * platform bus.
>  	 */
>  	dev = bus_find_device(&platform_bus_type, NULL,
> -			      fwnode, coresight_fwnode_handle_match);
> +			      fwnode, coresight_match_fwnode_handle);
>  	if (dev)
>  		return dev;
>  
> @@ -55,7 +55,7 @@ coresight_find_device_by_fwnode(struct fwnode_handle *fwnode)
>  	 * looking for the device that matches the endpoint node.
>  	 */
>  	return bus_find_device(&amba_bustype, NULL,
> -			       fwnode, coresight_fwnode_handle_match);
> +			       fwnode, coresight_match_fwnode_handle);
>  }

Please change the name to coresight_match_fwnode_handle() in the previous patch
so that it is set only once.

>  
>  #ifdef CONFIG_OF
> @@ -214,9 +214,7 @@ static int of_coresight_parse_endpoint(struct device *dev,
>  		}
>  
>  		conn->outport = endpoint.port;
> -		conn->child_name = devm_kstrdup(dev,
> -						dev_name(rdev),
> -						GFP_KERNEL);
> +		conn->child_fwnode = fwnode_handle_get(rdev_fwnode);

I think it is worth adding a comment saying the refcount on the handle is
decremented in coresight_remove_match().  It is quite obvious when looking at
this patch but I suspect it won't be so in 1 year from now when trying to
understand this code again, especially since the increment/decrement are in
different files.

>  		conn->child_port = rendpoint.port;
>  		/* Connection record updated */
>  		ret = 1;
> diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
> index e0684d0..8fb1243 100644
> --- a/drivers/hwtracing/coresight/coresight-priv.h
> +++ b/drivers/hwtracing/coresight/coresight-priv.h
> @@ -153,6 +153,8 @@ struct list_head *coresight_build_path(struct coresight_device *csdev,
>  				       struct coresight_device *sink);
>  void coresight_release_path(struct list_head *path);
>  
> +int coresight_match_fwnode_handle(struct device *dev, void *data);
> +
>  #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
>  extern int etm_readl_cp14(u32 off, unsigned int *val);
>  extern int etm_writel_cp14(u32 off, u32 val);
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index 29cef89..9cdedab 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -1005,13 +1005,11 @@ static int coresight_orphan_match(struct device *dev, void *data)
>  		/* We have found at least one orphan connection */
>  		if (conn->child_dev == NULL) {
>  			/* Does it match this newly added device? */
> -			if (conn->child_name &&
> -			    !strcmp(dev_name(&csdev->dev), conn->child_name)) {
> +			if (conn->child_fwnode ==  csdev->dev.fwnode)
>  				conn->child_dev = csdev;
> -			} else {
> +			else
>  				/* This component still has an orphan */
>  				still_orphan = true;
> -			}
>  		}
>  	}
>  
> @@ -1043,9 +1041,9 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev)
>  		struct coresight_connection *conn = &csdev->conns[i];
>  		struct device *dev = NULL;
>  
> -		if (conn->child_name)
> -			dev = bus_find_device_by_name(&coresight_bustype, NULL,
> -						      conn->child_name);
> +		dev = bus_find_device(&coresight_bustype, NULL,
> +				      (void *)conn->child_fwnode,
> +				      coresight_match_fwnode_handle);
>  		if (dev) {
>  			conn->child_dev = to_coresight_device(dev);
>  			/* and put reference from 'bus_find_device()' */
> @@ -1080,9 +1078,11 @@ static int coresight_remove_match(struct device *dev, void *data)
>  		if (conn->child_dev == NULL)
>  			continue;
>  
> -		if (!strcmp(dev_name(&csdev->dev), conn->child_name)) {
> +		if (csdev->dev.fwnode == conn->child_fwnode) {
>  			iterator->orphan = true;
>  			conn->child_dev = NULL;
> +			/* Drop the reference to the handle for connection */

Same as above, please comment where this gets incremented.

> +			fwnode_handle_put(conn->child_fwnode);
>  			/* No need to continue */
>  			break;
>  		}
> @@ -1198,6 +1198,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
>  	csdev->dev.parent = desc->dev;
>  	csdev->dev.release = coresight_device_release;
>  	csdev->dev.bus = &coresight_bustype;
> +	csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev));
> +
>  	dev_set_name(&csdev->dev, "%s", desc->pdata->name);
>  
>  	ret = device_register(&csdev->dev);
> @@ -1247,6 +1249,7 @@ void coresight_unregister(struct coresight_device *csdev)
>  	etm_perf_del_symlink_sink(csdev);
>  	/* Remove references of that device in the topology */
>  	coresight_remove_conns(csdev);
> +	fwnode_handle_put(csdev->dev.fwnode);
>  	device_unregister(&csdev->dev);
>  }
>  EXPORT_SYMBOL_GPL(coresight_unregister);
> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> index a48cd9b..76c31b2 100644
> --- a/include/linux/coresight.h
> +++ b/include/linux/coresight.h
> @@ -128,14 +128,14 @@ struct coresight_desc {
>  /**
>   * struct coresight_connection - representation of a single connection
>   * @outport:	a connection's output port number.
> - * @chid_name:	remote component's name.
> + * @chid_fwnode: remote component's fwnode handle.
>   * @child_port:	remote component's port number @output is connected to.
>   * @child_dev:	a @coresight_device representation of the component
>  		connected to @outport.
>   */
>  struct coresight_connection {
>  	int outport;
> -	const char *child_name;
> +	struct fwnode_handle *child_fwnode;

Please drop this one line to group all the struct together.

>  	int child_port;
>  	struct coresight_device *child_dev;
>  };
> -- 
> 2.7.4
> 

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

  reply	other threads:[~2019-03-28 17:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 18:49 [PATCH 00/25] coresight: Support for ACPI bindings Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 01/25] coresight: tmc: Report DMA setup failures Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 02/25] coresight: dynamic-replicator: Clean up error handling Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 03/25] coresight: replicator: Prepare for merging with dynamic-replicator Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 04/25] coresight: dynamic-replicator: Prepare for merging with static replicator Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 05/25] coresight: Merge the static and dynamic replicator drivers Suzuki K Poulose
2019-03-27 15:27   ` Mathieu Poirier
2019-03-27 17:33     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 06/25] coresight: funnel: Clean up device book keeping Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 07/25] coresight: replicator: Cleanup device tracking Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 08/25] coresight: tmc: Clean up device specific data Suzuki K Poulose
2019-03-26 21:53   ` Mathieu Poirier
2019-03-27 11:45     ` Suzuki K Poulose
2019-03-27 14:42     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 09/25] coresight: catu: Cleanup " Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 10/25] coresight: tpiu: Clean up " Suzuki K Poulose
2019-03-26 21:54   ` Mathieu Poirier
2019-03-27 11:52     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 11/25] coresight: stm: Cleanup " Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 12/25] coresight: etm: Clean up " Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 13/25] coresight: etb10: " Suzuki K Poulose
2019-03-27 21:39   ` Mathieu Poirier
2019-03-28 11:09     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 14/25] coresight: Rename of_coresight to coresight-platform Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 15/25] coresight: etm3x: Rearrange cp14 access detection Suzuki K Poulose
2019-03-27 22:05   ` Mathieu Poirier
2019-03-28 11:03     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 16/25] coresight: stm: Rearrange probing the stimulus area Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 17/25] coresight: tmc-etr: Rearrange probing default buffer size Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 18/25] coresight: Introduce generic platform data helper Suzuki K Poulose
2019-03-27 22:57   ` Mathieu Poirier
2019-03-28 10:59     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 19/25] coresight: Make device to CPU mapping generic Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 20/25] coresight: platform: Use fwnode handle for device search Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 21/25] coresight: Use fwnode handle instead of device names Suzuki K Poulose
2019-03-28 17:42   ` Mathieu Poirier [this message]
2019-03-28 18:42     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 22/25] coresight: Use platform agnostic names Suzuki K Poulose
2019-03-28 19:43   ` Mathieu Poirier
2019-03-20 18:49 ` [PATCH 23/25] coresight: stm: ACPI support for parsing stimulus base Suzuki K Poulose
2019-03-28 20:41   ` Mathieu Poirier
2019-04-04 11:27     ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 24/25] coresight: Support for ACPI bindings Suzuki K Poulose
2019-03-29 19:09   ` Mathieu Poirier
2019-03-20 18:49 ` [PATCH 25/25] coresight: acpi: Support for components Suzuki K Poulose
2019-03-20 18:49 ` [TEST PATCH 26/25] edk2-platform: juno: Update ACPI CoreSight Bindings Suzuki K Poulose
2019-03-22 10:13 ` [PATCH 00/25] coresight: Support for ACPI bindings Suzuki K Poulose

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=20190328174216.GD778@xps15 \
    --to=mathieu.poirier@linaro.org \
    --cc=coresight@lists.linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=robert.walker@arm.com \
    --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
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;
as well as URLs for NNTP newsgroup(s).