From patchwork Fri Dec 1 22:25:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13476536 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 4E4AEC4167B for ; Fri, 1 Dec 2023 22:40:24 +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=d8LqI8JeWo682bgMfKEDG6arm47GV+sc4da2+6ZI5+k=; b=mac9TXnzUqGqdk R2Xq119t9T4sOIi4FQrvTNqv5bNVCCxOorc8/xxME0R+o9PuhVhnlpFHE9fjAyRcb7k2FmcOnqixG 3l7Txw/iANclHuXIpm20JlmohK43p4fIKD6QOBN/Yyy2HoyLV2XsKTYAEBNP3JIsPduI2exe9diZp bvu9eRCuOhS7A2LK7QaEau4s9subtQZMjhrggGcOUPqV9TNlMXlX2gqp52kuQkGZBA/pXI5rRRRq3 m5LfFXxRUnjC1h0CzSquK2mP+noZuViDcq1C3AsvlwdP4IetBTCoTreKuAPTtSSulWvWLMLVOTeDW 7avEyM3gqnZQtkiSy1zA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r9CBL-00Em6y-2x; Fri, 01 Dec 2023 22:40:23 +0000 Received: from mail-db8eur05on2060b.outbound.protection.outlook.com ([2a01:111:f400:7e1a::60b] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r9CBI-00Em4y-2H for linux-i3c@lists.infradead.org; Fri, 01 Dec 2023 22:40:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RrTZy9azY07ipFoH8EyNf5YEfvSXVi75fjwBdVPfaQAtxgAQl2ioEi3YRm4k2f0n5MgPZc/1+Ez+WqF5VLUYuHEQCpsjOIbcOBhSV422NYsH6zcJN+5TsTM9EJs8oKe+gMwp+mDjcgNvmBEhB8sd8dvmm7BRMN1a7gCOgoMBrOP1uIQMUaYZbYhm8bxi3qmYkqt83JG3YKn7ty1HhMNyL0xUFHcfvBPrte3S4sfgI1UC5/xsEJ93f6mmRd1iFcdszs/DocWjEFz7MG6tUSSu5QKgQwFo58k6sSmEFVRikCdkHHK/4vPanz+SSDHYrLmIcDZ0er3Yu6aGI/iwsLv8HA== 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=piRRPE5LWefhXJGz8Zoeuo2aGktvTAfCXdTndUIkNMo=; b=HzSSZv5ocsEBezOXa2Ca716u5z3HXrdyOcYlriQaUn9IGzuNuZAFP3e3ek91TqDwG2e3sJXEvHGBBfMBR3XnCTE4fbpHqVwnEVLXA5D9LgeJK8mg55GoGv2ezlbkDTbp+j6uzcsOyHCgFbBnOGk1faiDaNTNkdhd6xj96sgraz2tO+iS/VCZ5Bs8JsLYju6/rDxyG9+OUHPpeF2IEvUYrEw7z1kahqYo6OO6tKoS/SugsrkWQCKiMSP45rrjL/rJssapnFTOsWyGySeF20QXWzQ71qP+GLAUxX/8uHamr7CYJEz4CD0ud8A7+t71V2TqwwAhU8H/C3oZSxJmOtu29Q== 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=piRRPE5LWefhXJGz8Zoeuo2aGktvTAfCXdTndUIkNMo=; b=lSQuoQewhEJtTxqNO4ElEeZiuy3bnvFGzIzm2f1JLbpUDZPNYYwzPaKAcJ+dmj7Fi2enSglcKhsyy8PCj1OPkWro+QjtF5Z++Mbw4MBVyAvQ/mH8Xf55krypT53CzBNvO9siscNdxtoBrh6wU8AjFjpyzte1Lwhb832T8xrUsSI= 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 AS4PR04MB9573.eurprd04.prod.outlook.com (2603:10a6:20b:4fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Fri, 1 Dec 2023 22:25: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.7068.016; Fri, 1 Dec 2023 22:25:57 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [v5 resend 1/6] i3c: master: add enable(disable) hot join in sys entry Date: Fri, 1 Dec 2023 17:25:27 -0500 Message-Id: <20231201222532.2431484-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201222532.2431484-1-Frank.Li@nxp.com> References: <20231201222532.2431484-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0022.namprd17.prod.outlook.com (2603:10b6:a03:1b8::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS4PR04MB9573:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b8a1bae-ecf7-4e7d-49d0-08dbf2bc7d64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B9rWT5ppyPQoN1Aken9WGUDuwIF/dmxOtx2jgN4C70iiTj65b41P3OuKztN13z6wnptcbuf2cTSs9biyqWh3eU41sfWlzC4Xb/mhaZwFDrpoWpAh+w0RN5om43X7/GNC+/yVIESODkalFqhPG5XqnPg4RJ1zLGjdjjSO1HAfBdqaff7vNPL0KywFZy5lsktKACUDVIum1OTnWgP/f7H+ac4RX0+qoolnXku4pE8gTdYOGT9LI4n6SqtC4wnVBY67OIsDwPWCNL9n/m8U2DvMwjS50J1Vr6ZJBVeehXz6w+2W9IxChb6Z0NHKR/ewX4C5jjtvI50LM0uNJ3Wz5oLWv5MLPo/g3xbUZ0E+pQz8VuzlOv5VxhRalX/UPOxB+MtnzV40AF9xYD+uS2FVMN/yCpEB8ZFYlu9uUI5PN/JvDgo2PP4ItrlAEEnPtx07vHGuhoIRhCom0wc+EquSwrooQsMfPDrDVm4v6zwB4eWsubiOQD/1auuqe00vQX9xOAN01VBl5q0yH2zg04SzrXXQLvWvdbv7RvG2SFu0kUXkuE2k6i9pNNFQzBQag4dcBPFnN565lJlPiaRAr2Me96ihE1qPf5gUi6H4LhqVWZxmOPeSks6xh0kF2ogC/MLEM5Ta 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)(39860400002)(366004)(346002)(376002)(136003)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(83380400001)(86362001)(6506007)(26005)(1076003)(6666004)(52116002)(2616005)(6512007)(41300700001)(5660300002)(8936002)(8676002)(6486002)(478600001)(2906002)(4326008)(316002)(66556008)(6916009)(66476007)(36756003)(38100700002)(66946007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RIhv5HcMyCvn/t2HFB+cJQLuLelGc4LBH9cY5TuXIEbFP0kUhpXMTK3GMRBSSd9E7TS8V/EiO1r9Th7JNMlvDxEmE+6w3aJItQCKXHBRWvlhlSiZb5DbtontWTN3/3Q/vK38FaV9XisqH1KeIDdweiODvJ1DM0qMxWfe/8PrucBERkDUuiEx69u3m+VW+cR9+AcM8fxy4/NobOmuk7lAsTHl9aUGSVaF9DHtgUth3fkPntQCnWL2Qbs1fK4yx6RK3+kBxdo1hatBbmbzK6N1kJqvSDTKaIQ9h+CUpaLl+NzJ+7ZaaqgIpWT6mXVfM71n1TDmEV9LU4KpyZttOgMVJOqKNxJqTY9ipWekcj1G0zafD/DQ+2aJkhlc8u3ysBkoz1FxTqOsPB4jOmg96FVrAEM29Ze1kHj2x8SN/A0zGVuZIiXNJU/Mwn/HsmgPRk3osqkbQFi2XpEmvfxk29crMNr2QV2SryBOUhmw0gT76EwHjMxfFO/dwFK4P5cyza6bHc4gJWHMZ5vex/tPUPufmoXUszAJMAIE+MJ53LqyFtcll2qHnT/UVJ3DjFPj4x6ZOpHxtC4Wa48C1z7jmE3wYzt3pq52a5rgT6OtjXgyc6iCkkMRLRvqL95QubybCPi849xlzhezaABnAbAgProgwjXeDIsR729oKqnBOd1az18YvgQHD8mEBUbzjDo9t39xAAorS9Eo+q97/P5SFBBnluwuKXeYNxbr+VDDSq++c/LJgMEPD1unucNhPjBNm5nz1CcmwBqq/fM7g+mSRYdZdtfZJ2JNvlMnqXNCsskjU/OfSC2/KuWaUUa5cMe0J6XBytpeENIPicc3NFO/OZWVE89HOmpkjNZqOqLrUuTDWBRxQRPKy2p4AzPOlUchAuoGO+zKTFWTki0UjYouwgAHzR07a/ZOs5wHSzh8BeuKWvtGH+YkqoUnVWRdCPM086vESIBjB8rFfi6aBg9rhBXt6HS9kvfOnkmET7Paf10JaRzG6n3IFqtaHq/Mtig6k8nHGhknF+o4bNnxS4zOdzGDE6lUWlCfS5lvFQkJAUf1CRA52A6bHBUyX9RONNAbm7wlpoziGMyr6NQaOiwstNqEwBGaab3OqrdiiUXXcC06PKFqY14AHy6NsPn9e2Wxf+kuol78aMuLj/VXUR9jDXjyknvFXn0jqE8AabrE2alyrJEa4wUUv3K9fMVGFN6uursbbw6iQazKD+WR7Qo8Xojeb3VSDb6uLfrFSIlCkKQu3rAv86bJgQGE9pO9ktWuMIlokgBZO6zfid1wzsLei98pTW/kBM+83ecgVh7CrHeDaP/wd1Pc+wuDGMAZ5nfpcSCKi63+U8j8sUsCQHgYSvdlHpn4oGGtpY51Hg6Wbn0oPhYc2MXtc0MsbVfLtxOtz6CSuFtH4tXUwzKtJAX4hh2qzlwla7D1UB6hrB2i8k3pKnirQtvxawPhUMAdIsprSK/SM7jmNu2svVZ6dMJyD3CHei4xQncIHuFyWnUq8PsYyDKRxINZzuGEzkHSDlg8rmGuT8/bdBbf1sb8UpG2+yViZFYWBGTVaQsgDKtmqtQvglJVH2/GnLpujckxlFrT0p6Y X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b8a1bae-ecf7-4e7d-49d0-08dbf2bc7d64 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 22:25:57.6493 (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: DZVIRm4zXdhDpAAMKyy/AnFeB05L6B7g6sT9IWs035GUU0rQSiAjT3K8Y1elCqOlL2hxB+72sUIsts1suXcnLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_144020_754431_0A972D2E X-CRM114-Status: GOOD ( 13.93 ) 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 --- Notes: Change from v4 to v5 - using kstrtobool() > + if (!master || > + !master->ops || > + !master->ops->enable_hotjoin || > + !master->ops->disable_hotjoin > + ) break into two if, which will be more clear. and one line is 101 chars. Change from v3 to v4 -none Change from v1 to v2. - Hotjoin control by sys entry, default enable hotjoin, which standard i3c feature, user can disable by echo 0 > /sys/bus/i3c/i3c-0/hotjoin drivers/i3c/master.c | 83 ++++++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 5 +++ 2 files changed, 88 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 08aeb69a78003..d3b56c9f601e2 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -526,6 +526,88 @@ 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) + return -EINVAL; + + if (!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; + bool res; + + if (!i3cbus->cur_master) + return -EINVAL; + + if (kstrtobool(buf, &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 +618,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 Fri Dec 1 22:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13476540 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 C949BC4167B for ; Fri, 1 Dec 2023 22:42: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=fxKk1Roo8/9PuxtO7jpM2boEEI3OgN0T9BIxE69b3es=; b=SarEr+FUAf22au akhucorAXbXAy8/rWrxpeeS5jFrC8JZC6HCfFnV4Y4IyhQX3vQqgWBrmZ+5pjKl737H9W2rZA/B7V MjrwVKZn5T27R4qggkQu6D0F/9UNtVSLBw7npRmkoMwKfxxxvn5WNOSMk6c7eDFXCJh3ag25WSGgc 19NiOl1pG0kk/dF2Bzu4r/b72waWTE5fBWe2opdnNIggrKq3wTGVBWGQxTACOMct2IwKcaguOOHjF flOi2QGby8n6cUWrgAL+hlYvPsz/V3BRnmnxgDo/RdzXJPp3ICS1MTZqybOelM69f9GCY0jJk7qwo 0xcJqHm9hyQlfOflLIAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r9CCu-00EmTP-1l; Fri, 01 Dec 2023 22:42:00 +0000 Received: from mail-db8eur05on2062e.outbound.protection.outlook.com ([2a01:111:f400:7e1a::62e] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r9CCr-00EmRu-2g for linux-i3c@lists.infradead.org; Fri, 01 Dec 2023 22:41:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nN3x/HKwo2lPWYenbfCDJSjN7UDo6I5jJMiru/Q0EzcJ85LF+Dkqscn9O9TZo87kYlWcBGLIQKzVaCcyS9erGuecTLv0/em9ejBzy8attV1T5gWsLDDhi3oA9vn7cS/vwP3hex12D+36Nvc0vXQQlyfvxX6pzXVOZWr0KnK5V3ERwj8k4IqNJPezAt0K23avb1xVrd57J1LxXV4QAXtL1ManmwWe46p3ouhXF7zAOlAxUHsi9ajZ2xmPX3nt7TmuCECS4pHM91taxijfamuI5i4X6kQX90coPimx+eeQDmTsvSn0TEp5ZIfPRyqBezTamNJDVOXvpN1pVq17UtVaDA== 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=CSwk4mrsbP/IlP95SQCItlUNiOZrW7VhvxjtbF83/ek=; b=ADAasgL0mg4ie0XKXu8rQnta5AkoqDf99Ck7hrFMd6WzyAu3B601ZCqBiQY9ja4IF4rA/gqLlvc5xP6WiqBR+fpYQUxdpRy8NQRAUlbjXPdUsoVkBjctASC/6tyJWQehBU/ELy1lVyLBI+vYqQ9+jvkH0gxDHN5v61FxvOGNO8DJoNIrY+e6kIBji3P3wmGZqmoCGohCpD6P6s2v8VhLZDrEdm1QYmnuJTAJYAvOKR53j6WTRCUJPg0lzvwsuDlZubhtiAPlNfJ3PqxMv4I/hh0SvsCEVCEJs4QWV1o/xzI3v09NKe0DBLO2rP8SLEfIL/UXB3Mc2ScQg0GfgJLcJg== 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=CSwk4mrsbP/IlP95SQCItlUNiOZrW7VhvxjtbF83/ek=; b=TFp8OPjzeAQr8O+YSLdHNcgiMTB3Y01OgSnjKHDZTo9OSTxh69gRXIwtNW123yfA9ELZS/O1XQHhPCc/rthCMurw26W7LlYMX5iOe5AGDzNJdL3762Y/UexZCrjuGnBUYILbsZncq6hFGD+iyn9sNUrB6T+xRN/0788qSgWAWjE= 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 AS4PR04MB9573.eurprd04.prod.outlook.com (2603:10a6:20b:4fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Fri, 1 Dec 2023 22:26:00 +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.7068.016; Fri, 1 Dec 2023 22:26:00 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [v5 resend 2/6] i3c: master: svc: add hot join support Date: Fri, 1 Dec 2023 17:25:28 -0500 Message-Id: <20231201222532.2431484-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201222532.2431484-1-Frank.Li@nxp.com> References: <20231201222532.2431484-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0022.namprd17.prod.outlook.com (2603:10b6:a03:1b8::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS4PR04MB9573:EE_ X-MS-Office365-Filtering-Correlation-Id: 51db0ffc-456d-40c5-c01b-08dbf2bc7f00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DJja0YpnTLFwlhiM38BF5+aQon7UW3rQpahwsNjjRaL11IujSVC3nh4Fwy3GmMq3aD7PCTFGMPPvW3+4k+NYpR2U/MXRDKce2haMW9pCr9oo+QLRrieLHabm/qe790jslUAANa29TbvBh78VKuoFkEtdvEyjJNbbRzZ3Jb6SB/c3obNIWJxaqZVFY+vl/Wm2KXRamxNWOnOeg6c18fJxAJTxftzP1My+2kOJBlcg5pw4inyDo4X5RI23RU5xgXn8MBP31I3mRpiZe3rhtBe6xzLthxxbr6fCbG3jvohhtgI1DKK8JJwQUQ0TOnXjXs8NvJtUSPntjhziNszqxVIy96n1iHkAl5qRqu4LfuVrcNbF+xXtiQIUUnKPiEg5whSyFfoLU+F/DTdX0stZE2C/mqJu/jm0EnhCd/xd9zJFd0ZRDzuoDv2Gd9nY/f5G5Uk2UgKrcev/J1zkdDAJnYjQ+svjvB05kJfNFJGDbE6nVssm+y1Tq8lm3+tdDXU7sAl7FfoDFS9gsiMf0nISvNLwFN1RxludjbY0JvakUgUCV1OXpfs1dRIYR+0UlcDX1SBdmpW7YA+PDVWqsy7WJpxlqwfCWhBdVMiYj+kb9w6OOi1aFcf+gz6hZRq9HiQ0GHqwLsNjm1+KHamLKpYeGs6aP3Uwvn+Z9Qqfu7M3iOjuvzc= 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)(39860400002)(366004)(346002)(376002)(136003)(396003)(230922051799003)(230273577357003)(230173577357003)(1800799012)(64100799003)(451199024)(186009)(83380400001)(86362001)(6506007)(26005)(1076003)(6666004)(52116002)(2616005)(6512007)(41300700001)(5660300002)(8936002)(8676002)(6486002)(478600001)(2906002)(4326008)(316002)(66556008)(6916009)(66476007)(36756003)(38100700002)(66946007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5ZVCdNGAIGXhJtZaB/9hrw+S8rpIsom7ui/guZyewXMg3zBcQdsXu0fuF1weTmmM2O1eYGFszIaD8llkyxHYrdNnk7SJtMxoBVnkQlTNB5sy3A9kBB6820uSRUZZ+NYQ6hqtAoBo+h/CYp9rqp0IUUfOjp367F0Ig4e0JfkYgoWJNcHGaSdLFrk6EE+JVO/zGfYHXdw1IJevJHzvLynrIulHQs5qJEeIUPLvahYW8Q/KrjxiHYfxOS3PIVkBDJuaNFgmSduuxssY/DezINwQT2//GvTSrXTVqz9OhwLMXKHSULDBsoi6u7fffww8MR8r3UgrsCM15g0MkZE8YIF8p3Av0pDTU88L8/guPvKV7Fu/aioA1LZRC5I2Be2u/a/Ky+VrNLQ8rC8W/Rps1tLQLpUxO9Nq1A4wYtaV3rfYTM/k7IfPUaR/mhwHV4q3EGqkx3KEGTCTNn11KeVdOSCTL8n5tVc86gW7o2MitMBVuNYErAmrRbL0q717gPpZI3LuEuwcI81JtNZSluTZuRnVgtrLDfQyxygiMpWlLqS0euatv1sXSaHLeC53epRNevJ2lBvCtCX1gH/xCUlXFJGwvdUUBpwrqRF+Vu6kTXzKawP/6lrYieRULpkdxaR1QhFLtvvAaoHb28wD68GBvdgxDHOYHhs5OHNdN3c4XOzdyG6U0nNMpBTXvZxCu0NaAKVNyEk8e0pcT0qjG0mqs4rvASWuPhcwhv6OnrWZusTr/BxLT70jRSVGjDIR9GKqt3NviVynwBfGyhNODIy70JaHtrP+lM4q1fDzYSELTpKpeDITu11PPwzfwGFBt+pIdYSGpKfkGbV/SEcscFRZLuwISjYtFSh11pTjq2EiA31wpdjrZDccAEsSbHRTmtAucPTeSGD3v59WUjMhn5R8y8sgKHNRGWb5pSjlw7YcibXITo4+ESaIg8zu50HBa8voDIWTTng3gKnUvl93omvu/F1F8oWiLIRsOJSCYiPahT8vGBbnXVjtFRNqD6Kx+wWadqMWxd0rmdV1RcKRsMzbJeU/OLqx2h0OPB/Ws1mLkD6emMC11HISckoLm9MytDXkCFleTHzKyqGYWU2cjcM6iJ4QXadd8zrv6xSrPeQczl4v3nbp5imLqQBbIdRi53DnR0S8XoX37v8QHnvtx05G5byTJ5rnVf/QjHQqqVKnY+w7b/VsbJj/1wiJKChLPRAehS5qYd8ZGP9h9P1NyWsE24rOj03yBwJrQlWQ6GG6iUfg1PHFB0yZg6FFvOlUKrBx6JgSRRLizlOyMPpD3a++jSbNfDPAJVZ4fRxvB16a18Cp6AvUmGLV/fLmLRUz8Ssg2ewKBANu6yEMlCGk8nitnT+Rw+AUSDTTbKbE8vv6NWYJm17ZWAJ2xrIS9ARI5249jnmAZtK0O3jUZuXF53QsJGVCqxNoMmaEHntt4A7C8ZdBW4lAY310LnWI8Z+1zwRGwdCv7t6N4YKMBEXqeVDOV6xXW6IWTw21tC81vcVYctCs6vB1uXy0GV+SPa9DTg/L18/zrlNmukM+eOItfOhLh20KQGDl698wL5nq2p0+ujFNtLviPkM3SGkFCMQII4LrFMxE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51db0ffc-456d-40c5-c01b-08dbf2bc7f00 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 22:26:00.3007 (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: TtUjwv/rEeiI7RTYtXKH34/CcUOJ4ZudH22bKDl9Sha+CnMuENIn3R6zhTCKDN+27vis84ydwUnd74KgeczfCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_144157_872651_61B0865A X-CRM114-Status: GOOD ( 16.99 ) 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. Disable hot join defaultly. User can use sys entry to enable hot join. Signed-off-by: Frank Li --- Notes: Change from v4 to v5 - default disable hotjoin - add help func is_events_enabled() Change from v3 to v4 -fix build warning All warnings (new ones prefixed by >>): drivers/i3c/master/svc-i3c-master.c:212: warning: Function parameter or member 'lock' not described in 'svc_i3c_master' >> drivers/i3c/master/svc-i3c-master.c:212: warning: Function parameter or member 'enabled_events' not described in 'svc_i3c_master' 2 warnings as Errors drivers/i3c/master/svc-i3c-master.c | 61 +++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 6b6bdd163af4f..f2058a36f869b 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; }; /** @@ -219,6 +224,11 @@ struct svc_i3c_i2c_dev_data { struct i3c_generic_ibi_pool *ibi_pool; }; +static inline bool is_events_enabled(struct svc_i3c_master *master, u32 mask) +{ + return !!(master->enabled_events & mask); +} + static bool svc_i3c_master_error(struct svc_i3c_master *master) { u32 mstatus, merrwarn; @@ -428,13 +438,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 || !is_events_enabled(master, 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 (is_events_enabled(master, 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 +484,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 (is_events_enabled(master, SVC_I3C_EVENT_HOTJOIN)) + queue_work(master->base.wq, &master->hj_work); break; case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST: default: @@ -1471,6 +1486,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 +1498,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 +1510,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 +1569,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) From patchwork Fri Dec 1 22:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13476539 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 4C4BCC4167B for ; Fri, 1 Dec 2023 22:41:53 +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=U2HQF1ozGghvNdfQdj6B80eDZHnJ+J3IKECpwbOenY4=; b=Sp+Zrc/p4Xpyr5 xfKTyZ1g8FaljIEmyx61nK0KCMR0hvbgSApfT2Ux0u8PNe9rxgvHvcoMfEqhzAbbEMvgAwlKuy6z/ NVt5cQnjcIcu+3Vldxg8nue+DJtfWGzua7zUDFjgMhbCpBhu6CtZ76rNNfajRRCn/OkYWBnAah4rg szYxn2HjGN7oefafOHLN9JObrl6eYnQqZZRI+W+yJtD5TqUvdU8siO1/d7iVnvNdMgNK80NOLK9QY obqUA2QP0Vxa3Q0PG5ps+XKTjmTC3HuEY54FADfHNpes25kQcIghyN3yaizseNCRbb0sANe/Eu+8E sZp5pXmqKKgllmR4ymTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r9CCn-00EmRW-01; Fri, 01 Dec 2023 22:41:53 +0000 Received: from mail-db8eur05on20627.outbound.protection.outlook.com ([2a01:111:f400:7e1a::627] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r9CCk-00EmQN-0h for linux-i3c@lists.infradead.org; Fri, 01 Dec 2023 22:41:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gI7dXhz+mYKhvnBa3ybrOW3r+AYM4CJIEfDUfaB2FdkdzJQparT5uepCVsTvOeQi76ZKEqlKcSYDJhO6nLsFYLPT2Ui307k0H292HYsv3E423koDQSTtMciPfCNFGpQcia2JCvTARfjCwTAEM/53EpXc7vbT0cip6i11C9zDSmbj3dw/n/Aigu9g25w8X/RknflevVynsqe7nmrEGRW1THmA8DhwAbgDutbrjugrS7Qi3p6z5aSkeqUY/oTyQeO0UjSg2nl4s2wcHH6Bfj/iTEpywGkZbfl9cPfTWwFV9BmsBYbhxLppjLBmCxWzWmA8pNIUGHGJUfyBSxMnKEOyFg== 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=ytSmslj5oOfXj/kvlZ0mw3AYP7VbssW1sje4uneG+bA=; b=OOu7NicjXo4y4sfIACOBfyQ9K18eeIXJmF6Gn21M92G1L22u/e23kPXT1VSy37Lq3/OpBY53XgbXVaSOd7HFikztr6DgacLArCUd2uqQhxws01efNcPll7FUhX/PL9wtWdZRPuc1TOd+6HaoP4L9drdMiPx1+VBJux++gz/jFbUweGMgfn20zTjzSty2sg9CFYhPLabOkczCqgCIpzdDWSDhwIDnfjkm9eYeBZCQnMWPxG8SF4I72UtTc2VFAhqfrt6oeeCpqq2zUAYlj70cPeDrV9YvKUYeVe4P5o/rfMVtaYWewCwcHEMwBC5+og0E7L1Jpl+cPRU9Zj7uF4JO8w== 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=ytSmslj5oOfXj/kvlZ0mw3AYP7VbssW1sje4uneG+bA=; b=JOunq7HbhLZHE+jT2FjBvJBXU8XQmL6FcuzAAtaNuJk1NgJMykpNoWKpj7DafQZ8vB982rtRWNwmXdW3XcKxJ/ZVx11Yo6Dv3SSmJ5m73KtyauzRwJNrOtgidbFy2Z1bR1qlCneWLIhyK2bUKIFire7aURyG82h2a6eVI41l2qo= 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 AS4PR04MB9573.eurprd04.prod.outlook.com (2603:10a6:20b:4fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Fri, 1 Dec 2023 22:26:03 +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.7068.016; Fri, 1 Dec 2023 22:26:02 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [v5 resend 3/6] i3c: add actual_len in i3c_priv_xfer Date: Fri, 1 Dec 2023 17:25:29 -0500 Message-Id: <20231201222532.2431484-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201222532.2431484-1-Frank.Li@nxp.com> References: <20231201222532.2431484-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0022.namprd17.prod.outlook.com (2603:10b6:a03:1b8::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS4PR04MB9573:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ad3cd6b-5a01-4d9c-85fd-08dbf2bc808c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vKP/NnJ07gyG4MTJe2TvXhceAzuQsoxkj80mFiMAnF8jJu3dq1mXdNfEDMvnwBHZSJVNUGZAIwMajlKheXIN7dbRjhJ73S8RzPvolTceunNFOhWdsjlmJA8BgOLtnvNv1lUdcLtUoeJ8ZHaJ4MfurJ3viwnIF3g8pRjHe00TVBVXNv4WXYz4PB20LrFa6Ew6EQaMv03/N2ASke5I905P1+G08izwV/FpOCqRZ35mZ/xiUn5oBwZi8ZeksSs79ClcJuCnF7HxNvZf2JbnxylJ3Jo3ji9HRGQIk2EQj+2IPMDC6vmOe4gxGIxOMZU825xa3Asgq4cqlurTSwVWZRw2meETwbhsxEn6U4n6KKpNdeHcgCDgI7woK9u6z9mdyUF4PxiY3zMlg3BtU2F1GdGsGdAndNMOgudecJNklqffDk7Hu3twF/goyykqimkgKIpVljLoFqoA9M6LlipjNUY3uKKNuHcoGnfb/Y5Gqjp1SNdF5BTRClYGjtG5gck/cJhraXLYzFPqeeCWqvrhmDYaTPdkPw5E+sepz2Rp7eHl4zht6Vxa/2TbCbYdkRt3tOfbI1tQsZTRJx7vsfvkObIU1mqXtoBeZFkpDJUtym2T67yp5elfOFgH6g8CMw56f90s 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)(39860400002)(366004)(346002)(376002)(136003)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(86362001)(6506007)(26005)(1076003)(6666004)(52116002)(2616005)(6512007)(41300700001)(5660300002)(8936002)(8676002)(6486002)(478600001)(2906002)(4326008)(316002)(66556008)(6916009)(66476007)(36756003)(38100700002)(66946007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xyD1ZsRH2UM37hHcIj294gaRDhVI?= =?utf-8?q?UtSSHLk1eu4Fc3YotYhxNkpBkxyYmUZ1T+wtK509LhT2nl9+1YjJom75zPc2mv9gy?= =?utf-8?q?0GxskZJsFlYw1ch1H0Mv4BJXEmSDaeGYTQvC96BD/qgHLhSqdn2qOnFt7RTo7Bgnb?= =?utf-8?q?JVsV//hTgdDzkvo0DzqgQBoe3aZ4HLyzFDGrc/oyIgiVeI/OPn68QjZZkr9y0JtRK?= =?utf-8?q?pYw+AC1yLTzQvc1FrmUIhKHtrUXxldqojnc0BY4mNx2p0Tk3Byi2FGYLZlTky9zFp?= =?utf-8?q?EM2chG2G0hXxLX+OQzzWXjjkUWeO8/n8v0oiAepy1yLmggq0JMPqRlxpUfzVKwwX9?= =?utf-8?q?6Tj56CA67O4ObmHrepnDQOflHedpeEdBqVlvAQ+oE8WO9qS4wPJxJcWU3IGASSo70?= =?utf-8?q?bwGoUclTd8V3t8FxlrZM/3GDtNm9y8yXp/dOJTvIBlN/60NqubrUEJwUsXMtjAcPj?= =?utf-8?q?qwFPejeqM5QE5CUEHQetMjVK8SSG5HBpwTfsja3ASlLvptfBkHt6ihca5RjUDZU69?= =?utf-8?q?FM7AHj0KDm8frOu9Q0U3zDtb97kvc0WjlUvhhaKtt+NyHbekPqfmufj8Wm5GNIFfE?= =?utf-8?q?5w1iPLlMwOazsLg1xebeMF5QmHmAafOtfXyOwUOodp3ArwgVVWwzfhbJz4K0AjOAx?= =?utf-8?q?7r+vJddQEUwZ4OV7uK6VzRBhWTcEN186md7ssV7w3wT0lEGFxUTqCRe8z41wikuD0?= =?utf-8?q?R1j+xue3xddF+LYiAiXl35bky+hd1RACm4BJb0MZ9R6t8tmx2hY5UTiNIWqYnmDEN?= =?utf-8?q?tluHPGMhjxBGf1dBeyn2l4f00GiyZC07IEK4pMXHg4LK3nzGECOqfKNNp7zjj/tTJ?= =?utf-8?q?cZYtpxP3WXoARPD7KUw6VJWpFe8hv1g6XSvdM5iWM1cucdDzptdFjQss/6YlV76O7?= =?utf-8?q?U+oSv7WdKoAr8rkigJitDav/JWj5iIixCXvKWvEsbcto/cg1J6SQGfB606vbEsr/h?= =?utf-8?q?d6EdGSH7zYoE3EXLxwzeLCiLnU1E2eWidzg7EGbYh+1O56CegVcOn1V+IwFEnMRA4?= =?utf-8?q?08ogmhKVAVreJRDxSvLDULzc4V1+99jJh2oVzvk1WT7LPl8ltiqio/hBvJzdc9WdG?= =?utf-8?q?+vw+NKSUtYXFcwy0JXVlG/Ft/e4zaWZyonI4TsOqbRnhyxcX/r83KwgEY19aM5eG6?= =?utf-8?q?MKuYs9gJo4gzDwbPwoBhI+b9+nYXVwj0nkKfUyza6zADZSY6AbZ0V5qdEgMSgxQdO?= =?utf-8?q?mLMwhghFLdCqf3L2Vsf1QzRT2Tje6QlePbTUL6HfybxEOoe4mdk2D50V5HAgschtW?= =?utf-8?q?kZmyPWytHAM1DuL5ltxLFtx5FWrG0oO8OEzRZBBzmKFsxUrgLVKJ3s7P4xcdUFy1Z?= =?utf-8?q?wxRVfS3rqsxcfB57iyha87AaWPmWDLrXtU2Utq4UDlerQxt1AlBNFF5oe33SqYBOK?= =?utf-8?q?xcfZ0bHT6pSwKXwiY/jgwz/I9y2Nx1M0GV+RdjtGvQNx9aEVPA8rRox6Gr78QWwGT?= =?utf-8?q?A4izkVFfjvXWH+4fmgcikljE057+ryKsyBf/06A2cDCRUq72OSmjYsa/mhk1aQpPO?= =?utf-8?q?fceX7qCQxfo8?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ad3cd6b-5a01-4d9c-85fd-08dbf2bc808c X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 22:26:02.9291 (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: 7m/GcAvMDmJACM0jynTnXT43VoZZzdffftkZpGQ1NZrlIVHGLynb+jb92++UVN9jXtJtcE4m7n+h1zXPl7qOAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_144150_256882_98A5B205 X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. 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. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Notes: change from v4 to v5 - Add Miquel review tag 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 Fri Dec 1 22:25:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13476541 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 ED07BC4167B for ; Fri, 1 Dec 2023 22:42:19 +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=k8eGGgEjz1oblNDd16RLvCOFBB/unow5f75q9Bz5PJQ=; b=ZbuUwP1K92d7er z7YJW6ZZivykAHJlEtm2Zx84PxM9JoYwZ4wkd/3USPi3t/iy5hZUMRFhojAGi8L+FbgkT2tNAmDPd XCmGPll23F0wqD+7ckCft/GI0vYh/+SKo2dFKrrB3vKk3443GSMtjmt5vfg2XRihrO5PjR+FpPh9D Imcwph7EU/hKpnRXZgyWTZu1ZhZ3Jr8ZGGnWtidbdW5B4jD7Cpd9wlRcS79ae32mjfDFAUjNriYUm e0+gYnN11v5fO1rfHqphoVCbDlkLeXMiLtM2k1A4ML+LVuFr2KXdU4d/t7wg/Qrd3H9T1RwtGLbvK X7rjCS+BebBH7BZ40Qyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r9CDD-00EmVv-1y; Fri, 01 Dec 2023 22:42:19 +0000 Received: from mail-db8eur05on20602.outbound.protection.outlook.com ([2a01:111:f400:7e1a::602] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r9CDA-00EmUt-2v for linux-i3c@lists.infradead.org; Fri, 01 Dec 2023 22:42:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eUuYK5msX9ii8yeSTLUcONLGnDftuResJdKkw1kP6xRQ84QgmLZYkk/FP5BVlQvVlqAx6rEWh3Wfc1OZLK27bCJhKJZtNFV276bmD6GffhhszQmLYqUUTsPqGVQJEvubAv/GbBUff351z1EDGtYV720D3JwbSTi6LzPF7/zoRLITQCeugkeOYWmkTQoHiPq9RBadTii2g1QhZ4NFwMzrJlFVDOjCKNxJktREoIbMudd734hLox5pC3AU79oLFN2FzRg2MeH2WQXHPHcxtx2k7g3c37AMccKCxQoVW8aOQ5Rsh5ihQB5BQDBciF+62eGh6i1+Fi3Vcpu9A8T7hMWtBg== 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=XXDAhNm+DCe1srAC+lBUWMnfd6Ayz3DSi20A50myyuQ=; b=hw+A5dOaA5rUKnG2EGLSxG4lmQ2TWMKO/bsLgaJQSqQte0nqntArkVIimwEmBmF6jtjh7JKwwT9KQbrnKTQ2UWIwuxDVz2mjIl0R06U2KSx8ILNshlvaZdOG15QbX1QjE/9w4etrdnW0rTMAjGHOtXJ2A6u12K+YzprPX57trz+0OnZm0pOb4yXklsejJKnMRiACcHpDY5l0LvnymgP3CVFwqtgR+lnKj7skiDfCyM41jDpJqVw8xpyblYINbzOw85OaNAv9QZXfSGjfMf7ap5GEzbVycZTbyTl6wbxw3Vsl7idLmXBLjgdzJIlKIEi8+X8UQh9Rs2b37MQiemqvRw== 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=XXDAhNm+DCe1srAC+lBUWMnfd6Ayz3DSi20A50myyuQ=; b=BiWV2Yi8BoudG1dCfLMF9dHOMGI0leb0xfaFgasZwD6EFXFgTYGTjnMY5n6LM+i3B3JHn8/l3EpqHV5gD+eyfWLR9pLnFS/pjj+a6HfaMcj8PZ2JiazF4k+q+zZSZGLDKwdAB9uuxNeypR6jWAPVLMpQklqFZaPWALYU9auRHIk= 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 AS4PR04MB9573.eurprd04.prod.outlook.com (2603:10a6:20b:4fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Fri, 1 Dec 2023 22:26:05 +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.7068.016; Fri, 1 Dec 2023 22:26:05 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [v5 resend 4/6] i3c: master: svc: rename read_len as actual_len Date: Fri, 1 Dec 2023 17:25:30 -0500 Message-Id: <20231201222532.2431484-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201222532.2431484-1-Frank.Li@nxp.com> References: <20231201222532.2431484-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0022.namprd17.prod.outlook.com (2603:10b6:a03:1b8::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS4PR04MB9573:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ecc0795-faf3-4e4d-d547-08dbf2bc8221 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 804oIkrUZLt1JqE32wR/UoPLmiFQWLgj7jwxfMBnDlQ/my1GHEBwVLkqOmrCSWpvVjF4UEEm39GGNOby1sY6U+5v6lA1Zz/CfyFqQn0uWIaoJNf6TUiyVm5OjWUcP1Yr6nc7h9h4S8cwi07UbfTUdzlvkynxj3V4Vtbkn7BHLjxS4NWV+18JkUGq5lwEmw+MfW5sREDBSSJL3uOTiqeZLDGhr0ym1Q9n8OVIE0AwzSdIfjQn6L5fDIE23gsWc/TBL55fxpCMbzBc3u1ZkK8gB8cKcZKBgOo7h1fw/Uvmr1Ous3bw+EZZdsPm+2fZH1VjkpYpeFgeYVfvSzGoMu5fxhXIGTmQ/EzXz1zzbSJQTRTzn1xSMDb4ac9nXPyo9jPHDaU138QyJaqmuwZaiBzk7N9oRmw3AVh1lPxCakx8fz/vizhCgYFwh89jw3+OB3abC2185K/igtEpo51aUfFCKrzRP85+zui1noIfQl+zpqJY+MTC5JROkDiC2/ENGP4BK3/8+pPrkjgVxAdncOBE5lZkcJv5rXKa4Kjof++D+2Q68mP/VAIvtDhwK6kh+V1I6EV2fyc+XNHBSNPqKodSYIfOaLLxzirZxUVbOFns8hW8UYHAG4IN/Bzmd1tjNU9t 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)(39860400002)(366004)(346002)(376002)(136003)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(83380400001)(86362001)(6506007)(26005)(1076003)(6666004)(52116002)(2616005)(6512007)(41300700001)(5660300002)(8936002)(8676002)(6486002)(478600001)(2906002)(4326008)(316002)(66556008)(6916009)(66476007)(36756003)(38100700002)(66946007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gMwAQf7vX7kXqhUrSiuBMCVeWFFq7RDOZKpaooKJGo0WWFNMGNHq/LrnlT/gqw0uIpeOmJlQ7CZmfFQMf4k68/LFsiUoE7gIIBmCaqFizms24QGh/+HlCVTC2aU0qp/8GjbD4yxfffiEAOA18YejKe5IczC9VzcPCw0p+KW4PK2WNRXeeiZnUaZFAfunoAfZ+BV65PgCiyNo7042HyybTUXn0v2yCravHbYv+4BIfcn876MLhGpaP3a9sysCRo/hMXxa29OCV0U8iVHJtW9P6qScds8XG6fk624jJqmBVDDCC5GD2+keLuwj3ONPS4t3EaqCIUjUXD8JUtPcxwUWMaujkRSnGMiDdPM6Y73nleRAo3+YQUWmoTwDog4qah60G9d8uxCuZHBo7hYQrFi7wevLt4NVs3JwgQiWM72waAh9cF0f9sOrpX2yGpbOWE8j9cWW1+oW3iXzuqiKSDJYjDYDxP0qE8w7k+YB737Hf8t6HOwuQVAnK7jHlZ42s9+4xiEROGPkqVtBjjz1E8dCuQ1JML0+OKyEGdO5I8khLi8VYEFLrmhcybOMcC5iH/rTolaLuWRKnyF35Fq+6Vmv9hxSYYUubyMBvIJsiEFVny4v2Lekztsj2jybPcZQRVZ93TUTWM6T/oe5B3tRUXBKbzKTkDpa3+ntWGlNLp+aMvhjIk7nANjK7dqx03LShMmEpwqR5yprpfeA1XAnWFqdKH7V3oA38NAJ3M4RCF6vVFyzoMNo2pvkDVd6t4/03QdK3z+LHAKR9AFvs/t4Rbhz5nRmt7wQpXfl1yZ9TnseCoLXP8MAp4ZnuI+0kytMOPqLfIXAt2Cpj1DXNrr39yMSb1xtvP6occXNkkLE0I7jp0T94dugrwjI/wUKUUDe9mmrOy3cUXvbOsUeQswa71XauaRaF+EPR5FGrl4co5zB1MXImfrLiVTswtQ6Tv9Tf0Y11Tyt1NZPM1T/rRdeKG5d2WA0MTJzJ8XMmep0bilYDFRrppWPtqjo9bm44tn7lMQ40hDNdlx/kMuE2a+YfVJ3QV/gjr71o6vArmRM263mTYrvbysc+cbt5YwjbzqDkBCj8zPYd/1EIDWWPRNOmEAhF3ZzHooa4HvXSQgwxoLSWTjncJToOBGeXZAk36/72y4ftIwKR/V47O+jgwvdAR0eeW+QsFE8Yiy2najLvWpr+0y3MFMjUCVt5ErHpWpQfVcGznbZv0UYYgLgRYjeuH/Is+w0gSTEIlENjs6rOXKJKrYFBDWj+YOvhM/7ydSajo2tV5MasE6UueCGZFbDv3XzIiq4RyveJgiN8Zg8ZDX8s29xEykg5x/94CndlJO6L8lnuQ5VUVnOLRWu/p8tko52+pik0CrurPzegkJOBWVxVAOtsBhZNPyvlMg/u3NkfIqq27qAi+bJXyLNpE/rSOcyW5JqonHXs94gQ0kULWHIz5zR/W7+JSbA9/GZxmWQKZfsMhdny7bHsDKbqaikB6yTDM8k04FOBRvSzIy/LYTf6fFzZ1LILpO8SkYFKI7NGZxdaOm8mbq1Pjrkyuq5BHtS8a8b6soi/t3C1Q+/kNTe/PKdFlKRgUya7eA0WfOBlYh0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ecc0795-faf3-4e4d-d547-08dbf2bc8221 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 22:26:05.6014 (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: EKBLPjwIntT7m4tEhFRpT9nCMr3MJF/sWNsMqlAM0tn8Owx1tKAWzX9eqK3CbS8uOoz89YZobsFiG1rtFb/Ucw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_144216_947635_7F6D1BB9 X-CRM114-Status: GOOD ( 11.17 ) 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 --- Notes: change from v4 to v5: use i3c: master: svc: prefix 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 f2058a36f869b..13a8b3c2aa541 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; }; @@ -1038,7 +1038,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; @@ -1051,7 +1051,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, @@ -1089,7 +1089,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); @@ -1171,7 +1171,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; @@ -1257,7 +1257,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); @@ -1277,7 +1277,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; @@ -1295,7 +1295,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 */ @@ -1305,7 +1305,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); @@ -1314,8 +1314,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); @@ -1365,7 +1365,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; } @@ -1405,7 +1405,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 Fri Dec 1 22:25:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13476537 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 A23D8C4167B for ; Fri, 1 Dec 2023 22:40:28 +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=1c5F4zWPCl8nWO5AZ9s+7+KXWKpUrf81bbCJyycpWvs=; b=bawYEnqcI6rY1x AqyzBwc7+ey3u4lv2qQREYgc8GlNyUOUbS3LrEiGPjn2yD2kwTm10toCL8VbsBGZUmD648uu0sox1 zjWwhVSHEilAYu83JhrB95RADR3sTZhikrLpFJyf1bnHyuHJyB37qS/j33zFtDooSSzNBsMd+GYQP akm1zHr6xoA724Wz3NihLnmpodTVYmHIdiWhlHYjLjG8YIOTrQU0+w++saCQgJG8xfKQ1Y6BnCXi0 cMbAz5EBdLMSsEsY+VYCDVgdVLBrybarN6TFkQWGO2T4/EcdhAB8sOwKhQt6wV0mu0VnP+i1PLvUZ 9dE/adp2EMk+rn5xRWAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r9CBQ-00Em8A-19; Fri, 01 Dec 2023 22:40:28 +0000 Received: from mail-db8eur05on20619.outbound.protection.outlook.com ([2a01:111:f400:7e1a::619] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r9CBN-00Em6u-2F for linux-i3c@lists.infradead.org; Fri, 01 Dec 2023 22:40:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NSWHchDzwVSO6I+2RcooBdWwGwhwblMKBQl11kupf48CmiaOxtCfYjQyLRQV94mcGuD3GOGUIn+TUIRjngJyZEv9+FNZ6ElY+7gCYcS7TDFVD1z+RRdxPxwv6A2DKAHy4yUUxhH5jlaqnvXzMcvLlisx7BYpSRbLxjQfjjTTeZnU7vOi5nqk7Gw+2QwUEJ2tmYIjrwpfgCAzcB6pA/3R56O2HbAN+QbNRHv04hltCtUbnEZ99/MlHAAyui/2V+O53eznN5KxAyA2vzRY8rIm8j55ddmwecW6csEF65eoxirWc3s2xECqp6I+MXw1LUPtr69Gblgz0WTsFwzQUr2ltw== 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=QZK3nbhXsExbv0Znn3D5HF/BW5CgmYGvGvpxgFhIT0s=; b=j3M5CSYXH9+yVy35GhAATf2hepFfDTdfI4Qh+6dbQsblAxGwJMAVGn843scHkY2yZxVPyYC75q64AdLb/fex7PZw4/3NKFKJHCmQWAyQnaDXEJ6N9idZrI8R6hZGFT0KU+6sd/iq7Hkn3F6x+fSRN9/TvoC4t88y6T/l9gi7qdolvtQcl13muXE59i8XVF3CofSMsXn9TQhSNl7UZaqkrMtHpSoOFBv1jML3pjok4ni0APLiqvJDbfuhS/LxMnIPRYO7QR+6vz622OZX9nfcHCh85C6Mcw9AViwXyQw2WM8C0ZQp2wbhNfxigFMYwAz3RGbjmc1elN8U60YPaFOBrQ== 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=QZK3nbhXsExbv0Znn3D5HF/BW5CgmYGvGvpxgFhIT0s=; b=M3fbhi1Uuar5MdcfOk4AeIpkb7dOadZ+1RexnoPFBXNJjY0eQd8N82s3tBGxEL2Odj3zG2Hs6fnvUxCj++vOFtCzA4hcjUxRPobXLQu3mdGnOfoWVeDjry+G/+4Og7ICgKmvgiL7cJ2yplrwkCJU8svNs+q4GIDkd6rkM4QBSxk= 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 AS4PR04MB9573.eurprd04.prod.outlook.com (2603:10a6:20b:4fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Fri, 1 Dec 2023 22:26:08 +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.7068.016; Fri, 1 Dec 2023 22:26:08 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [v5 resend 5/6] i3c: master: svc: return actual transfer data len Date: Fri, 1 Dec 2023 17:25:31 -0500 Message-Id: <20231201222532.2431484-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201222532.2431484-1-Frank.Li@nxp.com> References: <20231201222532.2431484-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0022.namprd17.prod.outlook.com (2603:10b6:a03:1b8::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS4PR04MB9573:EE_ X-MS-Office365-Filtering-Correlation-Id: 366b7918-1f91-4312-e94a-08dbf2bc83bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1jjMXqum+sE/hGrx8e3XaUUDC5r82rKoAK4Ney2fxyHM0yhinVOG0ixBJuUB1i5QcaI3cdH3YNER25mPM6KGwNBgEG92k8FEsCa0x8+InVnFJ+BfA5vsHMMBPb2Fik9875CJsO/Dj5KCHyy0TVjJ1WTrq2nTJHZ/0bcyeh92ughizlrlFCRh0k2iZwOLKGmmlI3r97N2KdEXJS4lidsVDMOflzvkioEUTmcUumxkVWWaVehjB365BusXe8YkWQrfvPN6neI77+NkOd0uUFbkFdm+2F1/rWZdjZW8Lg69TU97BUw9qiuEBap7Zlu3mSgdy6pfNc29I5sNMV1M2JKP5xQsrWo+llHo/B4vl7ACB9I2e9BhhdmWBV0l7jsQVHNd+3w7YDZfRLQeprV+Id4PWUD5qLan5YzAPQsgJjttirSlxM2yGsLhq6NXLl1ZcIWHz+MKUz+qO48MgKE0RxDO+rLYgYVSC6EU2/0drw28d/rCnJ0HGYBoMBDqCSYH0YYgxrujQU/FyHzxWIcGaMLzh2DqlfucdNrRSemfcEGHJ99OCZgR2QwqESBYOwX6HcYEc8Jgk06FfGuBMd0dxZnOHojf2w5CUEy6VqvY8Os7GWoIa0+WHo+cHfIeFswdb26f 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)(39860400002)(366004)(346002)(376002)(136003)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(83380400001)(86362001)(6506007)(26005)(1076003)(6666004)(52116002)(2616005)(6512007)(41300700001)(5660300002)(8936002)(8676002)(6486002)(478600001)(2906002)(4326008)(316002)(66556008)(6916009)(66476007)(36756003)(38100700002)(66946007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6J+m3IeuWmiOylioAIIPL0x+9yFnigaqYLlOvn9Ft3gZUUnxcU18cpfUW5m6dz7sgHSo0Q4GmLztUdgLQfep5pGpzKe2wFVUkaqHlN7NWxWs12j7uAscWEr6Idc9sNdIZ0h7AdXuzFOrJvWfqaI+4+RrYFImDyXQXCsHOL+NyQWAit1hU6940D7vzBWIVw9EV4LVOgAFG5NllDF1vn1P82pr2QF1hAZiqNWgWbHvaQqdm75oLT1ItqlogpwZeYPKjcCFZt5g2lEB1Q0fe6YtxL3bcaQID0sRcjNf2NgB8FNg+++UCbYHye8IF8doZ/jVt6e8PNHbvuM3Llhhxr7zBgWF8B6x1X0xsH9wJAV4Il/Ca4+SqdIPa2ebOGf8wg1dT5trAV6ThtPP0WkuWO+DYXKSuLmGkqHJsUyQVNgWq+Ox7GDH/p8ie2lwiVfmKX6awP2juQYnzCyyk0Q4d13uVIdd8anulOUhkUf8Tmy0NKnxk/LKkrrPindCQcUnpxaGmLv7QobeQJXsDspyLUUJaejm45QmbghEcFZ6pFLwn4HI4sCB/6snViOR1iVyQpOdR2pf/XgMvc45XniUcbperBBza9Vou8MNEJ94BbmZ6tLUFawwSKMAOWsIMTvIkKbxUsaT5VD8sfhvw7cKosWSJqd9YFRRD4tamzMp8UTDtAdJ2uv8twvGAEfnETgo++ntGFFQx0uzLR1v2yVVkzvOIUzSnhgqA9+2A04vx8BSkpCtk8GJxTN92INYAhumlpJkVeIBlewx1968O1rI+fGFxmc6En+TBvxx/f9m5mz0YbKdOyghNhqkhadJZzx1VRbd+aTa2QfFQVOG5f5ZV6OBGRqkG2QDiOVn4he96s+MYeADjpawbJWv2I5WzbWLClpHr+HwN6A+NbxuVUb9c+LPiNADxzjj2r8Zj6SIgrGXuWPw0Xxq4uF1UDsmjeg+d7n9MuRG1e+0tW2ntqJvKEqbbgz70jS496uT/2Kh906MjDl4c4tQu+OpG5iulzPujbNKdZIKQSbCwSNBNSrOcI1ADoXkMYZxPFEs7RMt5Zo6nIahiI03J+KIX2E4vX/9tH9WbKOigcCAzWauvApz9T2vK7rnbT2HaFfq/8ly6B18G56+7U+oFAORJdvSHrV1/pVjwTuavwWaluwvQ6HCoZ/F1ClM/b/z1S8+mX97CgIB+ptWURW1mYvCvxIlmbWNN0N7r07SWuZOCeBaiRgA1T3E20v4bxnqio6vN6ZK+r1Ss5KHhsjUjW/dkQlDMuuyJxqM7RXSD0txNCf7d4kcLEH/ZammhQujz05VhNJSBHFTlGZPE2nynauo01jO8QhGCpM7Rcbf+Ib88PMoeGCBgAv24LoCGbsiO1pdAUZnhdK8vtruuMWeXrThbxYIAtzrEohz2Na0SpWUQZxXYqqv2o3r+yhvq9PvgrCnDh1MlJGTx9uuUOX9oVm0C+7yp9JRn1M+Wf8NZppYw5/hD353WLrKEk6I+OSHTXrlOxHb8dZ9ucECjuEfcZkm0xQ5PCNiZEjX8feXGlfcV1cXntCB7ZriqVilnSQR870F11NhHpuiafiQggmTblFiDKSeDaqbW7kg X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 366b7918-1f91-4312-e94a-08dbf2bc83bb X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 22:26:08.2467 (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: 7dVlk5+EshCdBsMS2KGVvvvbqI0syIe7AGdj0IJ66CeXtFIiW/KN658rZdefg82As4ozqZawA7lLqznwDsMaDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_144025_735443_7FA0B01B X-CRM114-Status: GOOD ( 11.10 ) 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. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li --- Notes: change from v4 to v5 update prefix add Miquel's review tag 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 13a8b3c2aa541..bd10bb698da0f 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; }; @@ -1061,6 +1062,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; } @@ -1078,6 +1080,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; } @@ -1173,6 +1176,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; } @@ -1360,6 +1367,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 Fri Dec 1 22:25:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13476538 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 E942CC07E97 for ; Fri, 1 Dec 2023 22:41:51 +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=xALa8oVef5FJoufDbBy5/LwK1Ru9XQl4DGVbM6AlVyU=; b=i6OkQjINBIF/bi E7rRW9L4vFr3QASn1l5s4eBq8pQILDTA9jc3LYFpQpbIE0K5LNZqBGZa52i8Xh4djipb0kg61J7IO z9OYi0Utc/QmtTwrRiJbOC8F9pcl/bBgrWw+nPvEn+s1Qj+7TGggSjXOQJqOWtfrUf/ZvyftznTc0 3VY155Us7XSktbRCTMKfiIojh7QM7gcj8VarY0gEWUmOVpTCYckpX2Jw1/m5Gd9IBCsmGIxSsI0+K ujHJIUQeN8PcRrh4DclAmCWQdR1xme7cII10d2A5R8e/YT6TKQnb4iAq4MmOKBx1wZCOunmSw/mrE ww/JWULZH478TzzEdZZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r9CCl-00EmRF-25; Fri, 01 Dec 2023 22:41:51 +0000 Received: from mail-db8eur05on20627.outbound.protection.outlook.com ([2a01:111:f400:7e1a::627] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r9CCi-00EmQN-0x for linux-i3c@lists.infradead.org; Fri, 01 Dec 2023 22:41:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPNNC790ltESOQ2eLaifteaXDkyeF7bj/B/9hYQ6bFs2cI94K/W+4CQUuEdWBPEXBkPDevHAKH1u1J+D/GxyJhuo+/xuvv1iL1WXQJdRu/9Jjw+Z5bWj0KMHjCIcHLt5U+3Sy9O6ZY8DAEDL5G7xOZAIXTH8/XV59KCV2XmuzfhuyK9NNleoxBO+r59vQSXdVZxNvJ+tMF7u5Y495cUsgYs0Z/I9UaEMx7yi2V1SAZvyCbGJmL6IObWJGFcpcEyjLBT0GbM+oacWTScluO1cqJIW4RKoaRmH0vnek6r4/WrsOiuNF3CkYm2i4FgOmMnZJ/gGtbqwuTIVUP1HOuqldg== 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=FUJfh4y+uyDpoIRsDDLcoFS7UqmQdjwckiiFGvUdGQM=; b=dZRFAtfjUxwTYMR1Wun3fiC3JzdeU9/672PvrlzrsTFz7xy1YmPH0gkHgEa5JMJqOvAgF/FqvZV4/YD0WXrECNh5eFzeEKz5KlCxrxWHbVhq3/FstSPsmCbPo6QiM1Hb4m0n3bj7CvpZ9awXSDJWGFHer8ASFfinn4v4CjUrLvL/oHhfgFzKKUO8ZU1YjvbP7rMMvySjyVD26K3nFGjmizq3gi+7MTV3aCZKswpvShHUtqKjBQooNzg1Kv/aJTZVWuUjS4ggFxjOCqnNdQdE5ZyJ89LtzT6HVxkNaz7E7+ZNJCb6X3eRN03Ls0/zgFX0HKQ08WD4MBGkMv8ZbkZLHg== 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=FUJfh4y+uyDpoIRsDDLcoFS7UqmQdjwckiiFGvUdGQM=; b=hue24GSU6ydUoHWoXO58NQo3bWMmxbxSK5oWfUo9N7sDJP9UPzbwKUc6Gv9VsWt9KXG9cIIyoqCBIChhEQyuPnadAjgmktqPsl/yWOGSNdJ+/lnPyCbkPyNjGInDhMTYKTDzT0Iy9KhOnzfT8+BdDVwkHdwMrJZqeYtTxX6Clsc= 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 AS4PR04MB9573.eurprd04.prod.outlook.com (2603:10a6:20b:4fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Fri, 1 Dec 2023 22:26:10 +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.7068.016; Fri, 1 Dec 2023 22:26:10 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [v5 resend 6/6] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Fri, 1 Dec 2023 17:25:32 -0500 Message-Id: <20231201222532.2431484-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201222532.2431484-1-Frank.Li@nxp.com> References: <20231201222532.2431484-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY5PR17CA0022.namprd17.prod.outlook.com (2603:10b6:a03:1b8::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS4PR04MB9573:EE_ X-MS-Office365-Filtering-Correlation-Id: 9749e2b5-c88f-4dc2-d62f-08dbf2bc854e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tzKcmsMber+YWmSvxvUaIUCWnpLSOEowKGO1+rtt6uOzvUN7ps9IdOKJhwEcnq8fNxbZfbKC4NgqN7xGk0bQd2e1AfM7uNp1UUoAESy+euP9ALb3s9j0xMtJlsGenrfq9TzW6mUyX6R6U7rNpoCLEvPUrtKuFbmu4PB81latjEeUl6BhXciTM2PeNkQAbtHQDQpwbJ2W3bFZtrHssIybhAHu3j1M9VNJEFqFR/UstSvlwkVDkKafvRqtvQSBjFNF8bajs+bUkk5O3ft+brOTUIvE57gWpm8Y6BuVp/FapNzpgFQN+sYm30RsLDlnLxlR9iqTgJdC6l8WYgvCt7Ym1dZFoRNnNFms+fpzeQIHMoow0Jd4ShsNWt8KxYRXj0ELorPlGo1I9ozy6MMCTgnIjaW4qhNV4J7YE9hKPJmLj03rJhKZVSkAsYHg6a9wudR9/1j0fLeC27Tb3mWGFLcZU48eC2WUoGUjg8C3CG2PCtEcTD9BXEPj4kGdhczp3EPrRdG4RrWwNeAWLy2qpQwgEese6OdrvhKXcSQs1WxW682AtfWj2KBH2K/cD0Bs8YZQ3VAPLmbxFFmaFXbrA84u5ueaLO2A4X2Qa3qIIicrtmY= 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)(39860400002)(366004)(346002)(376002)(136003)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(83380400001)(86362001)(6506007)(26005)(1076003)(6666004)(52116002)(2616005)(6512007)(41300700001)(5660300002)(8936002)(8676002)(6486002)(478600001)(2906002)(966005)(4326008)(316002)(66556008)(6916009)(66476007)(36756003)(38100700002)(66946007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SeKz2SmTZa98kF2FD3jNDQyn+9EsLDed3LNdxGXuHE5XveAgYMazA3ik/eMCyBRlBQBJFABmBOc1EAp3NG5zKCR7jNUu84xt9wxApsmTBX4L44qCMYETznlnvtOtIFjK6T5hGltuYNZo9UUHvmM6x/8bCBoxLycLM5YJV+t9ae0qmUUsSskSaYQ8UYsFqxnyJCCp7+U0YwwisVRwEfyNKSgcsUNIAr83V/ID/0ymkkkpuRYv1oxeMTDrgWU9wADyXbwdnVenrxMTDxF6vVfqXr44TorAjEK9hxYiUfh9KUwFL/OKwlNVys90ETvNnno83pTBKNfEBds6YuLYuSc2iCzQykp+8vt69HN4FfKAUX13ZR+Ab+b5/muo3iDpZM5iTRB1cmRWv8gXxoHZb4/kkgBsM2c6U/Doz7hoqrRYHXAqSDb9afr41Ok77SJCFm0QLUA3JxspEvlIrh7DCXn+/YPsv3tePdF1ZoePgrz0qFoLjHXg7Zup7L5yBBs50CN7tKSTX+NTBnGya34iEOcpbj3/ZhrEdISjNYv0Dy3rzbh1ufyndqJkiVUy/fRy06ZkgPvM+kF61oOIeRnAMaWDmKv7An5GIb8Whqnerztm7CnWFfVxjxh3UDgZVvHgOovpPBLfP9pDvYZ/Zc8potNc2p4mddkXGUaRHteBxFZxgKbe1hGr9dHXCyd8TK9uijLCpSa0I4UiGsy/OJX9QWTkMazcWWndYdm00tBfmfGynXdvpXCD2DF1F2KhsMBO+6hSoTrTzXI2gGpJGk2AxEuYPaKOSfGWEc/9M9LubgZXimXEN78lC0JF7mO5ijg/WeO51UDuX7oCKZdYScdJZ28vpu3jeKH5OmKsRJ/02AmOL5egO778HTvwGeZaZtwBcHDNFHWxfVEstFmVE3Th0Ne3U9ZW64rQs1jq0TPNRtMvdh0k7KqsOa+j0WnEYgRGfo1RqvPPcjafekgpxfYwFf18PxZ2ESGsRNdYj/8/cibpmSxeL5Jv4/GQk3YbXLWVNWbV4jQP/RmV/MAHwzEBIodpk+f8Vv6GFGrQziA8A1+LtNivB74ymZGhcdP8i72M9Y5I5MXlBoX9qGuN8qd1sKSEDNuw8uGllp64mjcRIy5qHDHNlrSsKEs1cXD9TI4q9wmwML6lJAPVFTl/QjqPIJjcjGaGMPscsjuKX8SBFFLndBaBtiG7P+0eiJ7EvXEVHTvm/LrWCDNSj1aHE3eCshVTkuRTU5YwVC+8mBoga/WoweCIK12nPfSw6YBMfs6vji98fYklQ+EGRbocxn801TpooRlz476yh+7VHu4zDW9nn5MKCXHBPQXhk8w/Mk7oKICDFJ2AUtjxSXS6NNie6q9b9sxqldkMkLp7bAdvSgaR64Ms8sr31XfC9WX4mRTSLFruT7svPNJhKfERmx0o3+PZmIkzeWXcPM5FsJJX3I8tbzloVwH41TJylKbaJClUz4pnJ/5kyZDf5dSDVtY7ry9E+lLGcgXG6y38HwOH9814D80vK1jApnOFU7C2KUjfKl2ai77YxhYPuMkkHw3Gez4kwow4o+bgwxlPIoh+DANvZ9lpp9GiG4DawPGtHyeO/a1W X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9749e2b5-c88f-4dc2-d62f-08dbf2bc854e X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 22:26:10.8798 (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: 69DL4H7GH6ZiF3kCVeMlpaUJj778oUxq2pY+hGIwbE6A/x+oP+b93bIQO8m23Pi5lhcdYBmBUBM+fwLWidgQFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_144148_333901_C369F8D4 X-CRM114-Status: GOOD ( 12.03 ) 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 --- Notes: See below patch, which call i3c_dev_gettstatus_format1() https://lore.kernel.org/imx/202311070330.5mylauLR-lkp@intel.com/T/#t Change from v4 to v5 - none 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 d3b56c9f601e2..81611a3e3585a 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2923,6 +2923,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 */