Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7847910rdb; Thu, 4 Jan 2024 09:25:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4pqe0V2mbK7hqNMBgzhMuAjF7CVf4Yz1kxppqNYvnJPv/PzpCJsGJh7HELE6K/njiElSy X-Received: by 2002:a2e:9dcb:0:b0:2cd:1a1c:5957 with SMTP id x11-20020a2e9dcb000000b002cd1a1c5957mr493864ljj.11.1704389146230; Thu, 04 Jan 2024 09:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704389146; cv=none; d=google.com; s=arc-20160816; b=UItT0ILmcrJuWoftw4IQHL+k2t/ixdBs6T+gNFoa/Tqexk4XRUr6/83R8XJD+a5Yre Fg4sg7EIGA4Ep1qzUyReuZ7gb8aG22AlvSDwY5oKpdGBRBX8cOGu/4+FZomU633sG0H6 wyiaNYSl4G2x/dEYnG4EKCNbA0zs9MZ9zgWfgoqtpTwppzX2muAIQgP33ERlK9Ywc5QY U9KyaHZo0qFRV80WRF/YRhLGp/HvTuGdDCOenIC4lg8BgUAU+LhwzGWiiyl3HMyvz/S6 +/cU2HRsfMdqxOIdqweS7f+heVxBsp++eTKQbrPUmuJSbOZ4IF/v6MvN/ue58OoqBtyu FF/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=SneCguYreyjGXQzF3i7sYG1yhzrxbO3Wd59E1ARonos=; fh=kRsICXIJ9bUoBnCexRQ3d9cIVhXFpoLT6x1/J3gO/K8=; b=np7w6teBzvYajZT6F4Burzf9YoGHw+Ucz4Nq3Q0K6+tCgTG2UHx6NCSdIWm6KO1rKr ezGEaZoNyHtGfCo0zZu8dyB1cNjX9Xwl+l6nIlIkTFDcP6AjnYM9LbCVpxtXWToqkXp2 chbwv922pZ5AYpBSQ+I3hwMHPaeyEK2x3N9/31P+F5EYNTe6sf3nZzrmpqfYlUD5SoZy V997WTobLPXUVCTYNOqTrQuMeBu3WdWXQP9oKbqhRviS7RrmWGoL4R5ReoUmGYF1dLlR xAgQt6sPmduoesMzqEBaaAjkZkhaEWoGvPzjsGNHcnPzaPngjXp8g0Euqvv2cGw5ILA9 KIew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h6-20020a05640250c600b0055293148185si13527893edb.369.2024.01.04.09.25.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:25:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C38901F2278E for ; Thu, 4 Jan 2024 17:25:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C959288A7; Thu, 4 Jan 2024 17:25:24 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (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 4F1E8286AD; Thu, 4 Jan 2024 17:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-59614694ca2so107204eaf.1; Thu, 04 Jan 2024 09:25:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704389121; x=1704993921; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SneCguYreyjGXQzF3i7sYG1yhzrxbO3Wd59E1ARonos=; b=Yit4CHdsF5X64/0+vZ1OOcRwY88dhx7daB0xKr+IvWOfD2vonQtd4bNb3OF2EtmHgu WyoM7enu4OW9iaCUt+/cY+ag4adJyXG9/GG5Z3bKBsSTnl7a6Im6NltKIcq4CvY7rYjK Te28rEDd00NwWW1frvm1Xyul/gXG8zaalnYGnVnXI+/jHJaJkEzcK7f+w+GcFt70JJOu z2USa9qn329YdgcIy4Qb01LWxfGnAum0gZzDrD4ne77r8x5Lieut0g1I/WeUd0mbqRMw uvvqr04pXwi30+H6xZbYNNiUD4Kh8rCBJocTwEXusrk3G7w4rfBTRxIOUcHqQHgcDXs1 myYQ== X-Gm-Message-State: AOJu0Yx3AUXKxZ9vRID4UWLDXPo0dnSNzKB6jpT+dc12O0rB2FyG8wqv Ry09SiXprEWcPA53hVigx6Dvh3Al0n/V9oC6zqI= X-Received: by 2002:a4a:da09:0:b0:596:2965:be22 with SMTP id e9-20020a4ada09000000b005962965be22mr1405077oou.1.1704389121350; Thu, 04 Jan 2024 09:25:21 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240104024819.848979-1-kai.heng.feng@canonical.com> In-Reply-To: <20240104024819.848979-1-kai.heng.feng@canonical.com> From: "Rafael J. Wysocki" Date: Thu, 4 Jan 2024 18:25:10 +0100 Message-ID: Subject: Re: [PATCH v3 1/2] ACPI: IPMI: Add helper to wait for when SMI is selected To: Kai-Heng Feng Cc: jdelvare@suse.com, linux@roeck-us.net, "Rafael J. Wysocki" , Len Brown , Robert Moore , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, acpica-devel@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 4, 2024 at 3:48=E2=80=AFAM Kai-Heng Feng wrote: > > The function of acpi_power_meter module on Dell system requires IPMI > handler is installed and SMI is selected. > > So add a helper to let acpi_power_meter know when IPMI handler and SMI > are ready. The changelog is a bit terse. It could describe the problem at hand in more detail, for example. Also it wouldn't hurt to provide a Link: tag pointing to a place where some extra details could be found. > Signed-off-by: Kai-Heng Feng > --- > v3: > - New patch. > > drivers/acpi/acpi_ipmi.c | 17 ++++++++++++++++- > include/acpi/acpi_bus.h | 5 +++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c > index 0555f68c2dfd..54862cab7171 100644 > --- a/drivers/acpi/acpi_ipmi.c > +++ b/drivers/acpi/acpi_ipmi.c > @@ -23,6 +23,8 @@ MODULE_LICENSE("GPL"); > #define IPMI_TIMEOUT (5000) > #define ACPI_IPMI_MAX_MSG_LENGTH 64 > > +static struct completion smi_selected; > + > struct acpi_ipmi_device { > /* the device list attached to driver_data.ipmi_devices */ > struct list_head head; > @@ -463,8 +465,10 @@ static void ipmi_register_bmc(int iface, struct devi= ce *dev) > if (temp->handle =3D=3D handle) > goto err_lock; > } > - if (!driver_data.selected_smi) > + if (!driver_data.selected_smi) { > driver_data.selected_smi =3D ipmi_device; > + complete(&smi_selected); It looks like the new completion is at least related to driver_data, so should it be a member of the latter? > + } > list_add_tail(&ipmi_device->head, &driver_data.ipmi_devices); > mutex_unlock(&driver_data.ipmi_lock); > > @@ -578,10 +582,21 @@ acpi_ipmi_space_handler(u32 function, acpi_physical= _address address, > return status; > } > > +int acpi_wait_for_acpi_ipmi(void) > +{ > + long ret; > + > + ret =3D wait_for_completion_interruptible_timeout(&smi_selected, = 2 * HZ); Why does it wait for 2 ticks and not 3 or 5? Also it would be nice to have a symbol defined for this timeout value. > + > + return ret > 0 ? 0 : -ETIMEDOUT; if (ret <=3D 0) return -ETIMEDOUT; return 0; pretty please. > +} > +EXPORT_SYMBOL_GPL(acpi_wait_for_acpi_ipmi); > + > static int __init acpi_ipmi_init(void) > { > int result; > acpi_status status; Empty line here, please. > + init_completion(&smi_selected); Does it really make sense to initialize it when ACPI is disabled? > > if (acpi_disabled) > return 0; > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h > index 1216d72c650f..afa6e4d4bf46 100644 > --- a/include/acpi/acpi_bus.h > +++ b/include/acpi/acpi_bus.h > @@ -821,11 +821,16 @@ static inline void acpi_put_acpi_dev(struct acpi_de= vice *adev) > { > acpi_dev_put(adev); > } > + > +int acpi_wait_for_acpi_ipmi(void); > + > #else /* CONFIG_ACPI */ > > static inline int register_acpi_bus_type(void *bus) { return 0; } > static inline int unregister_acpi_bus_type(void *bus) { return 0; } > > +static inline int acpi_wait_for_acpi_ipmi(void) { return 0; } > + > #endif /* CONFIG_ACPI */ > > #endif /*__ACPI_BUS_H__*/ > --