From patchwork Wed Nov 29 22:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473582 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 44FADC07CB1 for ; Wed, 29 Nov 2023 22:12:55 +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=szeLe5NUEg6R1SGNN/H1a+UCrHF4GiFGr5ccTYUz96c=; b=2DO9PCSJLnp5fh GirDm4h5l5l+Ajo2Mdj6+8WhggApTtL9j0Yf+pnQsvVQzmaHKxXVWu2/3rRCm7fBNMiayitNrC0TS dhHzRer+uDJhV57U+OiQ9FkagBZuv5lfSWRcmp9f4IEgzohy6WaYftJSu1IC9YXruIXuov5SLQQnq 0l3TF2kDQ+4v5qQZBLHuDTn2HMrUseNNo4PmCUqMIU00bbzHi43yICC/VSwKp3EwOn8gHH3Y277Ib SSJISfsLBcjlaZOmRaPhgCPDdPrjl4X8RN2G01Vhn5bfPzIrwGDowvB7waSuVOEu2dt/NGxVt87iz mlghphSqVeZ38/B7kY7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snf-009PZU-01; Wed, 29 Nov 2023 22:12:55 +0000 Received: from mail-am0eur02on20621.outbound.protection.outlook.com ([2a01:111:f400:fe13::621] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snc-009PYC-1I for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:12:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E6AuFl7HL60izem5MOw0aNv4ZIYzrepqbcoDusqE65B2rUxrJGOFFQlO8bU1Vw7qqEyan3RG+hxe0MShWjSDR97QsqRD3+UOuTZ9wwcMyvNKm6ipODs6iP5H4JUIua5xKFNXGgqxY7RTEkGXP4NVI0J6V/Imx3nmXrRkZWJJeNfCDRKHCPHgC/INmV82sNxlHBseZCRykrSUq2wuRkHhcYQJggIJt4rUq2REiCsggt21bz5GQtk8qSN1llEesGR8Y/jLPFnSpZGckxBUANh6yDIomGH1EwL2IbhnqrgFr/dj9t1QaX3wAUeDuZQx1kEsdXipZcokGiBsTO81qRdFqw== 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=sDlf4xSFouG1bOinSyyY0+9HL8i98T9MXvpDH0ZtEyI=; b=NhvNVmfRClD2Th/UrKVNq4aesI6+SRik/7BeduKRjE5Bc8l04FAbpTx7Nr2l2fE8DcsnBBBsevCapYTAJ0yiKxQ1mAmnUkOqSSvxA3teyPyq+F4IE976/5mbF9nxYEiQuD6XEWGb+8RV1m3KU5pYICisWiRqcOXQKbUWq2MNmUZX83rT71EwWm5YkhmRvQVZOfB9FxaIXUlMUnAcBEAWbX1g4/ybWM2ho1yXFVqKDS7T2WfJnNxHgwd4uPigiO2/wDE39cnBgR5fMAOU9Cb+31W6EsyO52+XcqhYqdSAlNxuQMKpOrAX1x9j6nT+jgEB82+w9C2IYOiNDLKRIQikfg== 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=sDlf4xSFouG1bOinSyyY0+9HL8i98T9MXvpDH0ZtEyI=; b=pXgpmX5Ss+DIwAcDeTt2lXV7dzR0kRBsBeBVza52enzdrESUD4pIzzfdvW0YUgL5XVDoQxPLj8dRqKnTPuFhXx4VrpPI2JT3iIvbycdigXf16vh8TK1ji4azu2fzn6YZciBnVmmTx+c+QM5D1grsHEJPF7V80Hr4WfQs0f6tJmI= 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:47 +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:47 +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 1/6] i3c: master: add enable(disable) hot join in sys entry Date: Wed, 29 Nov 2023 17:12:20 -0500 Message-Id: <20231129221225.387952-2-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: c56aadeb-5476-4a4b-b5ec-08dbf1285164 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8T6UvqL72rIyTUg8dN18HgG6jDUJ66471hzNfWi4rBAHBtNeLEKaY8n5ysIqoWKvFyobVzmWIUrQda1xeS8ocov9vEInA7GRhL4+gpQQ3ESgMfSoRxP+N63iGKxtyArluV/7aDb9qQBPT02SmvBC7v3sDQhwdzFo6jeeXUiQR0uwmhNdGfveagwGTOYIeRIhfGpyU67YxF7Rt/uFbgwH2u2NZg+BkhrYr0nKJhaDn0062/IA8fjLZMYQoQx21OaMltLyxX7Z54e4XU+5ehLr9nE5tt5HXyVmlFZqNeKYPUPvl/03d6k1n6M+aF/Fv8rMnvWFdJiJOX6zZn6ZvLxfT7QRhUUPrpvxQuOvdp8/ivler5JknE5G8MuTNic2GjIWfns6H+3RRFBoNC6XYWhdN/QvqRzcWFyOutWPMXczMZ4QCDDKEopKdWbKe3PepGeP7npQPkh0RkLxssy6sGd0WvH4cu+1UzRUHMNVUhwq/8UZYVhuY8ec9Dl9nAgAAyMLC5KRjDetiKaKA51FmwTKZ6uCuDGlzz5fM0sLMgRTAbKJK0SJxAZEFPl2K7nRN0MSa5Qb4dIoSZu/aTsDdwofoNQox/HOHfByTUq80ywDDdfL6wt40q+PdUgiysL1SQL+yWnRaAkMeGeAt0aAUyukS8XTqzl3qHXXchMGKgFp4uVKezoYhERa8mPpDKBMzCFm 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)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KFsGWnNOwltynlexzi5u2ESBFmm4iqjE1fDffTCeku7zK4UrrwfCnqGemHSdXw1rDaQk1lm+zk2LiAd8xro07rPGryobO051Tz6i71AO8/JuATTbvc9VPjwyx+1S+Aqfm2jmf7y3grf7yWOEr2HYHDoJMIn9CD2izXqENzae1bi+GdXEdGBPYgdT+OkqCUVQiR5xm7KY5C4cWr+ikVXfO9a+g7V9iYt6SrRnfSeCjluJaruffc+5lhbqkn88Lu67jNfjWNtvlJkjT+KaoABfnuV1/WLAr9oYPuZ4cIZnuoZoyUdOcxmxqXQZ7Q1cQ01lXe+Ct8MjrpJgXSrk7v8daSuzwxFj8L9jy6UCQqhNxdSEbs3oa3QRapJVO3Ateskb2hPvtUYy5oscULCtj1K2jHrgVX3L4ocbOeKroLlkho9r8+FOgOaXRT6RRTTnVzdjIIlsQTTnaSED+vwQdPh9t/yRi4mjG6zwB9hPYdd+KCGCMuLg6l/u8INj+q1UV1RWR2zDzXsxP8IoPbp2Mgh2tnfJ0H90WmKoFOI4zSoferkl7U6s59bIgcM+HBhrsjuFrOyuqcswszFw5UWwOqW8TfahhjkFEqkm51TWlLsO++dZcbjuNU+tTJ7dAcASzbTfQDL1I6Vtn+aspWOR7aoDhl+JPqZX9dIMJaAJweWIVFvjmlGwL0GFM9CB0pyEaBbQPgmTbVawCCj0qIdtYM64yTX/HXup5ZZwBoYTk7uKCQJFpisfA/WIQ+wnqomAKYyuiQEdIUP5c3M816vnCy1+FqKqiJ0cMCx2VMGOT5Hh22mJaV0oBQSwiMiuf8G4nh6KJDqqDihRRvQGb2yiCwsFqhGNODltj5wv/MTP9J61XHgchg/tXnvUk+sgWS+Of89BUhdjpGRLz426gZWJcKei69fMGK9ZdXcmjOAr1aUbNTiio9AskVlQIQtt9eSJyFqnOfONktLrsUBb7T3C6g73j06oMrCWNAa4Bq7hS6SQ43/qQbvW3NLZpDM/j8wMAsrBn7o9Yg5I3xVat+0OrmXAYZANg+DXdDZr8AvF9x3QNEdkS76eHALUREOMX1LKIerVBR2SjPa6WfVJaYLJkxL0ioV6hiAuGQmqZul7mkGkTnY4WjNvspCdAJYVgyS6+Z44poTXwAgERuonxBkaKytv8Dx+25Fc6WKPH5qQEFWpkuVCJtBUI6yPaZD8Ao2WfmybazgpOOf2uE3YIQ7PbiLpMDDTnPSBsPvWh3CyeiM9eu3qskze84Xh2JS5WKlUIQxYPRoEi6MIj+nUKWjx0+E3Do0jJ/WB0SnRrkd4ChL+q9+ImbE2ce1yRDldW+n7qc5lsDJji16PCBAfwFKPFLOQ44lxIKNQcoThAkoX+MGQyo4G1ak5mVSSTwTkPtn84e5DebWyXPM2rK2G5lM6nh9Mx3As6XNYMuCFujtoBZdn4PHULldxFw6KNkl2x672Pzhu4UZWV/w1jcKup+TYsU97hQ/7xsDU+IvZDA4Ka+4wn3Aatf0KuoyZirCX/N+yWTe8NFpoclL9K1thtB7F7leTsrTdqa7BnIBLgV2WIrY2mbOGwNVX/WrLLLWExd1EOWGn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c56aadeb-5476-4a4b-b5ec-08dbf1285164 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:47.1334 (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: /g/ITY229ayTGX/TLiZUaYMzBUSjufNblxgFEyJ/f8Qwh6gN2WQjjkTbOxy/eikPE7640u0sATSk7r7wOZEhyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141252_441058_3542640E X-CRM114-Status: GOOD ( 12.45 ) 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 Add hotjoin entry in sys file system allow user enable/disable hotjoin feature. Add (*enable(disable)_hotjoin)() to i3c_master_controller_ops. Add api i3c_master_enable(disable)_hotjoin(); Signed-off-by: Frank Li --- drivers/i3c/master.c | 84 ++++++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 5 +++ 2 files changed, 89 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 08aeb69a78003..ed5e27cd20811 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -526,6 +526,89 @@ static ssize_t i2c_scl_frequency_show(struct device *dev, } static DEVICE_ATTR_RO(i2c_scl_frequency); +static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable) +{ + int ret; + + if (!master || + !master->ops || + !master->ops->enable_hotjoin || + !master->ops->disable_hotjoin + ) + return -EINVAL; + + i3c_bus_normaluse_lock(&master->bus); + + if (enable) + ret = master->ops->enable_hotjoin(master); + else + ret = master->ops->disable_hotjoin(master); + + master->hotjoin = enable; + + i3c_bus_normaluse_unlock(&master->bus); + + return ret; +} + +static ssize_t hotjoin_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i3c_bus *i3cbus = dev_to_i3cbus(dev); + int ret; + long res; + + if (!i3cbus->cur_master) + return -EINVAL; + + if (kstrtol(buf, 10, &res)) + return -EINVAL; + + ret = i3c_set_hotjoin(i3cbus->cur_master->common.master, !!res); + if (ret) + return ret; + + return count; +} + +/* + * i3c_master_enable_hotjoin - Enable hotjoin + * @master: I3C master object + * + * Return: a 0 in case of success, an negative error code otherwise. + */ +int i3c_master_enable_hotjoin(struct i3c_master_controller *master) +{ + return i3c_set_hotjoin(master, true); +} +EXPORT_SYMBOL_GPL(i3c_master_enable_hotjoin); + +/* + * i3c_master_disable_hotjoin - Disable hotjoin + * @master: I3C master object + * + * Return: a 0 in case of success, an negative error code otherwise. + */ +int i3c_master_disable_hotjoin(struct i3c_master_controller *master) +{ + return i3c_set_hotjoin(master, false); +} +EXPORT_SYMBOL_GPL(i3c_master_disable_hotjoin); + +static ssize_t hotjoin_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i3c_bus *i3cbus = dev_to_i3cbus(dev); + ssize_t ret; + + i3c_bus_normaluse_lock(i3cbus); + ret = sysfs_emit(buf, "%d\n", i3cbus->cur_master->common.master->hotjoin); + i3c_bus_normaluse_unlock(i3cbus); + + return ret; +} + +static DEVICE_ATTR_RW(hotjoin); + static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_mode.attr, &dev_attr_current_master.attr, @@ -536,6 +619,7 @@ static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_pid.attr, &dev_attr_dynamic_address.attr, &dev_attr_hdrcap.attr, + &dev_attr_hotjoin.attr, NULL, }; ATTRIBUTE_GROUPS(i3c_masterdev); diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 0b52da4f23467..65b8965968af2 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -452,6 +452,8 @@ struct i3c_master_controller_ops { int (*disable_ibi)(struct i3c_dev_desc *dev); void (*recycle_ibi_slot)(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot); + int (*enable_hotjoin)(struct i3c_master_controller *master); + int (*disable_hotjoin)(struct i3c_master_controller *master); }; /** @@ -487,6 +489,7 @@ struct i3c_master_controller { const struct i3c_master_controller_ops *ops; unsigned int secondary : 1; unsigned int init_done : 1; + unsigned int hotjoin: 1; struct { struct list_head i3c; struct list_head i2c; @@ -543,6 +546,8 @@ int i3c_master_register(struct i3c_master_controller *master, const struct i3c_master_controller_ops *ops, bool secondary); void i3c_master_unregister(struct i3c_master_controller *master); +int i3c_master_enable_hotjoin(struct i3c_master_controller *master); +int i3c_master_disable_hotjoin(struct i3c_master_controller *master); /** * i3c_dev_get_master_data() - get master private data attached to an I3C From patchwork Wed Nov 29 22:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473583 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 A967FC4167B for ; Wed, 29 Nov 2023 22:12:57 +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=XCQh5lF8XCQjdgoiW9a4uCw8twt37F9g5SCBi6rGRYI=; b=SubdtQfy7FIF0M 05qtmpRj7xIdHKjsZ4/mEMnmEFRR9/6/dSKwtzQuYPcqAe9HIT9wEcvBjCxI5CyuJPW8D1xIbKJeE q/b+Uk7eL5kwwroYuXKRe0QaFI7Jlv//skscbazawuu7iGWjcNkMmSgPd44kBzK3Q0mtVTF5OzUA/ V/f2axm1Q6QW+faQ/daUoCUHKiE54lXw6sv1i+do3CRqZ8rKdCWCzjcHapUlj/GR0i/ePxIEyHdh+ PMuf8+nZe9h6qu2SEESSvHtHFWe0gEMUNqVlzMDZpgh8hnL3DN8m+m3HzXByN2e8rTF5sQG/VgYaB nRs0wC1gRAhkM8mwfEhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snh-009PaO-1H; Wed, 29 Nov 2023 22:12:57 +0000 Received: from mail-am0eur02on20621.outbound.protection.outlook.com ([2a01:111:f400:fe13::621] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Sne-009PYC-0h for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:12:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cT9WW8COAZbtUwwb07C9LYivJFV+bKJzyz1PRRC9JE5h2fKXZL5KZ941Z4pW2T/Exi9x5AYCBE70ZtSOVCFqmHBp2mf2t+AcMOWqNsXBUvJ5mVLjK2NkosG69x7IAIHfzmYsoJ293pWHh2xo8GADOlIxeiiatHrXYnWQyPJLspVREskGSStOXdajU9FXeCjZuZku8E0u63fyS6qWwWIipNuKmjCCMw2qs+/X4DdSwCVIhWz6abNT4335JcW8qnCh2BOTwSTc16735I/d0TcCcuufgiWlpdANItk/NLK49yBQwzwBBw5diN9mFM6OX9uSJPM+MNAeKXEschZS+bA5FQ== 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=Ejs+fzDBAH2ZY/qjkH7dS4XB9G6YOzq3AX8ZgGT5dkU=; b=LiWAo6+YjmnJfZLqcmHyTf4+RtRv/3+RlxQ/rq/xNQ5VRqkdUPVd3turgxLnqmkVFPFcmYF1q6whoiKNGsKPOyz+ce735QQuUBb5uR6p9zi7Mwuz/TwdD5sVgHv2cQNtU+KH8I5FvVF9wxjzpFVIbxFDN3ktbC+2yHNQtehAWKTgy/zWhdhlZr+FsHbgDfX6fHWJPWjNvrHQUCQ7xHHtnmjub4KEKwZwzJKI8eVxamu9Tj34/NT1WuYZrVeIpUwlWoBn8jY7yTc6AAsRFTrFyAAbWEqPWQa60Gns/oM3oNxTYfNoxyuEikYV/XSdWfs6cLrJqR3kL3nxIDFPb+L4hQ== 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=Ejs+fzDBAH2ZY/qjkH7dS4XB9G6YOzq3AX8ZgGT5dkU=; b=SgkiI0iWA1pte1bkBn4uJFk4uzqq8uEoWbi/4Y5GjqMFVkD38NE5uIW/s2nrHL9LE6lWirc5BMA3SWVczA7tVWel/eRm+M8czKV2GJn24e/F0GSi9mAtm39jURIxBZ4NcVfky/P2QNoz8aZeC897t2hiK6CXgpOdXCoWku/1adQ= 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:49 +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:49 +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 2/6] i3c: master: svc: add hot join support Date: Wed, 29 Nov 2023 17:12:21 -0500 Message-Id: <20231129221225.387952-3-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: 0a3dec51-7000-4016-907f-08dbf12852e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NWUpI+ThdopmHyGa2HNuyyXLOxnXBFLVos/u0o0sM3fqmekFFBQgYnGJUkER1n15VHx4tKl2y22JdOfcgg75FT5LJvEpE03R5VzP7YEnnMox5IfSRIHkUnRC9wDHVn6igWqdzRYXWpMaYf0WX5u72+CuMoOlVX4GsDqgLo0+rtuMqkSXc/ATpSzxH4eQpZblrDt0CqaZBothkL0CFlYI94K0VR9FUeMDLa9o0xhHaypLXT1PSy26HzYFyfBNkPMz+xciRU0KHjKPrCQgWy/dGXFlGtP4cULj9odAMl2CSIFQjVN1Iys+T85Z8/dqbNLLGGgSGAHcL/dP+aSrzJ1H2UzGtO1EORjW8oxbuJIyktsA2rSRFgYapv9Wa6eQhCad6q0nHjXmXVB94mO+h7cY9+Dwadg6FCcSoxnHlmVtS+PM6RR5FK53yJkbhxvdySWvSJYY512x66PvWVo28XRgvILprxCHpaRRVfjJ12bpmADso+wVqorSc/cYc952DjrQ6Yn2vIOOtNzmvWqY/uAahRUYa4igKhKbmw6J4SBexC2fiofhR6Z4D6QWMu+56a1o69zvLfE3IkWZxH85qwz41ATKOaJrDbymPNHAqthPPyry9ywoKK5TX+UYBBYTcxdo3V4p0fyk/1s5zmwp5v3e1tD2UGBOIp/ak9/4yFHW3DY= 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: wqWsEHyiJP44QbnKJBehDrqARFaHHggpi/PdiXUUjz850JFIUHFc89+yfHUvfre1rwvRxfr6Azhdn2c3rWBnG/ndHZO3XWtTGaRKLm+oj5efl0sv49ZqspUKxVOZFJexSvi0rvDtPqJefKJdVwZ7urWm6ZZlNRBp4+SvmWFgT9tiD3mOSYkHko8x/UmIHrOluOViDZJMbYqV4a6h3lz2M+ayHixStZvlZcMSSgwOrvcfErWZIOELR+bf2Mgcu/cxr4ljC2v41dzri2a4EoQToT1QG21N9cRjBkq1RVQUR0BZJVD/+OrOfVKLfctGdd1yH6Vfsg6wqByesaqi95LR/cq+zYul/QI3DS4ey/Hcgd/IbojQsEullJQV1mH/LMlDpYZj86YO5aBXToMXiAuQmjWa/0v7b/ExOmJ1Tn5juAa3FKhLkE3EvhHn7M5mZPpw3Cs/Zz4HE04oEp/7lex8e7bNOHuykAwqPsxK/TiBBi0l6JU71gL8UQz50mr3ZwkbmEik2S1QPMu0IYQuZcwiAJfo3NgAGtv/ECJX5FvJso4bknPJUpfCYeoupBGZqeYnfB9C4IrIyypbWcwDXVt+PaPga4l5HN1juc2ncaNZ3M8rp5joa3RZbJ+jFZ2crXUvv5hlqPQ8rGenrca4jm5EnN+IG4atTY6u8/0mAtFSwPB7NVhWuq5Q2FGVqT1XqTn1kxY8jCANOuZN7OQPbW8DbMaofW3Vcw1a+IX7DqprD++NMix4xDaJw9xAC2AL9AD8FHXNvL07IUz/k3BNDWMXeaJzoDDnedn8riTLsss0IISomRqUceVxyHj2H7FPeuxb2LpMz6o77vZsbTRzJiJApJ3myxeLaD5lH+e3qX3QBzeIa/GHTV6IkxFARQvlHcbi1P98DttgfYUvZovXDXoxRB2hdE8ha2P56b3e7HPs2StJGCftqX8Nrqhed63fB2hIYmQsMbNhigaN4VeB63qjNPr5FkZJr4X3tMZSJCq+tnP9PCtnzYbtqToftT0oYjut722/5dG5FgYOzxIyuhnmwu26cH0qd+E0GZZE9F8p/lmhFB8hr56BQOi//lyio10L24C0f76g4kEwCF9gp96XGutVc48+vv+K3tcfnqVkQ5Gdy249b/m5PvPFvRlV92d3/oDi1rveqRdoVPxxngKalNe5zjxmRl15zX3tSR6lSLSURz9ZBY6MSOjci3fT0K7e0H5T621GYBfMeK6bdY1sLVp1R7NlQdCjzU3G7mFmCIg9Dbb6K1EiWLORBt8ku1SjtAqHXi0m4EqnjvgmDeOHleN/kcVMSj4QqTkMKo5tfIRM4FnnBEB/q7v8Oei1zfb4TdnCgjFU0R5Z931SzAfnITtvwrkb/ZtPzqcgUSJmgO81GeHQQ4VjuCVHGn2FF9ZV12U34y2JQ68sDSNd4IHmx5z4H7a7IuAwAZVmv9i3w7bSoTvq/TZJ8MfaPuM0SBAwMkTjKplP5Z97sBtzYvuouodeuuMeeuVwSvO4/0RwD/cUJe16nGD+FWbcEFhMEJq80l4Gj9mf6EnYhW01nzUXGMIHSrxpjsKwjwBximLAlSLuRphQh/8Tp/bp0CrJhRQH X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a3dec51-7000-4016-907f-08dbf12852e3 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:49.6112 (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: 5O6DsE43ddHBoZIj0/4hSXlcg8S+1HtXKNWa8Ny6IN+vCUBnwo3UPaFFJi/yEoNY8a2wWRbNeVd8xgSk0UpAVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141254_258549_941B27BD X-CRM114-Status: GOOD ( 16.54 ) 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 Add hot join support for svc master controller. Enable hot join defaultly. User can use sys entry to disable hot join. Signed-off-by: Frank Li --- drivers/i3c/master/svc-i3c-master.c | 58 +++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 6b6bdd163af4f..880c6ae76c013 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -128,6 +128,9 @@ /* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16 +#define SVC_I3C_EVENT_IBI BIT(0) +#define SVC_I3C_EVENT_HOTJOIN BIT(1) + struct svc_i3c_cmd { u8 addr; bool rnw; @@ -176,6 +179,7 @@ struct svc_i3c_regs_save { * @ibi.tbq_slot: To be queued IBI slot * @ibi.lock: IBI lock * @lock: Transfer lock, protect between IBI work thread and callbacks from master + * @enabled_events: Bit masks for enable events (IBI, HotJoin). */ struct svc_i3c_master { struct i3c_master_controller base; @@ -205,6 +209,7 @@ struct svc_i3c_master { spinlock_t lock; } ibi; struct mutex lock; + int enabled_events; }; /** @@ -428,13 +433,16 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) switch (ibitype) { case SVC_I3C_MSTATUS_IBITYPE_IBI: dev = svc_i3c_master_dev_from_addr(master, ibiaddr); - if (!dev) + if (!dev || !(master->enabled_events & SVC_I3C_EVENT_IBI)) svc_i3c_master_nack_ibi(master); else svc_i3c_master_handle_ibi(master, dev); break; case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: - svc_i3c_master_ack_ibi(master, false); + if (master->enabled_events & SVC_I3C_EVENT_HOTJOIN) + svc_i3c_master_ack_ibi(master, false); + else + svc_i3c_master_nack_ibi(master); break; case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: svc_i3c_master_nack_ibi(master); @@ -471,7 +479,9 @@ static void svc_i3c_master_ibi_work(struct work_struct *work) svc_i3c_master_emit_stop(master); break; case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN: - queue_work(master->base.wq, &master->hj_work); + svc_i3c_master_emit_stop(master); + if (master->enabled_events & SVC_I3C_EVENT_HOTJOIN) + queue_work(master->base.wq, &master->hj_work); break; case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: default: @@ -1471,6 +1481,7 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev) return ret; } + master->enabled_events |= SVC_I3C_EVENT_IBI; svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART); return i3c_master_enec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR); @@ -1482,7 +1493,9 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev) struct svc_i3c_master *master = to_svc_i3c_master(m); int ret; - svc_i3c_master_disable_interrupts(master); + master->enabled_events &= ~SVC_I3C_EVENT_IBI; + if (!master->enabled_events) + svc_i3c_master_disable_interrupts(master); ret = i3c_master_disec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR); @@ -1492,6 +1505,39 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev) return ret; } +static int svc_i3c_master_enable_hotjoin(struct i3c_master_controller *m) +{ + struct svc_i3c_master *master = to_svc_i3c_master(m); + int ret; + + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return ret; + } + + master->enabled_events |= SVC_I3C_EVENT_HOTJOIN; + + svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART); + + return 0; +} + +static int svc_i3c_master_disable_hotjoin(struct i3c_master_controller *m) +{ + struct svc_i3c_master *master = to_svc_i3c_master(m); + + master->enabled_events &= ~SVC_I3C_EVENT_HOTJOIN; + + if (!master->enabled_events) + svc_i3c_master_disable_interrupts(master); + + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); + + return 0; +} + static void svc_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot) { @@ -1518,6 +1564,8 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .recycle_ibi_slot = svc_i3c_master_recycle_ibi_slot, .enable_ibi = svc_i3c_master_enable_ibi, .disable_ibi = svc_i3c_master_disable_ibi, + .enable_hotjoin = svc_i3c_master_enable_hotjoin, + .disable_hotjoin = svc_i3c_master_disable_hotjoin, }; static int svc_i3c_master_prepare_clks(struct svc_i3c_master *master) @@ -1630,6 +1678,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev) pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); + i3c_master_enable_hotjoin(&master->base); + return 0; rpm_disable: From patchwork Wed Nov 29 22:12:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473584 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 50676C10DC1 for ; Wed, 29 Nov 2023 22:12:58 +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=zvmrYfWb6Jyzx5plF9p56RaSdTLBSS5cqyyLPh7MCJk=; b=nB5+gChk5BtMB/ ATZUPbxYJ88Z7hof4GYyHinmnDKt4JoF+u2q8w6e5SnBhKzE3R6AoSqNa7iQ/06pJkgOg4fwMFIZc zb5IAsRg8bg3Q/8GtjPO4fcfp3Vh3WNg3gpF9mhjVIL6Dl5OyiXtekuLH7CdknjHvDWjlHUzZMyuX RNUSLc5GFwrMck++xE2+u+ylGy2xyKwp/kWJDOFwbLqjjlLfeTsB7oFS31Yibgb+RHVS89vrfTW1I Lf2iMNoLHpXW6J0VXxmwIP/x1QOKlthyj7oS04VN0x00fA5XJpsF7SF3yopXshY/f8xtJkY/LJyl+ FFKLXVRAdl27P1fntC/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Sni-009Pay-06; Wed, 29 Nov 2023 22:12:58 +0000 Received: from mail-am0eur02on20621.outbound.protection.outlook.com ([2a01:111:f400:fe13::621] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Sng-009PYC-03 for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:12:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EDsQ2KcAuz0d8mg2XG882N4R69w2/0MdK1pXwB0+3F5g/OdIYJD4WqNZSiIo9RUACqgsSOM0q6O5/Mg1mt+fxI8n8Jhc+xqzLF2G3ObsyW5jOVwncvRaZcYb7uqz05PSx9nQgu9xR7T9gqsGBCH8FfO61ZgNSIiSlUuKRKMmqWCx+Rqd1xFsWNvzgiDLwceDwXXDEly6e7GDBLe12ssRc8KRg0dI4y14znO7ou3PRwjVOZT2Hw3p2iStn9vyj5sdLhC+zSDYRFGqI3eB2HGaRt/1YeityntyD3N1OildUV8wz9WbNnldkMNZdrIyuSzww6yvdcprW3UwAlSkv75Kvg== 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=++WWKqxHPtPOuShZ9C+n6tM8dcE6BdIrF96tSwG9XqE=; b=nf7a5rgOv+UPOHZTadyLE+anwpzul7VX5pgl7FvBAksfwGOIgg4C2ONXcEvrm63sJGgeqzd3/fgwk+P7IISgPo2mPMBXqAjY8Qi8lDD1up2b0N1JPQtP35CQvg3RwiaM0tjsnE6lXhPLrAqZ2gkUr9ZgzX7g/4pgNtgiCW6TXuq8e9E3fMwwbMPYvCNNAuzhkv8v0o5silQz8DkQmEc+3yF3clzGe3G4Z3LwRMFoFOEX/ztYs4aRQ+13jB8HEs7DkLPpqTso3S7D/REFu8tGWT6Ux/g9pw1EHRUJwYpl9POJV9n7UV/Rty2IF9HgPYx8KdlusiZ7VW4U/88UcpRshA== 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=++WWKqxHPtPOuShZ9C+n6tM8dcE6BdIrF96tSwG9XqE=; b=OmtZJzw0E+IRJfBDs/uBI9vKMDzYcCMcwdOdyw9UA25l1FxYNAD1tcoiKngu8SVepfALNU6DIa3ALik8yHfhQE1zbK9iaR9Ejy5ez0zrRUL+ns8G+FfMRiHqe0AgpMYi416bFi/buVI52B51hwyfve70zWf4iSqfhgBCmgrUWv4= 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:52 +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:52 +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 3/6] i3c: add actual_len in i3c_priv_xfer Date: Wed, 29 Nov 2023 17:12:22 -0500 Message-Id: <20231129221225.387952-4-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: 4b0a95dc-92c5-4ba6-89fc-08dbf128545a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LU9ldm+8pEXiKI5yIpulC0Za5ZMpklP4GoQ0jnVdV4KmKgBco9ckwHKqCI843WF7e3Ptvn/aH5PvsfGQbQCrPmv0yz4hoT/5SUZgy7nvqH8bombV3map6TQ4JGR70w+QSAcdeY4gmq1RAqxcymJtMMSz4hFCnpH1TUGsJ9PdKYA/2O3K01qUOYyRg5UT8B22SJe6f/QpnHkOIQWZ3Gcect0/BLGn+vS4t+ZLIWbeUWwXDzxxqQLbXwyMCLPk77kqd972R4mMhd7Oe+E3a5cLhYfboHDSVnw8qJ5xEt+rZiBX9Aj2aQ1Owi8PhUrKXBX3kYBd25RpaJdOhjBOT/k+TOMbViWYKul40fh8jDiDUz/Jn0DsfEj59hMt/yKPuqyr4Fg9H9dmybq7yZpuMhilmeGr2s0gAJwIZN2IcWk5gj6jawg0lFG/P1mue6+RsyWzuIiLEpz3A0IubCx7zeckRsOH+Mb9gk3qeI6KJOT2t91nH8TzFYJZBUPnNLAZsXVMstf8UgqCwP/LxiqQp1jav1eDdUW83uMED38f5eVso/go17TuacEaG0MSGaFEIS8NcOfxGHZSyk2Zs/u3M0vbt+uDQL8jrh/UzzFcYSsI3Nwy0GQ/rWBZJO95CPQyXOHzWoQyApQini0gPpQuAMxyow2fzn/oiuHvTvOMky39eyg= 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)(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: =?utf-8?q?TMME2RyQfrhkR/ayBTqJFyfFBE9o?= =?utf-8?q?s8hGR2VnT6HqsFpQXOVeDS33vxrmsxfRc8CVHZGZ92nGpi9Rb7EvqeRwZrhK8kZnk?= =?utf-8?q?EnXGzc4aPDAanmxMnS151Sj/uW4RjXc2V3QW/aw28/dtlyCvuXYn1/U1zJrWxNXam?= =?utf-8?q?L3JYjQZ2bMpJ4SQM9XZTHYjjj9jlGlqFF0lQwe7QDndMqy+Oi7EUcv/+aEtcEI18w?= =?utf-8?q?ibbgGftbgCo8AjxivhSBUdF+ICcNEy1q3ETKC2vUJqRJORpF5bxcswuam8l1BC4Nc?= =?utf-8?q?KQ13CdFaiPowaHDyundDFDhWCw9aNyrKaPIIFsH6gaRd+WFmF/PPzfsymp7hzbBTt?= =?utf-8?q?0IOjFj4HOLmJnE8ZVHxjwG6DNKiZ1fPuNId5zEX0HwKRJs0kpHxdI8CLA7SAAyo+F?= =?utf-8?q?0CMUC4mj0ouqSFCmUesqwMwPjzut8HB3R34i+unOxeghO8dVlOLqpSXpMVgWTq/Cc?= =?utf-8?q?GPv+R4Sjuj5DBiT0cT+yndZKmm/XWfVHb3j8hnoLlG1Lrh2bXZfAv87WEQl3Nkz94?= =?utf-8?q?IpwkC6iAFR2p56WUTDNFe8nPEGlcy5v2b2ECp/JXQfv6M+w6xoFC6EiDoLT7xdwHR?= =?utf-8?q?8oVm3I+pV8VGpiA+9DpqYl1AOf1IgQkcwZCSYaa2EKGI+KE47zxlQbfxlJ8kDhgve?= =?utf-8?q?sxz3/fZxmzXuGgx1+VTM32nUI7ctCl4PjzYUoQJxLQp+ejvky/8DYoxVwkcb1cC8y?= =?utf-8?q?rzRUkeh7tfx6LRCfNjb8ZEAcjXMpSh1XaTGzni6TY9IvYt+JlwkoM4aCn5PN8FNqL?= =?utf-8?q?s3l1mwHFrh+f0dhafxeSJgm1sNF/kqJz7S9GpRoieYxEEgqcyP91Pqzo39xhOOGPZ?= =?utf-8?q?o+MNz+9ogTaIPmWqvkjEwKKvBikqPqur+SrWPGG7jQsvVJQxihhvnr1Lx9weicowF?= =?utf-8?q?lIDwt55BhziUfRyxqHpBD+6U0qwu6mW6G1HIB0dtgNPRZ16T3LkzKFEngoa8JHP94?= =?utf-8?q?5HBLamwuPUTph6fMaeKo6WyAQa7WP02aHqsmVy5HquPML3Zta/htEzUEupaSja9wl?= =?utf-8?q?Pkp3STjuTc4eFX4dsw4YKRRp6a08r/NTneVLMo0rARm5QKtB/60MEe10uYdPC0UT+?= =?utf-8?q?GPbWKUcdVMYmXNhS/7U5A5qMeUd44lSnl/nP8rlgXfWk6ISW+1FPOTnZTquxuQ16o?= =?utf-8?q?NwEhAvUKf7KpgSCaeB3NTC5tu71J7k5Vq6dOLm/GAWC8LhctD+XS9MSvDa8e6BOAg?= =?utf-8?q?fq4oZBGM0ZxBeY3M94gdQ8bzhu9di63XgH9RALbgyPWxkQoht9VWJAgtrMzYn27e8?= =?utf-8?q?IQjtJqmp7WmLzH37mUlRWD0Pl4febdMtuq8r5yaB7nJsZx7gT5QG9KgCDQ35A5dCG?= =?utf-8?q?SXG7XPC6mBSp0OpfV/PUAR80sp3eaD1bZFJy7qidXNPuOE896mndN9EoSblLPd/4H?= =?utf-8?q?qID1SCc4rAHOqyc4ghOlA1Has6tV4l9JCDh9pyC1dr76wD8vmb2s+bL+Xg2A2n7TB?= =?utf-8?q?zO4QN2tvAn10XtM1TNvXXCD0Hdl9HXwayvbuTddcDYpaGzGoBFKDcyZ3QNSwZclYM?= =?utf-8?q?YdO5xRSq97gC?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b0a95dc-92c5-4ba6-89fc-08dbf128545a X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:52.0818 (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: GqW7yc0q+PBmiRvVU9wojR9eEHastHvAeMhzhrSM4YuvLvhV5ROZUhkpXIA1IZ6M2QCPNYoMhWY5IAi68aHvAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141256_056506_A6C7D898 X-CRM114-Status: GOOD ( 10.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 In MIPI I3C Specification: "Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the ninth Data bit from Target to Controller is an ACK by the Controller. By contrast, in I3C this bit allows the Target to end a Read, and allows the Controller to Abort a Read. In SDR terms, the ninth bit of Read data is referred to as the T-Bit (for ‘Transition’)" I3C allow devices early terminate data transfer. So need "actual_len" field to indicate how much get by i3c_priv_xfer. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- include/linux/i3c/device.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h index 90fa83464f003..ef6217da8253b 100644 --- a/include/linux/i3c/device.h +++ b/include/linux/i3c/device.h @@ -54,6 +54,7 @@ enum i3c_hdr_mode { * struct i3c_priv_xfer - I3C SDR private transfer * @rnw: encodes the transfer direction. true for a read, false for a write * @len: transfer length in bytes of the transfer + * @actual_len: actual length in bytes are transferred by the controller * @data: input/output buffer * @data.in: input buffer. Must point to a DMA-able buffer * @data.out: output buffer. Must point to a DMA-able buffer @@ -62,6 +63,7 @@ enum i3c_hdr_mode { struct i3c_priv_xfer { u8 rnw; u16 len; + u16 actual_len; union { void *in; const void *out; From patchwork Wed Nov 29 22:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473585 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 B292CC4167B for ; Wed, 29 Nov 2023 22:13: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: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=j5DNwHaxBXG91HtA7QjB34TzcVHYnNmKthIiBrZjHd8=; b=s3Sx1Hxl7ZKWhc JFH/Kg12/72+YC8VzGWfoacTiBh6uJwr9l+2NWorXxMZ6Lsz5Lb3ELdooB8Nnxte0CdxRIi+V+X4l g4FrKAZQoAeCO9HfmkI55J8iWtZy/z+tIahh6A+gw1myFzEtkfGRD45t/BlFQVdMcahyv5NxTybzB rD6Qe4x2Mq4YGeiP+G0iR1mRp9Me/4CB3XaAeBv93fHKafO2Y4Y+sItiDv0KyAAseCHInooJohHEP fb3NCm4vjzlo+I/ctMkXXGtcifPbyXaQpqEF7DqRE4Z5lrMc/i9TSKvY/CoD/xbdmoRrVVYgtTWDl MFTLebZz2QLlmH7R00Ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snk-009Pc1-1R; Wed, 29 Nov 2023 22:13:00 +0000 Received: from mail-am0eur02on20621.outbound.protection.outlook.com ([2a01:111:f400:fe13::621] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snh-009PYC-21 for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:12:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i6nRBm6HmlXSe0fgBJhrfl7GwD4Pu/A53VBh7XqKLBOOQwp5KFJhr2LVSeZ1xlumtjX+YKYcNEKcNXNlePGvp5fze1+IJA12lw0LLLU07w1kTbS+LPFKpzWzqs+XD9mYKzolgNajzp+K9rerRErd2AqO28YQB5H31x/euygJXg8LTbIarTOQLfoDXYev1PVYvb1DIh0iOA1KoJH573H6g+j4KC4hmX5/ILUERbyCkIbP74Jm5i5BDaPGYNhwjcr2zRQH5lAOVlMhhSluLwUVHvwxkbuxEgZ4Fp073cnQybFmuz0YeuPC/W0U9k8zPIN9s05/oJYpOjdClI5Aw8J53g== 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=BYlOqxYRwrA/DY9Y5S2Maw7Zy0Q7zqC4/7Z+mE81oiY=; b=G5KrcNF9k09by/6YAbtPqo+m4HIVNLyq4efZZj6jaNKeraUXNjrKuAVyuD4+6g+nq3CaHnQqWFoiSlMeGJUEbdGBUOJIR9QrG/z8L9NGskZCytehRDKmAtO3SLH5sC2A4x6r/+hmEv0H2BzslIO4ZOaeGcdrERZnPd4fVx4am0tur9mulsFGDyqzb9GEVuq+HFO52jAX7L1JnB7YtTJ64w8LyZzjxxunHNxGwpTySjL2O7kRTKkZtygUpsDe4JlH9nmZlhAbktA/XDqq1LAyJ0Tbs6V/SYgXzcclF2NTmoVx8XVMh9OUydCCUd8te3JyQK1PAEeWHTuqt93QCjsnkQ== 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=BYlOqxYRwrA/DY9Y5S2Maw7Zy0Q7zqC4/7Z+mE81oiY=; b=Z+ccet5PNfwC/ORYRkCQ17euIW71id/jczcPU+k7xZbTkfeQ4eUPAZTIs+r5b0P5MceADYlEhQBVjghRSIxRE6lOqe7ICwjmfFZzJuvBGjfqsY8NH92kPelsP+jN4xHDW+sa1anRQ14jtKhuI7AYW8DoMIbRLdp3HpU4wSSHW24= 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:54 +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:54 +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 4/6] i3c: svc: rename read_len as actual_len Date: Wed, 29 Nov 2023 17:12:23 -0500 Message-Id: <20231129221225.387952-5-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: 4bc5fb55-3f16-41f8-9f7c-08dbf12855ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yffM/LEHeaoxrU3rL35KGNd/otUostXP8CSy7cEL/nJ9ajmpeIktFO/BuL7wzUsF85qgqXW9xyK4n8ueI4YtSZE3GyP2ZKs1TrerwtR9XXYgDJb8MaxzsbzMtnGWnHBjtT7Gwkjm4BbdIutokfPieGRXeCry/huFsjS1Ypvdu1t85wUIrKtEqkJiKiUjsWO3Bvk+C/VEF6hKuCMvGgcvPvVf7M6J/vwrWknhsjTYVQlCxePZcUp+E34KVDwy4bEAh3h8TyglrVO+/9d10XouVCELSRFkBjO6KEpIyzYnw+j5sYyTzzS006zwNdNv9WPABxaNTalaF5neqwieBtT0BCTaipGf1lHoRLm5RUE8zJitTdIglxy2ZyXUGOdsMwj/UQseAfFKJnWo8hmbRk3wsVmsQ8n38wKaDO3rRkwyEK6iqQsQGvDbZsFAQsxT14kDqFA7Oxf2uI7Cin7M6c/QwTnTHp2mwNeNg7DS4VGZCk6vXX2UGJMgACVFaStSrelvo6VlOVA1ZGgZ6tIzTEgktt3zfSslNm3WuYxGSbHQd5JDWWB+pyoSU654kXtqi3AU83+Waoq/1Y4cJDDz9tV3koJIli9IUQORFpobQEWxOKbQAlVmrxhYyrmgooU3CSGIeHBYd70NrJit9bjkDNWSabhjPoslXWAIeX+OjQwZpMM= 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: wQfaAaYDOE+n44EAMDweCBLfUc/K4O05VxbNaIxH3HbaBi53jI7HUTTM6tZ10lBVAPfTzVRKMuXcOkmRd7SI8BZc8nB2Wb+RXhruPCJqTUhK61wR9n68o+bk7nzKGrdI0l+Dm7aYI+AZHgVLa+WmbxZB8IUiWcY+0Tutq7uIKW7Xyos/uvZl9IIDn40UHKJx11mLp6+0C76JX8V/qxE8BpLnM1DrOyuWfrGZ917G2JgwVohpvbwjg5hhK9DRFuL9l0A/1U8CuixUYRlkHKAJ45ioc/95NJ3DYo1gqLTLuGLg/O5TZSKx2d9tVv3IajiQmawNqRNgzMYfyv2LSVXdcUcYsI4lDlIrU4ZVOOWcaIwtXg5QigBEbGXLq8nSmi6yWTo7gUU9/sMbbmkSYST2azeU7zjmtn5cN/5TbgAhPVS71uR6wWbOqQGuYOfjahIi20l7rQzB1tTf/BdUtG+6U1NHCvuyfVXpzDW1UM8JexmpIXVm9nbI4esvErIDvWCe1GvSSuLowMD4/BKDyKhhriG67CY0p+kmlp2w8qeLOE9rqSYLF+Bi8D3sVQm5i3apDRnku3smQVFUG/VUvxuUifwnyCkY2ElG5foopGvXmFoeT97wfZ0MBudLNhjZEznKTv8SatSU4FzFV7p6DT8lGGgCycvTzCB3KnKb+uotkfCec2T0cPaPicCNGH9u1adnLyh2J7M/a06A6xtrxU1wfvLKz3oa7LgFvu3ZmoorHjK+7i8gwSlNuK9Hu5XIa9z/WhUp3DoNORhUH8EDgxT/YBeyNkOqmZR53CcKZc1WwWrJXBenPHW9N5uKMh9gQ+oTrYo0jGwu+cC74EqQcn6uJn+JZ/i4tFeUsOi+Z7IlCAFbcKBrAtZ0pKnjNp+uU1lkywN0o42WAPfGyaFHbTgtdtYeGY14sgHa8YIO+6tVG/y9JfFbckgf+c86XM8CJYffaz7lNKeB3z5eCqQjBicwIjU7FP/UDoAlzXZ55+QVuHbllMUgbyeR8WD4BrtcqIDJv7qhBW/5ZTZPpghO5TcziDLK57we5LrLxEv2FL/60wFKpUVDmbOyRT/dbHB24Q1mmh3pNBIsmzbxlg3UHPI6hK6PqpMpZ+xOragqO+EndXeK7hNvOug02SMEdxzV/+xFEY3RDMocJl3dnEIF5NYjzdXM4ZMKYYbb49aHQpQT1BeEJG8gasJ2bmVGNaWo2KKqa41ExnVUDY9DlA6ZxxIwNmFPYB2RYAFZhZI3z+ekBKdHOtLHuXQm61micHVw7C6vcfiTADrg3mn72wr+qEpm5EN7ZMX4EOnqyWVHv/mEDpf57ag0g6pNodhTR/CYwUvi5W4CuCCkqpzcHZL0zapIaG+PL4AHFlYGM5bVzBdNVCnK1QM3eFpHMmGO4kxzihyI4+JXGo0eqIkALesjjr2MZyCwt/Gr04CCCXC+gGSSAbwhpToosPSpC4G7vPixootnec0FsTgWPzae2DnXcZsjE9SmDABxkk12WIg5X3nQvR+AOPBmQL7onbd0Q8UMCufBtzJIH01ebeMAlevSeNuSFsHWCrm7qony15kslKxvMKeOmqCH83nowVSPJxQ0xln3 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bc5fb55-3f16-41f8-9f7c-08dbf12855ce X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:54.5021 (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: 2wfL4SNdkS13YTO1bgQeQWhTV4WahUgkr2YMONHhlvnFnPxNTHyAFnquhr3VQwEoo9IxlETznEhffTJSvHBnJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141257_668147_F511B627 X-CRM114-Status: GOOD ( 11.88 ) 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 transfer (SDR), target can early terminate read transfer. I3C transfer (HDR), target can end write transfer. I2C transfer, target can NACK write transfer. 'actual_len' is better name than 'read_len'. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- drivers/i3c/master/svc-i3c-master.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 880c6ae76c013..be742e6734e39 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -137,7 +137,7 @@ struct svc_i3c_cmd { u8 *in; const void *out; unsigned int len; - unsigned int read_len; + unsigned int actual_len; bool continued; }; @@ -1033,7 +1033,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master, static int svc_i3c_master_xfer(struct svc_i3c_master *master, bool rnw, unsigned int xfer_type, u8 addr, u8 *in, const u8 *out, unsigned int xfer_len, - unsigned int *read_len, bool continued) + unsigned int *actual_len, bool continued) { u32 reg; int ret; @@ -1046,7 +1046,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, SVC_I3C_MCTRL_IBIRESP_NACK | SVC_I3C_MCTRL_DIR(rnw) | SVC_I3C_MCTRL_ADDR(addr) | - SVC_I3C_MCTRL_RDTERM(*read_len), + SVC_I3C_MCTRL_RDTERM(*actual_len), master->regs + SVC_I3C_MCTRL); ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, @@ -1084,7 +1084,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, goto emit_stop; if (rnw) - *read_len = ret; + *actual_len = ret; ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg, SVC_I3C_MSTATUS_COMPLETE(reg), 0, 1000); @@ -1166,7 +1166,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type, cmd->addr, cmd->in, cmd->out, - cmd->len, &cmd->read_len, + cmd->len, &cmd->actual_len, cmd->continued); if (ret) break; @@ -1252,7 +1252,7 @@ static int svc_i3c_master_send_bdcast_ccc_cmd(struct svc_i3c_master *master, cmd->in = NULL; cmd->out = buf; cmd->len = xfer_len; - cmd->read_len = 0; + cmd->actual_len = 0; cmd->continued = false; mutex_lock(&master->lock); @@ -1272,7 +1272,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, struct i3c_ccc_cmd *ccc) { unsigned int xfer_len = ccc->dests[0].payload.len; - unsigned int read_len = ccc->rnw ? xfer_len : 0; + unsigned int actual_len = ccc->rnw ? xfer_len : 0; struct svc_i3c_xfer *xfer; struct svc_i3c_cmd *cmd; int ret; @@ -1290,7 +1290,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, cmd->in = NULL; cmd->out = &ccc->id; cmd->len = 1; - cmd->read_len = 0; + cmd->actual_len = 0; cmd->continued = true; /* Directed message */ @@ -1300,7 +1300,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, cmd->in = ccc->rnw ? ccc->dests[0].payload.data : NULL; cmd->out = ccc->rnw ? NULL : ccc->dests[0].payload.data, cmd->len = xfer_len; - cmd->read_len = read_len; + cmd->actual_len = actual_len; cmd->continued = false; mutex_lock(&master->lock); @@ -1309,8 +1309,8 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, svc_i3c_master_dequeue_xfer(master, xfer); mutex_unlock(&master->lock); - if (cmd->read_len != xfer_len) - ccc->dests[0].payload.len = cmd->read_len; + if (cmd->actual_len != xfer_len) + ccc->dests[0].payload.len = cmd->actual_len; ret = xfer->ret; svc_i3c_master_free_xfer(xfer); @@ -1360,7 +1360,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev, cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL; cmd->out = xfers[i].rnw ? NULL : xfers[i].data.out; cmd->len = xfers[i].len; - cmd->read_len = xfers[i].rnw ? xfers[i].len : 0; + cmd->actual_len = xfers[i].rnw ? xfers[i].len : 0; cmd->continued = (i + 1) < nxfers; } @@ -1400,7 +1400,7 @@ static int svc_i3c_master_i2c_xfers(struct i2c_dev_desc *dev, cmd->in = cmd->rnw ? xfers[i].buf : NULL; cmd->out = cmd->rnw ? NULL : xfers[i].buf; cmd->len = xfers[i].len; - cmd->read_len = cmd->rnw ? xfers[i].len : 0; + cmd->actual_len = cmd->rnw ? xfers[i].len : 0; cmd->continued = (i + 1 < nxfers); } 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/GbboNRqBxwDK3pcWGQmm9PLAuMHOYTkx7MwZQzZwKeQAuo2rjJ6b33VXP75OB2nEblEE3BHFGFRFnKA4dFpbQ1W7wu9vWHJAM30pYl/bUO2tNdMBXGhIWkRyR/R2mseIgf2jOb8TiL4aunXO6BYcL5hfSgatsk5lsZFyleblThJbRbS1IYK6Fh2QK7kLPd7zJZDBjVHn9Iyb9IG2LVV8eBwGiRpYQfeBEWNYIrwb+RzRj4Pafgi3ncytnzLmStdn6SoQ263QTZwm/w+p1O6DjOs43uON6BKBXiWXVAQhJNmQmWjieMqkdVK6MWqmH5L9x4O+W4ltxxywMRiqZ1PRiPFgyhiyfFG5BvSzu183a5jFBTcdNTTO7bN4lL/w1LZ7WABxd7UkjtN1lFgJbE5F6Xf51Tif0aXS6jGe5DGSfy2f5+waca4ltHTp29hhGlPe7dY5nrj8b00rKMG39HGbIdbZxyeU/E0+DcElxpAd+JKmCu6M3hlbjt8IeYIu82FBhc3eaV68/jY4Tre6GYNKwsfVaYLEyPROUTEQtBPcygOqbHrSpdbXrwg54CnSUNoTgcmU+fZBaP5hMnT0ZUIzMwGAe9fsACt77Uh+7dM1EqJcmoZ1Js84KoPa1jo2IQgvLs8hcbgzWu34vH/p82QqQN4sLKNysuC/GD7wxY3a9+xwoZ7F2vQi16JSLii1Mm8HH/Kg2d9VXpoWFjXaMNifyDrXfLV2HAwm+BBjJ1Y/jFTcd+Kc1WnI8mv08jGJcNpvFJxIwSLQWlpyBo21Obrds0p7t/YadSyuC39WY+Z/6GPV9QqwLPkqoHYWaWGRDKMBnfW36sJtDvz8gsRglgBDSUrjyWhhScWXuPjp79MpxBbcvOhWc9AN90dTkt3WkFxzPfsZd7hR2O9NeZadU49rYPvKguSXINzYW3FD9gLNYvRA8Kn0suFNzm8WtOC3iLSQuRTitYutId/2Ocpjzw X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58f96f7c-c90f-4b49-5c68-08dbf128574d X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.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; From patchwork Wed Nov 29 22:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473587 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 E680FC4167B for ; Wed, 29 Nov 2023 22:13:08 +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=J/lIOoluavE0zGnZubQPfxA1PHlglLGPcB/U94J2M9o=; b=Ea3PnAThaaan0F 78p0iTlTjueGXdw74Fngcss62pxoviM/LQXPAEEFdf5z9VLPXXiANaPuMXqgfRGcllfepEErwg0bz DKMSZqoV3a2S67pMOUwaqXTXcWoGvO+XgTqnLwT8UcxLyD03hI8FTFtR/Gvu4YvUItX1PCSf5TSE4 35X62VSAWbsvQfrxqX3iSHf2LA8Q9tVoZUbh6xVezcGMrhHnYIJsxk9zZApO1mhlB7TQRm/vVWsY/ SAXGN4O1/+2LWV2BBSjI0sGWfi1Hjz6vUHQltrkfYBuxo8HPmT2xHjtk/O+lYvqQz8PBo20Wn6GV1 ubd/KV7St2CoNMQJziZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Sns-009Pf3-1q; Wed, 29 Nov 2023 22:13:08 +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 1r8Snp-009PcW-22 for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:13:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hOcinrE5Q2bcnp1WngSndbSfwXsvOt0k35uVVAfQkVPm8lq4Y3SbmNkpY8s0OpfDl4Ldyz0aQaz6vrFn8vPEcUaX9O86GFuwO+Urvu2pSe/n6yz6WIcsoCh+mPKUJN+KeS5mrueIWGFHqz9ISJvLYhWU5nVqgIGVV5IzIU7sQMT2nC0ICn6I0Sw2n/TGp2WiRR523QiDF9KxpbDinPGobGyagHh5ESvBR4JGGcd4XivtZKWysGoNJhKqQiiOVcgekoeXQL1e5TgoNxB4sVPwSCZA70ZIE9FAU4/98vEH4LuHwMEKKsDJfLZg/UtBwyver/yyE3T/xEFymDNosHXGVA== 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=pPWQn2l7iuQDprEGwbhMq6laPM8yM/hxK/Z8Bbastmc=; b=McfJWlnwxlJWIHhz6TKUDUd8yiuZ/1JY5B7VK4mva0/XpMOF+XMhZlGcCIq0h/4XCG3a0nfZcQXavO6qTGvaBDyg54Zl6IjC2OKOCIiJDouGgNFKE6yRsRcAsWzzlJmg6XfF2JRA89mn3J7/g+NjKK1VKNOk0VZwcXlsa9MobqSkoyy+qZOjx5sVa/bitbcPZL76Kg4akSjJvmpSELxGDY2yiavnb5SwLINDQ5TMWh+Vu/TQb9CkUpuhKleaSIkqrEpO3d5EZAaoiK5nWE8HeeG57DgM+3zg1m+ToOqvv0aHDshfhjL6uF2s3x3jMeElnTMWe+UbJ48hjjW3HIaqZg== 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=pPWQn2l7iuQDprEGwbhMq6laPM8yM/hxK/Z8Bbastmc=; b=oIUt/M1U63K5xrZjQ9nJOrsJEz/2zh05RrJVADZfc4ANyTBHncU6phspWaIN8qOeAaQgchzS5iMM8A1O0r8kh1QqK5y6KpIinWFIZL+BOLa8dF8x6sXeOUPYDhSKuunIIYReCWSDwGyuMgTdtTBZgRDv9K7fL4/DiMhysZtZ5U4= 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:59 +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:59 +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 6/6] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Wed, 29 Nov 2023 17:12:25 -0500 Message-Id: <20231129221225.387952-7-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: 8ec119a3-88e5-43cf-9742-08dbf12858c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fRxqB7tA6jyw0QU+IMByfrrbJz2pUDseokMYLhf4DLjtJeQRDDYv56osvP+iRyr/udM8mXnrV6H8zUxyU8ZtV+rVOxT9ZqHiUOtVwmmEkRy40Aon+O4N5/z5VrZ8lE7MnGI/GB+Z3u24J/W/OnfM9X6jlgbOfxj9wVZry/bMHGuNk/Ibx7J9FBfuN5ZzBBfQKr+jSDNPIHLib8RAn/5DzhI9Grcki7up8Fl1h8bWmZx0rKDatkwDXEPpNQLJsKFvAMoqXtIEJvEwX4CK/O+EgokPZNIvwQBM4t6kB59pCpkVZI8eCLnbBRfpY/P3VpQiHBF10Z/VqweGsoY2nzuc2rS6glW5KShLwSCvhAU/IUAtbR4D/0OjVZFCW4cfNMpEuA5a9BaDbGnB7YRqkZNPnmYq4HJ709IrJiPl2MGAHZD6GqLyujalGlh+/pRCZZ1jqKA2zsaJDP54W+FZdKXe4ypKq9kxEK1iQIJXBJn5Uqbn6maLBW6JALXpuEMMji2MxSjoVtZ+ecKuHUuawFITJjwQSgLUEZ2eHMLBi5Fa/4ui2+F4xLmmdU2yOvjohOXCi9Tw2FcVys1pjlCXu0mA5pGKhJDVaq9TOteuwIWcsOWDbmDdU4W5qnTo6dk3kBuMQgSxPlUccmAGaMOde0k0QKQ9QzuWM5P2NBMUoITfqfs= 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: vAC3A2Bdrm5/uqw3WZVDX1nE87b6iXtQ4yoZ2jfMWsVRGhxQ18D+s9tefKn4j9XSp3cOwxbsFKIOJbr2HWte7pXZFHm+QhUkOQdF8r5ISYI0jFQdHyG56Mrio68FtEgOa9F1DYcGbyEnAXxOtP2klDFEJJOfGolA/SGeRIVDPd5JhIwI+A3kA8VpH36GgH1+s1mjkvDSZl5iJ75RRVRmDEhvrV4VDOA/TPrN+xVj/c1kLFDsHUUvHdfyM5uBPPMxildLQwB3iEIPe5qqI7bwQz6ATMAon/fAbyHTV6HBzhQ8S+DihUnolZIOi+HvcgjoT95N8x5zHr0ZaTU5UjXubjJaPdLsqaDnIZcAHg0Ste0Nm+u/O+ZBwCcyEKVBJhK6Z8ps6XY0/MPWO6uXFZS13PWkHObJNMUNHp6Kc2G9rQUEfUsECXfM3GlOqQ8ZOLU5RCJSqB3vF86RaCuF/0YCGvEW403eCQ+PzzcTpMFPAb8++OCGqqnj7qFPamafxoU+kT+M8moMu3r895kVLJo9My2Imzesy9qc0T5BtyfM2vage4f1zHj93EVCmH18GtNIuE1y0/cDweZNrfb73kG1JRzdtFf2YA9+BynmJMQRUXH5oRmlZO72owjEZO23g3uDaA2CO6NpCjwJP+6k0Ip1Arp6nkLkTsisQYEFVFSQnA64z6HMRlr6XLY5OltOzGoLrxjVHOMlEWpRqQ1ZM7OUjv7VhJ8VoYI52fzo27vjmU6QRKxlw96LefAct3smUEiwcHuB7MLrSzZijXekxo09HeQLBxqB8TaU+S+V9pWlPtsJP9/Y51/M5tFW2z8GjGkUuX/ppgGAqQhH7p1nuk6n4deMXVQVoTTNWgAy7GnqYRZk68ZxzLUsPTjf5eLXQoDWIAVa7GChc7j6saBf6AhuVidHYQdDI9P1EUenHWM8wbYJJbFr3hqch0TnQW7/HiN5PRKdXLunOfgRJDNC3J45vFD/tmdxhdKyJni7OS2V+VhMS2LvhZDDNPgX25eVAtPhe9wP0ezTSd4+LUUzwL37TTHgYjgNIKnVNnX5jca0BZdIe2WtdxfWJm8kLBtyM8IvSdUV14Y8PVAiWL2ygutV3qCgf8UprgdWE3/w3NJcb7fBQJXNdtLDiTh1237QjGG7H3rk26CHibA5MpgWmGYEWbm4PJxM2n1AtHd1UuzG1FFvuQF/BbUqKAxeporlf30Pgd/VelEFOKJPajmoy28WDBoQm39zKrMhoH2p62uTxOyeGZxwJrLtE7CuacKNKyrgdmW31g2qWqXtciqKqQUSenvJeTYDWsJYMaa9eH/53+KkuUbKIvaf5FUrdUNkYkmuPiOzr5JVY1wXIv2SRDlVzTbRZoN08w8Omn/nxCvcPnkFFF+Mh2aH51urh4EJOCM5pAlwyer8EP9f6PfjMGc33rH7IegsVUfeMyTGaOQMSBXUjoeqfzjQyRIPlKxI1lumibzJK3SS1+CAHpvjy6veq65ySHhKrvuQB+SnUKNbwseg1nZLvlESHkUXv936BemHCvgPOOYLK6oEaAB7wtBJOv0n3utgJ9Ne04jWh3F6XOmc4wAc/71fGXiALBhh7MEA X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ec119a3-88e5-43cf-9742-08dbf12858c1 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:59.4434 (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: ZAlhJh+/uo36cs6bdEyPr0f6EauS45hPjoVWfFZv6ZQdLGH1lR4e4MvG1626woOvut3efu7Gh0conSjqJOZtSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141305_669771_6DBD08D4 X-CRM114-Status: GOOD ( 12.98 ) 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 standard 5.1.9.3.15 Get Device Status (GETSTATUS): Get request for one I3C Target Device to return its current status. Add API to fetch it with format1. Signed-off-by: Frank Li --- drivers/i3c/device.c | 24 ++++++++++++++++++++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 26 ++++++++++++++++++++++++++ include/linux/i3c/device.h | 1 + 4 files changed, 52 insertions(+) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index 1a6a8703dbc3a..aa26cf50ab9c6 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -196,6 +196,30 @@ void i3c_device_free_ibi(struct i3c_device *dev) } EXPORT_SYMBOL_GPL(i3c_device_free_ibi); +/** + * i3c_device_getstatus_format1() - Get device status with format 1. + * @dev: device for which you want to get status. + * @status: I3C status format 1 + * + * Return: 0 in case of success, a negative error core otherwise. + */ +int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status) +{ + int ret = -EINVAL; + + if (!status) + return -EINVAL; + + i3c_bus_normaluse_lock(dev->bus); + if (dev->desc) + ret = i3c_dev_getstatus_format1_locked(dev->desc, status); + + i3c_bus_normaluse_unlock(dev->bus); + + return ret; +} +EXPORT_SYMBOL_GPL(i3c_device_getstatus_format1); + /** * i3cdev_to_dev() - Returns the device embedded in @i3cdev * @i3cdev: I3C device diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 908a807badaf9..976ad26ca79c2 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -24,4 +24,5 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev); int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev, const struct i3c_ibi_setup *req); void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev); +int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status); #endif /* I3C_INTERNAL_H */ diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index ed5e27cd20811..6a16ebdd180b5 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2924,6 +2924,32 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev) dev->ibi = NULL; } +int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status) +{ + struct i3c_master_controller *master = i3c_dev_get_master(dev); + struct i3c_ccc_getstatus *format1; + struct i3c_ccc_cmd_dest dest; + struct i3c_ccc_cmd cmd; + int ret; + + format1 = i3c_ccc_cmd_dest_init(&dest, dev->info.dyn_addr, sizeof(*format1)); + if (!format1) + return -ENOMEM; + + i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETSTATUS, &dest, 1); + + ret = i3c_master_send_ccc_cmd_locked(master, &cmd); + if (ret) + goto out; + + *status = be16_to_cpu(format1->status); + +out: + i3c_ccc_cmd_dest_cleanup(&dest); + + return ret; +} + static int __init i3c_init(void) { int res; diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h index ef6217da8253b..5f511bd400f11 100644 --- a/include/linux/i3c/device.h +++ b/include/linux/i3c/device.h @@ -345,4 +345,5 @@ void i3c_device_free_ibi(struct i3c_device *dev); int i3c_device_enable_ibi(struct i3c_device *dev); int i3c_device_disable_ibi(struct i3c_device *dev); +int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status); #endif /* I3C_DEV_H */