* [PATCH v2 0/8] drivers: Transition to the faux device interface
@ 2025-03-18 17:01 Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate Sudeep Holla
` (7 more replies)
0 siblings, 8 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel
Cc: Sudeep Holla, Greg Kroah-Hartman, Lorenzo Pieralisi,
Rafael J. Wysocki, Daniel Lezcano, linux-pm, Andre Przywara,
Herbert Xu, Jeff Johnson, linux-crypto, Ard Biesheuvel,
Alexandre Belloni, linux-rtc, linux-efi, Borislav Petkov,
linux-acpi, Andrew Lunn, David S. Miller, netdev
Recently when debugging why one of the scmi platform device was not
showing up under /sys/devices/platform/firmware:scmi instead was
appearing directly under /sys/devices/platform, I noticed the new
faux interface /sys/devices/faux.
Looking through the discussion and the background, I got excited and
took the opportunity to clear all the platform devices under
/sys/devices/platform on the Arm Juno/FVP platforms that are really
faux devices. Only the platform devices created for the device nodes
from the DT remain under /sys/devices/platform after these changes.
All the patches are independent of each other and are part of the series
just to demonstrate the use of macro module_faux_driver() where
applicable. The idea is to get the macro merged first and then push the
individual patches via respective subsystem later.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
Changes in v2:
- Dropped all the modalias expect efivars(reason in the patch)
- Defined new helper macro module_faux_driver() and moved most of the
drivers to use it
- Dropped already queued ASoC and regulator changes
- Link to v1: https://lore.kernel.org/r/20250317-plat2faux_dev-v1-0-5fe67c085ad5@arm.com
---
Sudeep Holla (8):
driver core: add helper macro for module_faux_driver() boilerplate
cpuidle: psci: Transition to the faux device interface
hwrng: arm-smccc-trng - transition to the faux device interface
rtc: efi: Transition to the faux device interface
virt: efi_secret: Transition to the faux device interface
efi: efivars: Transition to the faux device interface
ACPI: APEI: EINJ: Transition to the faux device interface
net: phy: fixed_phy: transition to the faux device interface
drivers/acpi/apei/einj-core.c | 51 ++++---------------------------
drivers/char/hw_random/arm_smccc_trng.c | 19 +++++-------
drivers/cpuidle/cpuidle-psci.c | 32 +++----------------
drivers/firmware/efi/efi-pstore.c | 2 +-
drivers/firmware/efi/efi.c | 12 ++------
drivers/firmware/smccc/smccc.c | 17 -----------
drivers/net/phy/fixed_phy.c | 16 +++++-----
drivers/rtc/rtc-efi.c | 16 +++-------
drivers/virt/coco/efi_secret/efi_secret.c | 29 +++++-------------
include/linux/device/faux.h | 49 +++++++++++++++++++++++++++++
10 files changed, 90 insertions(+), 153 deletions(-)
---
base-commit: 4701f33a10702d5fc577c32434eb62adde0a1ae1
change-id: 20250315-plat2faux_dev-8c28b35be96a
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-04-15 12:21 ` Greg Kroah-Hartman
2025-03-18 17:01 ` [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface Sudeep Holla
` (6 subsequent siblings)
7 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Sudeep Holla, Greg Kroah-Hartman
For simple modules that needs to create a faux device without any
additional setup code ends up being a block of duplicated boilerplate.
Add a new macro, module_faux_driver(), which help to replaces the
those duplicated boilerplate.
This macro use the same idea of module_platform_driver() but adds this
initial condition to avoid creation of faux device if not necessary.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
include/linux/device/faux.h | 49 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/include/linux/device/faux.h b/include/linux/device/faux.h
index 9f43c0e46aa45bf492788adcdc081df5cc0c5fc0..4a54736d86595e46c98ac3ab9c45a7e5a344333e 100644
--- a/include/linux/device/faux.h
+++ b/include/linux/device/faux.h
@@ -15,6 +15,7 @@
#include <linux/container_of.h>
#include <linux/device.h>
+#include <linux/stringify.h>
/**
* struct faux_device - a "faux" device
@@ -66,4 +67,52 @@ static inline void faux_device_set_drvdata(struct faux_device *faux_dev, void *d
dev_set_drvdata(&faux_dev->dev, data);
}
+#define FAUX_DEVICE(__faux_devname) \
+static struct faux_device *__faux_devname##_dev;
+
+#define FAUX_DEVICE_OPS(__faux_devname, __faux_probe, __faux_remove) \
+static const struct faux_device_ops __faux_devname##_ops = { \
+ .probe = __faux_probe, \
+ .remove = __faux_remove, \
+}; \
+FAUX_DEVICE(__faux_devname)
+
+static inline int
+__faux_device_register(struct faux_device **faux_dev, const char *name,
+ const struct faux_device_ops *faux_ops, bool condition)
+{
+ struct faux_device *fdev;
+
+ if (!condition)
+ return 0;
+
+ fdev = faux_device_create(name, NULL, faux_ops);
+ if (!fdev)
+ return -ENODEV;
+
+ *faux_dev = fdev;
+ return 0;
+}
+
+#define faux_device_register(faux_dev, faux_devname, init_condition) \
+ __faux_device_register(faux_dev, __stringify(faux_devname), \
+ &faux_devname##_ops, init_condition)
+
+#define faux_device_unregister(faux_dev, ...) \
+ faux_device_destroy(*faux_dev)
+
+/* module_faux_driver() - Helper macro for faux drivers that don't do
+ * anything special in module init/exit. This eliminates a lot of
+ * boilerplate. Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit(). The module init
+ * creates a faux device if the init condition is met and module exit
+ * destroys the created device. FAUX_DEVICE_OPS must be used to declare
+ * faux device ops and the device pointer.
+ */
+#define module_faux_driver(__faux_devname, __faux_probe, __faux_remove, \
+ __init_condition) \
+ FAUX_DEVICE_OPS(__faux_devname, __faux_probe, __faux_remove) \
+ module_driver(__faux_devname##_dev, faux_device_register, \
+ faux_device_unregister, __faux_devname, __init_condition)
+
#endif /* _FAUX_DEVICE_H_ */
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-04-15 12:21 ` Greg Kroah-Hartman
2025-05-01 13:01 ` Jon Hunter
2025-03-18 17:01 ` [PATCH v2 3/8] hwrng: arm-smccc-trng - transition " Sudeep Holla
` (5 subsequent siblings)
7 siblings, 2 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel
Cc: Sudeep Holla, Greg Kroah-Hartman, Lorenzo Pieralisi,
Rafael J. Wysocki, Daniel Lezcano, linux-pm
The PSCI cpuidle driver does not require the creation of a platform
device. Originally, this approach was chosen for simplicity when the
driver was first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate the driver to utilize the
faux bus, given that the platform device it previously created was not
a real one anyway. This will simplify the code, reducing its footprint
while maintaining functionality.
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/cpuidle/cpuidle-psci.c | 32 ++++----------------------------
1 file changed, 4 insertions(+), 28 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
index 2562dc001fc1de69732ef28f383d2809262a3d96..5d4d6daed36d8540ba2ce3dc54a3180731b03d22 100644
--- a/drivers/cpuidle/cpuidle-psci.c
+++ b/drivers/cpuidle/cpuidle-psci.c
@@ -16,7 +16,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/psci.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
@@ -404,14 +404,14 @@ static int psci_idle_init_cpu(struct device *dev, int cpu)
* to register cpuidle driver then rollback to cancel all CPUs
* registration.
*/
-static int psci_cpuidle_probe(struct platform_device *pdev)
+static int psci_cpuidle_probe(struct faux_device *fdev)
{
int cpu, ret;
struct cpuidle_driver *drv;
struct cpuidle_device *dev;
for_each_possible_cpu(cpu) {
- ret = psci_idle_init_cpu(&pdev->dev, cpu);
+ ret = psci_idle_init_cpu(&fdev->dev, cpu);
if (ret)
goto out_fail;
}
@@ -431,28 +431,4 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
return ret;
}
-static struct platform_driver psci_cpuidle_driver = {
- .probe = psci_cpuidle_probe,
- .driver = {
- .name = "psci-cpuidle",
- },
-};
-
-static int __init psci_idle_init(void)
-{
- struct platform_device *pdev;
- int ret;
-
- ret = platform_driver_register(&psci_cpuidle_driver);
- if (ret)
- return ret;
-
- pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0);
- if (IS_ERR(pdev)) {
- platform_driver_unregister(&psci_cpuidle_driver);
- return PTR_ERR(pdev);
- }
-
- return 0;
-}
-device_initcall(psci_idle_init);
+module_faux_driver(psci_cpuidle, psci_cpuidle_probe, NULL, true);
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 3/8] hwrng: arm-smccc-trng - transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 4/8] rtc: efi: Transition " Sudeep Holla
` (4 subsequent siblings)
7 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel
Cc: Sudeep Holla, Greg Kroah-Hartman, Andre Przywara, Herbert Xu,
Jeff Johnson, linux-crypto
The Arm SMCCC based true random number generator driver does not require
the creation of a platform device/driver. Originally, this approach was
chosen for simplicity when the driver was first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate the driver to utilize the
faux bus, given that the platform device it previously created was not
a real one anyway. This will simplify the code, reducing its footprint
while maintaining functionality.
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/char/hw_random/arm_smccc_trng.c | 19 +++++++------------
drivers/firmware/smccc/smccc.c | 17 -----------------
2 files changed, 7 insertions(+), 29 deletions(-)
diff --git a/drivers/char/hw_random/arm_smccc_trng.c b/drivers/char/hw_random/arm_smccc_trng.c
index dcb8e7f37f25c6b39f76050369b9f324b7fb2e33..1c70e8bbea956c8e1f07a8083c33a8d011772c26 100644
--- a/drivers/char/hw_random/arm_smccc_trng.c
+++ b/drivers/char/hw_random/arm_smccc_trng.c
@@ -16,9 +16,11 @@
#include <linux/device.h>
#include <linux/hw_random.h>
#include <linux/module.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/arm-smccc.h>
+#include <asm/archrandom.h>
+
#ifdef CONFIG_ARM64
#define ARM_SMCCC_TRNG_RND ARM_SMCCC_TRNG_RND64
#define MAX_BITS_PER_CALL (3 * 64UL)
@@ -94,29 +96,22 @@ static int smccc_trng_read(struct hwrng *rng, void *data, size_t max, bool wait)
return copied;
}
-static int smccc_trng_probe(struct platform_device *pdev)
+static int smccc_trng_probe(struct faux_device *fdev)
{
struct hwrng *trng;
- trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
+ trng = devm_kzalloc(&fdev->dev, sizeof(*trng), GFP_KERNEL);
if (!trng)
return -ENOMEM;
trng->name = "smccc_trng";
trng->read = smccc_trng_read;
- return devm_hwrng_register(&pdev->dev, trng);
+ return devm_hwrng_register(&fdev->dev, trng);
}
-static struct platform_driver smccc_trng_driver = {
- .driver = {
- .name = "smccc_trng",
- },
- .probe = smccc_trng_probe,
-};
-module_platform_driver(smccc_trng_driver);
+module_faux_driver(smccc_trng, smccc_trng_probe, NULL, smccc_trng_available);
-MODULE_ALIAS("platform:smccc_trng");
MODULE_AUTHOR("Andre Przywara");
MODULE_DESCRIPTION("Arm SMCCC TRNG firmware interface support");
MODULE_LICENSE("GPL");
diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c
index a74600d9f2d72a5aa0096004f53088c255927a43..cc131894623eff95f906ebf08511c123add7fe88 100644
--- a/drivers/firmware/smccc/smccc.c
+++ b/drivers/firmware/smccc/smccc.c
@@ -9,7 +9,6 @@
#include <linux/init.h>
#include <linux/arm-smccc.h>
#include <linux/kernel.h>
-#include <linux/platform_device.h>
#include <asm/archrandom.h>
static u32 smccc_version = ARM_SMCCC_VERSION_1_0;
@@ -66,19 +65,3 @@ s32 arm_smccc_get_soc_id_revision(void)
return smccc_soc_id_revision;
}
EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision);
-
-static int __init smccc_devices_init(void)
-{
- struct platform_device *pdev;
-
- if (smccc_trng_available) {
- pdev = platform_device_register_simple("smccc_trng", -1,
- NULL, 0);
- if (IS_ERR(pdev))
- pr_err("smccc_trng: could not register device: %ld\n",
- PTR_ERR(pdev));
- }
-
- return 0;
-}
-device_initcall(smccc_devices_init);
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 4/8] rtc: efi: Transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
` (2 preceding siblings ...)
2025-03-18 17:01 ` [PATCH v2 3/8] hwrng: arm-smccc-trng - transition " Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-04-08 14:45 ` (subset) " Alexandre Belloni
2025-03-18 17:01 ` [PATCH v2 5/8] virt: efi_secret: " Sudeep Holla
` (3 subsequent siblings)
7 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel
Cc: Sudeep Holla, Greg Kroah-Hartman, Ard Biesheuvel,
Alexandre Belloni, linux-rtc, linux-efi
The EFI RTC driver does not require the creation of a platform device.
Originally, this approach was chosen for simplicity when the driver was
first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate the driver to utilize the
faux bus, given that the platform device it previously created was not
a real one anyway. This will simplify the code, reducing its footprint
while maintaining functionality.
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/efi/efi.c | 3 ---
drivers/rtc/rtc-efi.c | 16 +++++-----------
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 7309394b8fc98cf7a3424af209b752f0251c8c89..8aebc747c65bc1b63d514a50fe6f35a9e3c1af0a 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -427,9 +427,6 @@ static int __init efisubsys_init(void)
}
}
- if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES))
- platform_device_register_simple("rtc-efi", 0, NULL, 0);
-
/* We register the efi directory at /sys/firmware/efi */
efi_kobj = kobject_create_and_add("efi", firmware_kobj);
if (!efi_kobj) {
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index fa8bf82df9488e7d1c23c058b4a3032dde74bc6e..681d917d541e51b37f2d59b0567caf6aa8bf05f4 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -14,7 +14,7 @@
#include <linux/module.h>
#include <linux/stringify.h>
#include <linux/time.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/rtc.h>
#include <linux/efi.h>
@@ -254,7 +254,7 @@ static const struct rtc_class_ops efi_rtc_ops = {
.proc = efi_procfs,
};
-static int __init efi_rtc_probe(struct platform_device *dev)
+static int __init efi_rtc_probe(struct faux_device *dev)
{
struct rtc_device *rtc;
efi_time_t eft;
@@ -268,7 +268,7 @@ static int __init efi_rtc_probe(struct platform_device *dev)
if (IS_ERR(rtc))
return PTR_ERR(rtc);
- platform_set_drvdata(dev, rtc);
+ faux_device_set_drvdata(dev, rtc);
rtc->ops = &efi_rtc_ops;
clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
@@ -282,15 +282,9 @@ static int __init efi_rtc_probe(struct platform_device *dev)
return devm_rtc_register_device(rtc);
}
-static struct platform_driver efi_rtc_driver = {
- .driver = {
- .name = "rtc-efi",
- },
-};
-
-module_platform_driver_probe(efi_rtc_driver, efi_rtc_probe);
+module_faux_driver(rtc_efi, efi_rtc_probe, NULL,
+ efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES));
MODULE_AUTHOR("dann frazier <dannf@dannf.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("EFI RTC driver");
-MODULE_ALIAS("platform:rtc-efi");
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 5/8] virt: efi_secret: Transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
` (3 preceding siblings ...)
2025-03-18 17:01 ` [PATCH v2 4/8] rtc: efi: Transition " Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-03-18 17:10 ` Ard Biesheuvel
2025-03-18 17:01 ` [PATCH v2 6/8] efi: efivars: " Sudeep Holla
` (2 subsequent siblings)
7 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Sudeep Holla, Greg Kroah-Hartman, Ard Biesheuvel, linux-efi
The EFI secret area driver does not require the creation of a platform
device. Originally, this approach was chosen for simplicity when the
driver was first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate the driver to utilize the
faux bus, given that the platform device it previously created was not
a real one anyway. This will simplify the code, reducing its footprint
while maintaining functionality.
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-efi@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/efi/efi.c | 5 -----
drivers/virt/coco/efi_secret/efi_secret.c | 29 ++++++++---------------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 8aebc747c65bc1b63d514a50fe6f35a9e3c1af0a..862b7744c28ecc9e5a64bbb3533c34119f50267f 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -465,11 +465,6 @@ static int __init efisubsys_init(void)
if (efi_enabled(EFI_DBG) && efi_enabled(EFI_PRESERVE_BS_REGIONS))
efi_debugfs_init();
-#ifdef CONFIG_EFI_COCO_SECRET
- if (efi.coco_secret != EFI_INVALID_TABLE_ADDR)
- platform_device_register_simple("efi_secret", 0, NULL, 0);
-#endif
-
return 0;
err_remove_group:
diff --git a/drivers/virt/coco/efi_secret/efi_secret.c b/drivers/virt/coco/efi_secret/efi_secret.c
index 1864f9f80617e082feb574a15327949972c8cc1e..a60976750bef787c78401bf4569ee5d0c7d2b5f4 100644
--- a/drivers/virt/coco/efi_secret/efi_secret.c
+++ b/drivers/virt/coco/efi_secret/efi_secret.c
@@ -16,7 +16,7 @@
* is the GUID of the secret entry, and its content is the secret data.
*/
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/seq_file.h>
#include <linux/fs.h>
#include <linux/kernel.h>
@@ -152,17 +152,12 @@ static const struct inode_operations efi_secret_dir_inode_operations = {
.unlink = efi_secret_unlink,
};
-static int efi_secret_map_area(struct platform_device *dev)
+static int efi_secret_map_area(struct faux_device *dev)
{
int ret;
struct efi_secret *s = efi_secret_get();
struct linux_efi_coco_secret_area *secret_area;
- if (efi.coco_secret == EFI_INVALID_TABLE_ADDR) {
- dev_err(&dev->dev, "Secret area address is not available\n");
- return -EINVAL;
- }
-
secret_area = memremap(efi.coco_secret, sizeof(*secret_area), MEMREMAP_WB);
if (secret_area == NULL) {
dev_err(&dev->dev, "Could not map secret area EFI config entry\n");
@@ -191,7 +186,7 @@ static int efi_secret_map_area(struct platform_device *dev)
return ret;
}
-static void efi_secret_securityfs_teardown(struct platform_device *dev)
+static void efi_secret_securityfs_teardown(struct faux_device *dev)
{
struct efi_secret *s = efi_secret_get();
int i;
@@ -210,7 +205,7 @@ static void efi_secret_securityfs_teardown(struct platform_device *dev)
dev_dbg(&dev->dev, "Removed securityfs entries\n");
}
-static int efi_secret_securityfs_setup(struct platform_device *dev)
+static int efi_secret_securityfs_setup(struct faux_device *dev)
{
struct efi_secret *s = efi_secret_get();
int ret = 0, i = 0, bytes_left;
@@ -307,7 +302,7 @@ static void efi_secret_unmap_area(void)
}
}
-static int efi_secret_probe(struct platform_device *dev)
+static int efi_secret_probe(struct faux_device *dev)
{
int ret;
@@ -326,23 +321,15 @@ static int efi_secret_probe(struct platform_device *dev)
return ret;
}
-static void efi_secret_remove(struct platform_device *dev)
+static void efi_secret_remove(struct faux_device *dev)
{
efi_secret_securityfs_teardown(dev);
efi_secret_unmap_area();
}
-static struct platform_driver efi_secret_driver = {
- .probe = efi_secret_probe,
- .remove = efi_secret_remove,
- .driver = {
- .name = "efi_secret",
- },
-};
-
-module_platform_driver(efi_secret_driver);
+module_faux_driver(efi_secret, efi_secret_probe, efi_secret_remove,
+ efi.coco_secret != EFI_INVALID_TABLE_ADDR);
MODULE_DESCRIPTION("Confidential computing EFI secret area access");
MODULE_AUTHOR("IBM");
MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:efi_secret");
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 6/8] efi: efivars: Transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
` (4 preceding siblings ...)
2025-03-18 17:01 ` [PATCH v2 5/8] virt: efi_secret: " Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 7/8] ACPI: APEI: EINJ: " Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 8/8] net: phy: fixed_phy: transition " Sudeep Holla
7 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Sudeep Holla, Greg Kroah-Hartman, Ard Biesheuvel, linux-efi
The "efivars" platform device is created just to enable the efi-pstore
module to autoload based on it. It doesn't have to be platform device
though. Originally, this approach was chosen for simplicity when the
driver was first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate this efivars device to
utilize the faux bus, given that the platform device it previously
created was not a real one anyway.
The modalias is retained here as efi-pstore module is dependent on it.
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-efi@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/efi/efi-pstore.c | 2 +-
drivers/firmware/efi/efi.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index a253b61449459eca31afc6ca780a20c4557659ba..eed756a59bba3b5a58cd2e238400c3c12fd5edd5 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -301,4 +301,4 @@ module_exit(efivars_pstore_exit);
MODULE_DESCRIPTION("EFI variable backend for pstore");
MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:efivars");
+MODULE_ALIAS("faux:efivars");
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 862b7744c28ecc9e5a64bbb3533c34119f50267f..dc5c24a7ca540cac342ceddcdbf75b55bf82c889 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -24,7 +24,7 @@
#include <linux/initrd.h>
#include <linux/io.h>
#include <linux/kexec.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/random.h>
#include <linux/reboot.h>
#include <linux/slab.h>
@@ -443,7 +443,7 @@ static int __init efisubsys_init(void)
error = efivar_ssdt_load();
if (error)
pr_err("efi: failed to load SSDT, error %d.\n", error);
- platform_device_register_simple("efivars", 0, NULL, 0);
+ faux_device_create("efivars", NULL, NULL);
}
BLOCKING_INIT_NOTIFIER_HEAD(&efivar_ops_nh);
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 7/8] ACPI: APEI: EINJ: Transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
` (5 preceding siblings ...)
2025-03-18 17:01 ` [PATCH v2 6/8] efi: efivars: " Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-04-09 18:18 ` Rafael J. Wysocki
2025-03-18 17:01 ` [PATCH v2 8/8] net: phy: fixed_phy: transition " Sudeep Holla
7 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel
Cc: Sudeep Holla, Greg Kroah-Hartman, Rafael J. Wysocki,
Borislav Petkov, linux-acpi
The APEI error injection driver does not require the creation of a
platform device. Originally, this approach was chosen for simplicity
when the driver was first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate the driver to utilize the
faux bus, given that the platform device it previously created was not
a real one anyway. This will simplify the code, reducing its footprint
while maintaining functionality.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/acpi/apei/einj-core.c | 51 +++++--------------------------------------
1 file changed, 6 insertions(+), 45 deletions(-)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 04731a5b01faaba534bad853d0acc4c8a873a53b..5fddd01074bafab2f7b23fd7ef9f863c0856637b 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -21,7 +21,7 @@
#include <linux/nmi.h>
#include <linux/delay.h>
#include <linux/mm.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/unaligned.h>
#include "apei-internal.h"
@@ -749,7 +749,7 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
return 0;
}
-static int __init einj_probe(struct platform_device *pdev)
+static int __init einj_probe(struct faux_device *fdev)
{
int rc;
acpi_status status;
@@ -838,6 +838,8 @@ static int __init einj_probe(struct platform_device *pdev)
pr_info("Error INJection is initialized.\n");
+ einj_initialized = true;
+
return 0;
err_release:
@@ -851,7 +853,7 @@ static int __init einj_probe(struct platform_device *pdev)
return rc;
}
-static void __exit einj_remove(struct platform_device *pdev)
+static void __exit einj_remove(struct faux_device *fdev)
{
struct apei_exec_context ctx;
@@ -872,48 +874,7 @@ static void __exit einj_remove(struct platform_device *pdev)
acpi_put_table((struct acpi_table_header *)einj_tab);
}
-static struct platform_device *einj_dev;
-/*
- * einj_remove() lives in .exit.text. For drivers registered via
- * platform_driver_probe() this is ok because they cannot get unbound at
- * runtime. So mark the driver struct with __refdata to prevent modpost
- * triggering a section mismatch warning.
- */
-static struct platform_driver einj_driver __refdata = {
- .remove = __exit_p(einj_remove),
- .driver = {
- .name = "acpi-einj",
- },
-};
-
-static int __init einj_init(void)
-{
- struct platform_device_info einj_dev_info = {
- .name = "acpi-einj",
- .id = -1,
- };
- int rc;
-
- einj_dev = platform_device_register_full(&einj_dev_info);
- if (IS_ERR(einj_dev))
- return PTR_ERR(einj_dev);
-
- rc = platform_driver_probe(&einj_driver, einj_probe);
- einj_initialized = rc == 0;
-
- return 0;
-}
-
-static void __exit einj_exit(void)
-{
- if (einj_initialized)
- platform_driver_unregister(&einj_driver);
-
- platform_device_unregister(einj_dev);
-}
-
-module_init(einj_init);
-module_exit(einj_exit);
+module_faux_driver(acpi_einj, einj_probe, __exit_p(einj_remove), true);
MODULE_AUTHOR("Huang Ying");
MODULE_DESCRIPTION("APEI Error INJection support");
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v2 8/8] net: phy: fixed_phy: transition to the faux device interface
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
` (6 preceding siblings ...)
2025-03-18 17:01 ` [PATCH v2 7/8] ACPI: APEI: EINJ: " Sudeep Holla
@ 2025-03-18 17:01 ` Sudeep Holla
2025-03-18 17:12 ` Andrew Lunn
7 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-03-18 17:01 UTC (permalink / raw)
To: linux-kernel
Cc: Sudeep Holla, Greg Kroah-Hartman, Andrew Lunn, David S. Miller,
netdev
The net fixed phy driver does not require the creation of a platform
device. Originally, this approach was chosen for simplicity when the
driver was first implemented.
With the introduction of the lightweight faux device interface, we now
have a more appropriate alternative. Migrate the device to utilize the
faux bus, given that the platform device it previously created was not
a real one anyway. This will get rid of the fake platform device.
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/net/phy/fixed_phy.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index aef739c20ac4d5a271465a677a85ef7c18cfce70..ee7831a9849b3728ca9c541da35d17e089985da2 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -10,7 +10,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/list.h>
#include <linux/mii.h>
#include <linux/phy.h>
@@ -40,7 +40,7 @@ struct fixed_phy {
struct gpio_desc *link_gpiod;
};
-static struct platform_device *pdev;
+static struct faux_device *fdev;
static struct fixed_mdio_bus platform_fmb = {
.phys = LIST_HEAD_INIT(platform_fmb.phys),
};
@@ -337,9 +337,9 @@ static int __init fixed_mdio_bus_init(void)
struct fixed_mdio_bus *fmb = &platform_fmb;
int ret;
- pdev = platform_device_register_simple("Fixed MDIO bus", 0, NULL, 0);
- if (IS_ERR(pdev))
- return PTR_ERR(pdev);
+ fdev = faux_device_create("Fixed MDIO bus", NULL, NULL);
+ if (!fdev)
+ return -ENODEV;
fmb->mii_bus = mdiobus_alloc();
if (fmb->mii_bus == NULL) {
@@ -350,7 +350,7 @@ static int __init fixed_mdio_bus_init(void)
snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0");
fmb->mii_bus->name = "Fixed MDIO Bus";
fmb->mii_bus->priv = fmb;
- fmb->mii_bus->parent = &pdev->dev;
+ fmb->mii_bus->parent = &fdev->dev;
fmb->mii_bus->read = &fixed_mdio_read;
fmb->mii_bus->write = &fixed_mdio_write;
fmb->mii_bus->phy_mask = ~0;
@@ -364,7 +364,7 @@ static int __init fixed_mdio_bus_init(void)
err_mdiobus_alloc:
mdiobus_free(fmb->mii_bus);
err_mdiobus_reg:
- platform_device_unregister(pdev);
+ faux_device_destroy(fdev);
return ret;
}
module_init(fixed_mdio_bus_init);
@@ -376,7 +376,7 @@ static void __exit fixed_mdio_bus_exit(void)
mdiobus_unregister(fmb->mii_bus);
mdiobus_free(fmb->mii_bus);
- platform_device_unregister(pdev);
+ faux_device_destroy(fdev);
list_for_each_entry_safe(fp, tmp, &fmb->phys, node) {
list_del(&fp->node);
--
2.34.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v2 5/8] virt: efi_secret: Transition to the faux device interface
2025-03-18 17:01 ` [PATCH v2 5/8] virt: efi_secret: " Sudeep Holla
@ 2025-03-18 17:10 ` Ard Biesheuvel
2025-03-19 13:15 ` Sudeep Holla
0 siblings, 1 reply; 25+ messages in thread
From: Ard Biesheuvel @ 2025-03-18 17:10 UTC (permalink / raw)
To: Sudeep Holla; +Cc: linux-kernel, Greg Kroah-Hartman, linux-efi
On Tue, 18 Mar 2025 at 18:02, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> The EFI secret area driver does not require the creation of a platform
> device. Originally, this approach was chosen for simplicity when the
> driver was first implemented.
>
> With the introduction of the lightweight faux device interface, we now
> have a more appropriate alternative. Migrate the driver to utilize the
> faux bus, given that the platform device it previously created was not
> a real one anyway. This will simplify the code, reducing its footprint
> while maintaining functionality.
>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: linux-efi@vger.kernel.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
So how is module autoload supposed to work with this driver?
> ---
> drivers/firmware/efi/efi.c | 5 -----
> drivers/virt/coco/efi_secret/efi_secret.c | 29 ++++++++---------------------
> 2 files changed, 8 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 8aebc747c65bc1b63d514a50fe6f35a9e3c1af0a..862b7744c28ecc9e5a64bbb3533c34119f50267f 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -465,11 +465,6 @@ static int __init efisubsys_init(void)
> if (efi_enabled(EFI_DBG) && efi_enabled(EFI_PRESERVE_BS_REGIONS))
> efi_debugfs_init();
>
> -#ifdef CONFIG_EFI_COCO_SECRET
> - if (efi.coco_secret != EFI_INVALID_TABLE_ADDR)
> - platform_device_register_simple("efi_secret", 0, NULL, 0);
> -#endif
> -
> return 0;
>
> err_remove_group:
> diff --git a/drivers/virt/coco/efi_secret/efi_secret.c b/drivers/virt/coco/efi_secret/efi_secret.c
> index 1864f9f80617e082feb574a15327949972c8cc1e..a60976750bef787c78401bf4569ee5d0c7d2b5f4 100644
> --- a/drivers/virt/coco/efi_secret/efi_secret.c
> +++ b/drivers/virt/coco/efi_secret/efi_secret.c
> @@ -16,7 +16,7 @@
> * is the GUID of the secret entry, and its content is the secret data.
> */
>
> -#include <linux/platform_device.h>
> +#include <linux/device/faux.h>
> #include <linux/seq_file.h>
> #include <linux/fs.h>
> #include <linux/kernel.h>
> @@ -152,17 +152,12 @@ static const struct inode_operations efi_secret_dir_inode_operations = {
> .unlink = efi_secret_unlink,
> };
>
> -static int efi_secret_map_area(struct platform_device *dev)
> +static int efi_secret_map_area(struct faux_device *dev)
> {
> int ret;
> struct efi_secret *s = efi_secret_get();
> struct linux_efi_coco_secret_area *secret_area;
>
> - if (efi.coco_secret == EFI_INVALID_TABLE_ADDR) {
> - dev_err(&dev->dev, "Secret area address is not available\n");
> - return -EINVAL;
> - }
> -
> secret_area = memremap(efi.coco_secret, sizeof(*secret_area), MEMREMAP_WB);
> if (secret_area == NULL) {
> dev_err(&dev->dev, "Could not map secret area EFI config entry\n");
> @@ -191,7 +186,7 @@ static int efi_secret_map_area(struct platform_device *dev)
> return ret;
> }
>
> -static void efi_secret_securityfs_teardown(struct platform_device *dev)
> +static void efi_secret_securityfs_teardown(struct faux_device *dev)
> {
> struct efi_secret *s = efi_secret_get();
> int i;
> @@ -210,7 +205,7 @@ static void efi_secret_securityfs_teardown(struct platform_device *dev)
> dev_dbg(&dev->dev, "Removed securityfs entries\n");
> }
>
> -static int efi_secret_securityfs_setup(struct platform_device *dev)
> +static int efi_secret_securityfs_setup(struct faux_device *dev)
> {
> struct efi_secret *s = efi_secret_get();
> int ret = 0, i = 0, bytes_left;
> @@ -307,7 +302,7 @@ static void efi_secret_unmap_area(void)
> }
> }
>
> -static int efi_secret_probe(struct platform_device *dev)
> +static int efi_secret_probe(struct faux_device *dev)
> {
> int ret;
>
> @@ -326,23 +321,15 @@ static int efi_secret_probe(struct platform_device *dev)
> return ret;
> }
>
> -static void efi_secret_remove(struct platform_device *dev)
> +static void efi_secret_remove(struct faux_device *dev)
> {
> efi_secret_securityfs_teardown(dev);
> efi_secret_unmap_area();
> }
>
> -static struct platform_driver efi_secret_driver = {
> - .probe = efi_secret_probe,
> - .remove = efi_secret_remove,
> - .driver = {
> - .name = "efi_secret",
> - },
> -};
> -
> -module_platform_driver(efi_secret_driver);
> +module_faux_driver(efi_secret, efi_secret_probe, efi_secret_remove,
> + efi.coco_secret != EFI_INVALID_TABLE_ADDR);
>
> MODULE_DESCRIPTION("Confidential computing EFI secret area access");
> MODULE_AUTHOR("IBM");
> MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:efi_secret");
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 8/8] net: phy: fixed_phy: transition to the faux device interface
2025-03-18 17:01 ` [PATCH v2 8/8] net: phy: fixed_phy: transition " Sudeep Holla
@ 2025-03-18 17:12 ` Andrew Lunn
2025-03-19 11:05 ` Sudeep Holla
0 siblings, 1 reply; 25+ messages in thread
From: Andrew Lunn @ 2025-03-18 17:12 UTC (permalink / raw)
To: Sudeep Holla; +Cc: linux-kernel, Greg Kroah-Hartman, David S. Miller, netdev
On Tue, Mar 18, 2025 at 05:01:46PM +0000, Sudeep Holla wrote:
> The net fixed phy driver does not require the creation of a platform
> device. Originally, this approach was chosen for simplicity when the
> driver was first implemented.
>
> With the introduction of the lightweight faux device interface, we now
> have a more appropriate alternative. Migrate the device to utilize the
> faux bus, given that the platform device it previously created was not
> a real one anyway. This will get rid of the fake platform device.
You were asked to split this up by subsystem. So why is this 8/8?
There are not 7 other patches for netdev.
Please also take a read of:
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 8/8] net: phy: fixed_phy: transition to the faux device interface
2025-03-18 17:12 ` Andrew Lunn
@ 2025-03-19 11:05 ` Sudeep Holla
0 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-03-19 11:05 UTC (permalink / raw)
To: Andrew Lunn
Cc: linux-kernel, Sudeep Holla, Greg Kroah-Hartman, David S. Miller,
netdev
On Tue, Mar 18, 2025 at 06:12:21PM +0100, Andrew Lunn wrote:
> On Tue, Mar 18, 2025 at 05:01:46PM +0000, Sudeep Holla wrote:
> > The net fixed phy driver does not require the creation of a platform
> > device. Originally, this approach was chosen for simplicity when the
> > driver was first implemented.
> >
> > With the introduction of the lightweight faux device interface, we now
> > have a more appropriate alternative. Migrate the device to utilize the
> > faux bus, given that the platform device it previously created was not
> > a real one anyway. This will get rid of the fake platform device.
>
> You were asked to split this up by subsystem. So why is this 8/8?
> There are not 7 other patches for netdev.
>
Sorry for that. I admit this patch unlike other patches in the series is
not dependent on the macro introduced in 1/8. I should have posted this
independent of the series, my bad. I will do that. Thanks!
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 5/8] virt: efi_secret: Transition to the faux device interface
2025-03-18 17:10 ` Ard Biesheuvel
@ 2025-03-19 13:15 ` Sudeep Holla
2025-03-19 14:24 ` Greg Kroah-Hartman
0 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-03-19 13:15 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: linux-kernel, Sudeep Holla, Greg Kroah-Hartman, linux-efi
On Tue, Mar 18, 2025 at 06:10:41PM +0100, Ard Biesheuvel wrote:
> On Tue, 18 Mar 2025 at 18:02, Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > The EFI secret area driver does not require the creation of a platform
> > device. Originally, this approach was chosen for simplicity when the
> > driver was first implemented.
> >
> > With the introduction of the lightweight faux device interface, we now
> > have a more appropriate alternative. Migrate the driver to utilize the
> > faux bus, given that the platform device it previously created was not
> > a real one anyway. This will simplify the code, reducing its footprint
> > while maintaining functionality.
> >
> > Cc: Ard Biesheuvel <ardb@kernel.org>
> > Cc: linux-efi@vger.kernel.org
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>
> So how is module autoload supposed to work with this driver?
>
IIUC, you are right. It doesn't work. I got carried away how efi_pstore was
autoloaded in Ubuntu even without alias or platform/faux device creation. I
don't know how yet but that works. This modules doesn't.
So we may have to retain platform device/driver for autoloading reasons ?
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 5/8] virt: efi_secret: Transition to the faux device interface
2025-03-19 13:15 ` Sudeep Holla
@ 2025-03-19 14:24 ` Greg Kroah-Hartman
2025-03-19 14:30 ` Sudeep Holla
0 siblings, 1 reply; 25+ messages in thread
From: Greg Kroah-Hartman @ 2025-03-19 14:24 UTC (permalink / raw)
To: Sudeep Holla; +Cc: Ard Biesheuvel, linux-kernel, linux-efi
On Wed, Mar 19, 2025 at 01:15:38PM +0000, Sudeep Holla wrote:
> On Tue, Mar 18, 2025 at 06:10:41PM +0100, Ard Biesheuvel wrote:
> > On Tue, 18 Mar 2025 at 18:02, Sudeep Holla <sudeep.holla@arm.com> wrote:
> > >
> > > The EFI secret area driver does not require the creation of a platform
> > > device. Originally, this approach was chosen for simplicity when the
> > > driver was first implemented.
> > >
> > > With the introduction of the lightweight faux device interface, we now
> > > have a more appropriate alternative. Migrate the driver to utilize the
> > > faux bus, given that the platform device it previously created was not
> > > a real one anyway. This will simplify the code, reducing its footprint
> > > while maintaining functionality.
> > >
> > > Cc: Ard Biesheuvel <ardb@kernel.org>
> > > Cc: linux-efi@vger.kernel.org
> > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> >
> > So how is module autoload supposed to work with this driver?
> >
>
> IIUC, you are right. It doesn't work. I got carried away how efi_pstore was
> autoloaded in Ubuntu even without alias or platform/faux device creation. I
> don't know how yet but that works. This modules doesn't.
>
> So we may have to retain platform device/driver for autoloading reasons ?
If that's required, yes.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 5/8] virt: efi_secret: Transition to the faux device interface
2025-03-19 14:24 ` Greg Kroah-Hartman
@ 2025-03-19 14:30 ` Sudeep Holla
0 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-03-19 14:30 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Ard Biesheuvel, linux-kernel, Sudeep Holla, linux-efi
On Wed, Mar 19, 2025 at 07:24:53AM -0700, Greg Kroah-Hartman wrote:
> On Wed, Mar 19, 2025 at 01:15:38PM +0000, Sudeep Holla wrote:
> > On Tue, Mar 18, 2025 at 06:10:41PM +0100, Ard Biesheuvel wrote:
> > > On Tue, 18 Mar 2025 at 18:02, Sudeep Holla <sudeep.holla@arm.com> wrote:
> > > >
> > > > The EFI secret area driver does not require the creation of a platform
> > > > device. Originally, this approach was chosen for simplicity when the
> > > > driver was first implemented.
> > > >
> > > > With the introduction of the lightweight faux device interface, we now
> > > > have a more appropriate alternative. Migrate the driver to utilize the
> > > > faux bus, given that the platform device it previously created was not
> > > > a real one anyway. This will simplify the code, reducing its footprint
> > > > while maintaining functionality.
> > > >
> > > > Cc: Ard Biesheuvel <ardb@kernel.org>
> > > > Cc: linux-efi@vger.kernel.org
> > > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > >
> > > So how is module autoload supposed to work with this driver?
> > >
> >
> > IIUC, you are right. It doesn't work. I got carried away how efi_pstore was
> > autoloaded in Ubuntu even without alias or platform/faux device creation. I
> > don't know how yet but that works. This modules doesn't.
> >
> > So we may have to retain platform device/driver for autoloading reasons ?
>
> If that's required, yes.
Thanks for confirming. I will drop this and see if autoloading is needed
in any other modules as well.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: (subset) [PATCH v2 4/8] rtc: efi: Transition to the faux device interface
2025-03-18 17:01 ` [PATCH v2 4/8] rtc: efi: Transition " Sudeep Holla
@ 2025-04-08 14:45 ` Alexandre Belloni
2025-04-08 15:01 ` Sudeep Holla
0 siblings, 1 reply; 25+ messages in thread
From: Alexandre Belloni @ 2025-04-08 14:45 UTC (permalink / raw)
To: linux-kernel, Sudeep Holla
Cc: Greg Kroah-Hartman, Ard Biesheuvel, linux-rtc, linux-efi
On Tue, 18 Mar 2025 17:01:42 +0000, Sudeep Holla wrote:
> The EFI RTC driver does not require the creation of a platform device.
> Originally, this approach was chosen for simplicity when the driver was
> first implemented.
>
> With the introduction of the lightweight faux device interface, we now
> have a more appropriate alternative. Migrate the driver to utilize the
> faux bus, given that the platform device it previously created was not
> a real one anyway. This will simplify the code, reducing its footprint
> while maintaining functionality.
>
> [...]
Applied, thanks!
[4/8] rtc: efi: Transition to the faux device interface
https://git.kernel.org/abelloni/c/89a378d01e7e
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: (subset) [PATCH v2 4/8] rtc: efi: Transition to the faux device interface
2025-04-08 14:45 ` (subset) " Alexandre Belloni
@ 2025-04-08 15:01 ` Sudeep Holla
0 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-04-08 15:01 UTC (permalink / raw)
To: Alexandre Belloni
Cc: linux-kernel, Sudeep Holla, Greg Kroah-Hartman, Ard Biesheuvel,
linux-rtc, linux-efi
On Tue, Apr 08, 2025 at 04:45:31PM +0200, Alexandre Belloni wrote:
> On Tue, 18 Mar 2025 17:01:42 +0000, Sudeep Holla wrote:
> > The EFI RTC driver does not require the creation of a platform device.
> > Originally, this approach was chosen for simplicity when the driver was
> > first implemented.
> >
> > With the introduction of the lightweight faux device interface, we now
> > have a more appropriate alternative. Migrate the driver to utilize the
> > faux bus, given that the platform device it previously created was not
> > a real one anyway. This will simplify the code, reducing its footprint
> > while maintaining functionality.
> >
> > [...]
>
> Applied, thanks!
>
> [4/8] rtc: efi: Transition to the faux device interface
> https://git.kernel.org/abelloni/c/89a378d01e7e
>
You need to drop it, sorry for not mentioning it explicitly.
module alias doesn't work which I think is a requirement and also
module_faux_driver() macro is not upstream.
Sorry for the trouble.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 7/8] ACPI: APEI: EINJ: Transition to the faux device interface
2025-03-18 17:01 ` [PATCH v2 7/8] ACPI: APEI: EINJ: " Sudeep Holla
@ 2025-04-09 18:18 ` Rafael J. Wysocki
0 siblings, 0 replies; 25+ messages in thread
From: Rafael J. Wysocki @ 2025-04-09 18:18 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
Borislav Petkov, linux-acpi
On Tue, Mar 18, 2025 at 6:02 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> The APEI error injection driver does not require the creation of a
> platform device. Originally, this approach was chosen for simplicity
> when the driver was first implemented.
>
> With the introduction of the lightweight faux device interface, we now
> have a more appropriate alternative. Migrate the driver to utilize the
> faux bus, given that the platform device it previously created was not
> a real one anyway. This will simplify the code, reducing its footprint
> while maintaining functionality.
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This causes 0-day to complain when applied on top of 6.15-rc1:
https://lore.kernel.org/linux-acpi/202504100128.AjbVDQgK-lkp@intel.com/
> ---
> drivers/acpi/apei/einj-core.c | 51 +++++--------------------------------------
> 1 file changed, 6 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 04731a5b01faaba534bad853d0acc4c8a873a53b..5fddd01074bafab2f7b23fd7ef9f863c0856637b 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -21,7 +21,7 @@
> #include <linux/nmi.h>
> #include <linux/delay.h>
> #include <linux/mm.h>
> -#include <linux/platform_device.h>
> +#include <linux/device/faux.h>
> #include <linux/unaligned.h>
>
> #include "apei-internal.h"
> @@ -749,7 +749,7 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
> return 0;
> }
>
> -static int __init einj_probe(struct platform_device *pdev)
> +static int __init einj_probe(struct faux_device *fdev)
> {
> int rc;
> acpi_status status;
> @@ -838,6 +838,8 @@ static int __init einj_probe(struct platform_device *pdev)
>
> pr_info("Error INJection is initialized.\n");
>
> + einj_initialized = true;
> +
> return 0;
>
> err_release:
> @@ -851,7 +853,7 @@ static int __init einj_probe(struct platform_device *pdev)
> return rc;
> }
>
> -static void __exit einj_remove(struct platform_device *pdev)
> +static void __exit einj_remove(struct faux_device *fdev)
> {
> struct apei_exec_context ctx;
>
> @@ -872,48 +874,7 @@ static void __exit einj_remove(struct platform_device *pdev)
> acpi_put_table((struct acpi_table_header *)einj_tab);
> }
>
> -static struct platform_device *einj_dev;
> -/*
> - * einj_remove() lives in .exit.text. For drivers registered via
> - * platform_driver_probe() this is ok because they cannot get unbound at
> - * runtime. So mark the driver struct with __refdata to prevent modpost
> - * triggering a section mismatch warning.
> - */
> -static struct platform_driver einj_driver __refdata = {
> - .remove = __exit_p(einj_remove),
> - .driver = {
> - .name = "acpi-einj",
> - },
> -};
> -
> -static int __init einj_init(void)
> -{
> - struct platform_device_info einj_dev_info = {
> - .name = "acpi-einj",
> - .id = -1,
> - };
> - int rc;
> -
> - einj_dev = platform_device_register_full(&einj_dev_info);
> - if (IS_ERR(einj_dev))
> - return PTR_ERR(einj_dev);
> -
> - rc = platform_driver_probe(&einj_driver, einj_probe);
> - einj_initialized = rc == 0;
> -
> - return 0;
> -}
> -
> -static void __exit einj_exit(void)
> -{
> - if (einj_initialized)
> - platform_driver_unregister(&einj_driver);
> -
> - platform_device_unregister(einj_dev);
> -}
> -
> -module_init(einj_init);
> -module_exit(einj_exit);
> +module_faux_driver(acpi_einj, einj_probe, __exit_p(einj_remove), true);
>
> MODULE_AUTHOR("Huang Ying");
> MODULE_DESCRIPTION("APEI Error INJection support");
>
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate
2025-03-18 17:01 ` [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate Sudeep Holla
@ 2025-04-15 12:21 ` Greg Kroah-Hartman
2025-04-15 12:25 ` Sudeep Holla
0 siblings, 1 reply; 25+ messages in thread
From: Greg Kroah-Hartman @ 2025-04-15 12:21 UTC (permalink / raw)
To: Sudeep Holla; +Cc: linux-kernel
On Tue, Mar 18, 2025 at 05:01:39PM +0000, Sudeep Holla wrote:
> For simple modules that needs to create a faux device without any
> additional setup code ends up being a block of duplicated boilerplate.
>
> Add a new macro, module_faux_driver(), which help to replaces the
> those duplicated boilerplate.
>
> This macro use the same idea of module_platform_driver() but adds this
> initial condition to avoid creation of faux device if not necessary.
What is this "condition" for?
Every time you put "true" or "false" in the function call, someone will
have to look it up to see what is going on, that's going to be a pain.
Making apis is hard, let's not making using them even harder.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface
2025-03-18 17:01 ` [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface Sudeep Holla
@ 2025-04-15 12:21 ` Greg Kroah-Hartman
2025-04-15 12:35 ` Sudeep Holla
2025-05-01 13:01 ` Jon Hunter
1 sibling, 1 reply; 25+ messages in thread
From: Greg Kroah-Hartman @ 2025-04-15 12:21 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-kernel, Lorenzo Pieralisi, Rafael J. Wysocki,
Daniel Lezcano, linux-pm
On Tue, Mar 18, 2025 at 05:01:40PM +0000, Sudeep Holla wrote:
> The PSCI cpuidle driver does not require the creation of a platform
> device. Originally, this approach was chosen for simplicity when the
> driver was first implemented.
>
> With the introduction of the lightweight faux device interface, we now
> have a more appropriate alternative. Migrate the driver to utilize the
> faux bus, given that the platform device it previously created was not
> a real one anyway. This will simplify the code, reducing its footprint
> while maintaining functionality.
>
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/cpuidle/cpuidle-psci.c | 32 ++++----------------------------
> 1 file changed, 4 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> index 2562dc001fc1de69732ef28f383d2809262a3d96..5d4d6daed36d8540ba2ce3dc54a3180731b03d22 100644
> --- a/drivers/cpuidle/cpuidle-psci.c
> +++ b/drivers/cpuidle/cpuidle-psci.c
> @@ -16,7 +16,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/of.h>
> -#include <linux/platform_device.h>
> +#include <linux/device/faux.h>
> #include <linux/psci.h>
> #include <linux/pm_domain.h>
> #include <linux/pm_runtime.h>
> @@ -404,14 +404,14 @@ static int psci_idle_init_cpu(struct device *dev, int cpu)
> * to register cpuidle driver then rollback to cancel all CPUs
> * registration.
> */
> -static int psci_cpuidle_probe(struct platform_device *pdev)
> +static int psci_cpuidle_probe(struct faux_device *fdev)
> {
> int cpu, ret;
> struct cpuidle_driver *drv;
> struct cpuidle_device *dev;
>
> for_each_possible_cpu(cpu) {
> - ret = psci_idle_init_cpu(&pdev->dev, cpu);
> + ret = psci_idle_init_cpu(&fdev->dev, cpu);
> if (ret)
> goto out_fail;
> }
> @@ -431,28 +431,4 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static struct platform_driver psci_cpuidle_driver = {
> - .probe = psci_cpuidle_probe,
> - .driver = {
> - .name = "psci-cpuidle",
> - },
> -};
> -
> -static int __init psci_idle_init(void)
> -{
> - struct platform_device *pdev;
> - int ret;
> -
> - ret = platform_driver_register(&psci_cpuidle_driver);
> - if (ret)
> - return ret;
> -
> - pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0);
> - if (IS_ERR(pdev)) {
> - platform_driver_unregister(&psci_cpuidle_driver);
> - return PTR_ERR(pdev);
> - }
> -
> - return 0;
> -}
> -device_initcall(psci_idle_init);
> +module_faux_driver(psci_cpuidle, psci_cpuidle_probe, NULL, true);
See, what does "true" mean here?
Why would you ever want "false"?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate
2025-04-15 12:21 ` Greg Kroah-Hartman
@ 2025-04-15 12:25 ` Sudeep Holla
0 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-04-15 12:25 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, Sudeep Holla
On Tue, Apr 15, 2025 at 02:21:10PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Mar 18, 2025 at 05:01:39PM +0000, Sudeep Holla wrote:
> > For simple modules that needs to create a faux device without any
> > additional setup code ends up being a block of duplicated boilerplate.
> >
> > Add a new macro, module_faux_driver(), which help to replaces the
> > those duplicated boilerplate.
> >
> > This macro use the same idea of module_platform_driver() but adds this
> > initial condition to avoid creation of faux device if not necessary.
>
> What is this "condition" for?
>
> Every time you put "true" or "false" in the function call, someone will
> have to look it up to see what is going on, that's going to be a pain.
>
> Making apis is hard, let's not making using them even harder.
>
Agreed and also since the number of users the would use reduced due to
their autoload dependency, I dropped the idea of having the macro. All the
ones that can be moved to use faux_device have now moved(I mean queued)
without this macro as it was in v1 of the series.
Thanks for the time and review. Sorry I should have provided update on this
after I had to drop all the efi related patches for the above reason.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface
2025-04-15 12:21 ` Greg Kroah-Hartman
@ 2025-04-15 12:35 ` Sudeep Holla
0 siblings, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2025-04-15 12:35 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, Lorenzo Pieralisi, Sudeep Holla, Rafael J. Wysocki,
Daniel Lezcano, linux-pm
On Tue, Apr 15, 2025 at 02:21:33PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Mar 18, 2025 at 05:01:40PM +0000, Sudeep Holla wrote:
> > The PSCI cpuidle driver does not require the creation of a platform
> > device. Originally, this approach was chosen for simplicity when the
> > driver was first implemented.
> >
> > With the introduction of the lightweight faux device interface, we now
> > have a more appropriate alternative. Migrate the driver to utilize the
> > faux bus, given that the platform device it previously created was not
> > a real one anyway. This will simplify the code, reducing its footprint
> > while maintaining functionality.
> >
> > Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: linux-pm@vger.kernel.org
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> > drivers/cpuidle/cpuidle-psci.c | 32 ++++----------------------------
> > 1 file changed, 4 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> > index 2562dc001fc1de69732ef28f383d2809262a3d96..5d4d6daed36d8540ba2ce3dc54a3180731b03d22 100644
> > --- a/drivers/cpuidle/cpuidle-psci.c
> > +++ b/drivers/cpuidle/cpuidle-psci.c
> > @@ -16,7 +16,7 @@
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > #include <linux/of.h>
> > -#include <linux/platform_device.h>
> > +#include <linux/device/faux.h>
> > #include <linux/psci.h>
> > #include <linux/pm_domain.h>
> > #include <linux/pm_runtime.h>
> > @@ -404,14 +404,14 @@ static int psci_idle_init_cpu(struct device *dev, int cpu)
> > * to register cpuidle driver then rollback to cancel all CPUs
> > * registration.
> > */
> > -static int psci_cpuidle_probe(struct platform_device *pdev)
> > +static int psci_cpuidle_probe(struct faux_device *fdev)
> > {
> > int cpu, ret;
> > struct cpuidle_driver *drv;
> > struct cpuidle_device *dev;
> >
> > for_each_possible_cpu(cpu) {
> > - ret = psci_idle_init_cpu(&pdev->dev, cpu);
> > + ret = psci_idle_init_cpu(&fdev->dev, cpu);
> > if (ret)
> > goto out_fail;
> > }
> > @@ -431,28 +431,4 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
> > return ret;
> > }
> >
> > -static struct platform_driver psci_cpuidle_driver = {
> > - .probe = psci_cpuidle_probe,
> > - .driver = {
> > - .name = "psci-cpuidle",
> > - },
> > -};
> > -
> > -static int __init psci_idle_init(void)
> > -{
> > - struct platform_device *pdev;
> > - int ret;
> > -
> > - ret = platform_driver_register(&psci_cpuidle_driver);
> > - if (ret)
> > - return ret;
> > -
> > - pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0);
> > - if (IS_ERR(pdev)) {
> > - platform_driver_unregister(&psci_cpuidle_driver);
> > - return PTR_ERR(pdev);
> > - }
> > -
> > - return 0;
> > -}
> > -device_initcall(psci_idle_init);
> > +module_faux_driver(psci_cpuidle, psci_cpuidle_probe, NULL, true);
>
> See, what does "true" mean here?
>
> Why would you ever want "false"?
>
There were few efi platform devices that were created conditionally and
the idea with this true/false was to pass that condition. I agree it was
not clean. Anyways since efi platform devices can't be moved to faux
devices, this flag becomes useless as it is most true for all other users.
Also as mention in the other thread, the need for macro also become very
weak as efi devices can't be moved into faux.
So all the patches in v1 except efi and trng are now queued via respective
trees using faux device apis directly without this weird macro 😄.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface
2025-03-18 17:01 ` [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface Sudeep Holla
2025-04-15 12:21 ` Greg Kroah-Hartman
@ 2025-05-01 13:01 ` Jon Hunter
2025-05-01 16:07 ` Sudeep Holla
1 sibling, 1 reply; 25+ messages in thread
From: Jon Hunter @ 2025-05-01 13:01 UTC (permalink / raw)
To: Sudeep Holla, linux-kernel
Cc: Greg Kroah-Hartman, Lorenzo Pieralisi, Rafael J. Wysocki,
Daniel Lezcano, linux-pm, linux-tegra@vger.kernel.org
Hi Sudeep,
On 18/03/2025 17:01, Sudeep Holla wrote:
> The PSCI cpuidle driver does not require the creation of a platform
> device. Originally, this approach was chosen for simplicity when the
> driver was first implemented.
>
> With the introduction of the lightweight faux device interface, we now
> have a more appropriate alternative. Migrate the driver to utilize the
> faux bus, given that the platform device it previously created was not
> a real one anyway. This will simplify the code, reducing its footprint
> while maintaining functionality.
>
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/cpuidle/cpuidle-psci.c | 32 ++++----------------------------
> 1 file changed, 4 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> index 2562dc001fc1de69732ef28f383d2809262a3d96..5d4d6daed36d8540ba2ce3dc54a3180731b03d22 100644
> --- a/drivers/cpuidle/cpuidle-psci.c
> +++ b/drivers/cpuidle/cpuidle-psci.c
> @@ -16,7 +16,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/of.h>
> -#include <linux/platform_device.h>
> +#include <linux/device/faux.h>
> #include <linux/psci.h>
> #include <linux/pm_domain.h>
> #include <linux/pm_runtime.h>
> @@ -404,14 +404,14 @@ static int psci_idle_init_cpu(struct device *dev, int cpu)
> * to register cpuidle driver then rollback to cancel all CPUs
> * registration.
> */
> -static int psci_cpuidle_probe(struct platform_device *pdev)
> +static int psci_cpuidle_probe(struct faux_device *fdev)
> {
> int cpu, ret;
> struct cpuidle_driver *drv;
> struct cpuidle_device *dev;
>
> for_each_possible_cpu(cpu) {
> - ret = psci_idle_init_cpu(&pdev->dev, cpu);
> + ret = psci_idle_init_cpu(&fdev->dev, cpu);
> if (ret)
> goto out_fail;
> }
> @@ -431,28 +431,4 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
> return ret;
> }
>
> -static struct platform_driver psci_cpuidle_driver = {
> - .probe = psci_cpuidle_probe,
> - .driver = {
> - .name = "psci-cpuidle",
> - },
> -};
> -
> -static int __init psci_idle_init(void)
> -{
> - struct platform_device *pdev;
> - int ret;
> -
> - ret = platform_driver_register(&psci_cpuidle_driver);
> - if (ret)
> - return ret;
> -
> - pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0);
> - if (IS_ERR(pdev)) {
> - platform_driver_unregister(&psci_cpuidle_driver);
> - return PTR_ERR(pdev);
> - }
> -
> - return 0;
> -}
> -device_initcall(psci_idle_init);
> +module_faux_driver(psci_cpuidle, psci_cpuidle_probe, NULL, true);
>
I have noticed the following error messages on some of our Tegra devices ...
ERR KERN faux psci-cpuidle: probe did not succeed, tearing down the device
ERR KERN CPUidle PSCI: Failed to create psci-cpuidle device
I had a quick look at this and this occurs because of the following code
in the probe cpuidle-psci driver ...
/*
* If no DT idle states are detected (ret == 0) let the driver
* initialization fail accordingly since there is no reason to
* initialize the idle driver if only wfi is supported, the
* default archictectural back-end already executes wfi
* on idle entry.
*/
ret = dt_init_idle_driver(drv, psci_idle_state_match, 1);
if (ret <= 0)
return ret ? : -ENODEV;
So although it could be argued that the error message is valid, I am not
sure if there is anything that mandates that we need to have the
idle-states present.
We are always checking for new kernel errors and so if something new
occurs, I am trying to figure out what is the correct way to fix. For
this case I am not sure what is best.
Thanks
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface
2025-05-01 13:01 ` Jon Hunter
@ 2025-05-01 16:07 ` Sudeep Holla
2025-05-02 10:20 ` Jon Hunter
0 siblings, 1 reply; 25+ messages in thread
From: Sudeep Holla @ 2025-05-01 16:07 UTC (permalink / raw)
To: Jon Hunter
Cc: linux-kernel, Greg Kroah-Hartman, Lorenzo Pieralisi,
Rafael J. Wysocki, Daniel Lezcano, linux-pm,
linux-tegra@vger.kernel.org
On Thu, May 01, 2025 at 02:01:19PM +0100, Jon Hunter wrote:
> Hi Sudeep,
>
> On 18/03/2025 17:01, Sudeep Holla wrote:
> > The PSCI cpuidle driver does not require the creation of a platform
> > device. Originally, this approach was chosen for simplicity when the
> > driver was first implemented.
> >
> > With the introduction of the lightweight faux device interface, we now
> > have a more appropriate alternative. Migrate the driver to utilize the
> > faux bus, given that the platform device it previously created was not
> > a real one anyway. This will simplify the code, reducing its footprint
> > while maintaining functionality.
> >
> > Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: linux-pm@vger.kernel.org
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> > drivers/cpuidle/cpuidle-psci.c | 32 ++++----------------------------
> > 1 file changed, 4 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> > index 2562dc001fc1de69732ef28f383d2809262a3d96..5d4d6daed36d8540ba2ce3dc54a3180731b03d22 100644
> > --- a/drivers/cpuidle/cpuidle-psci.c
> > +++ b/drivers/cpuidle/cpuidle-psci.c
> > @@ -16,7 +16,7 @@
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > #include <linux/of.h>
> > -#include <linux/platform_device.h>
> > +#include <linux/device/faux.h>
> > #include <linux/psci.h>
> > #include <linux/pm_domain.h>
> > #include <linux/pm_runtime.h>
> > @@ -404,14 +404,14 @@ static int psci_idle_init_cpu(struct device *dev, int cpu)
> > * to register cpuidle driver then rollback to cancel all CPUs
> > * registration.
> > */
> > -static int psci_cpuidle_probe(struct platform_device *pdev)
> > +static int psci_cpuidle_probe(struct faux_device *fdev)
> > {
> > int cpu, ret;
> > struct cpuidle_driver *drv;
> > struct cpuidle_device *dev;
> > for_each_possible_cpu(cpu) {
> > - ret = psci_idle_init_cpu(&pdev->dev, cpu);
> > + ret = psci_idle_init_cpu(&fdev->dev, cpu);
> > if (ret)
> > goto out_fail;
> > }
> > @@ -431,28 +431,4 @@ static int psci_cpuidle_probe(struct platform_device *pdev)
> > return ret;
> > }
> > -static struct platform_driver psci_cpuidle_driver = {
> > - .probe = psci_cpuidle_probe,
> > - .driver = {
> > - .name = "psci-cpuidle",
> > - },
> > -};
> > -
> > -static int __init psci_idle_init(void)
> > -{
> > - struct platform_device *pdev;
> > - int ret;
> > -
> > - ret = platform_driver_register(&psci_cpuidle_driver);
> > - if (ret)
> > - return ret;
> > -
> > - pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0);
> > - if (IS_ERR(pdev)) {
> > - platform_driver_unregister(&psci_cpuidle_driver);
> > - return PTR_ERR(pdev);
> > - }
> > -
> > - return 0;
> > -}
> > -device_initcall(psci_idle_init);
> > +module_faux_driver(psci_cpuidle, psci_cpuidle_probe, NULL, true);
> >
>
>
> I have noticed the following error messages on some of our Tegra devices ...
>
> ERR KERN faux psci-cpuidle: probe did not succeed, tearing down the device
> ERR KERN CPUidle PSCI: Failed to create psci-cpuidle device
>
> I had a quick look at this and this occurs because of the following code in
> the probe cpuidle-psci driver ...
>
> /*
> * If no DT idle states are detected (ret == 0) let the driver
> * initialization fail accordingly since there is no reason to
> * initialize the idle driver if only wfi is supported, the
> * default archictectural back-end already executes wfi
> * on idle entry.
> */
> ret = dt_init_idle_driver(drv, psci_idle_state_match, 1);
> if (ret <= 0)
> return ret ? : -ENODEV;
>
>
> So although it could be argued that the error message is valid, I am not
> sure if there is anything that mandates that we need to have the idle-states
> present.
>
> We are always checking for new kernel errors and so if something new occurs,
> I am trying to figure out what is the correct way to fix. For this case I am
> not sure what is best.
>
This is another case where probe was failing before too just that faux
device probe throws the error. I will take a look and see what can be done.
But yes, we shouldn't throw error if no idle-states are present in the DT.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface
2025-05-01 16:07 ` Sudeep Holla
@ 2025-05-02 10:20 ` Jon Hunter
0 siblings, 0 replies; 25+ messages in thread
From: Jon Hunter @ 2025-05-02 10:20 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-kernel, Greg Kroah-Hartman, Lorenzo Pieralisi,
Rafael J. Wysocki, Daniel Lezcano, linux-pm,
linux-tegra@vger.kernel.org
On 01/05/2025 17:07, Sudeep Holla wrote:
...
>> I have noticed the following error messages on some of our Tegra devices ...
>>
>> ERR KERN faux psci-cpuidle: probe did not succeed, tearing down the device
>> ERR KERN CPUidle PSCI: Failed to create psci-cpuidle device
>>
>> I had a quick look at this and this occurs because of the following code in
>> the probe cpuidle-psci driver ...
>>
>> /*
>> * If no DT idle states are detected (ret == 0) let the driver
>> * initialization fail accordingly since there is no reason to
>> * initialize the idle driver if only wfi is supported, the
>> * default archictectural back-end already executes wfi
>> * on idle entry.
>> */
>> ret = dt_init_idle_driver(drv, psci_idle_state_match, 1);
>> if (ret <= 0)
>> return ret ? : -ENODEV;
>>
>>
>> So although it could be argued that the error message is valid, I am not
>> sure if there is anything that mandates that we need to have the idle-states
>> present.
>>
>> We are always checking for new kernel errors and so if something new occurs,
>> I am trying to figure out what is the correct way to fix. For this case I am
>> not sure what is best.
>>
>
> This is another case where probe was failing before too just that faux
> device probe throws the error. I will take a look and see what can be done.
> But yes, we shouldn't throw error if no idle-states are present in the DT.
Yes exactly this was already failing. Thanks for taking a look!
Cheers
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2025-05-02 10:21 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 17:01 [PATCH v2 0/8] drivers: Transition to the faux device interface Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 1/8] driver core: add helper macro for module_faux_driver() boilerplate Sudeep Holla
2025-04-15 12:21 ` Greg Kroah-Hartman
2025-04-15 12:25 ` Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 2/8] cpuidle: psci: Transition to the faux device interface Sudeep Holla
2025-04-15 12:21 ` Greg Kroah-Hartman
2025-04-15 12:35 ` Sudeep Holla
2025-05-01 13:01 ` Jon Hunter
2025-05-01 16:07 ` Sudeep Holla
2025-05-02 10:20 ` Jon Hunter
2025-03-18 17:01 ` [PATCH v2 3/8] hwrng: arm-smccc-trng - transition " Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 4/8] rtc: efi: Transition " Sudeep Holla
2025-04-08 14:45 ` (subset) " Alexandre Belloni
2025-04-08 15:01 ` Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 5/8] virt: efi_secret: " Sudeep Holla
2025-03-18 17:10 ` Ard Biesheuvel
2025-03-19 13:15 ` Sudeep Holla
2025-03-19 14:24 ` Greg Kroah-Hartman
2025-03-19 14:30 ` Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 6/8] efi: efivars: " Sudeep Holla
2025-03-18 17:01 ` [PATCH v2 7/8] ACPI: APEI: EINJ: " Sudeep Holla
2025-04-09 18:18 ` Rafael J. Wysocki
2025-03-18 17:01 ` [PATCH v2 8/8] net: phy: fixed_phy: transition " Sudeep Holla
2025-03-18 17:12 ` Andrew Lunn
2025-03-19 11:05 ` Sudeep Holla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.