From patchwork Thu Aug 31 14:13:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13371629 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 C80FAC83F01 for ; Thu, 31 Aug 2023 14:13:52 +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=Vx+n7PB/lqkBDBAUZCTtjhZRsjCuEVUb3NvYJ9mNRyg=; b=EdJV0UO5MqA0wr 7n/5IArOLSDtNhOmseXChkGvzC0J1osWZEZmdnMUrUeMMjOooGoYyPMOkfOiKEOJQi4VqD4r7Q0PS cPDS+Beu0EpwzonlbNiib9ksLH1cuxqDagxXGSRD/XBfbJ/vMOih3PzPJ001J7ESo+/dXl/Qi7iXf t+0wmrGUbvmxSQf8jYxgTPCnVjIt/Q8UvtdiOwcZDh37j5zx8Bq2lsCxUMhMAe0lGcGNXvqFHTXEN Wb0Rh2C7moAI6lVJHWIMRM8/r/ICEFHplaSer3yBRyWwgAHoB6d4qMJNSNovMuWs+RBB20fHhZtDX 9UYi6MBvjEOhnZlbZwdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbiQi-00FQFe-0h; Thu, 31 Aug 2023 14:13:52 +0000 Received: from mail-db8eur05on2062b.outbound.protection.outlook.com ([2a01:111:f400:7e1a::62b] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qbiQf-00FQEv-0L for linux-i3c@lists.infradead.org; Thu, 31 Aug 2023 14:13:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHi+GKUVWMK/Sh1c7GOAvmwRfXJyyVnE3ZBwLz7yaoEOpVqKSRNqniHRzifwGsXkovyRCcvoPx0MRw+Pb3gSttewyRxRTqpcQ6i1rDh/v/9NIHdsJihbSKRgtOu+uk8SFP+PX6s9v8RILr+ev1vHxs3yB9o1jCioRVmORwl0yR+MuiupcjFZYIXkfXYa5bgVSBGrgxEIVNpSRnEiS0ekvvudkXtH/5R2Y8UHKF07tpQOtsu5oTrhAt7CvJyXhczdatR/lUijuppU0dRaywzC6jNRn4+h/8tEPnVH2fvRN3CH0v79Qj+20RLs6Rs8xOOKlOP4KAaQUaB8MPp48GtGyw== 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=JXCgGAgo2yg7mxfrE3xiHcgvOzmTe2mgO4psV1SyNlw=; b=lbpjw9rvAKn2rgXaAwpN3OR80IFu1huvroHKqZrXsV6Sn7S3RmfgFZrSDFXnuQ0LZS9KeH1Sp9UccBp6pkiMm/1Xk2GQI5RfRLA/BRX6BL0htLG1/XhYTdXeOZQgspLyb3Jq4hLPhukJ2Zkscx/qd0ndXxoNEO2AH0PJm0N2AexZzohFS5zE6aLWyyOZMEhS9YGJX7s8SjvboSs2vEXNL5WeBYEjtRUBUPi7qwNiRXjociANOgTmA3zUdCoNdOSV24s3FM+AgE+moY/fpxc6JEDrqsNdA0956vDuNPxugkHM13QI/prZHKytoQrCRohPUOyF+hqMMQWBp1kGq4KRng== 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=JXCgGAgo2yg7mxfrE3xiHcgvOzmTe2mgO4psV1SyNlw=; b=ThtlWjOm2M4sFPMWJ7XoJItPggxONLZ06m/DgumXrySdh28gVO4RYmx4x5HeRmDdairS2LYLi2WdnsqsLmPE9qZlhI1F3DhUCfpmQh2f+caNY5AcL2uyrVkvD+TSDhudqcFRa1aWpF5GOHJ86yOkfCqKiqpPxiR18bHqv/xjDnc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by AM0PR04MB7140.eurprd04.prod.outlook.com (2603:10a6:208:192::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Thu, 31 Aug 2023 14:13:42 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::a680:2943:82d1:6aa8%3]) with mapi id 15.20.6745.021; Thu, 31 Aug 2023 14:13:42 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/1] i3c: master: svc: fix probe failure when no i3c device exist Date: Thu, 31 Aug 2023 10:13:24 -0400 Message-Id: <20230831141324.2841525-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BY3PR03CA0030.namprd03.prod.outlook.com (2603:10b6:a03:39a::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AM0PR04MB7140:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f3e98d0-4828-4a65-2515-08dbaa2c7ac5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T+CKOrGWcb0mVYH83rmmEoqrJH+MK9nMlmnLvcIs9Tb4+ejfjNyuHfgtwg/wxD1z08YwnntkeJrHe8MRUIqGxCaeyVwFs1RhmKOsGsiwtncfAcSPaLD9N8ub7Fl/Rm9FZ9fBQ/+yWLKWQxfKo4MBsMnsayZUIeqH/nLQnzl/YN5MOoqAzznuC22YVWhY6X/MitLZtXqB1EGaLGB5AshGcK2nQYafLlKRBPY927BnBXEq5fhDO0RwJIY47xEGomGKoh3khGYaAnM6KS1C12XpB8o54EmpTw7pVwqEBYpIidbw4CZyxDM/wjuSFNU4EFWywZh5x/kez8lGqOeBuXDi9j5PCcxVGv7km/PdQqhGuGHaAuyj43BqpEhOZ6/La2jgHxdgfP2MvTmP/NMTRpRYpSJNe7amVutBoHeecRRwVgEGfR4qtxyoc4pXSi78ebDGp+nTnl2U5/7u5nsak/qy51PdAKHSDlbBlOWNzm1KP2rqpAREGJ7bWN6iY3kieJDPQXMUrmBKJ5+BXALCUzkSyFwnUmXlPXwf5fFPNXVr2ADRYM7sGpgPqVCc2/DSHLWvVx6ZZlkXeKqN9sF7fU6g5yrLM8GAWeSVdmfNsYg+5yrwVoBk3fUDRNo/SRukY9mCjn2CsV/GcWHC5iTG2m5uRw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(39860400002)(346002)(396003)(376002)(366004)(451199024)(1800799009)(186009)(6512007)(6666004)(6486002)(6506007)(36756003)(38350700002)(86362001)(38100700002)(2906002)(2616005)(26005)(52116002)(83380400001)(478600001)(1076003)(66946007)(8936002)(66476007)(4326008)(8676002)(5660300002)(41300700001)(316002)(66556008)(6916009)(42413004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E1zmnNs3t4zVP29sU0zAH5iV91e522Cx67iLbUCB/WyU+ILxhvBDJY+Y0KTEucqvSorzjxthEZSv9buzooJ/Fizh4ujKzEkvlwgGuMQ9AvE8LvrxjUJG0/t7nIpGXJIe+akXhA34hW/lkWdBNQALvXXpWnF71H+sMix2ljOhKNGNVJtahxt/YGhizDBmNT1NME1kx7tyPbO9y09vWj2OeNJGKcckGvErDFippVjVzmX58LtXrnj46+jRnjk1VpOM+5wh2PNN/UxqFhOkVBE6H+JtLbj8yswW5YNIID+IdkABxreTNHQK6t7+TTZKZAcImNlko3ST7w2vrc5lsFrpRK8o8HY4N79HRu//sGYvxNTXyFBlvIIwHDvUobCFMmaccCqrI260fcmmFodZf/oDp10bxvPCYHU8eWDDJpkAtMn+wEBERpIu4Kmr3WFlSdffyaX7i8HS4GuNGo57qd5JuHTmZbQCFjUWgyW/PL1l4Lu3oAuhF9J6GxWp5/FTcvMAaU+KCJyLwKSkDwCJMxGvBqlAVP59+nY/TLD3Mei7rrCktNOBD6vWry/8aVc/FVfwSh6n0o1ki1hCq2Zi7bY8NWBnqAOvrJ8AZJSG53cFjE4nRArnM5xx0qJxG/YIev3UNBRO4xTMksZjKQmtB4VlppnFIWHw1LPoB0iMxUtV4awV0qKBZXShRSNt7BX1SrbjaUjc6nOlC87vXasB6/X6e9CI/kIHpCX9OZt0oLWrPQ9CXHhpXECAdrc9IThHGMrg7HPyp5SAL8jOmC9/0UWs0sNnzAivdN7OpUy3+mGLswSXEaa3b3Xjuo2MPsz9MX0kdwhiXXrQ1vJpXbr7Ca9eGBIBOvicDEmPO2rmHnYv1w6nz4aTpKFv9g94dhCtcUzzaTjUNDe63A4JpygamIWP5ju2+ISRDyIKRubMFScJDJ2SC8FOpbo/WYdPwD9LGnbTyL/v2RtEqoYarusBRNgKcsfwiNYYn/HoRLIkgy7cP+Q0D8ndaopWP2LGFGbCump2c3i07AS6Ch7FTaAzqIEri5ab279+BRdpTPf+DyCLHNUpl6aDflIkca37AEZ9g2WeHX3hmv3mQyY5xSb5MzdV4jaiKeufMWb66il3DXSHt4jIcpGEXJsYNx62z233yYnh8TksdzYNXz3eIklCov30ydMRN14ggCs/QJbR+0g5sV/YFBtq/PFUQES9ZwVSw/Sj3vrvEQ4fQIaLSVTfvUFqCJI2XQXsUXuJD8EgnY5Yb8nH8S5SFzIHk5aZwxOosULGSdp2/4jZHv4XMtqVNXKIcIhkniBeyfOONp1zU5Wsx0nQZWSCO5r9alEkyPcSGq/r1lHPIGCgqlskciLCluR1cWB3GkyByD+0mSjK8zrzcS2se2AIT009Nz8wLKsC1JY/7T0+Qw2FfetTx5XDkrIpcCl+5WOMwSJe//eXuqPu69aT3dNZDa2KZUGpvHPxcXkyPBGSSFRBOKIYReTrw1IhKHJOTcZACv0HYV1lzdPAC6wHFLc0Bh6bNmDjMYAxjeMVjRcnhygSFcAOIwgEtAnzq9cwR+uT0uNjem7oEQ9VtcEYGmCxaHMBP8V9TZuNPmEd X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f3e98d0-4828-4a65-2515-08dbaa2c7ac5 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 14:13:42.0516 (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: /lbI0p4ZzZYcE09Zj5Oghb2r7RjWQLdcT5lLeXqFOmQA3I191IGxV3PWtKfA5Hlb5iz3QmTxWRR6JzGHVbxr4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7140 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230831_071349_206668_33DE6CA9 X-CRM114-Status: GOOD ( 15.71 ) X-BeenThere: linux-i3c@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-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org I3C masters are expected to support hot-join. This means at initialization time we might not yet discover any device and this should not be treated as a fatal error. During the DAA procedure which happens at probe time, if no device has joined, all CCC will be NACKed (from a bus perspective). This leads to an early return with an error code which fails the probe of the master. Let's avoid this by just telling the core through an I3C_ERROR_M2 return command code that no device was discovered, which is a valid situation. This way the master will no longer bail out and fail to probe for a wrong reason. Cc: stable@vger.kernel.org Fixes: dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver") Signed-off-by: Frank Li Acked-by: Miquel Raynal --- Notes: Change from v3 to v3 - No code change - Remove patch i3c: master: fixes i3c bus driver probe failure if no i3c device attached - After test, only need this patch to fix probe failure because i3c_master_rstdaa_locked() already correct handle error code. Change from v1 to v2: - rewrite commit message - cc stable - add empty line in daa() drivers/i3c/master/svc-i3c-master.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 770b40e28015e..cf932ee056ef9 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -789,6 +789,10 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, */ break; } else if (SVC_I3C_MSTATUS_NACKED(reg)) { + /* No I3C devices attached */ + if (dev_nb == 0) + break; + /* * A slave device nacked the address, this is * allowed only once, DAA will be stopped and @@ -1263,11 +1267,17 @@ static int svc_i3c_master_send_ccc_cmd(struct i3c_master_controller *m, { struct svc_i3c_master *master = to_svc_i3c_master(m); bool broadcast = cmd->id < 0x80; + int ret; if (broadcast) - return svc_i3c_master_send_bdcast_ccc_cmd(master, cmd); + ret = svc_i3c_master_send_bdcast_ccc_cmd(master, cmd); else - return svc_i3c_master_send_direct_ccc_cmd(master, cmd); + ret = svc_i3c_master_send_direct_ccc_cmd(master, cmd); + + if (ret) + cmd->err = I3C_ERROR_M2; + + return ret; } static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,