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: 13427312 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 533F7CDB47E for ; Wed, 18 Oct 2023 15:59:57 +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:References:In-Reply-To: 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: List-Owner; bh=i/03raLpHkFpBZHbL3x7/mxMwSA0r+c2IOm5t1zdeoI=; b=3evCbLgDe4cKgK fl+BDdoJ+FBFM3pRaZpRh3B5b8uWJJUvFd3yzjih5/squRYM6lPZLIlVcpMtYcRD1gVHtL8ID5Dr+ PO8IF8io93FnRs0pqBPTnmfJPiNRpRcVuqRumFnJwQgexWxmRN+ZeqE2kt7Sfqx3RAdvXf3W1j50c 1HS3m2oW4JNbpQnHsRHiZhQiTc/3c5gE4rV7IeoW/aRt5mMyweHvNjXeb8ZDnxBSlRiWqPyuiSsma MSFPeXbHS2olNryiy33j4g/ZQyU8hUAEVJHb4uouMD8AJnxqVhaOWMEBiyW9ChtJpiEd34QFU+Sr1 gtLBF73EJg+1TnPC8q2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qt8xh-00F7qg-0F; Wed, 18 Oct 2023 15:59:57 +0000 Received: from mail-vi1eur04on060c.outbound.protection.outlook.com ([2a01:111:f400:fe0e::60c] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qt8xe-00F7oP-0o for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 15:59:55 +0000 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+hGNW1aPoL8?= =?utf-8?q?y63QHfK36xQfwEI07QsVS2Npbjq2TRTXRDsiRhCYuAbbZDvvxlciTo9lElkN+Lqnx?= =?utf-8?q?Ll6xGWgRa8B33JKpAgnO4gD9wjUKMVKitUBNpSVTiRR1XJUfN/Q6B4u2R3wdcUfOG?= =?utf-8?q?Jp+xlV2mxTh/1/0j5ugduWxJ7BsD2NEzmJI7f637fQH/cToeEyjuag40CjpCFA7Ed?= =?utf-8?q?SQL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VXMp73CdJ2ErYADVML7Th4hF9DC2wibiX0SGO/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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_085954_297303_4D37B5E6 X-CRM114-Status: GOOD ( 12.43 ) 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 ┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌───── 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