Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2231365rbb; Tue, 27 Feb 2024 15:29:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVW9f3UGvrUHhGeHcJOw5hKfAroNcmmjYjmWA2WDABrNPhp2nw/F7ZImRo22+B/5q+cW3B4ZcmAu1nE8QXUsYAGcEEVznQ8982TK3Upmw== X-Google-Smtp-Source: AGHT+IGfMwdqQ769NkZKVEmxOnLxhZlfi0AYyrKNsDsaGTHuDhvDsosEqiklF2hCC4Y6mGAflyEi X-Received: by 2002:a05:6808:1202:b0:3c0:4b11:dc54 with SMTP id a2-20020a056808120200b003c04b11dc54mr3117293oil.35.1709076575128; Tue, 27 Feb 2024 15:29:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709076575; cv=pass; d=google.com; s=arc-20160816; b=0EUeJD/jLfj5ZknonSbLbAqCIcTGObNACzoltclIDr3aOnS1q5fOq38V3MkoPtwzEr 6Cm7FFZXwF3f/OGpSkz+C8DPc1bVUcQ6trkkJmRCsLEis3U6jCIi8HhW2ts0kkpV88GM mWwZ/j9Mcb7AN/ceUZloKRbZJ7qZUeuhWPLC1YqWzqH2RZnXfi0ZniVsV2SsIqw86mNP d+/P+2IN49flNbCoMazoEOZ5qqZtFYRNN6gExFg5uDjCQlG6mKvQ5pWsZ0zrD5xyav5N Cl6dMETN3986sI3A524+4QFFm5wIR5FIVFtuAJKApeT3OYVoEho+LK/fdTBXsP1yd3OS +1cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bIpLkpN9FSZkuvtU2/1ciQaYGaBa9+D3lcBd5Yg98t4=; fh=/gyGctSVQfAEE22FbyQYUnvDZBKkjdMMVRhAx5akSKs=; b=iDGlG3iTc2bBmtwb/bvxgfXkeGXR7XXnHAbCp5GfreQiDAry6LHaUU5VvyYDx53B4b omuNB9cG4pLsUPmwgUbtLqxtQdReJYbs5qJTh56I6INXwV39RIlohevTu+Dx6mHwIcMC jdi3WcyRnD0AIuwA1/vJDPgjUXH+nFfa6qcYZxc+e0czQ5D51NMCUPBqybGiAdnDNxLp BHzIvwuLojcSElJvb6qnmTICZmL8SF6LLCh/LqNNuEvbAAacEzo8j79KyylK2qGaN7IK rznq3jb6ObkLD07obAcexCIzUBJoexPyFBHJiTrLPa8XG7UF8gqWCm9s6QWZbDM2G8xW IJyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VLEw6F33; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84144-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id dq23-20020a056a020f9700b005dc498de156si6165739pgb.502.2024.02.27.15.29.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:29:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VLEw6F33; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84144-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84144-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 99200B228C9 for ; Tue, 27 Feb 2024 22:53:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A213F55C28; Tue, 27 Feb 2024 22:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VLEw6F33" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E36E54664; Tue, 27 Feb 2024 22:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709074425; cv=none; b=QtmWq/gxvn/aBeCR3WWfRJgaWJxpFO078k40a6AnvuLuCa7+MG9w6gGW1+WVq0pHBAkUFenDMuwCNhS6ttu99vNaLASGrc+tj2dK1K77tcfaRNR0qqkMVXZKHoZDAcCntijLIZnLscym96zyMPTSeMtlaGA1MOBlitfLoVTK1go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709074425; c=relaxed/simple; bh=DMuZf3Z6sY7althpV6SNiCdHASJoLRAjXzLLI/6q/fM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CKvbE8n6wJ+SbhOY1ijNlV5NWQx1gl3JOQT9ArfbIOfSqRDgM60XpUaaWAaJ2s39e4zdp9re2nBy6Bm4laLb0iaIsDf3uoLTlpgTR0etvFrE3EouhSJgrRz0Q6erD6X1mzL0RDw2H1xg6WrVADDTTaYmYxj4G/B8deG7t3q3uWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VLEw6F33; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B45F7C433C7; Tue, 27 Feb 2024 22:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709074425; bh=DMuZf3Z6sY7althpV6SNiCdHASJoLRAjXzLLI/6q/fM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VLEw6F33f9GFY5tJQj0wLbTyuKmJD1JQR3+cudCePUHGmbyouQLc2+hS3TvJPGzRc tBAuRn7yvpKuGAYQQKxYJZm/0t+I+JUNtEvhNUxOS6TYVAa+UdmM3FDuW40bRyqE2k tobjy+38ER3l3JltXp1x8NkNm3TvO8T5wOhJ2K9qMzusH5gpMTR4ytsYP8QwL5jUaW J53p0cUWP+xZZwEfNOT93X/9qgWQOJERrJ3HPDqrEJs8E60Mlx4p1g1UBYFYm0l3IQ FAgwGZ2vvFU/2xd6llo1nZ5LyY7qOxto2AV4cpKEnEincnxGOKGSaFLSvy9plNjylL 4aDTnSaSFt1BA== Received: by pali.im (Postfix) id 1E156828; Tue, 27 Feb 2024 23:53:42 +0100 (CET) Date: Tue, 27 Feb 2024 23:53:41 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Armin Wolf Cc: jithu.joseph@intel.com, linux@weissschuh.net, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, Dell.Client.Kernel@dell.com, jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] platform/x86: wmi: Do not instantiate older WMI drivers multiple times Message-ID: <20240227225341.jqhkq7xmwprtgj7x@pali> References: <20240226193557.2888-1-W_Armin@gmx.de> <20240226193557.2888-2-W_Armin@gmx.de> <20240227203058.eun4ylvhk4t7uogk@pali> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 On Tuesday 27 February 2024 23:47:11 Armin Wolf wrote: > Am 27.02.24 um 21:30 schrieb Pali Rohár: > > > On Monday 26 February 2024 20:35:56 Armin Wolf wrote: > > > Many older WMI drivers cannot be instantiated multiple times for > > > two reasons: > > > > > > - they are using the legacy GUID-based WMI API > > > - they are singletons (with global state) > > > > > > Prevent such WMI drivers from binding to WMI devices with a duplicated > > > GUID, as this would mean that the WMI driver will be instantiated at > > > least two times (one for the original GUID and one for the duplicated > > > GUID). > > > WMI drivers which can be instantiated multiple times can signal this > > > by setting a flag inside struct wmi_driver. > > What do you think about opposite direction? Adding ".singleton = true" > > into every driver which is not compatible with duplicated initialization > > and having the default value that drivers are not singletons. > > > > But if the direction it to not accept new "legacy" drivers and start get > > rid of all "legacy" drivers by rewriting them, then it does not matter > > if "no_singleton" or "is_singleton" is used... > > Hi, > > i want to make sure that i wont forget any legacy WMI drivers. This way, the > older legacy WMI drivers automatically initialize no_singleton with false. > > Also i intent to not accept new legacy WMI drivers. Ok. In this case it does not matter. > Thanks, > Armin Wolf > > > > Tested on a ASUS Prime B650-Plus. > > > > > > Signed-off-by: Armin Wolf > > > --- > > > drivers/hwmon/dell-smm-hwmon.c | 1 + > > > drivers/platform/x86/dell/dell-wmi-ddv.c | 1 + > > > drivers/platform/x86/intel/wmi/sbl-fw-update.c | 1 + > > > drivers/platform/x86/intel/wmi/thunderbolt.c | 1 + > > > drivers/platform/x86/wmi-bmof.c | 1 + > > > drivers/platform/x86/wmi.c | 12 ++++++++++++ > > > include/linux/wmi.h | 2 ++ > > > 7 files changed, 19 insertions(+) > > > > > > diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c > > > index 6d8c0f328b7b..168d669c4eca 100644 > > > --- a/drivers/hwmon/dell-smm-hwmon.c > > > +++ b/drivers/hwmon/dell-smm-hwmon.c > > > @@ -1587,6 +1587,7 @@ static struct wmi_driver dell_smm_wmi_driver = { > > > }, > > > .id_table = dell_smm_wmi_id_table, > > > .probe = dell_smm_wmi_probe, > > > + .no_singleton = true, > > > }; > > > > > > /* > > > diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c > > > index db1e9240dd02..0b2299f7a2de 100644 > > > --- a/drivers/platform/x86/dell/dell-wmi-ddv.c > > > +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c > > > @@ -882,6 +882,7 @@ static struct wmi_driver dell_wmi_ddv_driver = { > > > }, > > > .id_table = dell_wmi_ddv_id_table, > > > .probe = dell_wmi_ddv_probe, > > > + .no_singleton = true, > > > }; > > > module_wmi_driver(dell_wmi_ddv_driver); > > > > > > diff --git a/drivers/platform/x86/intel/wmi/sbl-fw-update.c b/drivers/platform/x86/intel/wmi/sbl-fw-update.c > > > index 040153ad67c1..75c82c08117f 100644 > > > --- a/drivers/platform/x86/intel/wmi/sbl-fw-update.c > > > +++ b/drivers/platform/x86/intel/wmi/sbl-fw-update.c > > > @@ -131,6 +131,7 @@ static struct wmi_driver intel_wmi_sbl_fw_update_driver = { > > > .probe = intel_wmi_sbl_fw_update_probe, > > > .remove = intel_wmi_sbl_fw_update_remove, > > > .id_table = intel_wmi_sbl_id_table, > > > + .no_singleton = true, > > > }; > > > module_wmi_driver(intel_wmi_sbl_fw_update_driver); > > > > > > diff --git a/drivers/platform/x86/intel/wmi/thunderbolt.c b/drivers/platform/x86/intel/wmi/thunderbolt.c > > > index e2ad3f46f356..08df560a2c7a 100644 > > > --- a/drivers/platform/x86/intel/wmi/thunderbolt.c > > > +++ b/drivers/platform/x86/intel/wmi/thunderbolt.c > > > @@ -63,6 +63,7 @@ static struct wmi_driver intel_wmi_thunderbolt_driver = { > > > .dev_groups = tbt_groups, > > > }, > > > .id_table = intel_wmi_thunderbolt_id_table, > > > + .no_singleton = true, > > > }; > > > > > > module_wmi_driver(intel_wmi_thunderbolt_driver); > > > diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c > > > index 644d2fd889c0..df6f0ae6e6c7 100644 > > > --- a/drivers/platform/x86/wmi-bmof.c > > > +++ b/drivers/platform/x86/wmi-bmof.c > > > @@ -94,6 +94,7 @@ static struct wmi_driver wmi_bmof_driver = { > > > .probe = wmi_bmof_probe, > > > .remove = wmi_bmof_remove, > > > .id_table = wmi_bmof_id_table, > > > + .no_singleton = true, > > > }; > > > > > > module_wmi_driver(wmi_bmof_driver); > > > diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c > > > index 29dfe52eb802..349deced87e8 100644 > > > --- a/drivers/platform/x86/wmi.c > > > +++ b/drivers/platform/x86/wmi.c > > > @@ -883,6 +883,18 @@ static int wmi_dev_probe(struct device *dev) > > > struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); > > > int ret = 0; > > > > > > + /* Some older WMI drivers will break if instantiated multiple times, > > > + * so they are blocked from probing WMI devices with a duplicated GUID. > > > + * > > > + * New WMI drivers should support being instantiated multiple times. > > > + */ > > > + if (test_bit(WMI_GUID_DUPLICATED, &wblock->flags) && !wdriver->no_singleton) { > > > + dev_warn(dev, "Legacy driver %s cannot be instantiated multiple times\n", > > > + dev->driver->name); > > > + > > > + return -ENODEV; > > > + } > > > + > > > if (wdriver->notify) { > > > if (test_bit(WMI_NO_EVENT_DATA, &wblock->flags) && !wdriver->no_notify_data) > > > return -ENODEV; > > > diff --git a/include/linux/wmi.h b/include/linux/wmi.h > > > index 781958310bfb..63cca3b58d6d 100644 > > > --- a/include/linux/wmi.h > > > +++ b/include/linux/wmi.h > > > @@ -49,6 +49,7 @@ u8 wmidev_instance_count(struct wmi_device *wdev); > > > * @driver: Driver model structure > > > * @id_table: List of WMI GUIDs supported by this driver > > > * @no_notify_data: Driver supports WMI events which provide no event data > > > + * @no_singleton: Driver can be instantiated multiple times > > > * @probe: Callback for device binding > > > * @remove: Callback for device unbinding > > > * @notify: Callback for receiving WMI events > > > @@ -59,6 +60,7 @@ struct wmi_driver { > > > struct device_driver driver; > > > const struct wmi_device_id *id_table; > > > bool no_notify_data; > > > + bool no_singleton; > > > > > > int (*probe)(struct wmi_device *wdev, const void *context); > > > void (*remove)(struct wmi_device *wdev); > > > -- > > > 2.39.2 > > >