These patches present a few fix and some cleanup code for the coresight
subsystem. The set serves as a foundation for the upcoming 8th iteration
of the "coresight: integration with perf" patch set but not part of the
new functionality, hence choosing to send separately.
This set is based on [1].
Thanks,
Mathieu
Mathieu Poirier (5):
coresight: fixing indentation problem
coresight: fixing lockdep error
coresight: coresight_unregister() function cleanup
coresight: release reference taken by 'bus_find_device()'
coresight: remove csdev's link from topology
drivers/hwtracing/coresight/coresight.c | 57 +++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 6 deletions(-)
--
2.1.4
In its current form the code never frees csdev->refcnt allocated
in coresight_register(). There is also a problem with csdev->conns
that is freed before device_unregister() rather than in the device
release function.
This patch addresses both issues by moving kfree(csdev->conns) to
coresight_device_release() and freeing csdev->refcnt, also in
the same function.
Reported-by: Rabin Vincent <redacted>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/hwtracing/coresight/coresight.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
In function 'coresight_unregister()', all references to the csdev that
is being taken away need to be removed from the topology. Otherwise
building the next coresight path from source to sink may use memory
that has been released.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/hwtracing/coresight/coresight.c | 46 +++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
@@ -579,6 +579,50 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev)}}+staticintcoresight_remove_match(structdevice*dev,void*data)+{+inti;+structcoresight_device*csdev,*iterator;+structcoresight_connection*conn;++csdev=data;+iterator=to_coresight_device(dev);++/* No need to check oneself */+if(csdev==iterator)+return0;++/*+*Circlethrouchalltheconnectionofthatcomponent.Ifwefind+*aconnectionwhosenamematches@csdev,removeit.+*/+for(i=0;i<iterator->nr_outport;i++){+conn=&iterator->conns[i];++if(conn->child_dev==NULL)+continue;++if(!strcmp(dev_name(&csdev->dev),conn->child_name)){+iterator->orphan=true;+conn->child_dev=NULL;+/* No need to continue */+break;+}+}++/*+*Returning'0'ensuresthatallknowncomponentonthe+*buswillbechecked.+*/+return0;+}++staticvoidcoresight_remove_conns(structcoresight_device*csdev)+{+bus_for_each_dev(&coresight_bustype,NULL,+csdev,coresight_remove_match);+}+/***coresight_timeout-loopuntilabithaschangedtoaspecificstate.*@addr:baseaddressoftheareaofinterest.
@@ -717,6 +761,8 @@ EXPORT_SYMBOL_GPL(coresight_register);voidcoresight_unregister(structcoresight_device*csdev){+/* Remove references of that device in the topology */+coresight_remove_conns(csdev);device_unregister(&csdev->dev);}EXPORT_SYMBOL_GPL(coresight_unregister);
The reference count taken by function bus_find_device() needs
to be released if a child device is found, something this patch
is adding.
Reported-by: Rabin Vincent <redacted>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/hwtracing/coresight/coresight.c | 2 ++
1 file changed, 2 insertions(+)
@@ -570,6 +570,8 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev)if(dev){conn->child_dev=to_coresight_device(dev);+/* and put reference from 'bus_find_device()' */+put_device(dev);}else{csdev->orphan=true;conn->child_dev=NULL;