Message ID | 20240124084636.1415652-1-xu.yang_2@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-36646-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp853812dyi; Wed, 24 Jan 2024 00:40:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHh59z6UCCyj1JxPYQdX2Sm+8izNOi/Yvl0aGMFeD4H4upmGoQGsqJC7WGsLq7fNuEOYvJG X-Received: by 2002:a17:907:d510:b0:a31:f2b:15d5 with SMTP id wb16-20020a170907d51000b00a310f2b15d5mr477519ejc.116.1706085634022; Wed, 24 Jan 2024 00:40:34 -0800 (PST) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bs8-20020a170906d1c800b00a30f3e7ebd0si891760ejb.781.2024.01.24.00.40.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 00:40:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ZtkUA70i; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-36646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36646-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7BEE61F284DB for <ouuuleilei@gmail.com>; Wed, 24 Jan 2024 08:40:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A514179A7; Wed, 24 Jan 2024 08:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ZtkUA70i" Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2079.outbound.protection.outlook.com [40.107.21.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D6E417980 for <linux-kernel@vger.kernel.org>; Wed, 24 Jan 2024 08:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706085614; cv=fail; b=PX6p4h7VtNh3IDhyg9zGA3yQWO4NvifJ1rhViPNZK3uKn2LhVDL0lja+QPz2zdRCMA0FHC2Hy7tsPLQ2DFncxwzFRQysO68JDHcIYelb1SglnI19gpFWinK0MHKNfFsyuvOw/SIvyWFLu2Ooq6if4QcodQBc72/tZh2W6EqIjko= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706085614; c=relaxed/simple; bh=r4qMzkoZRSE6PLOeCrYzIvc+jTvcHs9ZNV2b9BqTHcU=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=EfZsIyhW5GsrVzw+l7nvSatZ1yLfPvcVriZsxxOzbr8ImgL8erPr8uPjIeK1o+3Y+6BI4NaAgRn9Rnor5OoLf2yEezOpLLjMpK7AAb1lteLLAD4rkYuFdQk5yx73YAGmPw8p4KaiZlGQ13jV/edTzoXW7Up7FxhfOrPGPPwLpmw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=ZtkUA70i; arc=fail smtp.client-ip=40.107.21.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dl4xv6EHVIK5FilBFCbNVv4wndCbe4DhDIK2W9qvTOdaKTNpihxUtSZR/0PNScmCVXKZKJHjoDEzAGeD8pvv9UmFDrYOLXda9sdAE7EiBb323ZiQSy4s4/9VVSHZjPdh75Ot+msGIdqAYLav12kiOnawU6z2cgsiWbrJ5Sgj2NXK8DPyz37jvV5le0MjKGbgQu9vaI2VJaNTu0e1VPij+5cY6zwyXjf3tP8LkCUS3r8GeZHvuM4hRRuXgGsqFtbkgOQFuL4VygiAkMlV+RTVKdQjdTWHF6voMkvWKFLcZ1INloupwDN59fXYbvzdSp2JxDJXM8QIRr3b27pld3V0zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VYJn+eCOQ4JTTRQzwK/YWaYeGQZCUL4YpQsCf1W1SIo=; b=BdMG5hdj1td1ID4q3w2RkLmAB7b49k250YvbMFBRPyiQAwf6viHTi9lXLTxA9hMpJvoxbTaFOTSEaOh/Un5S4aGHqY9YPzTbI8pm0feS871Cr+b2j8aBk1/4vXv41v6Yrake9U8ycGZwfrmRsKICgfJah2/49i2KADHxzbtE0IGzkFNFvbJtd/9ijx8bNZ+O/jB0fxnO2IGBpzO+26gjuaJPZr98kxRIPPTM8E1o3AH9EXfFFiHvpzj/xfeyiQR+zSs2a1gcbl1qLnaoeCMpjZYXI6GvMVaszPyE4d70KsuqBtNU2DttwqlX+N4v51zeCFRfH2s7IoxujIaJAwMzPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VYJn+eCOQ4JTTRQzwK/YWaYeGQZCUL4YpQsCf1W1SIo=; b=ZtkUA70ih/husquPis2/GrSFhibMxHGAk5kHpjiMlzOS8gq2qY08/ISNHn90zII4mtuL419d1uU3U/1oO8m0lSS34vQ991oOM31jsb5VJlFUKAJ6L5bFgqhNcOrXAn0iBM+7yBs9nKJ1BmxOtedVn7LTVm/DJbqjBixtSHHKJNw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by GV1PR04MB9104.eurprd04.prod.outlook.com (2603:10a6:150:23::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Wed, 24 Jan 2024 08:40:08 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::d45f:4483:c11:68b0]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::d45f:4483:c11:68b0%6]) with mapi id 15.20.7202.035; Wed, 24 Jan 2024 08:40:08 +0000 From: Xu Yang <xu.yang_2@nxp.com> To: gregkh@linuxfoundation.org, rafael@kernel.org, saravanak@google.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] driver core: improve cycle detection on fwnode graph Date: Wed, 24 Jan 2024 16:46:36 +0800 Message-Id: <20240124084636.1415652-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0125.apcprd01.prod.exchangelabs.com (2603:1096:4:40::29) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|GV1PR04MB9104:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f5e99b1-bdd7-47d5-fec8-08dc1cb81224 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VN9XTgvwo+Vqof3kVG8frxhul4qmDpWqTki4ceIcZoTl2vjmyVR9TL2A7UUL2rqrwNFAtVU2ONxIJ3ZvesJdZC8eG13ucULGSRRoq0+Hp4sy10CgGVzXgTcqku95g3AZUwfFvIo4tTD/rxThoYh4x0TvSsma/Jb1VaXL6xS5A5RHvyoB3B0in00xFkiwsLEYOtp/O54eMyEcDsg5t6ktLAR9L7Ei2PHseZjeXtI82Mxf9BKHttloUqQemri0nXg8KcPawKXJDeYj962RRrINjjZPjLxZRnSyEdJsLQGRS+Uxz6E8KFjBoTxlWQ1ENr/YP3kJ6H+vqzfFr/Ks2m/TMBekEa3ZSgRblxMko+QV5NyNxVOOEpLFLIyWoSwwtH56/vjh6AQzd801r/2xnse2e8GxJFkEhWV8/MuO6pawvFNHCw/b6Lc3ETbMQWAHkSgn8rBNhqj7GyKOaNwO/ZzxcQcPqwRiWQbsjJC4lEHvMY0oJbzs3psO4NyddLIFmAvypU0v0PVQKQjcTSR95LZJZJ1LykZT4HrCrNFdGqitVFwfafwBLN0K72QxsQfkLi4vL4lZlqoqDx+tEUrBG0aGEnBnYuVPo4MzWAGI0ZcPjxqPvsmZl/FdWnmLcSDrTdu1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8822.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(366004)(396003)(39860400002)(136003)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(41300700001)(83380400001)(36756003)(86362001)(38350700005)(38100700002)(1076003)(2616005)(26005)(6512007)(6486002)(2906002)(6506007)(478600001)(66946007)(316002)(52116002)(66556008)(66476007)(6666004)(4326008)(8676002)(8936002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dsmodTnWvxPkrYbgKYrbP3rJKAVD/B52sATdhPO9F0SkPEgy0nfl5fNlEFtRCJE5UUxJFY9i9nEfObr3wXRBxELhMNW3B0H51jBlBZj1XQQXTU6xaJlIbiTF+M7RKIggz7rqASEnSWLxMVz9phKXquAoIs6Fwxsc68Cx2+sgRNhbzK8dooeK/pHGWcCMwQK9wIEsOeDHIeehiTRxNp0s02R0u0rJJkA0Vimu14Xfl+6y6GJUoL7tUfZbb5I0uCEV9CbxxclVVwD2cQnWnLppudZv5ReOSXblX62Y6R96XqD8Kry1Ssm1CdcMKri1Apci83ljHgY84b7NpduCrc5gub5cAEUkGL6MTxq/yKPWDS/5VEqxlSPRuxOkXwtcbHTpIPRqPFnpRYXcKzWrFDExIRu785KAV4fPtyNzCBeOt9Frjp5dA8uu0dEgnRxd4WwjP1AfDazfNg6kMaRjaiujAz9SnW8Dd/NKkfiGuukaVxNvaSuDHd6xC3Rf5lGvCC3F3FNbfRdc/TecvoDIrBVhKXaEwHBZgU8Z01zAGxyCvOqrEgWiXji25f3ia33t9C7NmTQEx7RjI3v3pX+VvidGm4MGdwpQbuCv1s18Ord/2prXZx5p6yAY55uTS+J3Id366K8dc5fE8sh/9ygWoOepl4AtQowi/EEp9Az+gISCEvNI3bFWsd4gB0uNs/MJd/tEQf5wjdKcsv3nLf6AKnI8cCdVawizkX+IdXr8Jtl7NbiQQYtK1fFuQNnlMCr+M1i2ANU/JVbNQ3dpedGAiW08KuT26rLQFMS7eUzW5rzI2z5WTusipfgT84ZfFqHRmta6+ehIxXRzuidrPYn4EPk28FPgqzO+1xJhBB8ms1x4M01f1b0cYlQimfYohFlrUSRjLkzo7Y+6XkmeTRzx+Aqx7ECsSZo70ne0n8F9EAonaZzZSZn/YMI9rh4Ms7a9xScrwLFcMLrv8mJz3bHmyF4HwQCAzLLA+9L9EX4uwynA2E92Imea2+8pGU7xW2hP2vateFm8fd+oLGD7U4QuG4KiVmWEbcdd/LWtX642fffTO4M5/+uW4RmBxSjVUp8hHp9TtIULu6FhqdIPu8pVicoASEr5pTamcpLTnIgfpK2HpQZJ1EmQPm37/MJTuBigmLqqndMZ1MelUza1eYoZlr8yW85n5wiMgLeB2CUXropF//4uOR6jvk/vGVa56CqPXDiGHIs6HyxKis9coSx1Y7PColjOx40w8H1HCBpXo8uabpg3HsS2/OlJYvOEShF2sCbkSu0ToHznrSBVmO8FUgK/oh9e2C+O3IdtQMxruvW0P4Y3/P3PknKFYSjjbBeH5X6bpeYa2dpQA5yOTXpZ0CsSQ0yXsvzJRjnA3VjnxL1QKG2lx8fKFwRM9ivAvpfb6krzHf96s8MCxjHpPpwGq/WcqdR6MBUKRzhBNxYFW53jIuYM2KkliBSQBfpl6TMQRZDFPPB3CNS7MTLvjxRVhxS8GnvSAPv2LcW5wZGelxDFmVMVvjnAFO8MGa/if1/H/W8mUnOF6zHEf7LjsV5lIqqboVzaLZWAVg8aMXPIMr3zF3gWiTPcKdg/ESyhAvmMThoW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f5e99b1-bdd7-47d5-fec8-08dc1cb81224 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 08:40:08.6781 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zAHzsXie6l3j2C+64MjmTeZwjoaedr6VyBN1nJ3h7uuidM2dK3RHZ4whjLmi7JU8P8cG/j5gqKRVyvYOIT57hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9104 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788960449802024670 X-GMAIL-MSGID: 1788960449802024670 |
Series |
driver core: improve cycle detection on fwnode graph
|
|
Commit Message
Xu Yang
Jan. 24, 2024, 8:46 a.m. UTC
Currently, cycle detection on fwnode graph is still defective.
Such as fwnode link A.EP->B is not marked as cycle in below case:
+-----+
| |
+-----+ | +--|
| |<-----------|EP|
|--+ | | +--|
|EP|----------->| |
|--+ | | B |
| | +-----+
| A | ^
+-----+ +-----+ |
| | | |
+----->| C |--+
| |
+-----+
1. Node C is populated as device C. But nodes A and B are still not
populated. When do cycle detection with device C, no cycle is found.
2. Node B is populated as device B. When do cycle detection with device
B, it found a link cycle B.EP->A->C->B. Then, fwnode link B.EP->A,
A->C and C->B are marked as cycle. The fwnode link C->B is converted
to device link too.
3. Node A is populated as device A. When do cycle detection with device
A, it find A->C is marked as cycle and convert it to device link. It
also find B.EP->A is marked as cycle but will not convert it to device
link since node B.EP is not a device.
Finally, fwnode link C->B and A->C is removed, B.EP->A is only marked as
cycle and A.EP->B is neither been marked as cycle nor removed.
For fwnode graph, the endpoint node can only be a supplier of other node
and the endpoint node will never be populated as device. Therefore, when
creating device link to supplier for fwnode graph, we need to relax cycle
with the real node rather endpoint node.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/base/core.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Wed, Jan 24, 2024 at 12:40 AM Xu Yang <xu.yang_2@nxp.com> wrote: > > Currently, cycle detection on fwnode graph is still defective. > Such as fwnode link A.EP->B is not marked as cycle in below case: > > +-----+ > | | > +-----+ | +--| > | |<-----------|EP| > |--+ | | +--| > |EP|----------->| | > |--+ | | B | > | | +-----+ > | A | ^ > +-----+ +-----+ | > | | | | > +----->| C |--+ > | | > +-----+ > > 1. Node C is populated as device C. But nodes A and B are still not > populated. When do cycle detection with device C, no cycle is found. > 2. Node B is populated as device B. When do cycle detection with device > B, it found a link cycle B.EP->A->C->B. Then, fwnode link B.EP->A, > A->C and C->B are marked as cycle. The fwnode link C->B is converted > to device link too. > 3. Node A is populated as device A. When do cycle detection with device > A, it find A->C is marked as cycle and convert it to device link. It > also find B.EP->A is marked as cycle but will not convert it to device > link since node B.EP is not a device. Your example doesn't sound correct (I'l explain further down) and it is vague. Need a couple of clarifications first. 1. What is the ---> representing? Is it references in DT or fwnode links? Which end of the arrow is the consumer? The tail or the pointy end? I typically use the format consumer --> supplier. 2. You say "link" sometimes but it's not clear if you mean fwnode links or device links. So please be explicit about it. 3. Your statement "Such as fwnode link A.EP->B is not marked as cycle" doesn't sound correct. When remote-endpoint properties are parsed, the fwnode is created from the device node with compatible property to the destination. So A.EP ----> B can't exist if I assume the consumer --> supplier format. 4. Has this actually caused an issue? If so, what is it? And give me an example in an upstream DT. Btw, I definitely don't anticipate ACKing this patch because the cycle detection code shouldn't be having property specific logic. It's not even DT specific in this place. If there is an issue and it needs fixing, it should be where the fwnode links are created. But then again I'm not sure what the actual symptom we are trying to solve is. -Saravana > > Finally, fwnode link C->B and A->C is removed, B.EP->A is only marked as > cycle and A.EP->B is neither been marked as cycle nor removed. > > For fwnode graph, the endpoint node can only be a supplier of other node > and the endpoint node will never be populated as device. Therefore, when > creating device link to supplier for fwnode graph, we need to relax cycle > with the real node rather endpoint node. > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> > --- > drivers/base/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 14d46af40f9a..278ded6cd3ce 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -2217,6 +2217,9 @@ static void __fw_devlink_link_to_suppliers(struct device *dev, > int ret; > struct fwnode_handle *sup = link->supplier; > > + if (fwnode_graph_is_endpoint(sup)) > + sup = fwnode_graph_get_port_parent(sup); > + > ret = fw_devlink_create_devlink(dev, sup, link); > if (!own_link || ret == -EAGAIN) > continue; > -- > 2.34.1 >
Hi Saravana, > > On Wed, Jan 24, 2024 at 12:40 AM Xu Yang <xu.yang_2@nxp.com> wrote: > > > > Currently, cycle detection on fwnode graph is still defective. > > Such as fwnode link A.EP->B is not marked as cycle in below case: > > > > +-----+ > > | | > > +-----+ | +--| > > | |<-----------|EP| > > |--+ | | +--| > > |EP|----------->| | > > |--+ | | B | > > | | +-----+ > > | A | ^ > > +-----+ +-----+ | > > | | | | > > +----->| C |--+ > > | | > > +-----+ > > > > 1. Node C is populated as device C. But nodes A and B are still not > > populated. When do cycle detection with device C, no cycle is found. > > 2. Node B is populated as device B. When do cycle detection with device > > B, it found a link cycle B.EP->A->C->B. Then, fwnode link B.EP->A, > > A->C and C->B are marked as cycle. The fwnode link C->B is converted > > to device link too. > > 3. Node A is populated as device A. When do cycle detection with device > > A, it find A->C is marked as cycle and convert it to device link. It > > also find B.EP->A is marked as cycle but will not convert it to device > > link since node B.EP is not a device. > > Your example doesn't sound correct (I'l explain further down) and it > is vague. Need a couple of clarifications first. > > 1. What is the ---> representing? Is it references in DT or fwnode > links? Which end of the arrow is the consumer? The tail or the pointy > end? I typically use the format consumer --> supplier. Sorry, I represent "-->" as "supplier --> consumer" and it's a fwnode link. > > 2. You say "link" sometimes but it's not clear if you mean fwnode > links or device links. So please be explicit about it. It’s fwnode link by default. > > 3. Your statement "Such as fwnode link A.EP->B is not marked as cycle" > doesn't sound correct. When remote-endpoint properties are parsed, the > fwnode is created from the device node with compatible property to the > destination. So A.EP ----> B can't exist if I assume the consumer --> > supplier format. The fwnode is not created from the device node with compatible property since below commit. The endpoint node is the supplier. No, you can see my case later. 4a032827daa8 (of: property: Simplify of_link_to_phandle(), 2023-02-06) > > 4. Has this actually caused an issue? If so, what is it? And give me > an example in an upstream DT. Yes, there are two cycles (B.EP->A->C->B and B.EP->A/A.EP->B) in above example. But only one cycle (B.EP->A->C->B) is recognized. My real case as below: --- tcpc@50 { compatible = "nxp,ptn5110"; ... port { typec_dr_sw: endpoint { remote-endpoint = <&usb3_drd_sw>; }; }; }; usb@38100000 { compatible = "snps,dwc3"; phys = <&usb3_phy0>, <&usb3_phy0>; ... port { usb3_drd_sw: endpoint { remote-endpoint = <&typec_dr_sw>; }; }; }; usb3_phy0: usb-phy@381f0040 { compatible = "fsl,imx8mp-usb-phy"; ... }; And fwnode links are created as below: --- [ 0.059553] /soc@0/bus@30800000/i2c@30a30000/tcpc@50 Linked as a fwnode consumer to /soc@0/usb@32f10100/usb@38100000/port/endpoint [ 0.066365] /soc@0/usb-phy@381f0040 Linked as a fwnode consumer to /soc@0/bus@30800000/i2c@30a30000/tcpc@50 [ 0.066624] /soc@0/usb@32f10100/usb@38100000 Linked as a fwnode consumer to /soc@0/usb-phy@381f0040 [ 0.066702] /soc@0/usb@32f10100/usb@38100000 Linked as a fwnode consumer to /soc@0/bus@30800000/i2c@30a30000/tcpc@50/port/endpoint > > Btw, I definitely don't anticipate ACKing this patch because the cycle > detection code shouldn't be having property specific logic. It's not > even DT specific in this place. If there is an issue and it needs > fixing, it should be where the fwnode links are created. But then > again I'm not sure what the actual symptom we are trying to solve is. Sorry for the inconvenience. I saw that you push some patches about fwnode link and device link handling, so I think you may understand this issue well and give some suggestions. Thanks, Xu Yang
On Wed, Jan 24, 2024 at 8:21 PM Xu Yang <xu.yang_2@nxp.com> wrote: > > Hi Saravana, > > > > > On Wed, Jan 24, 2024 at 12:40 AM Xu Yang <xu.yang_2@nxp.com> wrote: > > > > > > Currently, cycle detection on fwnode graph is still defective. > > > Such as fwnode link A.EP->B is not marked as cycle in below case: > > > > > > +-----+ > > > | | > > > +-----+ | +--| > > > | |<-----------|EP| > > > |--+ | | +--| > > > |EP|----------->| | > > > |--+ | | B | > > > | | +-----+ > > > | A | ^ > > > +-----+ +-----+ | > > > | | | | > > > +----->| C |--+ > > > | | > > > +-----+ > > > > > > 1. Node C is populated as device C. But nodes A and B are still not > > > populated. When do cycle detection with device C, no cycle is found. > > > 2. Node B is populated as device B. When do cycle detection with device > > > B, it found a link cycle B.EP->A->C->B. Then, fwnode link B.EP->A, > > > A->C and C->B are marked as cycle. The fwnode link C->B is converted > > > to device link too. > > > 3. Node A is populated as device A. When do cycle detection with device > > > A, it find A->C is marked as cycle and convert it to device link. It > > > also find B.EP->A is marked as cycle but will not convert it to device > > > link since node B.EP is not a device. > > > > Your example doesn't sound correct (I'l explain further down) and it > > is vague. Need a couple of clarifications first. > > > > 1. What is the ---> representing? Is it references in DT or fwnode > > links? Which end of the arrow is the consumer? The tail or the pointy > > end? I typically use the format consumer --> supplier. > > Sorry, I represent "-->" as "supplier --> consumer" and it's a fwnode link. > > > > > 2. You say "link" sometimes but it's not clear if you mean fwnode > > links or device links. So please be explicit about it. > > It’s fwnode link by default. > > > > > 3. Your statement "Such as fwnode link A.EP->B is not marked as cycle" > > doesn't sound correct. When remote-endpoint properties are parsed, the > > fwnode is created from the device node with compatible property to the > > destination. So A.EP ----> B can't exist if I assume the consumer --> > > supplier format. > > The fwnode is not created from the device node with compatible property > since below commit. The endpoint node is the supplier. No, you can see my > case later. > > 4a032827daa8 (of: property: Simplify of_link_to_phandle(), 2023-02-06) I think my confusion was because you use ----> in the opposite way to what I have used for all my fw_devlink and cycle detection patches. The part I was referring to is related to how driver/of/property.c has node_not_dev set to true for pasrse_remote_endpoint. > > > > 4. Has this actually caused an issue? If so, what is it? And give me > > an example in an upstream DT. > > Yes, there are two cycles (B.EP->A->C->B and B.EP->A/A.EP->B) in above > example. But only one cycle (B.EP->A->C->B) is recognized. > > My real case as below: I think you still missed some details because usb3_phy0 seems irrelevant here. Can you just point me to the dts (not dtsi) file for this platform in the kernel tree? Also, can you change all the pr_debug and dev_dbg in drivers/base/core.c to their info equivalent and boot up the system and give me the logs? That'll be a lot easier for me to understand your case. > --- > tcpc@50 { > compatible = "nxp,ptn5110"; > ... > > port { > typec_dr_sw: endpoint { > remote-endpoint = <&usb3_drd_sw>; > }; > }; > }; > > usb@38100000 { > compatible = "snps,dwc3"; > phys = <&usb3_phy0>, <&usb3_phy0>; > ... > > port { > usb3_drd_sw: endpoint { > remote-endpoint = <&typec_dr_sw>; > }; > }; > }; > > usb3_phy0: usb-phy@381f0040 { > compatible = "fsl,imx8mp-usb-phy"; > > ... > }; > > And fwnode links are created as below: > --- > [ 0.059553] /soc@0/bus@30800000/i2c@30a30000/tcpc@50 Linked as a fwnode consumer to /soc@0/usb@32f10100/usb@38100000/port/endpoint > [ 0.066365] /soc@0/usb-phy@381f0040 Linked as a fwnode consumer to /soc@0/bus@30800000/i2c@30a30000/tcpc@50 > [ 0.066624] /soc@0/usb@32f10100/usb@38100000 Linked as a fwnode consumer to /soc@0/usb-phy@381f0040 > [ 0.066702] /soc@0/usb@32f10100/usb@38100000 Linked as a fwnode consumer to /soc@0/bus@30800000/i2c@30a30000/tcpc@50/port/endpoint > So let's say I see your logs and what you say is true, but you still aren't telling me what's the problem you have because of this incorrect cycle detection. What's breaking? Is something not allowed to probe? If so, which one? What's supposed to be the right order of probes? > > > > Btw, I definitely don't anticipate ACKing this patch because the cycle > > detection code shouldn't be having property specific logic. It's not > > even DT specific in this place. If there is an issue and it needs > > fixing, it should be where the fwnode links are created. But then > > again I'm not sure what the actual symptom we are trying to solve is. > > Sorry for the inconvenience. I saw that you push some patches about fwnode > link and device link handling, so I think you may understand this issue > well and give some suggestions. No worries at all. Thanks for reporting the issue and thanks for trying to fix it. -Saravana
Hi Saravana, > > On Wed, Jan 24, 2024 at 8:21 PM Xu Yang <xu.yang_2@nxp.com> wrote: > > > I think my confusion was because you use ----> in the opposite way to > what I have used for all my fw_devlink and cycle detection patches. Okay, I will follow the usage of "-->" later as yours. > > The part I was referring to is related to how driver/of/property.c has > node_not_dev set to true for pasrse_remote_endpoint. > > > > > > > 4. Has this actually caused an issue? If so, what is it? And give me > > > an example in an upstream DT. > > > > Yes, there are two cycles (B.EP->A->C->B and B.EP->A/A.EP->B) in above > > example. But only one cycle (B.EP->A->C->B) is recognized. > > > > My real case as below: > > I think you still missed some details because usb3_phy0 seems One line is indeed missing in usb3_phy0. > irrelevant here. Can you just point me to the dts (not dtsi) file for > this platform in the kernel tree? This parts of dts is not in upstream kernel tree due to some reasons. Allow me to show the necessary parts as below again, you can also get the full dts file from the link I attached below: --- ptn5110: tcpc@50 { compatible = "nxp,ptn5110"; ... port { typec_dr_sw: endpoint { remote-endpoint = <&usb3_drd_sw>; }; }; }; usb_dwc3_0: usb@38100000 { compatible = "snps,dwc3"; phys = <&usb3_phy0>, <&usb3_phy0>; ... port { usb3_drd_sw: endpoint { remote-endpoint = <&typec_dr_sw>; }; }; }; usb3_phy0: usb-phy@381f0040 { compatible = "fsl,imx8mp-usb-phy"; vbus-power-supply = <&ptn5110>; ... }; > Also, can you change all the pr_debug and dev_dbg in > drivers/base/core.c to their info equivalent and boot up the system > and give me the logs? That'll be a lot easier for me to understand > your case. Thank you for willing to debug this issue. The boot log and dts file is under: https://drive.google.com/drive/folders/1hlkzg042q5_b5l59DCW2pECXRmTH4Vy_?usp=sharing > > So let's say I see your logs and what you say is true, but you still > aren't telling me what's the problem you have because of this > incorrect cycle detection. What's breaking? Is something not allowed > to probe? If so, which one? What's supposed to be the right order of > probes? > Let me describe the issue again based on above log and dts: usb +-----+ tcpc | | +-----+ | +--| | |----------->|EP| |--+ | | +--| |EP|<-----------| | |--+ | | B | | | +-----+ | A | | +-----+ | ^ +-----+ | | | | | +-----| C |<--+ | | +-----+ usb-phy Node A (tcpc) will be populated as device 1-0050. Node B (usb) will be populated as device 38100000.usb. Node C (usb-phy) will be populated as device 381f0040.usb-phy. 1. Node C is populated as device C. But nodes A and B are still not populated. When do cycle detection with device C, no cycle is found. 2. Node B is populated as device B. When do cycle detection with device B, it found a fwnode link cycle B-->C-->A-->B.EP. Then, fwnode link A-->B.EP, C-->A and B-->C are marked as cycle. The fwnode link B-->C is converted to device link too. 3. Node A is populated as device A. When do cycle detection with device A, it find C-->A is marked as cycle and convert it to device link. It also find A-->B.EP is marked as cycle but will not convert it to device link since node B.EP is not a device. Finally, fwnode link B-->C and C-->A is removed, A-->B.EP is only marked as cycle and B-->A.EP is neither been marked as cycle nor removed. So there are 2 cycles and only the first cycle is detected. 1. B-->C-->A-->B.EP--B 2. B-->A.EP--A-->B.EP--B In the end, device 38100000.usb (node B) is defered probe due to node B still has a supplier node A.EP. Device 1-0050 (node A) is also defered probe due to it depends on one device which is created by 38100000.usb. The normal behavior is all of the devices can be successfully probed after two cycles are detected. Thanks, Xu Yang
On Fri, Jan 26, 2024 at 1:00 AM Xu Yang <xu.yang_2@nxp.com> wrote: > > Hi Saravana, > > > > > On Wed, Jan 24, 2024 at 8:21 PM Xu Yang <xu.yang_2@nxp.com> wrote: > > > > > I think my confusion was because you use ----> in the opposite way to > > what I have used for all my fw_devlink and cycle detection patches. > > Okay, I will follow the usage of "-->" later as yours. > > > > > The part I was referring to is related to how driver/of/property.c has > > node_not_dev set to true for pasrse_remote_endpoint. > > > > > > > > > > 4. Has this actually caused an issue? If so, what is it? And give me > > > > an example in an upstream DT. > > > > > > Yes, there are two cycles (B.EP->A->C->B and B.EP->A/A.EP->B) in above > > > example. But only one cycle (B.EP->A->C->B) is recognized. > > > > > > My real case as below: > > > > I think you still missed some details because usb3_phy0 seems > > One line is indeed missing in usb3_phy0. > > > irrelevant here. Can you just point me to the dts (not dtsi) file for > > this platform in the kernel tree? > > This parts of dts is not in upstream kernel tree due to some reasons. > Allow me to show the necessary parts as below again, you can also > get the full dts file from the link I attached below: > > --- > ptn5110: tcpc@50 { > compatible = "nxp,ptn5110"; > ... > > port { > typec_dr_sw: endpoint { > remote-endpoint = <&usb3_drd_sw>; > }; > }; > }; > > usb_dwc3_0: usb@38100000 { > compatible = "snps,dwc3"; > phys = <&usb3_phy0>, <&usb3_phy0>; > ... > > port { > usb3_drd_sw: endpoint { > remote-endpoint = <&typec_dr_sw>; > }; > }; > }; > > usb3_phy0: usb-phy@381f0040 { > compatible = "fsl,imx8mp-usb-phy"; > vbus-power-supply = <&ptn5110>; > > ... > }; > > > Also, can you change all the pr_debug and dev_dbg in > > drivers/base/core.c to their info equivalent and boot up the system > > and give me the logs? That'll be a lot easier for me to understand > > your case. > > Thank you for willing to debug this issue. > The boot log and dts file is under: > https://drive.google.com/drive/folders/1hlkzg042q5_b5l59DCW2pECXRmTH4Vy_?usp=sharing > > > > > So let's say I see your logs and what you say is true, but you still > > aren't telling me what's the problem you have because of this > > incorrect cycle detection. What's breaking? Is something not allowed > > to probe? If so, which one? What's supposed to be the right order of > > probes? > > > > Let me describe the issue again based on above log and dts: > > usb > +-----+ > tcpc | | > +-----+ | +--| > | |----------->|EP| > |--+ | | +--| > |EP|<-----------| | > |--+ | | B | > | | +-----+ > | A | | > +-----+ | > ^ +-----+ | > | | | | > +-----| C |<--+ > | | > +-----+ > usb-phy > > Node A (tcpc) will be populated as device 1-0050. > Node B (usb) will be populated as device 38100000.usb. > Node C (usb-phy) will be populated as device 381f0040.usb-phy. > > 1. Node C is populated as device C. But nodes A and B are still not > populated. When do cycle detection with device C, no cycle is found. > 2. Node B is populated as device B. When do cycle detection with device > B, it found a fwnode link cycle B-->C-->A-->B.EP. Then, fwnode link > A-->B.EP, C-->A and B-->C are marked as cycle. The fwnode link B-->C > is converted to device link too. > 3. Node A is populated as device A. When do cycle detection with device > A, it find C-->A is marked as cycle and convert it to device link. It > also find A-->B.EP is marked as cycle but will not convert it to device > link since node B.EP is not a device. > > Finally, fwnode link B-->C and C-->A is removed, A-->B.EP is only marked > as cycle and B-->A.EP is neither been marked as cycle nor removed. > > So there are 2 cycles and only the first cycle is detected. > 1. B-->C-->A-->B.EP--B > 2. B-->A.EP--A-->B.EP--B > > In the end, device 38100000.usb (node B) is defered probe due to node B > still has a supplier node A.EP. > Device 1-0050 (node A) is also defered probe due to it depends on one device > which is created by 38100000.usb. > > The normal behavior is all of the devices can be successfully probed after two > cycles are detected. > This took me several hours to debug this and I almost gave you the "wrong" fix. A fix to create fwnode links between A --> and B --> A in your example and remove EPs from the loop. But when typing up the commit text, I realized what I was saying wasn't correct because this cycle detection works fine if you don't have "C" in the example. Yet again this bug comes down to my attempt to optimize some "unnecessary" cycle detection logic that ended up being necessary. Here's a test patch that I'm 99% sure will fix your issue. Please give it a shot and let me know. After that, I need to run some more local tests to make sure I'm not messing anything else up, clean up some redundant logging, and then I can send a proper fix upstream. diff --git a/drivers/base/core.c b/drivers/base/core.c index 14d46af40f9a..75203ccc96f6 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2060,7 +2060,6 @@ static int fw_devlink_create_devlink(struct device *con, * SYNC_STATE_ONLY device links don't block probing and supports cycles. * So cycle detection isn't necessary and shouldn't be done. */ - if (!(flags & DL_FLAG_SYNC_STATE_ONLY)) { device_links_write_lock(); if (__fw_devlink_relax_cycles(con, sup_handle)) { __fwnode_link_cycle(link); @@ -2069,7 +2068,6 @@ static int fw_devlink_create_devlink(struct device *con, sup_handle); } device_links_write_unlock(); - } if (sup_handle->flags & FWNODE_FLAG_NOT_DEVICE) sup_dev = fwnode_get_next_parent_dev(sup_handle); Thanks, Saravana
Hi Saravana, > > On Fri, Jan 26, 2024 at 1:00 AM Xu Yang <xu.yang_2@nxp.com> wrote: > > > > Hi Saravana, > > > > > > > > On Wed, Jan 24, 2024 at 8:21 PM Xu Yang <xu.yang_2@nxp.com> wrote: > > > > > > > I think my confusion was because you use ----> in the opposite way to > > > what I have used for all my fw_devlink and cycle detection patches. > > > > Okay, I will follow the usage of "-->" later as yours. > > > > > > > > The part I was referring to is related to how driver/of/property.c has > > > node_not_dev set to true for pasrse_remote_endpoint. > > > > > > > > > > > > > 4. Has this actually caused an issue? If so, what is it? And give me > > > > > an example in an upstream DT. > > > > > > > > Yes, there are two cycles (B.EP->A->C->B and B.EP->A/A.EP->B) in above > > > > example. But only one cycle (B.EP->A->C->B) is recognized. > > > > > > > > My real case as below: > > > > > > I think you still missed some details because usb3_phy0 seems > > > > One line is indeed missing in usb3_phy0. > > > > > irrelevant here. Can you just point me to the dts (not dtsi) file for > > > this platform in the kernel tree? > > > > This parts of dts is not in upstream kernel tree due to some reasons. > > Allow me to show the necessary parts as below again, you can also > > get the full dts file from the link I attached below: > > > > --- > > ptn5110: tcpc@50 { > > compatible = "nxp,ptn5110"; > > ... > > > > port { > > typec_dr_sw: endpoint { > > remote-endpoint = <&usb3_drd_sw>; > > }; > > }; > > }; > > > > usb_dwc3_0: usb@38100000 { > > compatible = "snps,dwc3"; > > phys = <&usb3_phy0>, <&usb3_phy0>; > > ... > > > > port { > > usb3_drd_sw: endpoint { > > remote-endpoint = <&typec_dr_sw>; > > }; > > }; > > }; > > > > usb3_phy0: usb-phy@381f0040 { > > compatible = "fsl,imx8mp-usb-phy"; > > vbus-power-supply = <&ptn5110>; > > > > ... > > }; > > > > > Also, can you change all the pr_debug and dev_dbg in > > > drivers/base/core.c to their info equivalent and boot up the system > > > and give me the logs? That'll be a lot easier for me to understand > > > your case. > > > > Thank you for willing to debug this issue. > > The boot log and dts file is under: > > > https://drive.google.com/drive/folders/1hlkzg042 > q5_b5l59DCW2pECXRmTH4Vy_%3Fusp%3Dsharing&data=05%7C02%7Cxu.yang_2%40nxp.com%7Ca3d2f5c60e58402ba7a30 > 8dc21411d1b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638421810737996636%7CUnknown%7CTWFpbGZsb3d > 8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=yhw729d%2F5%2 > BKwoHcpjb0Bqcv%2BhhtGEQ75zE0N2d2Agac%3D&reserved=0 > > > > > > > > So let's say I see your logs and what you say is true, but you still > > > aren't telling me what's the problem you have because of this > > > incorrect cycle detection. What's breaking? Is something not allowed > > > to probe? If so, which one? What's supposed to be the right order of > > > probes? > > > > > > > Let me describe the issue again based on above log and dts: > > > > usb > > +-----+ > > tcpc | | > > +-----+ | +--| > > | |----------->|EP| > > |--+ | | +--| > > |EP|<-----------| | > > |--+ | | B | > > | | +-----+ > > | A | | > > +-----+ | > > ^ +-----+ | > > | | | | > > +-----| C |<--+ > > | | > > +-----+ > > usb-phy > > > > Node A (tcpc) will be populated as device 1-0050. > > Node B (usb) will be populated as device 38100000.usb. > > Node C (usb-phy) will be populated as device 381f0040.usb-phy. > > > > 1. Node C is populated as device C. But nodes A and B are still not > > populated. When do cycle detection with device C, no cycle is found. > > 2. Node B is populated as device B. When do cycle detection with device > > B, it found a fwnode link cycle B-->C-->A-->B.EP. Then, fwnode link > > A-->B.EP, C-->A and B-->C are marked as cycle. The fwnode link B-->C > > is converted to device link too. > > 3. Node A is populated as device A. When do cycle detection with device > > A, it find C-->A is marked as cycle and convert it to device link. It > > also find A-->B.EP is marked as cycle but will not convert it to device > > link since node B.EP is not a device. > > > > Finally, fwnode link B-->C and C-->A is removed, A-->B.EP is only marked > > as cycle and B-->A.EP is neither been marked as cycle nor removed. > > > > So there are 2 cycles and only the first cycle is detected. > > 1. B-->C-->A-->B.EP--B > > 2. B-->A.EP--A-->B.EP--B > > > > In the end, device 38100000.usb (node B) is defered probe due to node B > > still has a supplier node A.EP. > > Device 1-0050 (node A) is also defered probe due to it depends on one device > > which is created by 38100000.usb. > > > > The normal behavior is all of the devices can be successfully probed after two > > cycles are detected. > > > > This took me several hours to debug this and I almost gave you the > "wrong" fix. A fix to create fwnode links between A --> and B --> A in > your example and remove EPs from the loop. But when typing up the > commit text, I realized what I was saying wasn't correct because this > cycle detection works fine if you don't have "C" in the example. Yet > again this bug comes down to my attempt to optimize some "unnecessary" > cycle detection logic that ended up being necessary. > > Here's a test patch that I'm 99% sure will fix your issue. Please give > it a shot and let me know. After that, I need to run some more local > tests to make sure I'm not messing anything else up, clean up some > redundant logging, and then I can send a proper fix upstream. > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 14d46af40f9a..75203ccc96f6 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -2060,7 +2060,6 @@ static int fw_devlink_create_devlink(struct device *con, > * SYNC_STATE_ONLY device links don't block probing and supports cycles. > * So cycle detection isn't necessary and shouldn't be done. > */ > - if (!(flags & DL_FLAG_SYNC_STATE_ONLY)) { > device_links_write_lock(); > if (__fw_devlink_relax_cycles(con, sup_handle)) { > __fwnode_link_cycle(link); > @@ -2069,7 +2068,6 @@ static int fw_devlink_create_devlink(struct device *con, > sup_handle); > } > device_links_write_unlock(); > - } > > if (sup_handle->flags & FWNODE_FLAG_NOT_DEVICE) > sup_dev = fwnode_get_next_parent_dev(sup_handle); > It works now. All of these devices are probed correctly on my board. Thanks for your input! Best Regards, Xu Yang
diff --git a/drivers/base/core.c b/drivers/base/core.c index 14d46af40f9a..278ded6cd3ce 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2217,6 +2217,9 @@ static void __fw_devlink_link_to_suppliers(struct device *dev, int ret; struct fwnode_handle *sup = link->supplier; + if (fwnode_graph_is_endpoint(sup)) + sup = fwnode_graph_get_port_parent(sup); + ret = fw_devlink_create_devlink(dev, sup, link); if (!own_link || ret == -EAGAIN) continue;