From patchwork Wed Nov 29 22:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473586 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 37D05C07CB1 for ; Wed, 29 Nov 2023 22:13:06 +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=LBgc1JfkzZkc4rYEQXNbllJEZxz+m0mlWuHNSCiFgoM=; b=B+87XgI2Pe8H3s anGjNwMKQcW+C/VCtiSB1ekVJYMaGIioqCp2AYYPPri6Rs6LYAATDKG2zhkHFKkgNB8jEU9+53xF4 zpJa239GM1SHSFkblpULMdV2iYKSCosH0r3ALxep3k5WRzZQrYRWGX/0secMtjAbZ6AwsjJA7deTb Siiey/1Lw1IL0kmprVgVdZBrRdrjzlkUAcYC37+rQvLAez7qQWBDgxuFVlpVCgN6UxRFMklKEchdY 0CTTSuX1JZ41mGVrN2YwteQcB1jfHzJIYqmFN+WiIuvAdJN0khOpnTFpanzFpPo747LR8XG5aLYxw QAMYsl15eY6jouwzVzPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snp-009Pe2-31; Wed, 29 Nov 2023 22:13:05 +0000 Received: from mail-ve1eur01on060f.outbound.protection.outlook.com ([2a01:111:f400:fe1f::60f] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snn-009PcW-2x for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:13:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e5QwvBRRs1kY7yJmGzFKM2vuRkpKLV5BCvsOO/R+uiZsT1vVhm5QCLkrNeQJI2hLl6NJkM/tH38AFieThU6ebg6uTZoz78vn1zmOFj17aCkS3c17jtDN6uH6yM0dMFFBcfc2KcRIcTw9hPIHMxHoNoz+MiPrZWR8AOtcjG1OvG1ThdJ6rBU1iAxALbj8eo0lvZMB9YA6pQGnimNPFkLxVZKOZ/CGhb1KSEdeSlnIfS6wjEHVsJ8xba38BM3pTMuqGR3AHcfdUN+mcAREwR/d/0rfNBiOp/pC4bjOoj12xukZHBz4TR0vzvV1e+blVHvxr91nuG0DjJPoYwrrqf7hOw== 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=R2/YV3nkqc3UDSc0gYS53JKr0jm5PsR0IRqF30SYf6s=; b=T6IfY/b6DTTfzLtlzWcN+ebztrQ8xNGnJ7kCnSPcE0z3u1mqvkRKwd+KFoFhOQXQe5hE8pEwkGNu5z2XZSxd8tJYbIXZzoTMG7CIvcHPE9e3ZbonhOAXl/HFiD498AugLCeBdPEIMQLEeEBYarVk9yisSzsY1hCcgGfQWvBMBpX7wc7j0thiN0kcW62jMkWIsjieB25M41AVGedPNX2l9fyYMTHuUGZ39jEwRrUrpDSyumxIJk0frsVdrZjBXUWKl5UOVtVcuuipcXkv7pewi9lScbxqCTIfAWVvobCMXndZ0jhuzUn8U2fpDqWKnbVLzEC2rJvi/VX8k2Fcvhf7Lw== 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=R2/YV3nkqc3UDSc0gYS53JKr0jm5PsR0IRqF30SYf6s=; b=F7BbBMsUhXUgcB1JZ0s4oTRQZY6bkVVsJSQZxI76xuLjdNjWMAU4HDshqu/3TkEfbl3VoLNcnkhUyt/q0CDybqwFmc6/uweBOT+iQvJLpjunbe/JKMkf3Qodba+GTjVmOGcJNVBpFvQ7E3D0l8+zIrW9Jy5cvxo+xgRaVNf51TY= 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 DB9PR04MB9578.eurprd04.prod.outlook.com (2603:10a6:10:305::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.21; Wed, 29 Nov 2023 22:12:57 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40%6]) with mapi id 15.20.7046.015; Wed, 29 Nov 2023 22:12:57 +0000 From: Frank Li To: alexandre.belloni@bootlin.com Cc: Frank.li@nxp.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, miquel.raynal@bootlin.com, zbigniew.lukwinski@linux.intel.com Subject: [PATCH v4 5/6] i3c: master: svc return actual transfer data len Date: Wed, 29 Nov 2023 17:12:24 -0500 Message-Id: <20231129221225.387952-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129221225.387952-1-Frank.Li@nxp.com> References: <20231129221225.387952-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR04CA0003.namprd04.prod.outlook.com (2603:10b6:a03:40::16) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB9578:EE_ X-MS-Office365-Filtering-Correlation-Id: 58f96f7c-c90f-4b49-5c68-08dbf128574d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xfwVV0mxbvSnUIqN43btO6qB9nIC3/6W7sKDlnJyJbpgI+kS+H90MjJqKntiRClDDUewHrdKzuow2PQUXtCca4dw37Df7FliQv38K+9JYY3NQAqbV5R/c0Dtr8hacJJALLW9/Mx83FnAd3gL3EpbNh+S+fCL6enAaNH3x5CifSsjKKjci38DVkVPtjScNERqWFdCPaVeEarGqh/JVMuaJ3JyXjL0bA5EzQChCqUMURmsfmNvKxeQCwQR76TLE8CjaN/pM26iouLFHBKxWufnKSgEtfXKJ5sdelBwhW9q+Q/cw49l9YO3l//B+MA7LNQmtk76DrMQ9afD1Ezh0g0iPk0/OdKhDvuTRVASMjXXmjwUjhcL+yIHj8rZbDp4YRCKFO0jhPsuRDFxrtgKIKs+D4MhyruhJiHShO+WPGp+bQ8V8FHuXQEYaCf2fa1aHfBz69WC80FlfcHR/cEf1vBrcuyFca6AUXDViK9di9HKUBOqubob6xp763fPfsVxxHoQ21A+KLWg5++v7AYPwNFCr3Lh0JLTJejeoA5Y+JdildEQXEwjI/u2RUHrqFdlyiAEmF+lu3P+srPUj9Eg2K9U9FCvcwtYOvqsXSVs9UMoIMyP8lnt5W7qhaFpWNL4azKDhF0E+wPVl308cEkCFdTJYiBNOWlO+RGVf5PX9BM8i7E= 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)(39860400002)(136003)(346002)(376002)(396003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(202311291699003)(38350700005)(36756003)(2906002)(41300700001)(5660300002)(86362001)(6666004)(6512007)(52116002)(83380400001)(2616005)(1076003)(38100700002)(6506007)(26005)(316002)(66476007)(478600001)(6486002)(8936002)(66946007)(8676002)(66556008)(4326008)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /okbGPYL3DNgegIHqv5WJKuKuArHt8I00VAZ69CRP+rTqNTZ1IqMaWt/+ASyezJjCs+keKu3cZWrmsPmHyn487/mK1iuLzFi5nqQ5KRceFqjL2e21sHYm7eebJ9E/YLmKWamRd2ncnq87AsCecA3EfJgD3Aqcob7drhCgdbH7ISX0KmemmCnJp29+ynHErhBhsVamtVXjYTOQcVM0nRKwOLefHEMkq8mZ+xX31t/VK9nxom4fVROX8jocVfD+niPjrHPwvhZCyRlBk8Pg6LErAUkDqRd9uot8PJ10J2cjmjbcekAbF+SP3NyiNOwjWQnQ6xBY9oV9ZDXlJUsN+1vla0ZWgDrXrI8757iG17qsGLjRLIQviM7SYRMnYbKcsDaxVMN7qP+noW/ogEgkT/H6GCGbC52KawUqiPK37MysKZVnxsVPn2Qn4jqTU+jiCLyJ+II4tuarB1B97amZg7z9sIjgjHMi6VNKVvuGRe0QaetyeIYcM3z90qLP73AHtOTo8fWDo/sg7br4GcLXHjFHfogKb8wg06boeThhJ2C6legp+TCoHM51Mz1zAFfEcptalUxXADexqaUx3SQTlsHJznzw2PVO+Xws5xcN9Ju6P74B/GbboNRqBxwDK3pcWGQ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urprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:57.0049 (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: 8VvR9+CqVtcyF9uTwbwidtWHxLlTZSl5xvWuEBim0Zr0Ak1KJnVmIXrS4YC+t9PGlKTi6fqteL4WPBbCEO/3Vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141303_957670_E9A89613 X-CRM114-Status: GOOD ( 12.38 ) 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 I3C allow devices early terminate data transfer. So set "actual_len" to indicate how much data get by i3c_priv_xfer. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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 be742e6734e39..9dc12f9936a27 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -138,6 +138,7 @@ struct svc_i3c_cmd { const void *out; unsigned int len; unsigned int actual_len; + struct i3c_priv_xfer *xfer; bool continued; }; @@ -1056,6 +1057,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, if (readl(master->regs + SVC_I3C_MERRWARN) & SVC_I3C_MERRWARN_NACK) { ret = -ENXIO; + *actual_len = 0; goto emit_stop; } @@ -1073,6 +1075,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, */ if (SVC_I3C_MSTATUS_IBIWON(reg)) { ret = -ENXIO; + *actual_len = 0; goto emit_stop; } @@ -1168,6 +1171,10 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) cmd->addr, cmd->in, cmd->out, cmd->len, &cmd->actual_len, cmd->continued); + /* cmd->xfer is NULL if I2C or CCC transfer */ + if (cmd->xfer) + cmd->xfer->actual_len = cmd->actual_len; + if (ret) break; } @@ -1355,6 +1362,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev, for (i = 0; i < nxfers; i++) { struct svc_i3c_cmd *cmd = &xfer->cmds[i]; + cmd->xfer = &xfers[i]; cmd->addr = master->addrs[data->index]; cmd->rnw = xfers[i].rnw; cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;