From patchwork Wed Oct 18 20:59: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: 13427905 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 9ECA1CDB482 for ; Wed, 18 Oct 2023 21:00:04 +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=0QXOPpknmhKX9N HRPL3UO19LbZGVb6RbxkhZmTsGkb4xv+skWiduuutnf6ArrUWwynsboU31NvwVgY8qzC19Q1Ir2Dr loAuB2fp2j8j2qgxuYJNjz3Fz7qHMFgV/dvvW4VwhJ3M1DvQjs2SMtbwo5VQ9vmpMSdVzRHHAIND8 BOKXDYFa0MAJiWd1szJMHaiZWTkMRqaDtsFVzShwYvI5EMjU9XAFlhSoCuPSnLW/INGx6u24FcZRr oRqc8ErHLADtjGZVPA8xgKWirO0jjrSrfs0a4C81pmRi3uBZ2FydO6ve0IVo8EBrnp0Y+8LnbvARU SYA/3jDeAsPxlldHQPAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtDe8-00FgnH-0c; Wed, 18 Oct 2023 21:00:04 +0000 Received: from mail-vi1eur04on062e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::62e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtDe3-00Fgk7-39 for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 21:00:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bnoHfGes6zd4u8U2AOxHG2CvtC3lFVkMvxmnFl4OYrPNvMJR0mMYoYSvs3/FCClORrlynCRhvTFDBl3kYCS9la8V4ggjQ7RXM+7fPO1X+79l6X2VREFoXrSxAsraLispuqc0TEXiLAiQImdSDBNvDcxBMlgsSnvmCUu/bV3JAcCu6dJdMJarV/agImCXB5skM4MRhBH5C1fDwHtBCx8HG0Oxm2V7iV0xxjPWGvzD+nHKjKGyIdwtreyF4HVHhSDk6zgA/ZYe1R+XyxAU4lcxeAUeRGuiZD5GxZBXQ6S4cTwXkrN9UTI9hg4M0XCTPcUWuXbc3TU8XcMeF3qRcSO/Tg== 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=ZSrHd3Kv2pxM7Buna4IKFGmK6BaayzbUyN2VocDevMDP/bzTvqtHe7IMegkOmD/8f+EY5PhB+V0wkJgHg5pJA32TRznNxLgYDXHeaM7CCq4T3t+Svfneb7l+4PxfvdNxm1ljir7wiX1L/86cufKhhz/N8Ic1io/RQclhOQqHH4aB3k1xiUNxemk7VBP0ebFKSU6jAelb2mvryD8R+/J8Qd8Fx+F5iQnEIfyfJdctyS2v0YacOizmE1zRc9BnNssoJHDs+dsaxAH9h0/jGyWVM5v2ZPJAGsMSLQ/j7MJOuy4uGKvF0vXqzBM/8bd8LgW+MNuROawcHUtep1zwa92+JQ== 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=qvM+vtYSVT7iqOG//bJgA0yG3dNGajkOnC8wfRPun2mtCUXeQwsbDCFkDFWT9oNMLAfns61iw1grQuqiY8CatZjdkpNaCeC1facGhapmQVBf40xAox9ECKuzLybCVFoKEEzdRuW23hkhujF+yGoGUBRMSRAgzvZs4eCxDTDE2YM= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 20:59:48 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 20:59:48 +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 Subject: [PATCH v2 1/6] i3c: master: add enable(disable) hot join in sys entry Date: Wed, 18 Oct 2023 16:59:24 -0400 Message-Id: <20231018205929.3435110-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: abd18189-f3a1-4fc3-5fda-08dbd01d29ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RF09ZxiVNeSIRC55hGj8pNrI9yPilx+/CSCqq73QJggaocvl0CuCthZasWMBCwyDiDDnhSM9/D6M4Ak+/NzScVDSiUzIkbU9tjZaUmOuCaFWH0BZjnOedi16RF5tIuPcLggttyX93mgn2ifUaxNFeQnzNhZvgHnZsQLTqukl7MdZnUEIW3WG9C796WqkWCSa3MaUSSX9ZYK7qvEteiIVGw4Y4SO84cAIDLrktaTmvki26xnCezWlsWQPWDcJjXl2cQtlAgC/tzRUNPE1p4BQeU5k8uYw0mgXAf7jhcVD0Zotq5xZr+JBJRttoNaES6TnRXBv4z8Iedi+z9cr26KDaZF0Zy0mKkOIWTRjFUAjhInnKb93DLbI0nSNlRpR3jPNaa8Sgo2av7Ux08ua5xcendbAORNSqrIY39c04SGDsmrmyzeDwHd1AHeszpFjToAbwlBQkFg4GvC09ozt5pnEH2miArvV/zGn1C3jMm83DTUQS6tAUnb2/co2uU5iia2mjkCVxXu/eJFX3HKrVepncwipgNneUS+b9Y5kpGko3YCeC7hi2zE0CfnmzReWQWvFdnx5xSA58bgsNeKiYg4qc/7s5eA+DLP7D2L9RyLkVWsqwC/4OsYKUW4saSFsTQutb7pLJJz/sflet7fiD0TZow== 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(83380400001)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Px24vC+CvtzjwezD6mdI5X+kUJxf+XHoR9MF9z1PJWejZEDTy65opOKQaFukbMiJhNDXOsDmRM4Y231VSeG1lREGF3YkCWG9SV6vej4DVJgn55B6/KpjFZDFcB2Zt4cDoB+Bb9adQnWgttF3sb/Gt7+nstWB8tnuhPijwHGQcSuPjeJUffGMYDLDKDy0PNvSxg3aW24TRSXy9nD6rHWXgQabL+Xa4A49hVMCAUF9zTeZKjOM0nYlmcqOoeRdfSot5z1Ljna62s4HmRv1/EEmFAJVgvWgZDrrdN88epBdTSyjCgxuegulmJatB1IVF051or6g3q/dfEQ8tGFimQwFSQ8XyMRwEzsjjSbmjJTKQGO9oPPmv9WiJDJqj2mIf/+ItJFzavbua7Covvq45yiPEsJTYQKhBkZCAuqQ1MJ1q6Wmj7x8J2pRZctY1rwu7EbnuogyavTIQ7u27ecF0+ZJGzTe8p+WYQhOafR9zXJnJc25nI+CssLbKhUbmCRCGn7p+RrxikKoz9ooFd56WtcCyurbNrZnWha5uN8NHlHWXOEymXSjZCgG77zNywbF9zncezGX1rZsjLWm72KRm95jyd90x3HmwQEbvEKmI2S9q8KnOR+eZ31IAzhVczulA8e7UoZbiJboNHakp+9f1RdwRL+3cu41NTRJA+gMtn3Rap6mj2wQSIvytOmIeVAgqM63Ai0Lz5zBa3fMUC99KuMzFi92ceelDYT6lB7rgy4+WeXDT8YcPSkThHiHtlXNmqTtN4O9KmFjJYMZpynDqRPvtVfwSD0ZqJXYW+iL4tLkaV++IfcAlEQvAVAQNF9YBKa57jHh1/LfT2ZUk7eHy5lhG8LyW1w6zzuiqr59wPOSXBmnpdZ7Z+uapnPusVYtJpBB4fjQmKSN7FBV0oHImmePCXvFB0IRyb84xPat0VKGcmgt1HfC2D0iPH/cq/wlw1CoNojQyafHqruDHGiEisAgaMROAMqL7xv2/JM9RTW56z9L9OEyiHygyb7woxH0U4ksHVJNYNoyR5VB6YwHZcbqi1OeSH7pRuMO/xB+yPyjoV4yiKnQcyqNA0eqIVkv9c5v738Wp0yTpskBmgNKA3PYKrVoGXUSoV1RGtH9nQtKiqd119fMupVlJOGors8QWUYgzf9oqlZSKZdzYkSeb9bSAPmeXK8JoqDfmDB384CBpgWQda535cN5d4n0LuTdHNa1dMlY6rQZsJEhhfkjUCaPUHHIvZI9Yr7wdq8SpbrChTxBm14q42cewQXNeolR554x1jRVwcy5fViM7ze3/i3ifJ0oF2kRq10/VuQNNXESrzoUJxv3x4jmP4mS/DEIuBPRUUH3vEL4Oj88Gl6A38UA4Pi+QshDYiPwjRkK+VCP7KYIzJ8y6G4YqxbVneGrqC7ljiqq7nHaMkTzaedmnP/C16Gw7LDogbswNlWDLGzZZK3DFKSr/+4upzHK5Hkm6GS1jj23ziX1frtWs9iV7L5OTl6jOuSG7/C3zeIYOeUZ//nxijgvmoWSbxhlWcXZZT6bMn98kF15MKEe1svfQAPb6f6BQ6B7/abhgfSk0a4LLu0WJVMgP8dkAufjzBXMCdrO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: abd18189-f3a1-4fc3-5fda-08dbd01d29ef X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 20:59:48.0674 (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: qSwioh/k6nRm/vdWr2UV6OEh9NiCbomkw+qXpzK3egcGYKFgPZEGKZqjlWvIZbWETQFybFWm616bVmgLBBAzMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_140000_019256_013338AC X-CRM114-Status: GOOD ( 12.86 ) 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 Oct 18 20:59: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: 13427908 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 19D56CDB482 for ; Wed, 18 Oct 2023 21:00:11 +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=GTqfceVAQ7HoXzhxTGHLSt8EH6dAOO1k96mc7NhWsjA=; b=Q2R0zDgQ0f/J9A yFx+D2epLmDs3meNE2Je+ja3dIEhFhftigLy2DpjJx9mzkli4hKpKXNv2tpXV0+qpbPBT5iQ7hYHz odlroTZu85imZFbX8pvqBB3tJgpUn11zRwEWWeJmi0A/mwnLjnpWLSCmneqJyc0qo4ZxGNAqL4RcG mNTRmBAtQlZuxm8M/AmI8IgiRio/XRmEC9nVgz+qIhxKJKxdWy+ZSobWomUAX6jgh94O57ZmeUGZ2 5Fk0edPY1OMvLLwLt6R6aZOl1XVYByoYche9p/EzMfDGE5bP8yQB0LBOEtoPbY4Q9WfIvfF+rP+A+ A1FaBQScR8CnAP+++r4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeE-00FgrX-20; Wed, 18 Oct 2023 21:00:10 +0000 Received: from mail-vi1eur04on061b.outbound.protection.outlook.com ([2a01:111:f400:fe0e::61b] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeB-00Fgoa-1X for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 21:00:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgIE5LBE0S9YAQVupmGoa8SessBxqLxSBfgSp48a8wQAnGPzWxxG8NJI+w1yHfCwFt4kSnDjNV9M+yc5L63momZ8ufZqZe5O9U62LevizFPI1zove8lpWEFQsJ5G2ABGN1SMHrbvNWOBiVEqZCR2IY9kiro0BonoGkMNHI2Y02fuu79QX/CrdzDqpXizSTJ8Py8WR3eWM7VELVeq8LV1cmZzgnOItgFEnjzfe9FT/ExzZJpbxMK6Rm4qRGkI7qn819R+2gncNFlSz3A9gJaQhVLt5c8BlpVZ4xicsmd8ee7Cut/YCsN45eQhcyrszgd7b9Iw2RgWnNgL4GJlqYPu7g== 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=aV5O+KnDC8aJlWmP/zQQ2IModh1TPKxQmPrXWRR1tDQ=; b=A6Cv6QgD/rg1XofK+gttbGXlfuKpdcj3L5oaQhzL9+PKYz8b7rmjCEorm/Ez+9z8ow0Tav9I9EUvYjYxNj9s7jV7BrNgYMH4Wh7zuAXGQzXl0Xn11r3B2Qty2GKQpKLmsddh7EyqN813037StQ0WwAvTj1DFLryZENQWimG2VfTqBPgRJYwvidR/BbQAmEKDkjs70u9LsNyvz2wtrAYDxmkXx9cM07o5TiZS86ETEvM+yhJZ4/drjL5Er9POPfUxqHu072KFMQ+4tSWmOT7tzt6HZVrmKYFRUCTWZ2t0rmjmf+p4Jq/mBIR9LoUe5bcvCtxAcAk3nq567X0k/pQfAw== 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=aV5O+KnDC8aJlWmP/zQQ2IModh1TPKxQmPrXWRR1tDQ=; b=DsCmD1IAMIbrZuMZW9R+P4H3FeRde37EYq0mvG4iojuEjflS666cHEQ26Zo6eBuQBKYZXbEO1nppJndpMklSH1EzfHSg81y/tH7FfZ2UNRiZMA0HV8D2ShL6I00xPqUbe2DSKlmrAftvSMKUweUIDbh8fBLCyOYxevk8k/ZR/VE= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 20:59:50 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 20:59:50 +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 Subject: [PATCH v2 2/6] i3c: master: svc: add hot join support Date: Wed, 18 Oct 2023 16:59:25 -0400 Message-Id: <20231018205929.3435110-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d712d90-3c47-4869-ebff-08dbd01d2b60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wRITWRfH++9ljcii91JTjetSDkweRHm3zGi9YCT0HRyw6lnccX55VGtZuQMN1wCUhqDsHKkJNggfXQzrwWWbFeKYSQApfn3Fot8zS4l2oV/ciwHQjJGgTFMqmV9wv8Icg9W+Oln4ISMfCo3w7wEwgwqkdSlwByu1EKO+l5swzfZqUqy7rawFOkxXNbYxk4gKXcTCdNDEJhJhWNedYCf4LDy3ZIVjV0yfoCBzQ2qDA/iXSuLxp2r6bBHLRR3F7xe1giwuyXqennxG0zGA4O6DLpwDMtjSlwRAO+Optj1qGITfk1+2s3uvdl8kQrZAL0tTcDPieUgUkzb9jaMtwDMuchMfyfzqqA6RqqZ0sJsxbQSX3yRZrXV+fET552zyHNA6nSmjF05DUQrtMqhWHHmjWETrmuvrF/rXkcAJuLSCURI0ZWR/FzWopqQQgktCxKYViCGXh+RY5z+Ip7Oy9CKGEsDDfardgYccLHp39EgMbW9QFKVxyB+/6MgyLwoLTxyxUtox0r4vXZbpzx2mauL8/srnGx6wO0zT1RuIjbQDoPlyVCUV2q3IXqk7wI+GorMC/GY/L1zWeQGb6EfoV8aGdoFYN/V4JaEkQ2xEKqKtiBOGIuOGv2la/QZs2Wv2gG4Y 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(83380400001)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G4oR+JQv6kj/xurRzPIelIvrmPF38BLfoALlENp7bleX51JRffNcMRy88oodJ5bGxkYv4coNqH2QvQhCHxpemg7YCY1c3LN8feT5uUhXRuw99YnSoWTmMKZJwzJhK5C3uiuJJIdW4W4APtXnalChf7BrrErS/k4u/5juEUw4WGKXb+dl7HWeCjKDwCZIe0lFQI15iMmQnVDMRL94BXXDyVpoNqk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2w26qKEKL+Xi7DVlUas/bE4tHUDLruvFhO8VCgXE7ucjukz6I2rdl9Tm56pBswF+spFj73Pi9YQ5WTC0mVRYXPbjKQhOTE9wCI+LBRuBRR9P7w4l/uhB7Eph1xGOZ2H/X1EGmkE61wHrBjfF9rsr/GOkH/NUgayD1722mvS5Q2OPV/g+MYnSK/8R17OMH+a5NN4ZHZqGVdMBeVooq9v9wTge6p2AlS9jrG4GvEhO9/kFs3hgqIgyCgjLTsL0qqDtI3cumPPJvYmQHYXBqWxeHYYPt8c0ak6U/nyfDQ445jt X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d712d90-3c47-4869-ebff-08dbd01d2b60 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 20:59:50.5123 (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: WparO/SF9wvAAJoIe98kF2U0Enb+Cnz+oqqt09Nfu4jG9BOBZEPXaUxTp+qvu24u2GZRrBl/6RKIN2zwr9IfXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_140007_527306_615856A3 X-CRM114-Status: GOOD ( 16.19 ) 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 | 57 +++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index fedb31e0076c4..d8467607602af 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; @@ -205,6 +208,7 @@ struct svc_i3c_master { spinlock_t lock; } ibi; struct mutex lock; + int enabled_events; }; /** @@ -425,13 +429,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); @@ -468,7 +475,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: @@ -1468,6 +1477,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); @@ -1479,7 +1489,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); @@ -1489,6 +1501,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) { @@ -1515,6 +1560,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) @@ -1627,6 +1674,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 Oct 18 20:59:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13427906 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 E2213CDB47E for ; Wed, 18 Oct 2023 21:00:05 +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=HfLVSQ7jEvNucr +QGVAf/XmiIC45vNzcNNO6xcxCNjuRv6/5hlknBeCj/FrQgiUEcDJ8F/wlV35BZk26+8+4aj/s8Lb RZA2fibO+ioNsxdjIUwGjcHhfLsMqmRTyNuPBpVl1gO/E0GsMgCd9esYd6E2dUaQ3JEwR6BpXozZ0 zhHvZZ83dPK6d19Eq2SSRVv6v4CBSzuSTh4RTL1rnSL9LjmlcRG/5OigkK+fG25m+EFm8w4Kx8x1o 3qfcmEtyY5pnhFHNKbW5x23D+/nVHeqrGdFQpuGgiBl9gRuBgrxkVBtDdgiNLflEyhmn0SsLXQr5V ijDc1S8npyEFgNJpJTow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtDe9-00Fgo6-1p; Wed, 18 Oct 2023 21:00:05 +0000 Received: from mail-vi1eur04on062e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::62e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtDe6-00Fgk7-2j for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 21:00:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gGgbfbSncd8p2bDrHLNik5lueWy8SbNxHYWAqL+uoru4wyoCmWS+u4TfX5YVwDQ7hf4NCHe1Vks751atTVmsiHU5MpIcsYDniQZ4cnGNAgjKr6kTLO2GVna1gSYvnHOFBHAVr4xU6hZ+RzsCjOvyyy5o1kJ2YcYkVl+PmhFQuwS33da/V/q1GrbvBAdjnLgsMwg4rYNDRBFsPt7Wts2mdmiwhniQYwsc/H4WPC4C+Ue8wLf5zyOoy/Sx32lECo4ZtYsH7FrN05SfrwD2iFMd2z2E1woxyPiq8gc8FYrir0loPlp7CNT+KOzoW4/Qav83FLcvwCTnhcL7N2hPPs+QFg== 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=jY/hTIw/hGqG5Pb/8e5ruRaKvaHE47YflqAHgqfXfvBCgrFiPH7TZ/VA9Gtc4bjzLGT4ZMyHm/A6cBj5v46/qgwZRSpzE309lW7E5GPOD1o9MwZZfE7aXmodxUhra71152lL+kCAnu3bmzGAjN19XS0oAXZRvQ1N/t+YnrClmTJp7iBEL159rpM0fKzayKpdFwvUOREWdH8AMIYM9+ycbM+vNzqu63ib7svqo2lgElDJOLysrllx3aRyAXWK8aFB7CquFzkDPPIGETp1EX++I4+33k+P+lfL+kEAMwpPGa3lZk/1M5X8kTD4CGnOfhoCGgBoSxhbeN7rdLqTB4sLpA== 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=M8Hv1gNKjOSb/AdUxOrgoV3OfRHashw3lq3tM0oBR8AGcsrknSpJH4RIfGWqa4BBFkJDXllS1V7/IHUlDXwWVN6vlU+4bi0iSDjyJmY8/0y5v02WCEymqxwp9qoBD7y577qQGHznXbPIN9WK6klxzyh7tpQls3h/26vWoN2S56E= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 20:59:53 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 20:59:52 +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 Subject: [PATCH v2 3/6] i3c: add actual_len in i3c_priv_xfer Date: Wed, 18 Oct 2023 16:59:26 -0400 Message-Id: <20231018205929.3435110-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e53ad2d-fdd7-4bbd-780d-08dbd01d2cd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a8QNzJRvOtNz5fh7/7kTG7y8nBigabHT4b3YaTA6IFQ2DzRMdPMby72LLsfyv+TuXRuc5EKDwnXZbQFNPTw0kC8cbBnSR0OQ+UvaHdKRb5kEBABBNoP9y59aOatA5o0zBobUGUbCXXzrQoFHCjOY/bJufTrCSqCEi9TdtIZIeQ+b0QJTrKHHQyyz51d7/g3uX5xg01qGpGsBGzxvCefJ8zt75n+Xux6auch7gJ5jfj9gfPXplQi2f8bNS89IiXIpeeyLKL+G7kUPzSvMZh6trawOIgoIF0+nO0UBqwMgFvuJ7RuxrJk2H+f19Y2u64tgD2bMgjFBT9qbiUjKSw/vsZsJPTk4z94prNhVIU7gYAA84eMcqxS9ydSOMZrGIioGjKQNQ/H+NABZfuLa8Y6HxIjNleLZ8oioNEMUfs38Jhf1Hmz1T4oSGUxH+xUHYR71eKLT4wwBVoiqTim1E3WND89KUcBhXD0CyO1+dqWzxoJG5n49Ofa+CMNKHk6yMhoNdldyUnegfEmF3KkLfQrNFm3y+oKk5i/k6qZpYmOwl3HRxYj1xy9q2j8xJXme/B4SokvyoLt4CNSNyy4CX0fJMyRnU3G3B27DKFdhk1Yni11nkq7XpGNxyia6HjvqVHBA 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kkTbY4Clfrh0W+tSr2T09f8rSnoa?= =?utf-8?q?+7fkEzRu8W3sHIEUpK2wSACQIU/Z38ceV+PeNNHnyefTF99brEEA7CyD9nfpsp2mE?= =?utf-8?q?oBqUvx/uxU6LI6dxfTRn/F/IPymbvoFwn1A1nH9nx5H396JP+Sv5EMw1XFHkjYtZi?= =?utf-8?q?s4An60eB/YfshvFSa5E8Tn9A+CkEDjrmVFGAvY5mrEkZTTvcw4vIk4d47zb/XH8G9?= =?utf-8?q?d45+el6SVuqa4HT3MRQupJQnLoqTEKfWp7SmvdPjfcRDDWjyClbVeVJ1eHHUxpa6X?= =?utf-8?q?SFk7iPDV/RfpCmTPYTsdBIjgjGRi0AdqHi18vpzx9lwbjEBhx2/d5Aak3eNuS/Rod?= =?utf-8?q?85SlAyg4zHduHmGDrcST4WL5iTfPwugBMJs2I4YtUHnY1Yk/0qyQ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+8nzLHbz?= =?utf-8?q?+uMH1jGLfkr+JICy8EtOp+8q034p4PNNf3KUcF0vjaREr+QSZRVv5/Tj1aYAnAeH/?= =?utf-8?q?mJxrw6V1rYNLHg9ofzrVvrM3Syi0J6XHamD7VSsxYtxDM2fIt+SDLNsONQdeYWasW?= =?utf-8?q?Urna6sXII4N9h+a5ne+IAnPUuc5cF0a1X45lMbekumJ/GhYvoZog2dlL1Xw3Ybtge?= =?utf-8?q?l9UqFFSbcVDQ41DGB5/vY3PhcTXn3M7rRXV7CPCcVZttnJ3vSODWezBI=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e53ad2d-fdd7-4bbd-780d-08dbd01d2cd2 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 20:59:52.9226 (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: l7t3pknfqVKU8dle9k9zzGg9Gs5dAAs22cI6t5PYcWucNBmZ03wSXWhWCCPLkV5b/80bopHkg/aipAXdi6uwtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_140002_892585_9A657AB6 X-CRM114-Status: GOOD ( 10.71 ) 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 --- 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 Oct 18 20:59: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: 13427907 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 44F87CDB47E for ; Wed, 18 Oct 2023 21:00:09 +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=xxxpLFVQuwdsXKfCYNnpLpOIDdLTBTwc+dAytiWldmc=; b=NSb8Wy/9uPXJWW RIT5awEMlZ5ocW86JX1iFr094OYXSTtO70F1HxuaqawC+L8PDn1SBIhmcqPooYZbB/twy3tKM6HGo c6yPhkSSd/Yknkcf2/O8JhIpbf32akfhfVE3Qn2gJjQFLI5CNowXNP0um1+V6rb3ksZNl4cI936lU vkNT+42yFkTo654+JUwzcY5XbaYt63XBSPGm5e0PgHdSYgjCsFOdFD9JSYYcIGmpuNGErWaQ8WsVz gfjpHEJjvc5liHKvyTzvA48jf/Y4NT81xnJ6xzmZLmyQdxUxUEm5zUwB0wCYUAcuCTj+OEEOvUlg5 1LMHOfbOfaUGic0ogq/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeC-00Fgqe-39; Wed, 18 Oct 2023 21:00:08 +0000 Received: from mail-vi1eur04on062e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::62e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtDe8-00Fgk7-3C for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 21:00:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZRghT4s+LZpzKBlc4IHOaUJXiyFY0dpbr2ZcUvzy1SVZlZ+AU7hq5BHoftPQbSzpdOutZ5zo3VDLODoNlL1pjc8+0GA4Z+Fxx4pUnKMaNzrhGkMbpOKM3cybe/3fH2SADeFNLmnS4uSdKWgHymDnk5dJVOV3eTNlGCgKFL9bzS/t162MGh6folX7lWSjQYV70VjCGop/aHW9MeNQZS45Ak53n9tYKbSfiPjL9Ndo3gqsX+ynm5xINXWbxDZXjEZB57FApl5IcPGuswE7KOqhcmohtYKha8uO+ZsJoNnYdnDI1Duka1EPRBxnLWjWliTamIQIHN8iqisM0hAaPAAWsg== 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=B6Cl60dnoPjAUbmXonCKZDXgPOEMJKNC0aDD2ikB6i0=; b=IUlXNjWAsOlHlblCN104+/aUdDnVUmzQbxmt1H+vHoWUnUPvf54wr86qzinnVOwAQ/JZLPEyth+JAptpp+xdJhm+VT+qsdcDstHJXQ1k1x8FMvjD/3U1psb077cwswWBWy7L9x6QWqFyAUUT6u+10Nu83Z7dE8ApasvIYnEkePGRRmILtKjlSrMsDjTA17pKy1vJDO6LblFRWSabx4/4eNwTepBv50qasvw0CVAJaTF1xRfyXvZP8/Eduj4CmV0wxY4mxCznNRg/AwHFv/F9+V7WazvvoJCK9YLabca8MGVgwJaaWYgCKqdUTjv41CFxrN6mgSJ5gkViy3oDWDyhYw== 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=B6Cl60dnoPjAUbmXonCKZDXgPOEMJKNC0aDD2ikB6i0=; b=ICX8KwTnYMtYPyggFhqvUAU/kahDnrwOIbVARL6WlTPhuwrzDze8suftIExPXclPZIbAwDFsE0obl9cHaESo+RS2l5Pnzk4bthdaeV7Lc3moaEJFiUn2vBV5uGLomp0vcOlGZmjCjRC73svryIL3IgWkg8EuQtpA1X99R/uGsyk= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 20:59:55 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 20:59:55 +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 Subject: [PATCH v2 4/6] i3c: svc: rename read_len as actual_len Date: Wed, 18 Oct 2023 16:59:27 -0400 Message-Id: <20231018205929.3435110-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: 91104df0-f2e1-49ed-0451-08dbd01d2e44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 05+ovSc22uh0dv5Dk8/VPv9/zY7TEN/sQ0r4EyOTEdR0KyEyVi/MhoN+SRvYJxQEbwpYS5cERIc3Jl31W/yS8FlxSiELOz+GdQ+VaFjdEljuGE1FFraAtjmnpi90c5tIWKRDj+E94IUNQ63bJt/K+8mTdKlzsAlmeueBWhsEoWaq95uWwvIe0jySaod23jpOf+SXfeovxR4sv3O+VZ4WvNtKn6Zg1wSbb+358ElifC+c5j8JyA13f4OdbDdA+vPYYQPm5k4mdTLWWORFDxd8Foma2EvhlCgxTopb8aOWjtAhYsKXFqUOtt1EqojyObWFdDRFx254Va3rwOpiCGFIy1QQeykTAErRjIEaHUsnsSGZ3S1o0XJvw7DJUvya4yyksknIOpmfDA0TxBxkinGicOZ35j0tXbG4q3C2URSjNJKnSJz/pqyaFtnUHqa7JwqIcAM0mFov7uGG2T3hS7U0zoJm5ArkUUcYYY88loXQb5nTzW6vkfdC9Qnr15SKU+u3OcZ8qrRRxkRZ65h1oyF5rO3Sn9lN8UAiqSicpP9p1t5KahkKfwyMDviZb6dDQeYGXR+YVZu3nevy1+Rkb+pzsgtiRc3BskoaG0AIwqwVQ7khQdfa4Z6UkBCEwkbC8egO 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(83380400001)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /XaQ5kBo214J62ywOYeK3Z9XaqiMbXmyCdwmlSB6i54gRkrUWFZBg6QspaxVg8ABKFr7HSD53Ct3Ge7nXoIBRQo3oo6LrinFWROoAw8XWrpM8OJh3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/G/pz0YtxkRNNYBVUoaaDxWFdBk64OZWbCqIDseb6H/jgNuB+JyPKdsC9+nsQOo5xKcZwreUwZBDWdmVxuzlkl3c1azTLsAxY81QbK/xaeKku9xNLk7geAq64h/pprV7qusR2DWqC16tcorUD9smXVjZAQhzJVfGQxfQfO4dyrNgI+6d2D+wo/c5GqbFJamy/MjGwkC3fTwBEjR6xvPODZIkacPCSxuszsx2PHhDhxjOE+Fa/QTGZssuOxKAjnL6GT+4/fYqSz6QiIXqkhfcljaMBJegixDeknQNQK/w17epcUOClqWyjZBpQSsT5528l1WQE1MWUdtHn4j31hvpyAT9R4Rd153YW/k3PDp5YRWUplc8jtm7SKDT78PnnqkM= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91104df0-f2e1-49ed-0451-08dbd01d2e44 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 20:59:55.3498 (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: 8aM0h3Gcphr1j3jPfVWwGDNrQBb1OhvRXiRWmbByPuY4CJeMw2BrrBCvE7+pgEucjhaR6QvJcSmC4XwBlSDgRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_140005_030540_32A24779 X-CRM114-Status: GOOD ( 12.00 ) 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 d8467607602af..6cd4cab26141c 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; }; @@ -1029,7 +1029,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; @@ -1042,7 +1042,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, @@ -1080,7 +1080,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); @@ -1162,7 +1162,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; @@ -1248,7 +1248,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); @@ -1268,7 +1268,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; @@ -1286,7 +1286,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 */ @@ -1296,7 +1296,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); @@ -1305,8 +1305,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); @@ -1356,7 +1356,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; } @@ -1396,7 +1396,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 Oct 18 20:59: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: 13427909 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 6850ACDB47E for ; Wed, 18 Oct 2023 21:00:13 +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=RF0xhk7m5oziVf5C5l0PSl/fMq311xDJG6Coj3eGtr8=; b=G0C0UI6I6DjmDX k3ahbXi21rAbRmG8wmwG4M2PaMgmllgdVX7lVlc2Vb63UstXtNy8hGqnTwDosGxiazdOhPHFURRFm 9dNmNaiBQR1yFnKcs5/VE4wslZTt48/X8UcMui/EEh0SgOkOtY6kuE7VzZzmqYcVDJcfBYwww2NSR QlxKs4hWjH5hsw8FDf7MoMnQmEHsj/icil8nydZpEgROgT1YxFehcUAcyurQBNNOJIssYBCG/BC+M NolgsVqr67XY52WAHvhVcyZiSXvbKnOiUdOwUUTA8XHBh0U7ThjyRAcmU2fyU4uBnLWwIyTEQIGpW uUO16LKkkVF+J+0YfDBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeH-00Fgso-0E; Wed, 18 Oct 2023 21:00:13 +0000 Received: from mail-vi1eur04on062e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::62e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeB-00Fgk7-2w for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 21:00:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LAx9Fi/NUKnIk/97Ks0YcHayuAw0p9KDkeoNboD1OI6rlEidXnyIWjFxZBieKPiCzNCTqbEx2rouP1wXOt0oNA1omnqGBOvVwd83xRurFt3J3F//uGs+dI3ATL2POwHBM+xS5lyW2v+8aIwafXGfdq256R1YcWW0TMiqwUV8BlM8p1DIiUuG0FwsJNHm3x46XUm1GmR5SPcAt9tkDli4dys1MpsxrC2wChMCNZijKaaLiNKVIRavMuS0cDvUbkSwP9UTMjrJOnYC9HCUeaqPTx2SrnRZTCRY8yE0VHJT/V5TPbI6kGgU+N2/IpC2FK7fsoB+uNW3y9PplGKSPnmPTQ== 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=WhDtfvRDJLQQEx6FBz1tV1+D+StUUIbatEyD1ujWtxY=; b=IdODSCibVLur5Af4PjhPcIMbduuF0fNYR1PdGtsYZkt1yuqo76mpB9xF/ymHjXkx8Uv+4PUwKRqA/xG5l9Fhy6xXG7x6qkc2s2NuRUtbNFyRGke2Na3Z7Kwq0qjuS8OC/xX8m9rHTIEhguNpeN4boai6wr0VbcQeJ2kwopdSxR9cRIT4wMRzHIIi049Gvmk8t3XOEAusAF1lwPsrlTYL4Efwu3M2HDAQjq9US9vqPXVPEpLhq0ijY4o9DTJJb1JYbqGc101LaGccjhNwa+1bozIwNn5x+EtjqP3mMEVlXQ6RGZP8RnQ0rFFEgIawWdLNlusewnehmOnQkvWX+b4JXA== 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=WhDtfvRDJLQQEx6FBz1tV1+D+StUUIbatEyD1ujWtxY=; b=HSogceWpmMNWAEbbfevIrDMqNjFd5m/IMAGvj0K1Ac/lex8S8wpKsyUHFfh08c5nqCKvbjAHyTYMokEoHKToH5DDBhxms/VDslkH+CUszg9ILS8LalNBk5jULQLmcEHzgK7I2MVdPNI3KRBblhTck1IoIrdqlGKevi1d7lfnbeg= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 20:59:57 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 20:59: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 Subject: [PATCH v2 5/6] i3c: master: svc return actual transfer data len Date: Wed, 18 Oct 2023 16:59:28 -0400 Message-Id: <20231018205929.3435110-6-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: ae579055-1f4f-4ac6-2e11-08dbd01d2fb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5fA9xrhPnbvTfVARSNAGeqbt0obl8qBTlbf2nrK3zRsU6NceKveTifqJ/qqXw9jMGoh/SajPvPp1wMAkOAT+7WO8IXwsZhEBJAjAS4z8mtM7daA3eX8lA8wUd/kT6Y4tODYiKnGJOUbPKVdiFstuf36x6b2o2bBde1ptn1714FrvLD2LihCUJETfr2SEuhe5JGwTFGiIOntq80HRPaQpjmbFlOLXKEVREtU5QQIrNKqFCEJp+caPA4hbPxyrdiFuBjnstgRXM8RH79WNTLB/oxTHS/rmHwYZFQEox0dMexEwnRYh7CZ+d6DEt8LlZzwtUTeNn3L4TyoJ9m8oH7Ex8Hx6v/BsUEXJxOT23ukCjI36UnPbri7dR6BfSJQaZo+y9OzveN76/x9392gP9sh+iS4woy+oZG7OoetQVcfX+E2xJRS9XKueqmLpVU/DFoDiEae2SuhDeSQxRo47oaVuRJdhpBQfEqTBFH8x0veSQG1yG+6uh5RTIFzLhMabJM7/9duM7TmxAXJlqdOXyKl24KGYNhQQTjRu2W6gjxfkoMz9YLj6tyrh31NkKhyZSlVaccA163UTrURwAAgVGljkclyVhdJyaKcmfqoVnI7smCmQ6o3MJpUFs/AmdFexOOxM 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(83380400001)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HmTj7euQlg8AZ4rOVj+Xa1qf9JkOR0fbkfHU4dus6Ipc2Oxde0inDj3oS1cvcwYdxUiPVaD+JwRKNBsA+mVYwW1Wz1BiBFHC0KXOvCjoqRW5OcMuEkAhD15bWKGbvs8zM1ih0sFD0XcPnnKWDwMqifogKg5tkhJaNFqEBYhFzRScymiCBlZVF/GgX+ExkCjaAUK8FEwBtnoDQfbwTe1ql7ai8Q/qBBuZThmvvtUCpxtsACNsaUzgzfb+tWGCxAfAHLDvtdl8IwY5at9eXlxwpit0E/IlTuRPoKJWR9hVj7/Z7KMou8XevEIiihndOwIMVonq1WpJpDy/+SbYizXG8m0Jbavq0H/74Xq4GDK5ZwY5Tuf2CphCfF/zu+hT8Sb6MPq8K3reMgy/aFp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CHxsyV36sjSPtHldR4fdLSjIXxaPKVnrjnHTdhTy23vTK4djgFA8+m5aWaCRhTVK+J3O6mppbbHLPx8YEGt7S0Cds8ax/CQWZ7evCt3IGDnhyZ1M/Bo= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae579055-1f4f-4ac6-2e11-08dbd01d2fb3 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 20:59:57.7393 (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: +5i6NmL/tsXZAqTArh/CCKdvFcVR9InZZfh/jWoJm1nsWvcIV0heTen2OeUwj5yB/oO+2VFA3IY4DCYsXODYiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_140007_953415_169690CE X-CRM114-Status: GOOD ( 12.31 ) 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 --- 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 6cd4cab26141c..17e953a47b1bb 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; }; @@ -1052,6 +1053,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; } @@ -1069,6 +1071,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; } @@ -1164,6 +1167,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; } @@ -1351,6 +1358,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 Oct 18 20:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13427910 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 CD8CECDB482 for ; Wed, 18 Oct 2023 21:00:14 +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=z7Ul3+TMBVslB/ w535gaXSfChjd9fREoXMvmP0g2W9GGszmR9TAiPAi9FBOOKt/0QIGEIgJoStXfINM8btysHFe+7fp 4dueTSzz6j0xhGnqdsN/jJ9HIaUTny7tXHXxUkuyDUOUM+RxL2gYav8nUvD2QJUnRhYyPF1JNsCDo N/94bjUI812wgCqWfTnGRBN7SIUTB2ctIgvCMFcVx/RBK31654Gys4bJycnvBej+swrQyQujZPN4d mcbObvG7FlsCQprUNdaRE6mB7qSrm1I3pSZ50CdeIf0R8rtGsYd6sCaXnp4yA61CGzzLu2Ua5l5CB 27lbai9HH3Z5iji/yqHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeI-00Fgtp-1l; Wed, 18 Oct 2023 21:00:14 +0000 Received: from mail-vi1eur04on061b.outbound.protection.outlook.com ([2a01:111:f400:fe0e::61b] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtDeE-00Fgoa-1F for linux-i3c@lists.infradead.org; Wed, 18 Oct 2023 21:00:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z6Co+EHdWCanZ952ieyV9ceK7OTEHKBS/XL2zdqc/KQejQHz3YyFBIKDmGlvNkqXtw2/wTdJR0G0Nwdl9/ZRPVFg72CV/AkxnTQP+D1YC/w4mg9riJWIVvNv0ZizthOvD36uvv0/V6XzhnCikp4roA+bWENfZjGeHafjvHAab1fThmEGE5shHk5gY2s1iYVz4cOF2AXV4YYojOC2htkZriR1mKEMZlqRGO8iBiRHZwt0ZNcsh0cVdhFfXu+6/yrilO3/4c+xBhICO1YI/8EFQuD9CRAiZjXZ9SJQEzibGQ/BWQtFU9pH41Y/EOaXSH2dmdPHKxhK2tF6PhyqukhOTg== 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=DLL20XYv/p6YV8lfZDC6isrRNpr5/rikRcHb+yG059cJpfiDLkvS/GlRJ0EBTHKAVEzu9ulW2ZW4/5A1mZUVUSt1M23YlT+TUZzirpmY38kPTcPKuRUpXaAqS3NaR2JEA7Z0RKrsCHqaV7GSMgJiFLaAoXuIp2stRNqnrkarilonBXHnqwC+JImaT0uzr/gmduCodWTcBHM5ZS4cm1cDFcmmMe6G1hdh8nXh3mdQPpyJ92+rm2G/LGH8ScWQ0KXZywEIHRbTk+yWVuwfVtpGK7GRfkE6+lgqrsr4Etr7AhfwnJd3mUia3Oxnm07t1nMmCENZfYrWjYo6+PLKbUXC2A== 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=D5WJ5I4poDP9tr8NmTLdruEItVz1b/SI2Bz2I0+I3yIdge48PuBA7jAtkUdsQDVRLWTrzNcfl6FuK1H5arrG4y4B9iyLw/tn5NPLDZh4frYd+IlS8tBCnqNraR5/4YN3eKAFkzfXxSLgYekOX0HTeDsXH3UFZFVpH2IMV4EFoTw= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 21:00:00 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 21:00: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 Subject: [PATCH v2 6/6] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Wed, 18 Oct 2023 16:59:29 -0400 Message-Id: <20231018205929.3435110-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c3db509-38f8-4d00-57d2-08dbd01d3122 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eXmQsfiEaRccNqVQh1deWn23RsXQyikL6+sim2T8w9bQhFls8NLAJDglbF5WfbtTFcVZn40Wp+cVpzAtc4+p7EY5io/41gmgHCW0x08z8dS1usmUc3NfbAI4bj/3OiZXCXsygcyz/BhwsLJCdI7i0syqRf/IL72CxftF8mmY24wj2tq+0mv4XzD85zI0KlLtQGMRakGTgKZt2wTKs3+jjREYImMTINMROSX78pZ86eDQ2eF4hmKTJ4JtWnCV4StR6r7AhQOCjf9V0WhzNc/fAatau6uRuHlGDy8m/mM8I9U78Mr/wnKtqwz2fU5CCn89Ez94Yem1LPijVTRVuUOqsPwUi+CTBt5zOAGmUvIwXfA75WdtDJ3kTZq38Y2BZTgqL9eZDL0ovp3Qjfyd9aWouzbtu0aRfnD5Y287ft5P1pcaIvMbY79Vy+Q2zji0eiOPx7B0MckgwNYfisHpKY12t6qb+HrLqK3KdyHV9l4ViazRFo/jG88525G/EGiL9ZAi8WL9O+BuItxqfxSdxw8KVucbfPb8SxIJqCn8wESc3SOnqKT8YgsDWN0wOtDkJKo4UslyKZOZfGgIylZzjeRkX7u6WPgOtGMzzGRNC/hS2M58TwkuPdi4dZ6K86yXRoxq 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(83380400001)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam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LgnJ6/iGT7aGhEQYkpyXWzz90KXdQQlNlcbUxfHpSEfizeGdcswNSOX3ei/RUd316QjmPomZnF/EiOA7afE/vv57hudmuVJRXWcvr8BoAokP6FwchIRpCASo0WJOAdOHplgmf+JMpyrafxFV9N3eGLIXJnYUeCeWRO++8VmQBZfs1xhYuQtWtD+yDQ9CH7YYx0iqgBS7c1aBBGf1MLAWYCW+wn5J+WB8DOkf+Hjp6MjUAJkhYKU3Yi9o/JQJLJ7er4KlDZmXQ4mOZCK6i8oVN4hNiSBoLc0nq3OHj0pXmsSlReKQIsvOKX3Dzq7/lSlCEZf8Db61ROm4clsImqrAU/Cpa1lzZF73G2PX4+wb1G29QOKZCTO8SKKqCuPclqta0PHUbEJbq0OahgtCzs2EbOOksWiVIo8lq60AzBheCYF/u56cmG/y8saeWnPho6SxocmJ1stlaAhyDe6yAy9jl5TcDBAOhCvJdl88+E33f18XCAbth0NawMBmXNl8hCys9ghp42acDIOjf9iGphf8C X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c3db509-38f8-4d00-57d2-08dbd01d3122 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 21:00:00.1560 (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: 5I2nE/qVE0L5o6XYqNPnaTP8GIM483Fefzids26mpLkQK+4GD7Md7f+4MC2B1TU602AECzpXJpjbBpvYKs1qrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_140010_428019_D24F1F4D X-CRM114-Status: GOOD ( 13.11 ) 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 */