Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp877690rdb; Fri, 20 Oct 2023 01:55:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9ApTGyOmDIrFk9yoU6aIBQlKia94/Tfd09b4FimZ/gOSzgZCHLXRcwycQuvN5gr6zECMB X-Received: by 2002:a05:690c:f08:b0:5a8:1e98:49b2 with SMTP id dc8-20020a05690c0f0800b005a81e9849b2mr1903175ywb.45.1697792146249; Fri, 20 Oct 2023 01:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697792146; cv=none; d=google.com; s=arc-20160816; b=XiwNCNGEOfKRONAJ9He49BSPwo7f82wLLE2EYhh+d5O/BqrCEREE2WV2JQZCUIkUhL 57K8rQDubaA2WNPJDJMnUyoWKDmlLbpz9jmlManFUvbu9e9OL12NwQ1CN2D1vmnOEGqe z1NXw6FxK57XLe5l308lq5/sSU4ZWaCMQ7/G7JCHDncm7x/qESX5gxVDeuknJErtg1l4 PCCQnvbT2YOa/Dd/zIrdlDok5aVh1dlie318dvKV17nJudsvYKqRjbgKHYXRG9j9iLmZ 1Vpxo1QaW/h7Kn1D3h3vlQh4FotEYeu5eK5Yh/8uCmhvK/kZI3PSTZI8gfS2ustUlg2d yk/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KNLxMHQ+GJVucWTMnkVow/BDexDh67/axsg7AlVrM5A=; fh=cPEZvn6MIPQBMYtL+Xl1bSPHsR10wI7rfVb8kGGj/Lk=; b=r+R6fpNsMrLEcWMSgDhWaqe27x+nDEM05VpikAdFLS5MMHIYAbBLpkrYos0tq/fc6C nKmC+ZPKKFjq+xOrxmMxLmB8R5WIbAb4ihSA42VrHgj78vEzkYslF599IOPFG3qgkqd1 v1KaDyVI066rdpxXzQhHzzseKmFgw2645sc51pTZ4kAnE13HmNZA3juwa5chKUSXgmrF keklhZyJ4h64cw1nm7iQjdYWDg92GW6VIO1oOPRaNV8GnJlCODzDrjWNiB7DahFGg5MO AGaBCfkb681/27Saysw7ai9EfKs97VIUmsF4dr71xyugpQWZClXcNrH9eOxhPpbno0vC 7klw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tl98TuJ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id i12-20020a633c4c000000b005acd3068202si1422936pgn.552.2023.10.20.01.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tl98TuJ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id E7D498028046; Fri, 20 Oct 2023 01:55:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376532AbjJTIzg (ORCPT + 99 others); Fri, 20 Oct 2023 04:55:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376487AbjJTIzf (ORCPT ); Fri, 20 Oct 2023 04:55:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AE3D45 for ; Fri, 20 Oct 2023 01:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697792133; x=1729328133; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ldKD9vWG59M8ubPGySLlaVJYtWih/t+41frfCeRocik=; b=Tl98TuJ6/fdsdXnyK/ty8TV43KP4hn53Fm4EKrh5tQ6XGQa5QiQCh9yD 7VjVwA5LhXqWOC2X0KLoWfwhFtWFNaxl3KntcVWxKcH9Beo+DXna9MbdP swtYBrNNhG9qEKbAi1hUr5ZXZAU1HY7Umg2R4OIbs3UOIOlZljScU94OR udOo/0EscG08711qyXVtaOyxGW37iKrZnISwBtWOd7jcWW/VXXPPIIqUO BUbq7RKdXScNi9Q92BkcAikuMPrmgnjCdFXJ2LoukI9mGomHgdGTCIKs8 ErfN7QSBU4E4RbsBgeirjxvk2J0QUkOPwJScqNbqlD7XqIcAv+Y1mqMVu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="366690149" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="366690149" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 01:55:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="750855353" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="750855353" Received: from linux.intel.com ([10.54.29.200]) by orsmga007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 01:55:32 -0700 Received: from [10.252.61.130] (zlukwins-mobl.ger.corp.intel.com [10.252.61.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 2B53C580BE3; Fri, 20 Oct 2023 01:55:29 -0700 (PDT) Message-ID: <57efe6de-cf65-32ed-fd1e-a388e1676c70@linux.intel.com> Date: Fri, 20 Oct 2023 10:55:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 1/6] i3c: master: add enable(disable) hot join in sys entry Content-Language: en-US To: Frank Li , miquel.raynal@bootlin.com Cc: 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 References: <20231018205929.3435110-1-Frank.Li@nxp.com> <20231018205929.3435110-2-Frank.Li@nxp.com> From: "Zbigniew, Lukwinski" In-Reply-To: <20231018205929.3435110-2-Frank.Li@nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 01:55:44 -0700 (PDT) On 10/18/2023 10:59 PM, Frank Li wrote: > 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(); What is the use case for having HJ enable knob in sysfs available for user space other than for debug stuff? In other words, does user space really need to enable/disable HJ in runtime for other reason but debug? If it is only for debug maybe it  could be move to debugFS? I think that maybe HJ enable knob shall be available in DT so you could control the default state for this feature also at compilation phase? > 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