From patchwork Fri Mar 4 08:23:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Jinlong X-Patchwork-Id: 12768708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A644C433F5 for ; Fri, 4 Mar 2022 08:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=GgtmxAV2ORcCG4ali5mqUjtt24NP7QA+jXHwmmOhYkA=; b=uNbDM2c9uxE1NX N+eYloAQPzTiJ8SwL/ormsmBEsefbI0Du2G/ppNJ9oa5okxrsWjKYBeMpM0h5OJphMBa5W5zV+g9j 64uznQ06kWDueyRXmFkkmrwknZCmv6+bzeI9KiZENHpo85jtU4HCFd2itdikl713hUYpLPcznJWWC aWOBnQ9WzUqSy0jQktC9QHif2vHXhNpn6S52W8XDhU+StvBcb0SxD7GxLHaFHzQKWIDSXTghFd3AD keYF7geuZeG/tiyx84ezVsiDo6D7T0HhflSNrUXvXimDTRiCl91efIgDJeitTf6KQ+lXyyVeQFeVX kjLp8xnDl1Q0jGtNwyPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ3ES-0091LN-GE; Fri, 04 Mar 2022 08:24:12 +0000 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ3EO-0091KR-Kf for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 08:24:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1646382248; x=1677918248; h=from:to:cc:subject:date:message-id:mime-version; bh=QnY+De45lh3dkdn8KOBNLbFmgPbGNeJtHbQNMrb6RTA=; b=fbdx6++W3gqcEVu+KEQ7fJBjBIkSMrd+AFUsHHxx4b41nHYoBQ/mzdYu sgjcKEr3D8llYnhc/jGh8DxsDF24jVVwBFRtkaiKpbCC/5xRqmSvFVlTA 5RHlYnqR7QV9T1uw4tjtGP7kyZ7hHvmogAWe7IimFZpA26Q/7O7rOHUPN o=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 04 Mar 2022 00:24:05 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 00:24:04 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Fri, 4 Mar 2022 00:24:04 -0800 Received: from hu-jinlmao-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Fri, 4 Mar 2022 00:24:03 -0800 From: Mao Jinlong To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , Alexander Shishkin CC: Mao Jinlong , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Hao Zhang Subject: [PATCH v2] coresight: core: Fix coresight device probe failure issue Date: Fri, 4 Mar 2022 00:23:50 -0800 Message-ID: <20220304082350.30069-1-quic_jinlmao@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01a.na.qualcomm.com (10.47.209.196) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_002408_752086_EA18C755 X-CRM114-Status: GOOD ( 13.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Suggested-by: Mike Leach Signed-off-by: Mao Jinlong --- drivers/hwtracing/coresight/coresight-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 88653d1c06a4..b3e3bc59c09b 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) @@ -1594,7 +1594,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,8 +1620,10 @@ 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); + mutex_lock(&coresight_mutex); ret = device_register(&csdev->dev); if (ret) { + mutex_unlock(&coresight_mutex); put_device(&csdev->dev); /* * All resources are free'd explicitly via @@ -1634,6 +1637,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) ret = etm_perf_add_symlink_sink(csdev); if (ret) { + mutex_unlock(&coresight_mutex); device_unregister(&csdev->dev); /* * As with the above, all resources are free'd @@ -1645,8 +1649,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) } } - mutex_lock(&coresight_mutex); - ret = coresight_create_conns_sysfs_group(csdev); if (!ret) ret = coresight_fixup_device_conns(csdev); @@ -1663,8 +1665,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) return csdev; -err_free_csdev: - kfree(csdev); err_out: /* Cleanup the connection information */ coresight_release_platform_data(NULL, desc->pdata);