From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3628D48EBF7 for ; Wed, 12 Aug 2026 21:30:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786570204; cv=none; b=aeFana/nDMFfwz0yEKF5P8vgvkTBat6iPAPG0QzsJAGEWNn1beJj4UBpPWIUDeEh/er4MUaKnmAo59+V934No+HHZw9GnOU97ajieVaWTOaoe1eZRVdXAKbFkeTYhF+Ltyxl/SJ5abjOYV5JIiaZajVDK6jKgsUjZopJjW+b+Ww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786570204; c=relaxed/simple; bh=RMaBdlDwb+ImNn1nuCFwig0T5BGm4/N8yEwskc54r3w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ngaZqAG+eb84nb1U2piX1uIl/GnKWZzWup/Yy0SWSvtUL/77T//hPNnEO0KPEvYtUdrYj6X6/t+TrtqVbIHDi9cgpnfRqXNVfjXypeYQkUvTuxxGy5R45sIwTr/NHMvhBUb9B++1sbOsM2Rg061YMxWwdFoesjPDImrBsJU6jRA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=minyard.net; spf=pass smtp.mailfrom=minyard.net; dkim=pass (2048-bit key) header.d=minyard.net header.i=@minyard.net header.b=PIisU90v; arc=none smtp.client-ip=209.85.167.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=minyard.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=minyard.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=minyard.net header.i=@minyard.net header.b="PIisU90v" Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-4b21f09ec76so390961b6e.0 for ; Wed, 12 Aug 2026 14:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=minyard.net; s=google; t=1786570201; x=1787175001; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:reply-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=k+lNtQiclMBYWD4+TIvcyfiv3Cs20RevoYuI2IMjHe8=; b=PIisU90v/RmtmIYZK1LhBKWOoHkDdFwCAFR9lLdkk6TfqGKcaNX7glZLGqJxUSL6G0 mYPePAMrJ39Pq2TRstyhhfwGQOUPEZFLGUYcMvkVfX2jauo5rEMq01N4251kTtrXU47+ PynJojTb36rXfXGKJ6FKxIv5FduhVYd7qJkIhLb4s23rj14Xk3JU//D7P5XUY+aH+ot9 ZoOvKjryBieqTIU/hE2VGXdqMZmBl/RKlnawrtKN3UgYbPPJ69SMBwyHSdQ2lWUqhKPU eATbyUEnMTAj94YovKzTRuMA2LYntZcgNxr9fPhbdYU3RHWFFM9T9jBvDAxuBk1TAzQS DPcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786570201; x=1787175001; h=in-reply-to:content-disposition:content-type:mime-version :references:reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=k+lNtQiclMBYWD4+TIvcyfiv3Cs20RevoYuI2IMjHe8=; b=VymXZgVfKrlSF/qmaIaZA1lYdllumLl2lsStG1ZldYam4UqEfUwwLrudqAOsEF7dhu w4Jzcq0iqxkUzNS7A8w6Whke7zSReBIIt7t659p6022o4qCE1b9M+BNLJvG9tFOj6R3C oZkXswiHxkQoDM8DMa7GzFXFHYIl2xpexxhZCpJwmF/zT3g/Xk2cHPqCKDTGuc1RW4cH lQeSEA+/HOixXGl0ND4XFdapYcT4jFqK2Wb1GfLJFw4E0as5lJiePJxFfSSBzQl/WBEb cGR1gthN50x4kvJ5NOD0DPT7osnuBMlTsv+LtRaJockSPVpnwk3F0EQ/XyzKFFvwiF55 Dx9w== X-Forwarded-Encrypted: i=1; AHgh+RqPjCfRyAx/qT0L1XE2CLJBFeIQJmh2soIXNn0xdxkESCQWtAlKGsyF68GTonu4GZv3qfeazesCJoSSLyU=@vger.kernel.org X-Gm-Message-State: AOJu0YxMurzZLX3enx57Lox0HwmqPvxKONyt4RTobuiIZ51/cRyRG7DL TCTriAQ+gvnqb4wuUAsTJ7xf8GTnYyv3D3JJoICa3p5fPoCg4Ufhu7z3RcdjHPLZQc8= X-Gm-Gg: AR+sD137gA2mro+Hqbfc9V+ST692W6KBOsaTwdmIV91OeEeDrFILfv4pKCnBzsfANSY mnmsW0AOWXjlXPBI0CXw5z66B2+voiLl5YPebADOJ/i1CdXkP+Ymgw29rF7HWIRWTAzoqowB6Hz 5iZlhRxb3m4UkuvJUm9ww7A/tWbCJKoBBr620LLYeBO9SeqcqafZ9PMI5YIYsJ3Lti162PXnIQt 5P3+2qiT73rnCn4jeD2zgN4z+q8UmBUTAJ2f/5pTsZTaAg3jjO1/gM9kQ/yHCZrFPO7gSKnX1My uXyLL4t5963voxPNsBUjpITo21NtlDtqdlbeSpBfWy/8iYcn8ClOapuEPcvQ5msZTRGi461x50U acZ23WsfUBMP67t3xmpgVqaBEGlwNEgThD8nr5CbbrQnv3rIn7NOg+XME1PKbH+8g0NTgsrw18m cWMFZ+18edWkF3SGRZhsUPNtsNcv12a8+Vyo5g3xCtofRclv7ZbPEE1FBntfuQWBrmIF2yaFowr Dy6W8noDd4bJN3nfO5MOI7nd98l1OQbsvxX3rTULR9Ic0JEOf0tFXz2dT6u4s3cWX5Cp0RfS5VF I3vOsHd8Jw== X-Received: by 2002:a05:6808:f07:b0:497:deab:2bfe with SMTP id 5614622812f47-4b2277d0154mr845967b6e.1.1786570199761; Wed, 12 Aug 2026 14:29:59 -0700 (PDT) Received: from mail.minyard.net ([2001:470:b8f6:1b:ec53:8290:86a1:aa7c]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4b223481490sm867292b6e.5.2026.08.12.14.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 14:29:59 -0700 (PDT) Date: Wed, 12 Aug 2026 16:29:55 -0500 From: Corey Minyard To: Michal Clapinski Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] ipmi:si: Add async init to ipmi_si Message-ID: Reply-To: corey@minyard.net References: <20260810074851.306979-1-mclapinski@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260810074851.306979-1-mclapinski@google.com> On Mon, Aug 10, 2026 at 09:48:51AM +0200, Michal Clapinski wrote: > Added a new config option to allow offloading individual calls to > try_smi_init() using workqueue. > > Saves 100ms on my system. Looks like you covered all the bases for this. It's in my linux-next tree. I'll be running test suites on it in the near future. -corey > > Signed-off-by: Michal Clapinski > --- > v3: > - removed __init from the async function > - reimplemented the whole thing with a workqueue > - added cancel_work_sync to cleanup_one_si, which means cleanup_one_si > now has to run without the smi_infos_lock > v2: > - instead of offloading the whole init function, offload just the > individual calls to try_smi_init() > --- > drivers/char/ipmi/Kconfig | 9 ++++ > drivers/char/ipmi/ipmi_si_intf.c | 79 +++++++++++++++++++++++++------- > 2 files changed, 72 insertions(+), 16 deletions(-) > > diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig > index 669f76000197..538a7d3c65bf 100644 > --- a/drivers/char/ipmi/Kconfig > +++ b/drivers/char/ipmi/Kconfig > @@ -67,6 +67,15 @@ config IPMI_SI > Currently, only KCS and SMIC are supported. If > you are using IPMI, you should probably say "y" here. > > +config IPMI_SI_ASYNC_INIT > + bool 'Asynchronous initialization of IPMI System Interface' > + depends on IPMI_SI > + default n > + help > + Offloads individual SMI inits. It speeds up the boot time. > + It also introduces a very small risk that something else might fail > + if it depends on synchronous IPMI init. > + > config IPMI_SSIF > tristate 'IPMI SMBus handler (SSIF)' > depends on I2C > diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c > index 9a9d12be9bf7..79c510a8d00a 100644 > --- a/drivers/char/ipmi/ipmi_si_intf.c > +++ b/drivers/char/ipmi/ipmi_si_intf.c > @@ -39,6 +39,7 @@ > #include > #include > #include > +#include > #include "ipmi_si.h" > #include "ipmi_si_sm.h" > #include > @@ -252,6 +253,8 @@ struct smi_info { > > struct task_struct *thread; > > + struct work_struct init_work; > + > struct list_head link; > }; > > @@ -272,6 +275,7 @@ static bool unload_when_empty = true; > static int try_smi_init(struct smi_info *smi); > static void cleanup_one_si(struct smi_info *smi_info); > static void cleanup_ipmi_si(void); > +static void smi_init_work_fn(struct work_struct *work); > > #ifdef DEBUG_TIMING > void debug_timestamp(struct smi_info *smi_info, char *msg) > @@ -1970,6 +1974,7 @@ int ipmi_si_add_smi(struct si_sm_io *io) > if (!new_smi) > return -ENOMEM; > spin_lock_init(&new_smi->si_lock); > + INIT_WORK(&new_smi->init_work, smi_init_work_fn); > > new_smi->io = *io; > > @@ -1982,7 +1987,12 @@ int ipmi_si_add_smi(struct si_sm_io *io) > dev_info(dup->io.dev, > "Removing SMBIOS-specified %s state machine in favor of ACPI\n", > si_to_str[new_smi->io.si_info->type]); > + list_del(&dup->link); > + mutex_unlock(&smi_infos_lock); > + > cleanup_one_si(dup); > + > + mutex_lock(&smi_infos_lock); > } else { > dev_info(new_smi->io.dev, > "%s-specified %s state machine: duplicate\n", > @@ -2000,8 +2010,12 @@ int ipmi_si_add_smi(struct si_sm_io *io) > > list_add_tail(&new_smi->link, &smi_infos); > > - if (initialized) > - rv = try_smi_init(new_smi); > + if (initialized) { > + if (IS_ENABLED(CONFIG_IPMI_SI_ASYNC_INIT)) > + queue_work(system_unbound_wq, &new_smi->init_work); > + else > + rv = try_smi_init(new_smi); > + } > out_err: > mutex_unlock(&smi_infos_lock); > return rv; > @@ -2174,6 +2188,15 @@ static bool __init ipmi_smi_info_same(struct smi_info *e1, struct smi_info *e2) > e1->io.addr_data == e2->io.addr_data); > } > > +static void smi_init_work_fn(struct work_struct *work) > +{ > + struct smi_info *smi = container_of(work, struct smi_info, init_work); > + > + mutex_lock(&smi_infos_lock); > + try_smi_init(smi); > + mutex_unlock(&smi_infos_lock); > +} > + > static int __init init_ipmi_si(void) > { > struct smi_info *e, *e2; > @@ -2219,8 +2242,12 @@ static int __init init_ipmi_si(void) > break; > } > } > - if (!dup) > - try_smi_init(e); > + if (!dup) { > + if (IS_ENABLED(CONFIG_IPMI_SI_ASYNC_INIT)) > + queue_work(system_unbound_wq, &e->init_work); > + else > + try_smi_init(e); > + } > } > > /* > @@ -2253,8 +2280,12 @@ static int __init init_ipmi_si(void) > break; > } > } > - if (!dup) > - try_smi_init(e); > + if (!dup) { > + if (IS_ENABLED(CONFIG_IPMI_SI_ASYNC_INIT)) > + queue_work(system_unbound_wq, &e->init_work); > + else > + try_smi_init(e); > + } > } > > initialized = true; > @@ -2344,31 +2375,36 @@ static void shutdown_smi(void *send_info) > } > > /* > - * Must be called with smi_infos_lock held, to serialize the > - * smi_info->intf check. > + * Must be called with smi_info unlinked from smi_infos and smi_infos_lock released. > */ > static void cleanup_one_si(struct smi_info *smi_info) > { > if (!smi_info) > return; > > - list_del(&smi_info->link); > + if (IS_ENABLED(CONFIG_IPMI_SI_ASYNC_INIT)) > + cancel_work_sync(&smi_info->init_work); > + > ipmi_unregister_smi(smi_info->intf); > kfree(smi_info); > } > > void ipmi_si_remove_by_dev(struct device *dev) > { > - struct smi_info *e; > + struct smi_info *e = NULL, *tmp; > > mutex_lock(&smi_infos_lock); > - list_for_each_entry(e, &smi_infos, link) { > - if (e->io.dev == dev) { > - cleanup_one_si(e); > + list_for_each_entry(tmp, &smi_infos, link) { > + if (tmp->io.dev == dev) { > + e = tmp; > + list_del(&e->link); > break; > } > } > mutex_unlock(&smi_infos_lock); > + > + if (e) > + cleanup_one_si(e); > } > > struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type, > @@ -2377,6 +2413,7 @@ struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type, > /* remove */ > struct smi_info *e, *tmp_e; > struct device *dev = NULL; > + LIST_HEAD(to_clean); > > mutex_lock(&smi_infos_lock); > list_for_each_entry_safe(e, tmp_e, &smi_infos, link) { > @@ -2386,17 +2423,23 @@ struct device *ipmi_si_remove_by_data(int addr_space, enum si_type si_type, > continue; > if (e->io.addr_data == addr) { > dev = get_device(e->io.dev); > - cleanup_one_si(e); > + list_move_tail(&e->link, &to_clean); > } > } > mutex_unlock(&smi_infos_lock); > > + list_for_each_entry_safe(e, tmp_e, &to_clean, link) { > + list_del(&e->link); > + cleanup_one_si(e); > + } > + > return dev; > } > > static void cleanup_ipmi_si(void) > { > struct smi_info *e, *tmp_e; > + LIST_HEAD(to_clean); > > if (!initialized) > return; > @@ -2410,10 +2453,14 @@ static void cleanup_ipmi_si(void) > ipmi_si_platform_shutdown(); > > mutex_lock(&smi_infos_lock); > - list_for_each_entry_safe(e, tmp_e, &smi_infos, link) > - cleanup_one_si(e); > + list_splice_init(&smi_infos, &to_clean); > mutex_unlock(&smi_infos_lock); > > + list_for_each_entry_safe(e, tmp_e, &to_clean, link) { > + list_del(&e->link); > + cleanup_one_si(e); > + } > + > ipmi_si_hardcode_exit(); > ipmi_si_hotmod_exit(); > } > -- > 2.55.0.654.g21b8a5bc05-goog >