From patchwork Wed Oct 18 15:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 154954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4894208vqb; Wed, 18 Oct 2023 09:01:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGT5aY5y0YdTinHu2hgaWZpKNlGwZcHFifB2dSTYDGkQizazuUcQbsH1TWwHI70oEiDOodd X-Received: by 2002:a05:6a21:627:b0:15c:b7bb:2bd9 with SMTP id ll39-20020a056a21062700b0015cb7bb2bd9mr5032742pzb.6.1697644885444; Wed, 18 Oct 2023 09:01:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697644885; cv=pass; d=google.com; s=arc-20160816; b=UpCnEk5eSfjN1uLgvKBixy0Fsd0Em8CHuWJsWy//YZoCWijsEAGwwkcw6AQA/MtlvA r3oifZBtqiDE0NbkWS5pRXv6K5z28FjBPq9fEFh+UBrIGOF4ZddNYBPIDLRLvge0upKQ wQ/L36vUWIAnzGMOQq385wTLdLR5q9CF5JrqR02LDB/R1xAWWYIn4BDS2qosftNuEXfs tiKVADaWp7eijX6zFuNSo0RSqqtVCgj905ThPptBNhSzmo6RFBrSx0iNLp0JS//VyVXY nLUiQHXqDbqeDloO2t4M5iji8Cyx99XdnHakoFB5QJTQU2cI+3D5wgFJoqPdmEoI8lSW YVdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nayoLnZA6AxlXnKCCet/C/KGKXlH5vBlf4Xff954ehM=; fh=sDe3TG6/b46JEOvF2xh0f1K4oYWCH8cpxTVfh1/w/G8=; b=BgnQvvzwvcLD3//41JLtZU4qlskTvhrfdOcJKPr7GbO9K87YAkIM9vj5gRqN1gqFnX PHxVzBVAKlu7LP8BMQCTx9VCvdtlpHzeYCfmOnvts6kkebcVL7994HZz8lsI20uphJ/l HMpaXsYvtO/Q5UCqqDIeMwD/dErjEVw4MLBbaaPnjwcBYfVoLUoQNvGeDwFowULbLkDK /mlS1IMl9x5fxL5YIxQt8uRO34PR2wxA/LUvCdfav7sYq4GRpfUX5gPFASKwN/GA5kjX HuaboXuMlpXS92wqQaRrXXUBT/+7Pd5nJAyXG4qpKLuxF29HYxkp2s1f6QuOHojM6csx pSpw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=fGsyOL39; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bf7-20020a656d07000000b005ab1fd6fbc1si2520180pgb.847.2023.10.18.09.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=fGsyOL39; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4341C808E675; Wed, 18 Oct 2023 09:00:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232260AbjJRQAB (ORCPT + 23 others); Wed, 18 Oct 2023 12:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232187AbjJRP76 (ORCPT ); Wed, 18 Oct 2023 11:59:58 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2075.outbound.protection.outlook.com [40.107.13.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D827A11C for ; Wed, 18 Oct 2023 08:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfaWnrYpE1jAknfEuW+BVJomXqFkgPRpuH3J2xbdsIHFxoGE/rzSLPrXy8LmE1WF/Nkp0NhjX+iFgsSiqgxSwEl4zkXPU4QYlGJTLJxFk+VOrQ8lQd2Tmqef5sU1sBqhq7Ya5QtUeorgr/Gl9SwQZ56SAPiWLqVVVkS4EDSX4B3pestrYx0eYGOvvnFJUSSwGrGupapT3UDtPml3Lqb7k+oArsS21V7VlKehxW/4fUzb3h6Dr3VnqTfsLkZGTVBnfdVBpqOTv4Z5m9rbiKwp6oEZNjUQpcUzStogIwXAgmjsShUZsuG17K7iKOwM2BkfhB2ZQRhJ8XK41WqAvvk1fA== 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=nayoLnZA6AxlXnKCCet/C/KGKXlH5vBlf4Xff954ehM=; b=Cs6A+f+UA2MHIjh7xAS+eKueKVu4GRgxDqtIwRuftQ3y1KkWx0e75QSdSrNqOPYLevH/9w3UGr67zj6EyEjmg3o3cVCma+M9dvtetbQPpjmsBnZCHoqg3nMJXVr54o3oksLi9a0OV6wlGxjfy2PQ3cWg4jnYYsaUnE2C2r/ox/NQUDztLO5ME6/ztL0tJDzFmbZTdqzQJvPQOFVEm9kGGzpKSb4hxfLUVYGdk7jCOxH5zmOncvYg4hTdrtuizB/OmOGga7Qz0jCIfpett0PK09CdcJr0TZdmNBKXDp+vlT+43Z1wjjDfPnIVW9Ir8ULvcXpv2Pk+U4M/jaUjsHx8qw== 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=nayoLnZA6AxlXnKCCet/C/KGKXlH5vBlf4Xff954ehM=; b=fGsyOL39waLA/RWuJbGv8x+k6tiNcRqmdvI9gY3nxfUtRD9D4HcuT4XSWqyEvqatBdMsfryPMAzk1MuIhVU1g3PkJeRFZ0JyiGJR60pk/ht+qo6A5tM5y7JC/LdqRf6NylCrBvvO0goO0DnrqR7507nOa0lY8ayi/rdVx1HSk+E= 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 PA4PR04MB7694.eurprd04.prod.outlook.com (2603:10a6:102:e7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 15:59:48 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 15:59:48 +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, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 Resent 2/6] i3c: master: svc: fix wrong data return when IBI happen during start frame Date: Wed, 18 Oct 2023 11:59:22 -0400 Message-Id: <20231018155926.3305476-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018155926.3305476-1-Frank.Li@nxp.com> References: <20231018155926.3305476-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR05CA0210.namprd05.prod.outlook.com (2603:10b6:a03:330::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_|PA4PR04MB7694:EE_ X-MS-Office365-Filtering-Correlation-Id: b3668cf9-f417-4413-0618-08dbcff34133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zU8c6VPiSrcWJUHv36UOlWkRAmNu97Wq+uEKfWVjc7WOjokflQ5N6N8479ayadzuPw7/Az5xmWR4jd6LoYNGEQM8yEnoP7ZomDxKpCn3d/zxyx0CEpetz6+INS1pr8ykGDwhxIJ0GBJ7zMUdH+agXXoH2aQVMRumvWOlRZHPk/8dgnKkAcqXhsdqqg0w7SDJ680PHv4ZbiNIerxjKY14K95EWJzRTeQJK7FqY1B6wowv18PiKgSMvq/nGnKz6f7IwsL9wP0uMRvONYR80MBXYGVgO17MRDtFGiqZVj/R7zsWNJsBtqU2OoNbNwdrUGecBtyZwNtRCUcN1dQW2K4gHgl25+NwKwPiK36RWUyU8A+PhHT+hqjKWF39yhDN26xBBl3V2uxHqIyA2lmQBRV06Vawg6qXhBJdNsBnQvKoFA46Wlax2MwXV8M2OwJvr9WFyLEIu+NBpzv6UA9G19MrS0xyd1rXGvzEMrRf6tGaAHCOd1VECPULzWFC3nNicc3Guwjb++2dP8FgekNz/qhuzZE6lOtY4Aoxoh1BRDCQX18OqS4/Ka+lE1Wil3SRfdyAIEc3yiC215XFIWJJe+KJb0N+mTQ18zPTbss6T6s4mZNJZk5CPVXoCXKbNkYkz+/H 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)(376002)(136003)(366004)(346002)(396003)(39860400002)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(66556008)(66476007)(66946007)(6916009)(316002)(6486002)(478600001)(6666004)(2906002)(38350700005)(36756003)(86362001)(5660300002)(8676002)(8936002)(4326008)(41300700001)(26005)(1076003)(2616005)(83380400001)(38100700002)(6512007)(52116002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?T7XP1e2l1omC+npStP2IC19zKKbo?= =?utf-8?q?oekPfaTd/ne+OSZ8wqloiMVgc85FJQZxLrGvVGAPpGtHXsIApcSlHuGW/lLZ7m/XK?= =?utf-8?q?025sSnMTsScSJIelGsofr34QJzxR34numm0CQHdVSFT4/BqYheLBYSLDYrlU6f7Q2?= =?utf-8?q?maevVgjNyluCOKucE09pj8UuKOoZ2OslqoTC+pHJ7CUPqeHoZFXhbV7YqROroJV2a?= =?utf-8?q?/ufUXqt+AktxI2F88CQERFdPIJiURWWar9GOQ6bAHxB9uIDSKmvKrYl2XRFC4UcSB?= =?utf-8?q?Kji1VMeI3K8dStJ+2SRzvRloJER4emgf+qOyVECECJbo7sQxsmncIh+hGNW1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6ra6AZ?= =?utf-8?q?dQlXRoxb3zsIr4jySElrB2c4ZHOIKNokE8lNGRSQ3afVswFdMRHZU7w7+wlKHAtzf?= =?utf-8?q?j+Ae6X4loMTuSDtgtdL9rdiIgHamEob9NP7OFpMiVgifRMVCKXDUQk0Eb/zlF+fp4?= =?utf-8?q?89e1UDUzTrnf/vs1Ke414C2LAQLZ7u5DTWALs6qevKUR3HiSfKWUOEjeUUJ3EsPZP?= =?utf-8?q?FVXMp73CdJ2ErYADVML7Th4hF9DC2wibiX0SGO/BE1sB+8eSdahuicC6Y97R7DMic?= =?utf-8?q?CHgFwbZioLxazk9TKYrwwSZHJ17HHfJLKQ/4G88W4byb1piGVmKOQgzfW1/VOEPaN?= =?utf-8?q?gb8FzLp548+1?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3668cf9-f417-4413-0618-08dbcff34133 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 15:59:48.2273 (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: QRsBa7JWfzK+YweX5EuEKX7chQbGcC9JZ5hku/S09EdEHmxrHjmRdQRqP6HzUZzLUXaUrmhI+Hx+VEVuYgCBjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7694 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 09:00:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780109682979659833 X-GMAIL-MSGID: 1780109682979659833 ┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌───── SCL: ┘ └─────┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┘ ───┐ ┌─────┐ ┌─────┐ ┌───────────┐ SDA: └───────────────────────┘ └─────┘ └─────┘ └───── xxx╱ ╲╱ ╲╱ ╲╱ ╲╱ ╲ : xxx╲IBI ╱╲ Addr(0x0a) ╱╲ RW ╱╲NACK╱╲ S ╱ If an In-Band Interrupt (IBI) occurs and IBI work thread is not immediately scheduled, When svc_i3c_master_priv_xfers() initiates the I3C transfer and attempts to send address 0x7e, the target interprets it as an IBI handler and returns the target address 0x0a. However, svc_i3c_master_priv_xfers() does not handle this case and proceeds with other transfers, resulting in incorrect data being returned. Add IBIWON check in svc_i3c_master_xfer(). In case this situation occurs, return a failure to the driver. Fixes: dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver") Cc: stable@vger.kernel.org Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Notes: Change from v1 to v2 - update commit message - fix typo yeild and falure drivers/i3c/master/svc-i3c-master.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 8cd708c965085..abebef666b2bb 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1010,6 +1010,9 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, u32 reg; int ret; + /* clean SVC_I3C_MINT_IBIWON w1c bits */ + writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS); + writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | xfer_type | SVC_I3C_MCTRL_IBIRESP_NACK | @@ -1028,6 +1031,23 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, goto emit_stop; } + /* + * According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a Frame + * with I3C Target Address. + * + * The I3C Controller normally should start a Frame, the Address may be arbitrated, and so + * the Controller shall monitor to see whether an In-Band Interrupt request, a Controller + * Role Request (i.e., Secondary Controller requests to become the Active Controller), or + * a Hot-Join Request has been made. + * + * If missed IBIWON check, the wrong data will be return. When IBIWON happen, return failure + * and yield the above events handler. + */ + if (SVC_I3C_MSTATUS_IBIWON(reg)) { + ret = -ENXIO; + goto emit_stop; + } + if (rnw) ret = svc_i3c_master_read(master, in, xfer_len); else