Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp654651rdb; Thu, 19 Oct 2023 15:28:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXxzBu97taRUmIvIbqSpoeuJvTacL4oe+EEYQyboYvh1kSL1Ou6LOQoUADNnY4TbVgM55O X-Received: by 2002:a05:6870:9f8a:b0:1dc:33a:40d8 with SMTP id xm10-20020a0568709f8a00b001dc033a40d8mr335539oab.4.1697754517272; Thu, 19 Oct 2023 15:28:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697754517; cv=pass; d=google.com; s=arc-20160816; b=IUoMez+R3FXETJ2cxafXFMdmdF0WYDvERGJJWNHp+eXUAAB6Un6hJzi0x6KeCRNm7x T4xgFrk2Z7a4/EepLjbTIIzJGwWXFUQoQ/uJt3WW4FAlUjLIf+Acx72WjJB7iog9YlPE JhOzaWz2IslTpONmw9WKBn/AwaVosyRquBcJjaGNzCrmOyUQbkOSiZqRfPkLQjTNwGIE nzWX04JnOAnJXP+JJNOdyqqnl5u0D1K+gQnCf2ZAohJqEO/muzbjoyEDveVwiialpW3b pap4o8Xu/QMPj2Z7WeePtAXKAWflcg1BH8yUh+aWduPnx9H5XSotAI7HkWA0OinSRKwQ sgIg== 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=yW+weJIpBdrdkhVd6zX1FerAeparB2mVU4jRYiSWRLDzlGHO64fBXRIG+dDOCcMtK1 bYZy1dj0nSZULvksfMp5H6+O0/RfofFZ/IXA/Cbl8eh4xknKuDKEUdGpY8g4xKR4W78G JFqKfSQIQm+aK6ofXqh9lzQIDTgFNZFv/uYYrhOdW9PdqWx5EqZbsrYrPmVriC8k8pKA /ogF4ticJZyugFOq+kdeG18prsZmla1ZwqNYqh2E7DvAd7FsIit0XCCGJmPcYoZOkMn7 p5Io9FiEurD9hJgv0nppzvTXunZ3z4yh+HzlGrl6v2n3/SoSOodDGiT7h3aduuqW/VKp KnAQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Qron0qZv; 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 Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h69-20020a636c48000000b005648d3f2031si467644pgc.362.2023.10.19.15.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 15:28:37 -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=Qron0qZv; 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 0D36781E5563; Thu, 19 Oct 2023 15:28:33 -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 S1346647AbjJSW1x (ORCPT + 99 others); Thu, 19 Oct 2023 18:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346636AbjJSW1u (ORCPT ); Thu, 19 Oct 2023 18:27:50 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 538EBCA for ; Thu, 19 Oct 2023 15:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lv4cDGShXeR/1JmdmgHJ4dEt2oaDEIGFOfPICkkgr2HiiW2jswV25ppOZ4+9ReqfGmJYH4Y0SyXrfecOLWXqJbXnKLbV4qVu+CLfgS5HZWc1NmAki5dyO5AnBIOTr/qTj0t6AV8jCOfFZ3jpq8i6kSBYAvnqBIsZp6i03NUtyv20178b7l4IYA/wsl1ElhOMA5YDlwhKX1SmBzBMRLIJs5xsxijhxabLHlyrTzRatbVqZkSQhuiMFoPMZi7tMK1LBSHwXOAp03nadExsVU+UJEBJbC8CbftNfaekoxCeR20JwiKCUflgQB01rNgitA6C5/OQHGQbDca1y+l/tyNg0g== 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=iz6226LEgDWXs93yzs8TRrEvKZ1ZQv900LHlhjGL3vSmtEI5MqcR4O0fQUjL6OdOf0E5JsP7TmtyiWOYYURsT9Wry4gckc2iGcp5NiY7W1keBE/QKigLQAesfBSSm3L5eRzuVRExL+gQNqYUVJ8GxHfpf7EHthEqYddoI3iqhCohOO1IfGsteA5sz5LzF+RnHdU4SCCJ64k6aMmolkPhzxTKNut3XpUpOlaK0/zHwXUPBGlinNExx1H21mdKiD3fYLyRTYuv3OiHbV9gIQ4AOoyCS70hSs4A3pXPwojqxBIeSUSB9zQRDtxhMWCUykyvll+u4+8Ka8Mm5+KcTD43sA== 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=Qron0qZvzh9R9lQ10mbL+NcL3ASOLaXPFXhCutOdPb6Yi5743Jbtwab82SgotNmL5IzjauCxs87mZmSR719v0LWAWsl7BjlPn4rFtKXhybwZvgHb6+f1i6Yk3D7XonKLgK/vm3e+Ou7h7GSpDddKSpcQhRMw2QMZecNkY1vGSU4= 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 DBBPR04MB7708.eurprd04.prod.outlook.com (2603:10a6:10:20d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.10; Thu, 19 Oct 2023 22:27:46 +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; Thu, 19 Oct 2023 22:27:46 +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 v3 2/6] i3c: master: svc: fix wrong data return when IBI happen during start frame Date: Thu, 19 Oct 2023 18:27:21 -0400 Message-Id: <20231019222725.3598022-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019222725.3598022-1-Frank.Li@nxp.com> References: <20231019222725.3598022-1-Frank.Li@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH7PR17CA0042.namprd17.prod.outlook.com (2603:10b6:510:323::21) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DBBPR04MB7708:EE_ X-MS-Office365-Filtering-Correlation-Id: e3b0df36-cc2d-477f-8eca-08dbd0f29ea5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /rHP0is51NSlclkO3cW50Eri7HQoNqkzrrZJEKFKRrtuocnt9IAFlaLzerTFFAV/al+vs9PNyFKIhILf7DIYBhPbgyMlLKeGbXzmajNF88DJXkjyYR9riej1tQqPfnt2kcPYmX7hg7wOqrk2G10iEF7IjfFJ9yI8z7KptK8F9w6aoj1bMyu3mE8D/v5R/XACkpjqnhO2Al9JyPWr8DeSwEVSNpTIhsrMujddeXMlx7gPdaPKi0OlK7tbRMfYSuOCEwCwmo1sCiShKva5UEzlTySeVWV0G2IdxasjFIOWaRUWdVHnFkHh3f6NvlLZhEVys9EBQKizMulXzKbVQwL1TqRGH3/BFfFOMWQbQ79n9vZ6TwbTLKj9vZBmUjUdSti1CMecQY4xQz0VJlpYb8XyKtYtFBfF86Yk8Q409LcGgj3p/lLZ9XZ0eep1/J1rOMv1POntr8fWTNE4fYB3d71lEiWdDpGMUuukDNdzTM/DAygZDJZJBZbWGklxSHxmZXi5p65AqJuAbny/f2uXQi6NZPXblGlKFvvOZwamTjDnAQPVeDQd2O8hYqEnOwu1qHuK1AQt6MuulawyYIvxDfOxd6g8CbICnJ8e9Ft+aFDIOMF33EydA//57oFxFKl610YoyO49gXiaZC7lYuGmz8iWIjzDGZWutQmvXIMj8Vwkv80= 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)(396003)(136003)(366004)(346002)(39860400002)(376002)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(6506007)(83380400001)(6512007)(38100700002)(478600001)(36756003)(66476007)(66556008)(66946007)(316002)(6916009)(86362001)(6486002)(52116002)(2616005)(1076003)(26005)(6666004)(5660300002)(2906002)(41300700001)(8676002)(8936002)(4326008)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bnV5QWVQWTRiUk9KRUlYbVhKSTk1VGpXUzhqcU5XL0JmOTV4M0g4dmR6L2tX?= =?utf-8?B?MEJ0M1llMStITlpBZGtGRzVQaUZVS1owMUpySURMRWxVV1M4TWxSQ1FlMEVy?= =?utf-8?B?VVVGVFNWY0FrZWxoSmJVemREdlZRM1hrVks2VVdDSC9TZVVPekQxREgvOGpS?= =?utf-8?B?STZYTUFuRUdoMkpPTXZ5czh2YjFxUjEyN0g1ajUwejFYdUJSTmpJK20vTmJx?= =?utf-8?B?MDkvcmRhSWdpL0t5ZFQ3a2JOZE1ad3JSTkpDaGp6amtvSzNNd0ozaW5NQ3B5?= =?utf-8?B?K2o1ckVvMlFFMDM2WWhncCsyWlJ5YmMvdGZva2F0azlhckJoUExmTnZ6V0ZK?= =?utf-8?B?TDFRTk5Lc1NTcHU5K0lDdkhuY3cyVmEzb2JqVWluZzJub2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CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 22:27:46.6967 (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: UjWOuI190NzS7D4LU06fTE+PcM4B2/M2KE1OyCW32WX+PrrxRmTAWWf65gJJeTK8T0vROiMQ2PRVDkh4cTEw5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7708 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]); Thu, 19 Oct 2023 15:28:33 -0700 (PDT) ┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌───── 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 -- 2.34.1