From patchwork Wed Oct 18 15:48:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 154942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4886939vqb; Wed, 18 Oct 2023 08:49:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG86tvIB0dsfs4EV8wFNVxLtfqfeGS+J0bRK2dn5kmLxLQSS2vT15hYlWmchF/4QWdptHI2 X-Received: by 2002:a17:903:334c:b0:1c7:5581:f9c with SMTP id ka12-20020a170903334c00b001c755810f9cmr5634935plb.0.1697644163438; Wed, 18 Oct 2023 08:49:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697644163; cv=pass; d=google.com; s=arc-20160816; b=Izqoc/js1Rqz4FozWATgS5aeBTRkoKWqSmfrRZW4AzTN2ev5vhDuuXvdxP1mHrgM4x tKxUM3pFbD69Wjcp3pIQonCY734Ydck131GPOP0zZSZkY/whuW7wietKgngRzGAAu2Lf xLSqpw6kPzbHZSlyecPjXc+J2awO8nZpPDcDppH3rpun8pYpX38Hdyzugu3B3VSo5zEX FKAT+MArdxisMiDPS89Ig39RJNLLhHsnQkpzNxRxSDFWgjTpMN6Xsqnh25qbxhCzq6CV xhfcEoSYCGQFxmGtTac9Y/vcgtT3jo7FewBc30b2XmvlO7HChR9qbySyoHEtfMolRgmx h60w== 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=Dc2N88CMmTZSjgLn5AoONsBi581k/cRIShP/BEVj4nfgYa3vYAlHF5HaEjTR5Ni1B8 yYCXag8cXcKc5McaD+rOMaoQdE8JE+rsJAT/hbWJ7wJf3/vKybiYHxGHZhZ6R2OVgORR UqnDKnAZLYK8GGGeCxfZH8PjtUQwqahJrRbQj8eNefJTNt15a2INHuOXyGUty9yjSaGl PemkFKtvIn56Jo12wkL8xPemF7AtHA7dvGnCkH4CB3lrqEGzLFS0+pyqLy77lVi6rNNt XrEuBmFxoGAHkBudpkRPqN5i+UWgHahj5MPoq8oCtLOV1tdpuo7UYHYEq0VX6SWua014 AcUg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=BQSHst45; 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:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id w16-20020a1709027b9000b001c9cc3a07c3si117617pll.280.2023.10.18.08.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=BQSHst45; 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:6 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 pete.vger.email (Postfix) with ESMTP id 2CCA980562ED; Wed, 18 Oct 2023 08:49:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344066AbjJRPsx (ORCPT + 23 others); Wed, 18 Oct 2023 11:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232129AbjJRPsn (ORCPT ); Wed, 18 Oct 2023 11:48:43 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2045.outbound.protection.outlook.com [40.107.6.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF8711A for ; Wed, 18 Oct 2023 08:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=afqTGQhBV+S01vmLED46XIzuai5p/fUBdGYFZg+zJTmUFIlHaz87EyVaKcDwzgoKJthCs87gmPNurfdGoqnKRmm7bjRco/BXUjBgGv/vHPJqtILG2p/RgMOCB/xa22jpfeTg43oqNodwaHeOxzBABLJsXP7zaB+SgNoFlFaF9Hd4pQaRqU5LcX1nRrkrTtZzKSsOhBc0t1Tjf/3ZoLAnTjgxcA/htgjhoMsVmarWui69OXU9uxQEWAwuvic5p7rO8dvuECmeXVK7nhtStQjxUDQbm23aujMFYCNkpNKxuO0WM0lXOlIJ/Yt+T1bL9GdIEolwnzLMPPLFbi1jJapCww== 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=AZB8u7/PU5Esj3h0w3ySjWfj6elivLpYHUqpyJIS/lnjCTc/HfNlHE04BdbjH0JMMLbqHk6cK+mTAlyKsoK8vrNF6UDwgm8+cFy7uAO1TpQR7eJQqBdW3Hp8z0Lr/pxcYdxLd3JVmwG7qNYzuEF9GPaTqCo66dj/M/gCvbSsVJsttVVzBPdkrOtMxQF9rJLUch/qyufm1qoPIJC7t4HLN/X5GAiKA4Ev+QUpzI2NuMKqyJnKOJgT/VomRHYFJ/eMhFbNWN7YrGNm7I//DWp0lO5C4HIo6heF5GmMmJ6oA/YW+zDrZ5PQFXu7GpASFVwOK6EWwHKSjQ1GBuU0v3/VfQ== 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=BQSHst45l4vP3VRu43j9WQfpoakSpnUa3oogy+JyqHX+vnLO29cHCSpDQJfowaWGIBlsSjJin+EdhVpzGASes8Ll1Z8hajw2CVLPQtzBsmMZvSWqEDSEYhFdcCNEh7TbufPGsB6ht1q2OCU6AyZKh5NURR93xaDnOI9wvOK1Xj8= 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 GVXPR04MB9777.eurprd04.prod.outlook.com (2603:10a6:150:115::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 15:48:36 +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:48:36 +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 3/6] i3c: master: svc: fix wrong data return when IBI happen during start frame Date: Wed, 18 Oct 2023 11:48:06 -0400 Message-Id: <20231018154809.3304558-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018154809.3304558-1-Frank.Li@nxp.com> References: <20231018154809.3304558-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0087.namprd03.prod.outlook.com (2603:10b6:a03:331::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|GVXPR04MB9777:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e79c569-37fe-446e-ffbc-08dbcff1b00a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g3pPO8fogqbRA8hyuXJwsLvPDK4fJ5FAH5cfIv6U3kL6WBsfBMhl+SnwG/wXbtUYVvE7kn7fLcQjP/ihem5fyCsFdacu4OMoLtfDENfLR3pMjKV5vuuN0jAS4L5hYbOEImQxiN0jnszJNlq1jrEatMwsz6EH1daqB3vAQgkWEWExRvK5mY9rpsQ77ivUFTdNOraA4EL5l3I5IsydGJTj70j+Ng4vK6PD+jL2Wk/eljIlbS0tlX5l03SWzIw3V+u3DKz7GlxdIVEWNXuN3HWwphISmqHP2/1Unqi36HqjKjhVXvVIHvtXnuKvNznKsyUJP5ow1cRMUkqpLNZ+f3CuO3gQF4jJvunWNhQNIYiS9EsJgBu+n7IWcR7uO/m6pP3qaboMf7HmsQfgV2dhAMnwg3WM03hkklMbj/7O1ivU9ywd1hG8Vu6EF3qF6HkSkROvRcbM/8nADPF7/xfKD2sEs5UHC8So2y1Cg0ihdEWi14VD2q4/sFEOn33B9hzh4R0oPHOnEO8A9stFRRaGM3fCBjK5V5/ms375pWvWkkZSWaQbefJ11IvvT8JO3+fDGHz6plSTAWOGuFsbgNXH4YRuh6Wp5h/lrZ/PrQaMxz2/RLgNZmtb4L6xVXlDpbKB9yEv 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)(366004)(396003)(136003)(346002)(376002)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(38350700005)(52116002)(6666004)(6486002)(6506007)(6512007)(478600001)(66556008)(6916009)(66476007)(316002)(66946007)(36756003)(2616005)(1076003)(83380400001)(26005)(41300700001)(38100700002)(5660300002)(8936002)(4326008)(8676002)(2906002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?USXCNXR6QdJHHS0g92DCpxBpschL?= =?utf-8?q?4s5+Xm6fXr62Zy+O0nMcNGragV6jlnJ64OXJnI0pCusO6a02JmREAtGSsJmkVMYIF?= =?utf-8?q?nPhO6BPYqpbX+sLC58rdjazbK2kHlNH1nU8JnOBzgGtGTspjn6EUC8hpIoiQK+7OA?= =?utf-8?q?Oc5r9kYueztfpyEAOgLGrl9MN9RthmwoPeWiK1GbGAk6jqN1FIqhNBKQqxUkCbS2t?= =?utf-8?q?O1Y6Pt3GCLpzXNwZiFQjqnba/JLJcOLBlUPW4zP3lo5S1MfBz/2dGExgh3Hc0Ri75?= =?utf-8?q?LHHsihLXWwe+keR4gRKN4hcwYbHXNArWbDZwkA1yc6TEGPYy8RQXTSZWevNC2Sif0?= =?ut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b3eD1zOYMt8JmxnEA441p9EGKSraEqSzBuYNdvOzIyPvvOiqq5Ntne4yNafThV+QC?= =?utf-8?q?7w2P1f6JysM3E3DZgGSgPnJGgnvEo+mKjEN+JPVudoKnYv3hCMI/VEbPsFUZOttFn?= =?utf-8?q?GSZ8VzWFVPV8gDI0RTHqhrfWoOpShMat0bkxMqa4kVxLJPQz4Tf134DxdUoE1g0uG?= =?utf-8?q?yPrggAs+QxeF5iV0YFyBunuvc9mXhbY3PoeDR2+2ws29zWpQwR20L8+Re7B+fG7w2?= =?utf-8?q?ucLceIWuyT2MbnKXW1INwuQeU+D267j1JUOKbTdihfkM8maz/jIdd+Q7UmyT/HhyZ?= =?utf-8?q?MqDrAEuUi6R1?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e79c569-37fe-446e-ffbc-08dbcff1b00a 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:48:35.7675 (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: zr8YtR3ICoQoXqSYGm4VOWefbS9VGz6RDy9MJDZM6fElBonGCflxgW34xSiKG6A6TldK2Wdld4A08LEwdIpq6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9777 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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 18 Oct 2023 08:49:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780108926231320710 X-GMAIL-MSGID: 1780108926231320710 ┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌───── 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