From patchwork Mon Oct 16 15:32:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13423590 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 B6CF5CDB465 for ; Mon, 16 Oct 2023 15:33:00 +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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=42riBebKxRVR+UsWusRfXukAQQHd1x8oWIpTMwa217k=; b=iHQsAaTXoD7plM fRaZ/AUtTFbe/nRHmdBMwehqC1cHGnQPQd4/yW4N0cy7bnZpTmn6NslDKfUj8VHdmzhv/2WTZDIiq K8YuCGzfo+5Smdt+EyqltXqwNskGKpiPJLXxBZY2YeXuyvx4Qx1+FRgWrn8df9Ihuvi9fB6888Op8 FTw8ukxxOSqnKMhcxceJpR0LiQ0ebrIbWbkyGsDsgOrokfqTCBnfKQSELwrvw7vjKy89r7POEeb3X CTNhXmDF+MC5dhUS15zqmZ/8WaKv+5XfLwBpfQ6vOBXlijgejMYruunJ5MXoIq2FDCuy2w+8Riv10 RtQ94jp/sHRHewlor3ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsPaW-009zPU-1V; Mon, 16 Oct 2023 15:33:00 +0000 Received: from mail-he1eur04on061e.outbound.protection.outlook.com ([2a01:111:f400:fe0d::61e] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsPaS-009zKr-0o for linux-i3c@lists.infradead.org; Mon, 16 Oct 2023 15:32:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eVkXKgA1+LpgBKJxpjyFd/bVugKjzVctsj3qK7B2kqE4GbY3rHdSw36nQYzu2+0wwbW6pMcnpcQF/Hgwc8Un++7SDSlUeak2hy7jcFmbZi3GofDeWdiebOWXkUJT2/UqFIG4Np+YIURQB3qjwvimmEG8G/Ny2BeFndW3/rVc4Dxt4iq9jh/vQycd2GLuv0nJ0z1hmKECymLEahE8Pw96R7Sc5MkVfjCaFjn9tp2tpvn+qYmGwh8GZNiq8aIvWt6tCa1GdeDEumS0O6PE13hAqEPP9//4E5tPf/+3eoCmoTmSqi07h9DggO9e/37epF30/n8Y9+vQhGcZDXnkk+uiNA== 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=PvIe54O5QCnNX7y3AwVwXO/OJ5Uma3/csUrgUguDejw=; b=IUS65wvn5eLDwJZ3br1/UW3zgvgVXBI39tw9TNPtFs8K4adLicWHfC6JKVWaL05opnW3DzbduKiAvq8Mobh62uuAH7Lw4fvmj5M8svEtz9gEVZAFmoSImClng2ePpe7rnhwe2awpGR3QY5pTdMgVYrJRTZf6EIUuYGIQQ2AkPvxZCINlgpAu5lers+jNSH4xFCTJou820pa4Q5lxvI9kmlu5up4uMgoJU4e6YIWlU3pMcqUjQEGHO4LmmiM/EhuDZd7KPkclZn/SgBTPx9SRz/8AAqUf55zswI3hEEy1OPwXqYUuZxMBYAvcwPLJfZNZi7K4roHXIO4nzpL0Ykv3Iw== 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=PvIe54O5QCnNX7y3AwVwXO/OJ5Uma3/csUrgUguDejw=; b=AKApbANDLCdTH72KxQAaf5/ykh5DjBg8ZE7TyhA0Bc3H/h4ey0T9ytt0F6XAgs3S0MxxNU4MMzcrSymTtYWwyHOavV5AdWU5kjwz6okdB6XaytQCKUf1QNlFyhDC5NYTU70FPEcXkdWNtgBsdlM/cY8A4vTB9Fk6zNgUyCjymV4= 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 AS8PR04MB7592.eurprd04.prod.outlook.com (2603:10a6:20b:23f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Mon, 16 Oct 2023 15:32:50 +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.6886.034; Mon, 16 Oct 2023 15:32:50 +0000 From: Frank Li To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH 2/6] i3c: master: svc: fix wrong data return when IBI happen during start frame Date: Mon, 16 Oct 2023 11:32:28 -0400 Message-Id: <20231016153232.2851095-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016153232.2851095-1-Frank.Li@nxp.com> References: <20231016153232.2851095-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0P220CA0029.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::13) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS8PR04MB7592:EE_ X-MS-Office365-Filtering-Correlation-Id: 2bba315f-0fe9-4cbd-5aa3-08dbce5d280b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TfD4F+UQUfCfQWT1KV3mgpduE+31+aM+gYyYgpwFlKHkL8HVnQM5XSoQuFmO8grJdRmXUFsagROQrIFyxuM5axm0Q4wDWSavbp9T47D+kNR37FzpLk15zcNt/119gM3qeCYExJb0K+GF/K5tdFp29J5FiXWjzUNuVM/UD5pEJXsVdZLW+iyL5RZeStx4uffpcjPljohq8tp1pg6xLWM3ytd0jNuxpWpSmkHf6rjU9T/3ri2Yyx658YCZL+MIbuHPB0CWIwO8zihdnDzugE8JgZ7ZJctZPCdrKI4Au3UcYa2gXPXjqB870l91KQkhE8HIN3cWZN3Uy/c4wZK+yQHnXoTGeEHIp8Pu1xuWojyE1y/MdtSKEffn8KGpYB+LuRmEmLVisWMDY4MDsWR1EsnuzZERCPsO7CiXsEXXxQdOWRVa/MNrhkLlsuGtLjnaDNIY0/qJxVAxoRffRw34l7Uhnx4f3HwNUvkLS/JH9c0A9kfpjsBATy1/rRJebp2IoU5zadqn51WuTXCdQg/NVPUopnipD475qbbrig8XsB1sJ19RFVEin9HVPCRa3QFxCKYlbZ4DWOEi+RD5GF1ksE73DeDtm0CEQ+TYobSQGxAKy39iww53Lg3qFKF/dKeSt8+r 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)(346002)(136003)(376002)(366004)(39860400002)(396003)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6486002)(38350700005)(36756003)(38100700002)(83380400001)(6666004)(6512007)(26005)(6506007)(316002)(66946007)(66556008)(66476007)(478600001)(1076003)(2616005)(52116002)(2906002)(41300700001)(86362001)(5660300002)(8936002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Uik+YhnbRqZfHOTGsnj9wVS94eZs?= =?utf-8?q?xZaD3mPKWgq6XcNQINovSgHWbkRCDveZPBPKV1yXKMuQND4RzWys5+3lHas/mvqtT?= =?utf-8?q?BJr2q0piHhceaSIkf+bSSN45xxsUaqsBCuWXR48xVpN9EC5A9+u9oMsg/mEgZPxhD?= =?utf-8?q?tzxQCZ4OOcWice2dRo4yiONzBBUOELOtK/B9tealNb4ljj45GqTsM8XYoPfAz/5ON?= =?utf-8?q?jcudBvJO33aJHFVWyVdS3Nz7Klqe3HpIVqLdWQZXTYtPsWeHXspnkNc9+BRYe5U6C?= =?utf-8?q?bly3SZsB9mT0OD8DddMFEAlOAVn/wwgTWyBEYp+gQqXRb1hUA6Xtmgw6XyKpzReuT?= =?utf-8?q?kWT4m9QrKeJUrUStAVRWT1k4H5L+jhKYH0FOokWRoBxfoGAWKF6KuSbGYzX8GpJWJ?= =?utf-8?q?3PFtbgARdi9HqHrCvg5tLCoYgwwFrddfNX4ManJ1d0oHHKTH0CFW2oAIaA9kMgRBI?= =?utf-8?q?p5ujl3WRluyCiBolXHBrMh9CIzILNQ/vwexQ+zPt7teqpfq0pICKsE9Ims0mAyuH2?= =?utf-8?q?52sePRSIth8CRlIbbsRjWVCRG92GhmrOGbQ5upWfrEASUEMMQ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Riv+KxJc10w2NebDjS?= =?utf-8?q?Xo3L9DlHV+cPII+M93/v7NU9oo8UqRCIps4qI2dwOzcd6wLpzuws0oA0=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bba315f-0fe9-4cbd-5aa3-08dbce5d280b X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 15:32:50.3807 (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: ULMIngN0t84bbebWLfXv0QzBaEJuC2xkOy/Txofu01yrltD6TSf0nnYFIieoQ4adtEcl4ZDDYKYqrBOTa3IrOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7592 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231016_083256_294426_3B8CB8EC X-CRM114-Status: GOOD ( 11.41 ) 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 ╱ In-Band Interrupt (IBI) occurred and IBI work thread may not to be scheduled. When svc_i3c_master_priv_xfers() initiates the I3C transfer frame 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. IBIWON check has been added in svc_i3c_master_xfer(). In case this situation occurs, a failure is now returned to the driver. Fixes: dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver") Cc: stable@vger.kernel.org Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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 ebdb3ea1af9d..0f57a5f75e39 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1009,6 +1009,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 | @@ -1027,6 +1030,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 falure + * and yeild 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