mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: mathieu.poirier@linaro.org
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, coresight@lists.linaro.org,
	mike.leach@linaro.org, rjw@rjwysocki.net, robert.walker@arm.com
Subject: Re: [PATCH v2 32/36] coresight: Support for ACPI bindings
Date: Thu, 25 Apr 2019 18:30:04 +0100	[thread overview]
Message-ID: <6e3c92e9-2a9f-353d-67ab-612434dab676@arm.com> (raw)
In-Reply-To: <20190425165010.GA4080@xps15>



On 25/04/2019 17:50, Mathieu Poirier wrote:
> On Mon, Apr 15, 2019 at 05:04:15PM +0100, Suzuki K Poulose wrote:
>> Add support for parsing the ACPI platform description
>> for CoreSight. The connections are encoded in a DSD graph
>> property with CoreSight specific variation of the property.
>>
>> The ETMs are listed as the children device of the respective
>> CPU.
>>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

...

>> +/*
>> + * acpi_validate_dsd_graph	- Make sure the given _DSD graph conforms
>> + * to the ACPI _DSD Graph specification.
>> + *
>> + * ACPI Devices Graph property has the following format:
>> + *	Revision	- Integer, must be 0
>> + *	NumberOfGraphs	- Integer, N indicating the following list.
>> + *	Graph[1],
>> + *	 ...
>> + *	Graph[N]
>> + *
>> + * And each Graph entry has the following format:
>> + *	GraphID		- Integer, identifying a graph the device belongs to.
>> + *	UUID		- UUID identifying the specification that governs
>> + *			  this graph. (e.g, see is_acpi_coresight_graph())
>> + *	NumberOfLinks	- Number "N" of connections on this node of the graph.
>> + *	Links[1]
>> + *	...
>> + *	Links[N]
>> + */
>> +static inline bool acpi_validate_dsd_graph(const union acpi_object *graph)
>> +{
>> +	int i, n;
>> +	const union acpi_object *rev, *nr_graphs;
>> +
>> +	/* The graph must contain at least the Revision and Number of Graphs */
>> +	if (graph->package.count < 2)
>> +		return false;
>> +
>> +	rev = &graph->package.elements[0];
>> +	nr_graphs = &graph->package.elements[1];
>> +
>> +	if (rev->type != ACPI_TYPE_INTEGER ||
>> +	    nr_graphs->type != ACPI_TYPE_INTEGER)
>> +		return false;
>> +
>> +	/* We only support revision 0 */
>> +	if (rev->integer.value != 0)
>> +		return false;
>> +
>> +	n = nr_graphs->integer.value;
>> +	/* Make sure the package has right number of elements */
>> +	if (graph->package.count != (n + 2))
>> +		return false;
>> +
>> +	/* Each entry must be a graph package with at least 3 members */
> 
> Please mention what the 3 members must be to avoid having to go back to the
> specs all the time.

Actually this is explained in the comment above. Graph entry contains :
GraphID, UUID and number of links. I could add make it explicit here,
just like I did it for the "Revision and Number of Graphs" above.

> 
>> +	for (i = 2; i < n + 2; i++) {
>> +		const union acpi_object *obj = &graph->package.elements[i];
>> +
>> +		if (obj->type != ACPI_TYPE_PACKAGE ||
>> +		    obj->package.count < 3)
>> +			return false;
>> +	}
>> +
>> +	return true;
>> +}


>> +
>> +/* acpi_get_dsd_graph	- Find the _DSD Graph property for the given device. */
>> +const union acpi_object *
>> +acpi_get_dsd_graph(struct acpi_device *adev)
>> +{
>> +	int i;
>> +	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
>> +	acpi_status status;
>> +	const union acpi_object *dsd;
>> +
>> +	status = acpi_evaluate_object_typed(adev->handle, "_DSD", NULL,
>> +					    &buf, ACPI_TYPE_PACKAGE);
>> +	if (ACPI_FAILURE(status))
>> +		return NULL;
>> +
>> +	dsd = buf.pointer;
> 
> Please add a comment to mention that a _DSD package consists of tuples, i.e a
> UUID and a package to explain the += 2.
> 

Sure, it took me a while to figure that out myself.

>> +static inline bool
>> +acpi_validate_coresight_graph(const union acpi_object *cs_graph)
>> +{
>> +	int nlinks;
>> +
>> +	nlinks = cs_graph->package.elements[2].integer.value;
> 
> As you did in acpi_validate_dsd_graph(), please add the rational for the + 3.

Sure.

>> +	if (cs_graph->package.count != (nlinks + 3))
>> +		return false;
>> +	/* The links are validated in acpi_coresight_parse_link() */
>> +	return true;
>> +}
>> +
>> +/*
>> + * acpi_get_coresight_graph	- Parse the device _DSD tables and find
>> + * the Graph property matching the CoreSight Graphs.
>> + *
>> + * Returns the pointer to the CoreSight Graph Package when found. Otherwise
>> + * returns NULL.
>> + */
>> +const union acpi_object *
>> +acpi_get_coresight_graph(struct acpi_device *adev)
>> +{
>> +	const union acpi_object *graph_list, *graph;
>> +	int i, nr_graphs;
>> +
>> +	graph_list = acpi_get_dsd_graph(adev);
>> +	if (!graph_list)
>> +		return graph_list;
>> +
>> +	nr_graphs = graph_list->package.elements[1].integer.value;
> 
> In what kind of scenario nr_graphs would be more than 1?  From what I've seen in
> DEN0067 and the implementation in patch 37 it shouldn't be the case.  As such I
> would treat nr_graphs != 1 as an error.

The device could be part of multiple graphs theoretically. However, for
CoreSight we have only one graph, which shows the ATB connections. I could
enforce that here.


> 
> I must admit I had a really hard time following the hard coded .element[]
> throughout the code.  With time I was able to verify them all but it would
> really help if the example of an ACPI device description was given at the
> top of the file, just before the ACPI Graph UUID.  The following taken from
> DEN0067 did the trick for me:

I understand the pain. It is indeed a bit tricky. I will add an example graph
property.

> 
> Device ( FUN1 ) { // Funnel 1 described in \SB scope
>    Name (_HID , " ARMHC9FF ")
>    Name (_CID , " ARMHC500 ")
>    Name (_CRS , ResourceTemplate () {
>    Memory32Fixed ( ReadWrite , 0 x208c0000 , 0 x1000 )
>    })
> 
>    Name (_DSD , Package () {
>      ToUUID (" ab02a46b -74 c7 -45a2 -bd68 - f7d344ef2153 ") ,
>      Package () {
>        0 , // Revision
>        1 , // Number of graphs
>        Package () {
>          1 , // GraphID // CoreSight graphs UUID
>          ToUUID ("3 ecbc8b6 -1 d0e -4 fb3 -8107 - e627f805c6cd ") ,
>          3 , // Number of links
>          Package () {0 , 0 , // output port 0 connected
>               \_SB.RPL0 ,1} , // to input port 0 on RPL0 .
>          Package () {0 , 0 , // input port 0 connected
>               \_SB.ETF0 ,0} , // to output port 0 on ETF0 .
>          Package () {1 , 0 , // input port 1 connected
>               \_SB.ETF1 ,0} // to output port 0 on ETF1 .
>          }
>      }
>    })
> 

...

>> +/*
>> + * acpi_coresigh_get_cpu - Find the logical CPU id of the CPU associated
>> + * with this coresight device. With ACPI bindings, the CoreSight components
>> + * are listed as child device of the associated CPU.
>> + *
>> + * Returns the logical CPU id when found. Otherwise returns < 0.
> 
> As far as I can tell this function can't return < 0.
> 

You're right. I will fix the comment.

>> +static struct coresight_platform_data *
>> +acpi_get_coresight_platform_data(struct device *dev,
>> +				 struct coresight_platform_data *pdata)
>> +{
>> +	int rc = -EINVAL;
>> +	struct acpi_device *adev;
>> +
>> +	adev = ACPI_COMPANION(dev);
>> +	if (!adev)
>> +		goto out;
>> +
>> +	rc = acpi_coresight_parse_graph(adev, pdata);
>> +	if (rc)
>> +		goto out;
> 
> The goto statement is not needed here.
> 

OK

>> +out:
>> +	if (rc)
>> +		return ERR_PTR(rc);
>> +	return pdata;
>> +}
>> +
>> +#else
>> +
>> +static inline struct coresight_platform_data *
>> +acpi_get_coresight_platform_data(struct device *dev,
>> +				 struct coresight_platform_data *pdata)
>> +{
>> +	return NULL;
>> +}
>> +
>> +static inline int acpi_coresight_get_cpu(struct device *dev)
>> +{
>> +	return 0;
>> +}
>> +#endif
>> +
> 
> Function of_coresight_get_cpu() and of_get_coresight_platform_data() will also
> need a stub if CONFIG_OF=n.
>

Yep, agreed.

Thank you so much for the review !
Suzuki

  reply	other threads:[~2019-04-25 17:30 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15 16:03 [PATCH v2 00/36] " Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 01/36] coresight: Fix freeing up the coresight connections Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 02/36] coresight: etb10: Cleanup power management Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 03/36] coresight: tpiu: " Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 04/36] coresight: catu: " Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 05/36] coresight: tmc: " Suzuki K Poulose
2019-04-17 20:03   ` Mathieu Poirier
2019-04-23  9:33     ` Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 06/36] coresight: funnel: Clean up device book keeping Suzuki K Poulose
2019-04-17 20:14   ` Mathieu Poirier
2019-04-15 16:03 ` [PATCH v2 07/36] coresight: replicator: Cleanup device tracking Suzuki K Poulose
2019-04-17 20:34   ` Mathieu Poirier
2019-04-15 16:03 ` [PATCH v2 08/36] coresight: tmc: Clean up device specific data Suzuki K Poulose
2019-04-17 21:23   ` Mathieu Poirier
2019-05-03 17:13     ` Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 09/36] coresight: catu: Cleanup " Suzuki K Poulose
2019-04-17 21:40   ` Mathieu Poirier
2019-04-15 16:03 ` [PATCH v2 10/36] coresight: tpiu: Clean up " Suzuki K Poulose
2019-04-17 21:41   ` Mathieu Poirier
2019-04-15 16:03 ` [PATCH v2 11/36] coresight: stm: Cleanup " Suzuki K Poulose
2019-04-18 16:50   ` Mathieu Poirier
2019-04-15 16:03 ` [PATCH v2 12/36] coresight: etm: Clean up " Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 13/36] coresight: etb10: " Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 14/36] coresight: Rename of_coresight to coresight-platform Suzuki K Poulose
2019-04-18 17:22   ` Mathieu Poirier
2019-04-15 16:03 ` [PATCH v2 15/36] coresight: etm3x: Rearrange cp14 access detection Suzuki K Poulose
2019-04-15 16:03 ` [PATCH v2 16/36] coresight: stm: Rearrange probing the stimulus area Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 17/36] coresight: tmc-etr: Rearrange probing default buffer size Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 18/36] coresight: platform: Make memory allocation helper generic Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 19/36] coresight: Introduce generic platform data helper Suzuki K Poulose
2019-04-22 18:09   ` Mathieu Poirier
2019-04-23  9:43     ` Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 20/36] coresight: Make device to CPU mapping generic Suzuki K Poulose
2019-04-18 18:14   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 21/36] coresight: Remove cpu field from platform data Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 22/36] coresight: Remove name from platform description Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 23/36] coresight: Cleanup coresight_remove_conns Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 24/36] coresight: Reuse platform data structure for connection tracking Suzuki K Poulose
2019-04-22 17:06   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 25/36] coresight: Rearrange platform data probing Suzuki K Poulose
2019-04-22 17:16   ` Mathieu Poirier
2019-04-25 17:12     ` Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 26/36] coresight: Add support for releasing platform specific data Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 27/36] drivers: Add a generic helper to match device by fwnode handle Suzuki K Poulose
2019-04-16 10:20   ` Rafael J. Wysocki
2019-04-16 10:34     ` Suzuki K Poulose
2019-04-16 10:45       ` Rafael J. Wysocki
2019-04-16 10:39   ` [RESEND][PATCH " Suzuki K Poulose
2019-04-16 10:48     ` Rafael J. Wysocki
2019-04-16 10:56       ` Suzuki K Poulose
2019-04-18 14:39         ` Rafael J. Wysocki
2019-04-18 15:18           ` Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 28/36] coresight: platform: Use fwnode handle for device search Suzuki K Poulose
2019-04-23 16:17   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 29/36] coresight: Use fwnode handle instead of device names Suzuki K Poulose
2019-04-23 16:14   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 30/36] coresight: Use platform agnostic names Suzuki K Poulose
2019-04-23 17:38   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 31/36] coresight: stm: ACPI support for parsing stimulus base Suzuki K Poulose
2019-04-23 17:59   ` Mathieu Poirier
2019-04-25 16:17     ` Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 32/36] coresight: Support for ACPI bindings Suzuki K Poulose
2019-04-25 16:50   ` Mathieu Poirier
2019-04-25 17:30     ` Suzuki K Poulose [this message]
2019-04-15 16:04 ` [PATCH v2 33/36] coresight: acpi: Support for components Suzuki K Poulose
2019-04-25 17:45   ` Mathieu Poirier
2019-04-29  8:54     ` Suzuki K Poulose
2019-04-15 16:04 ` [PATCH v2 34/36] [RFC] coresight: Pass coresight_device for coresight_release_platform_data Suzuki K Poulose
2019-04-29 17:40   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 35/36] [RFC] coresight: add return value for fixup connections Suzuki K Poulose
2019-04-29 17:44   ` Mathieu Poirier
2019-04-15 16:04 ` [PATCH v2 36/36] [RFC] coresight: Expose device connections via sysfs Suzuki K Poulose
2019-04-29 20:50   ` Mathieu Poirier
2019-04-15 16:04 ` [TEST PATCH 37/36][EDK2] edk2-platform: juno: Update ACPI CoreSight 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=6e3c92e9-2a9f-353d-67ab-612434dab676@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=robert.walker@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

all inboxes | Powered by JetHome®