From patchwork Mon Oct 16 15:32:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 153506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3543995vqb; Mon, 16 Oct 2023 08:33:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQLrKcwVlHXdvxCjXIaXDPHkgmHGdtbF3rNUqB0HOjHLDVwH7/0g3j3S8qEhm1FfsbPR/p X-Received: by 2002:a05:6870:450b:b0:1ea:6883:99ff with SMTP id e11-20020a056870450b00b001ea688399ffmr1521309oao.5.1697470421731; Mon, 16 Oct 2023 08:33:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697470421; cv=pass; d=google.com; s=arc-20160816; b=PJvQBLmTJx9L58/x5f4xp0anI7ltk7PMOAq4LzQbcgko1VbOyqms4JXu/TOFbcm/d2 uG9c0Trpy3WEdowFq5gLXIZRsqLqagjCOAWZfuQ2zPELnDL/Ft5T/yv0ql/AWFbBzGaD kVkD22G62qLqrIZyrte1fSQXrqTksM5uDl59Zj3yMlmnlHG5MovoorD/T+4bvIOq7q6x x3I36bJrMVyVRx3TbXpdNcvXrDJCyEHr3poWzGmrecsmp7tf+xDXfstYWmVunamI30M1 +hhWYe3LzQrynxemDKcKqaNOr/LAGgLMij+ra2DtOzT+E8k08m3poJlsCd68DYbzOodG 7aXg== 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:to:from :dkim-signature; bh=+nlpPOSgD82lCFohI2OxZVAzkZFLmByfJ5q7/Un/BtU=; fh=bn4KwJ7hiZC6iHD6ocv1YpB9R5Bd8J/ZarfJ7QImr28=; b=w53BfL9iM3kXsC6GAdJDIl28AGzJbn+mfuaLEcO3xbY6NLkIMuGbeQFuDKSq0549uE npWF3PVjt4bpsHJtI+MsBv8pZtTzO2htZIV1VBCKeHSMMjr2U3MOtNXlRgFfTRcSWBAF J/NZIhz2OXHv7lKlT8VczOv7T9icGob46IJz3HO0FWMzVe4X9W5lQ5eswNMaBTYrYE23 VVUrH/5TQFRT/DVgZoCyM5P/E7qGM60aVdH/fPVe3bVjPLuUH8bHwITL3hhkjOyMhQld s3f2AEIpzUgkwEowv8ud8eicD0c93KFFICHkU1k9trgyR92T22kgs8u3DsuC0/Ppn7JH O2Uw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QVgiMOnZ; 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 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 26-20020a63195a000000b00565e386ff44si10716725pgz.702.2023.10.16.08.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 08:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QVgiMOnZ; 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 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id AA46B80219C9; Mon, 16 Oct 2023 08:33:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233722AbjJPPdE (ORCPT + 18 others); Mon, 16 Oct 2023 11:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233643AbjJPPc4 (ORCPT ); Mon, 16 Oct 2023 11:32:56 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2078.outbound.protection.outlook.com [40.107.104.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89997E6 for ; Mon, 16 Oct 2023 08:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RBBxVUMQcPDWdqR3rhatFPJo32IP2xUTo+VKeqBERk019x75VsuAMvbOxI49k2IMJXA43YLbk+tnNxCG7rbMkKteCpQs7Fd3HI05R8MtzaQ+pFiCMY7iN6Z9Ub6FTXgZbA2nt/x4DuDYLZ0lD7cbfxjgWyb2GcErRTTekWeA5ObsHYgTWV5dszwH9w/keWni7h9xRG3waQW6BVP0ODRk14XdXNPm4r8skVq9eizLkhwFqd+dao3wzTl2bgHOCU4UeIH7JLShGdMDyuOiyxudXxu/Ihc2pqEqKR9Mxh1G9rl6cNRRIDeJdMLvlXyLk9tnIQWhY5sO6L8F6Y6qmYjLfQ== 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=+nlpPOSgD82lCFohI2OxZVAzkZFLmByfJ5q7/Un/BtU=; b=jYYc0yN/fggC1AM3E8EBeGYa5w0uMjMks63rvv/OOQ78ZQl2OSudoPyFr5QG+cgpCnG39ZQmPZLSnbUKUq9ZpYXFUHlwgyLph6xpCeJipYnTJkBNf9fT2dgSPDEppAbxLZmBQUgeP7zPY2xqDxTPP2pB4xlOyh/ddOXus+9IYXHs4xt8HMd49uGlus7/bE6w/7BqDSmuVbwVHtJQUKjOHT0CjrQKnd7UD2JhuFc9DF/R8AETkoy00ws+0fxG29PQ7Stpnx6Vjd11fqHrAJt6SDT8Qc+QvygHqwD1nb//tFBco7HgpachLWUvTG7o4VYJk2/pryTRXSR/0rYgwO1iJQ== 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=+nlpPOSgD82lCFohI2OxZVAzkZFLmByfJ5q7/Un/BtU=; b=QVgiMOnZ6e31r5UB8NQNNvxRd59Mw737pHPAFE3sD8ExIMJlYvrH0N0/OdbnOOixXXY/690iPSNsDBCMmGfkA5umxybyq9M5wAELCRNNof7ypLmFzHkCMUWb37StIdFWlKaYppr+z5oNPXniV6bxlspo70VGanO5m6FveNEnquI= 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:52 +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:52 +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 3/6] i3c: master: svc: fix ibi may not return mandatory data byte Date: Mon, 16 Oct 2023 11:32:29 -0400 Message-Id: <20231016153232.2851095-4-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: 228fb6ec-eb36-4ae8-85e1-08dbce5d295b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r5DQA8AAe9uCLCPw/yNtnHF/BtLLZ69MhREwJTvSOIez5aXdTkCF1A6/c8xUnWGcrxtBpzo7dhhfRinvgLyIZEcF3BlrLeg2Q2nLP7iCKrQLvsIkIO95YYU0j1zy373/aEkdGL5gafcDyu4yf+gnoh7JLPdh/0d/nOnvcUAAzGy0JSZRHUhm6iyDjitb/hWuLml8pLQmdk30f+F9Az9W2W+z0afAoCfuuO33f3AIpb2Uz8WkaDWTa7EpqvkDfVIyqRGljipGellu4mqw5wjUEmwa77qO6r3dNntVO2Z9usPT9mFkrAA8p1glwNVgCEF9NyTHfV01U3hdMCU2Y/mBOYYJjVyK7QwibjgwXYLgpqQVALrqqwKlGi6Me3JNJe1CDxIn6a1sJEY+b1e48Q43cTDYAxYaHmknn06YhiHxKXuGw+LyP9KVNC+rdixvHH6P0QoiDUZHdH0+W2V3P+6+6Hj4mv81du7s3a3vAlDs2FFdp9KkoFHfoD3TCyqcWKLV86vdoYjQkjgzapsHsgWlmAgMn7kG821cuZM5QvkNnS6aI/hCbpVStc8mSVIx8dWJHdVJg6Q9w9wE2NQ/8m10Y2KMRhRXPqOaiIvjMLxcuW4DVfyMb/cy/A7LN+x9yGaP 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: IoBqb4FNPokrL02kKzDsKh0FN2+tQuLyUOPGzgEtYslwTLUdJ2I2mvRkzfctUnsVX2jeEiViDKjY7ttXGPaLlr9A8LgSYIdnEJKtTgMuzXsuRr4PZX4v9KcgBAp/foqajeWElzOBPq34eNaRsRuUFZTYlNSR73QoRnOgkGIw0ruSZjc0uFt96Rc3/VztkYZdKF/7ie2ySBM7xTbOmyllIhclZF6uUkpf9zw6tNo3X2SiUsY8TPHKpX2nAEG3wS4YeYMSj9yDsgJLMV3Xphs9Gc4Zh4B/L7Wo2ZuQ58swDCSOw60nF1iw0I+2ycqw1d7uZW+NnLF83oUpdEEww88uh/FpWiaMiIFscjiQ5O43x+U0mcplVplUxWW2qOgbFhvNlZKWG9T78QaGvVUkvR9tBMsq1wzIroQLVjAw1v5rXExt5Q68gTNxekBdrYIhw/0LnEAtnthlY39JX4L0UE0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u67HsoUtIey9Wmte5NrHaxIa6Mxd5/0y8= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 228fb6ec-eb36-4ae8-85e1-08dbce5d295b 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:52.5814 (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: s8TH6LOoBvCXB3j3NM3BetkRqfwiIOaRbtjPpHw3s4Jy+SI1PqPDcN0o33A8+Jk6JvnF9NFGvckCHXGJfkIEEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7592 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 08:33:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779926745087001613 X-GMAIL-MSGID: 1779926745087001613 MSTATUS[RXPEND] is only updated after the data transfer cycle started. This creates an issue when the I3C clock is slow, and the CPU is running fast enough that MSTATUS[RXPEND] may not be updated when the code reach checking point. As a result, mandatory data are being missed. Add a wait for MSTATUS[COMPLETE] to ensure that all mandatory data already in FIFO. Fixes: dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver") Cc: stable@vger.kernel.org Signed-off-by: Frank Li --- drivers/i3c/master/svc-i3c-master.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 0f57a5f75e39..c252446b2bc5 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -331,6 +331,7 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, struct i3c_ibi_slot *slot; unsigned int count; u32 mdatactrl; + int ret, val; u8 *buf; slot = i3c_generic_ibi_get_free_slot(data->ibi_pool); @@ -340,6 +341,13 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, slot->len = 0; buf = slot->data; + ret = readl_relaxed_poll_timeout(master->regs + SVC_I3C_MSTATUS, val, + SVC_I3C_MSTATUS_COMPLETE(val), 0, 1000); + if (ret) { + dev_err(master->dev, "Timeout when polling for COMPLETE\n"); + return ret; + } + while (SVC_I3C_MSTATUS_RXPEND(readl(master->regs + SVC_I3C_MSTATUS)) && slot->len < SVC_I3C_FIFO_SIZE) { mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);