On 05/26/2020 11:46 AM, Mike Leach wrote:
Adds a method to select a suitable sink connected to a given source.
In cases where no sink is defined, the coresight_find_default_sink routine can search from a given source, through the child connections until a suitable sink is found.
The suitability is defined in by the sink coresight_dev_subtype on the CoreSight device, and the distance from the source by counting connections.
Higher value subtype is preferred - where these are equal, shorter distance from source is used as a tie-break.
This allows for default sink to be discovered were none is specified (e.g. perf command line)
Signed-off-by: Mike Leach mike.leach@linaro.org
Feel free to add: Suggested-by: Suzuki K Poulose suzuki.poulose@arm.com
+/**
- coresight_find_default_sink: Find a sink suitable for use as a
- default sink.
- @csdev: starting source to find a connected sink.
- Walks connections graph looking for a suitable sink to enable for the
- supplied source. Uses CoreSight device subtypes and distance from source
- to select the best sink.
- If a sink is found, then the default sink for this device is set and
- will be automatically used in future.
- Used in cases where the CoreSight user (perf / sysfs) has not selected a
- sink.
- */
+struct coresight_device * +coresight_find_default_sink(struct coresight_device *csdev) +{
- int depth = 0;
- /* look for a default sink if we have not found for this device */
- if (!csdev->def_sink)
csdev->def_sink = coresight_find_sink(csdev, &depth);
Could we add a helper to clear the cached "def-sink" from all the "sources", when the sink is going away ? You may be able to do this via coresight_remove_match()
Rest looks good to me. Suzuki