* [PATCH v3] coresight: core: Fix coresight device probe failure issue
@ 2022-03-09 14:22 Mao Jinlong
2022-03-10 9:10 ` Suzuki K Poulose
0 siblings, 1 reply; 6+ messages in thread
From: Mao Jinlong @ 2022-03-09 14:22 UTC (permalink / raw)
To: Mathieu Poirier, Suzuki K Poulose, Mike Leach, Leo Yan,
Alexander Shishkin
Cc: Mao Jinlong, coresight, linux-arm-kernel, linux-kernel,
linux-arm-msm, Tingwei Zhang, Yuanfang Zhang, Tao Zhang,
Hao Zhang
It is possibe that probe failure issue happens when the device
and its child_device's probe happens at the same time.
In coresight_make_links, has_conns_grp is true for parent, but
has_conns_grp is false for child device as has_conns_grp is set
to true in coresight_create_conns_sysfs_group. The probe of parent
device will fail at this condition. Add has_conns_grp check for
child device before make the links and make the process from
device_register to connection_create be atomic to avoid this
probe failure issue.
Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Suggested-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
---
drivers/hwtracing/coresight/coresight-core.c | 33 +++++++++++++-------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 88653d1c06a4..7fed6e9c0ca1 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1382,7 +1382,7 @@ static int coresight_fixup_device_conns(struct coresight_device *csdev)
continue;
conn->child_dev =
coresight_find_csdev_by_fwnode(conn->child_fwnode);
- if (conn->child_dev) {
+ if (conn->child_dev && conn->child_dev->has_conns_grp) {
ret = coresight_make_links(csdev, conn,
conn->child_dev);
if (ret)
@@ -1574,6 +1574,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
int nr_refcnts = 1;
atomic_t *refcnts = NULL;
struct coresight_device *csdev;
+ bool registered = false;
csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
if (!csdev) {
@@ -1594,7 +1595,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
refcnts = kcalloc(nr_refcnts, sizeof(*refcnts), GFP_KERNEL);
if (!refcnts) {
ret = -ENOMEM;
- goto err_free_csdev;
+ kfree(csdev);
+ goto err_out;
}
csdev->refcnt = refcnts;
@@ -1619,6 +1621,13 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev));
dev_set_name(&csdev->dev, "%s", desc->name);
+ /*
+ * Make sure the device registration and the connection fixup
+ * are synchronised, so that we don't see uninitialised devices
+ * on the coresight bus while trying to resolve the connections.
+ */
+ mutex_lock(&coresight_mutex);
+
ret = device_register(&csdev->dev);
if (ret) {
put_device(&csdev->dev);
@@ -1626,7 +1635,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
* All resources are free'd explicitly via
* coresight_device_release(), triggered from put_device().
*/
- goto err_out;
+ goto out_unlock;
}
if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
@@ -1641,11 +1650,11 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
* from put_device(), which is in turn called from
* function device_unregister().
*/
- goto err_out;
+ goto out_unlock;
}
}
-
- mutex_lock(&coresight_mutex);
+ /* Device is now registered */
+ registered = true;
ret = coresight_create_conns_sysfs_group(csdev);
if (!ret)
@@ -1655,16 +1664,18 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
if (!ret && cti_assoc_ops && cti_assoc_ops->add)
cti_assoc_ops->add(csdev);
+out_unlock:
mutex_unlock(&coresight_mutex);
- if (ret) {
+ /* Success */
+ if (!ret)
+ return csdev;
+
+ /* Unregister the device if needed */
+ if (registered) {
coresight_unregister(csdev);
return ERR_PTR(ret);
}
- return csdev;
-
-err_free_csdev:
- kfree(csdev);
err_out:
/* Cleanup the connection information */
coresight_release_platform_data(NULL, desc->pdata);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] coresight: core: Fix coresight device probe failure issue
2022-03-09 14:22 [PATCH v3] coresight: core: Fix coresight device probe failure issue Mao Jinlong
@ 2022-03-10 9:10 ` Suzuki K Poulose
2022-03-15 8:36 ` Jinlong Mao
0 siblings, 1 reply; 6+ messages in thread
From: Suzuki K Poulose @ 2022-03-10 9:10 UTC (permalink / raw)
To: Mao Jinlong, Mathieu Poirier, Mike Leach, Leo Yan,
Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, linux-arm-msm,
Tingwei Zhang, Yuanfang Zhang, Tao Zhang, Hao Zhang
Hi Jinlong
On 09/03/2022 14:22, Mao Jinlong wrote:
> It is possibe that probe failure issue happens when the device
> and its child_device's probe happens at the same time.
> In coresight_make_links, has_conns_grp is true for parent, but
> has_conns_grp is false for child device as has_conns_grp is set
> to true in coresight_create_conns_sysfs_group. The probe of parent
> device will fail at this condition. Add has_conns_grp check for
> child device before make the links and make the process from
> device_register to connection_create be atomic to avoid this
> probe failure issue.
>
> Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> Suggested-by: Mike Leach <mike.leach@linaro.org>
> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
Thanks for the rework. The patch looks good to me.
Suzuki
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] coresight: core: Fix coresight device probe failure issue
2022-03-10 9:10 ` Suzuki K Poulose
@ 2022-03-15 8:36 ` Jinlong Mao
2022-03-15 8:42 ` Suzuki K Poulose
0 siblings, 1 reply; 6+ messages in thread
From: Jinlong Mao @ 2022-03-15 8:36 UTC (permalink / raw)
To: Suzuki K Poulose, Mathieu Poirier, Mike Leach, Leo Yan,
Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, linux-arm-msm,
Tingwei Zhang, Yuanfang Zhang, Tao Zhang, Hao Zhang
On 3/10/2022 5:10 PM, Suzuki K Poulose wrote:
> Hi Jinlong
>
>
> On 09/03/2022 14:22, Mao Jinlong wrote:
>> It is possibe that probe failure issue happens when the device
>> and its child_device's probe happens at the same time.
>> In coresight_make_links, has_conns_grp is true for parent, but
>> has_conns_grp is false for child device as has_conns_grp is set
>> to true in coresight_create_conns_sysfs_group. The probe of parent
>> device will fail at this condition. Add has_conns_grp check for
>> child device before make the links and make the process from
>> device_register to connection_create be atomic to avoid this
>> probe failure issue.
>>
>> Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Suggested-by: Mike Leach <mike.leach@linaro.org>
>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>
> Thanks for the rework. The patch looks good to me.
>
> Suzuki
Thanks Suzuki.
Hi Mathieu & Mike,
Could you please help to review and provide your comments for the PATCH V3 ?
Thanks
Jinlong Mao
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] coresight: core: Fix coresight device probe failure issue
2022-03-15 8:36 ` Jinlong Mao
@ 2022-03-15 8:42 ` Suzuki K Poulose
2022-03-15 8:52 ` Jinlong Mao
0 siblings, 1 reply; 6+ messages in thread
From: Suzuki K Poulose @ 2022-03-15 8:42 UTC (permalink / raw)
To: Jinlong Mao, Mathieu Poirier, Mike Leach, Leo Yan,
Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, linux-arm-msm,
Tingwei Zhang, Yuanfang Zhang, Tao Zhang, Hao Zhang
On 15/03/2022 08:36, Jinlong Mao wrote:
> On 3/10/2022 5:10 PM, Suzuki K Poulose wrote:
>> Hi Jinlong
>>
>>
>> On 09/03/2022 14:22, Mao Jinlong wrote:
>>> It is possibe that probe failure issue happens when the device
>>> and its child_device's probe happens at the same time.
>>> In coresight_make_links, has_conns_grp is true for parent, but
>>> has_conns_grp is false for child device as has_conns_grp is set
>>> to true in coresight_create_conns_sysfs_group. The probe of parent
>>> device will fail at this condition. Add has_conns_grp check for
>>> child device before make the links and make the process from
>>> device_register to connection_create be atomic to avoid this
>>> probe failure issue.
>>>
>>> Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>> Suggested-by: Mike Leach <mike.leach@linaro.org>
>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>
>> Thanks for the rework. The patch looks good to me.
>>
>> Suzuki
> Thanks Suzuki.
>
> Hi Mathieu & Mike,
>
> Could you please help to review and provide your comments for the PATCH
> V3 ?
Thats what I just said above. The patch looks good to me, I can queue
this in the next cycle.
Kind regards
Suzuki
>
> Thanks
> Jinlong Mao
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] coresight: core: Fix coresight device probe failure issue
2022-03-15 8:42 ` Suzuki K Poulose
@ 2022-03-15 8:52 ` Jinlong Mao
2022-05-04 11:01 ` Suzuki K Poulose
0 siblings, 1 reply; 6+ messages in thread
From: Jinlong Mao @ 2022-03-15 8:52 UTC (permalink / raw)
To: Suzuki K Poulose, Mathieu Poirier, Mike Leach, Leo Yan,
Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, linux-arm-msm,
Tingwei Zhang, Yuanfang Zhang, Tao Zhang, Hao Zhang
On 3/15/2022 4:42 PM, Suzuki K Poulose wrote:
> On 15/03/2022 08:36, Jinlong Mao wrote:
>> On 3/10/2022 5:10 PM, Suzuki K Poulose wrote:
>>> Hi Jinlong
>>>
>>>
>>> On 09/03/2022 14:22, Mao Jinlong wrote:
>>>> It is possibe that probe failure issue happens when the device
>>>> and its child_device's probe happens at the same time.
>>>> In coresight_make_links, has_conns_grp is true for parent, but
>>>> has_conns_grp is false for child device as has_conns_grp is set
>>>> to true in coresight_create_conns_sysfs_group. The probe of parent
>>>> device will fail at this condition. Add has_conns_grp check for
>>>> child device before make the links and make the process from
>>>> device_register to connection_create be atomic to avoid this
>>>> probe failure issue.
>>>>
>>>> Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>>> Suggested-by: Mike Leach <mike.leach@linaro.org>
>>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>>
>>> Thanks for the rework. The patch looks good to me.
>>>
>>> Suzuki
>> Thanks Suzuki.
>>
>> Hi Mathieu & Mike,
>>
>> Could you please help to review and provide your comments for the
>> PATCH V3 ?
>
> Thats what I just said above. The patch looks good to me, I can queue
> this in the next cycle.
Thanks Suzuki.
Best Regards
Jinlong Mao
>
> Kind regards
> Suzuki
>
>>
>> Thanks
>> Jinlong Mao
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] coresight: core: Fix coresight device probe failure issue
2022-03-15 8:52 ` Jinlong Mao
@ 2022-05-04 11:01 ` Suzuki K Poulose
0 siblings, 0 replies; 6+ messages in thread
From: Suzuki K Poulose @ 2022-05-04 11:01 UTC (permalink / raw)
To: Jinlong Mao, Mathieu Poirier, Mike Leach, Leo Yan,
Alexander Shishkin
Cc: coresight, linux-arm-kernel, linux-kernel, linux-arm-msm,
Tingwei Zhang, Yuanfang Zhang, Tao Zhang, Hao Zhang
On 15/03/2022 08:52, Jinlong Mao wrote:
>
> On 3/15/2022 4:42 PM, Suzuki K Poulose wrote:
>> On 15/03/2022 08:36, Jinlong Mao wrote:
>>> On 3/10/2022 5:10 PM, Suzuki K Poulose wrote:
>>>> Hi Jinlong
>>>>
>>>>
>>>> On 09/03/2022 14:22, Mao Jinlong wrote:
>>>>> It is possibe that probe failure issue happens when the device
>>>>> and its child_device's probe happens at the same time.
>>>>> In coresight_make_links, has_conns_grp is true for parent, but
>>>>> has_conns_grp is false for child device as has_conns_grp is set
>>>>> to true in coresight_create_conns_sysfs_group. The probe of parent
>>>>> device will fail at this condition. Add has_conns_grp check for
>>>>> child device before make the links and make the process from
>>>>> device_register to connection_create be atomic to avoid this
>>>>> probe failure issue.
>>>>>
>>>>> Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>>>> Suggested-by: Mike Leach <mike.leach@linaro.org>
>>>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>>>
>>>> Thanks for the rework. The patch looks good to me.
>>>>
>>>> Suzuki
>>> Thanks Suzuki.
>>>
>>> Hi Mathieu & Mike,
>>>
>>> Could you please help to review and provide your comments for the
>>> PATCH V3 ?
>>
>> Thats what I just said above. The patch looks good to me, I can queue
>> this in the next cycle.
Queued here:
https://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux.git/commit/?h=next&id=8c1d3f79d9ca48e406b78e90e94cf09a8c076bf2
Cheers
Suzuki
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-04 11:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-09 14:22 [PATCH v3] coresight: core: Fix coresight device probe failure issue Mao Jinlong
2022-03-10 9:10 ` Suzuki K Poulose
2022-03-15 8:36 ` Jinlong Mao
2022-03-15 8:42 ` Suzuki K Poulose
2022-03-15 8:52 ` Jinlong Mao
2022-05-04 11:01 ` Suzuki K Poulose
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).