Linux ACPI
 help / color / mirror / Atom feed
* [PATCH 0/9] drivers: Transition to the faux device interface
@ 2025-03-17 10:13 Sudeep Holla
  2025-03-17 10:13 ` [PATCH 8/9] ACPI: APEI: EINJ: " Sudeep Holla
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Sudeep Holla @ 2025-03-17 10:13 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, linux-efi,
	Alexandre Belloni, linux-rtc, Mark Brown, Takashi Iwai,
	linux-sound, Andrew Lunn, David S. Miller, netdev,
	Borislav Petkov, linux-acpi, Jonathan Cameron

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.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
Greg Kroah-Hartman (1):
      regulator: dummy: convert to use the faux device interface

Sudeep Holla (8):
      cpuidle: psci: Transition to the faux device interface
      hwrng: arm-smccc-trng - transition to the faux device interface
      efi: Remove redundant creation of the "efivars" platform device
      rtc: efi: Transition to the faux device interface
      virt: efi_secret: Transition to the faux device interface
      ASoC: soc-utils: Transition to the faux device interface
      net: phy: fixed_phy: transition to the faux device interface
      ACPI: APEI: EINJ: Transition to the faux device interface

 drivers/acpi/apei/einj-core.c             | 32 +++++++++---------------
 drivers/char/hw_random/arm_smccc_trng.c   | 40 +++++++++++++++++++++---------
 drivers/cpuidle/cpuidle-psci.c            | 26 +++++++-------------
 drivers/firmware/efi/efi.c                | 10 --------
 drivers/firmware/smccc/smccc.c            | 21 ----------------
 drivers/net/phy/fixed_phy.c               | 16 ++++++------
 drivers/regulator/dummy.c                 | 37 +++++++---------------------
 drivers/rtc/rtc-efi.c                     | 31 ++++++++++++++++-------
 drivers/virt/coco/efi_secret/efi_secret.c | 41 ++++++++++++++++++-------------
 sound/soc/soc-utils.c                     | 34 +++++++++----------------
 10 files changed, 124 insertions(+), 164 deletions(-)
---
base-commit: 80e54e84911a923c40d7bee33a34c1b4be148d7a
change-id: 20250315-plat2faux_dev-8c28b35be96a
-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 8/9] ACPI: APEI: EINJ: Transition to the faux device interface
  2025-03-17 10:13 [PATCH 0/9] drivers: Transition to the faux device interface Sudeep Holla
@ 2025-03-17 10:13 ` Sudeep Holla
  2025-06-06  3:35   ` Dan Williams
  2025-03-17 13:01 ` [PATCH 0/9] drivers: " Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2025-03-17 10:13 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 | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 04731a5b01faaba534bad853d0acc4c8a873a53b..7ff334422899e757de918107202507dd171d61da 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;
@@ -851,7 +851,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,34 +872,25 @@ static void __exit einj_remove(struct platform_device *pdev)
 	acpi_put_table((struct acpi_table_header *)einj_tab);
 }
 
-static struct platform_device *einj_dev;
+static struct faux_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 = {
+static struct faux_device_ops einj_device_ops __refdata = {
+	.probe = einj_probe,
 	.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);
+	einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops);
+	if (!einj_dev)
+		return -ENODEV;
 
-	rc = platform_driver_probe(&einj_driver, einj_probe);
-	einj_initialized = rc == 0;
+	einj_initialized = true;
 
 	return 0;
 }
@@ -907,9 +898,8 @@ static int __init einj_init(void)
 static void __exit einj_exit(void)
 {
 	if (einj_initialized)
-		platform_driver_unregister(&einj_driver);
+		faux_device_destroy(einj_dev);
 
-	platform_device_unregister(einj_dev);
 }
 
 module_init(einj_init);

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/9] drivers: Transition to the faux device interface
  2025-03-17 10:13 [PATCH 0/9] drivers: Transition to the faux device interface Sudeep Holla
  2025-03-17 10:13 ` [PATCH 8/9] ACPI: APEI: EINJ: " Sudeep Holla
@ 2025-03-17 13:01 ` Greg Kroah-Hartman
  2025-03-17 14:28   ` Sudeep Holla
  2025-03-17 14:20 ` Mark Brown
  2025-03-17 18:10 ` (subset) " Mark Brown
  3 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2025-03-17 13:01 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-kernel, Lorenzo Pieralisi, Rafael J. Wysocki,
	Daniel Lezcano, linux-pm, Andre Przywara, Herbert Xu,
	Jeff Johnson, linux-crypto, Ard Biesheuvel, linux-efi,
	Alexandre Belloni, linux-rtc, Mark Brown, Takashi Iwai,
	linux-sound, Andrew Lunn, David S. Miller, netdev,
	Borislav Petkov, linux-acpi, Jonathan Cameron

On Mon, Mar 17, 2025 at 10:13:12AM +0000, Sudeep Holla wrote:
> 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.

That's great, but you need to send these all independently to each
subsystem as needed.  Having it all in one series doesn't work for any
of the maintainers of any of the subsystems.

And I'm glad to see this work happening, thanks for doing that!

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/9] drivers: Transition to the faux device interface
  2025-03-17 10:13 [PATCH 0/9] drivers: Transition to the faux device interface Sudeep Holla
  2025-03-17 10:13 ` [PATCH 8/9] ACPI: APEI: EINJ: " Sudeep Holla
  2025-03-17 13:01 ` [PATCH 0/9] drivers: " Greg Kroah-Hartman
@ 2025-03-17 14:20 ` Mark Brown
  2025-03-17 18:10 ` (subset) " Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-03-17 14:20 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-kernel, Greg Kroah-Hartman, Lorenzo Pieralisi,
	Rafael J. Wysocki, Daniel Lezcano, linux-pm, Andre Przywara,
	Herbert Xu, Jeff Johnson, linux-crypto, Ard Biesheuvel, linux-efi,
	Alexandre Belloni, linux-rtc, Takashi Iwai, linux-sound,
	Andrew Lunn, David S. Miller, netdev, Borislav Petkov, linux-acpi,
	Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

On Mon, Mar 17, 2025 at 10:13:12AM +0000, Sudeep Holla wrote:

> All the patches are independent of each other.

If that's the case don't send them in a series, it makes things more
complicated to apply and the CCs cause more mail.  Split independent
things up by subsystem.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/9] drivers: Transition to the faux device interface
  2025-03-17 13:01 ` [PATCH 0/9] drivers: " Greg Kroah-Hartman
@ 2025-03-17 14:28   ` Sudeep Holla
  0 siblings, 0 replies; 7+ messages in thread
From: Sudeep Holla @ 2025-03-17 14:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Lorenzo Pieralisi, Rafael J. Wysocki,
	Daniel Lezcano, linux-pm, Andre Przywara, Herbert Xu,
	Jeff Johnson, linux-crypto, Ard Biesheuvel, linux-efi,
	Alexandre Belloni, linux-rtc, Mark Brown, Takashi Iwai,
	linux-sound, Andrew Lunn, David S. Miller, netdev,
	Borislav Petkov, linux-acpi, Jonathan Cameron

On Mon, Mar 17, 2025 at 02:01:55PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Mar 17, 2025 at 10:13:12AM +0000, Sudeep Holla wrote:
> > 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.
> 
> That's great, but you need to send these all independently to each
> subsystem as needed.  Having it all in one series doesn't work for any
> of the maintainers of any of the subsystems.
> 

Sure I can do that. I initially had idea of creating a macro that made
all of them depend on the macro but later dropped as I wanted to check
if that is good or a bad idea. I just asked you in the thread 2/9.

> And I'm glad to see this work happening, thanks for doing that!
> 

Thanks for adding faux interface!

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: (subset) [PATCH 0/9] drivers: Transition to the faux device interface
  2025-03-17 10:13 [PATCH 0/9] drivers: Transition to the faux device interface Sudeep Holla
                   ` (2 preceding siblings ...)
  2025-03-17 14:20 ` Mark Brown
@ 2025-03-17 18:10 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-03-17 18:10 UTC (permalink / raw)
  To: linux-kernel, Sudeep Holla
  Cc: Greg Kroah-Hartman, Lorenzo Pieralisi, Rafael J. Wysocki,
	Daniel Lezcano, linux-pm, Andre Przywara, Herbert Xu,
	Jeff Johnson, linux-crypto, Ard Biesheuvel, linux-efi,
	Alexandre Belloni, linux-rtc, Takashi Iwai, linux-sound,
	Andrew Lunn, David S. Miller, netdev, Borislav Petkov, linux-acpi,
	Jonathan Cameron

On Mon, 17 Mar 2025 10:13:12 +0000, Sudeep Holla wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[6/9] ASoC: soc-utils: Transition to the faux device interface
      commit: 18abb3797f1ceca97a705aa1c14cbec5c6fcab79

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 8/9] ACPI: APEI: EINJ: Transition to the faux device interface
  2025-03-17 10:13 ` [PATCH 8/9] ACPI: APEI: EINJ: " Sudeep Holla
@ 2025-06-06  3:35   ` Dan Williams
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2025-06-06  3:35 UTC (permalink / raw)
  To: Sudeep Holla, linux-kernel
  Cc: Sudeep Holla, Greg Kroah-Hartman, Rafael J. Wysocki,
	Borislav Petkov, linux-acpi, linux-cxl

[ add linux-cxl ]

Sudeep Holla 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>
> ---
>  drivers/acpi/apei/einj-core.c | 32 +++++++++++---------------------
>  1 file changed, 11 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 04731a5b01faaba534bad853d0acc4c8a873a53b..7ff334422899e757de918107202507dd171d61da 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
[..]
>  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);
> +	einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops);
> +	if (!einj_dev)
> +		return -ENODEV;
>  
> -	rc = platform_driver_probe(&einj_driver, einj_probe);
> -	einj_initialized = rc == 0;
> +	einj_initialized = true;

git bisect says this change breaks CXL subsystem initialization. This
patch seems to not understand the semantic guarantees of
platform_driver_probe().

CXL init now fails with:

    faux acpi-einj: probe did not succeed, tearing down the device

...which will fire on the majority of CXL systems because EINJ is optional.

However, failure to probe is not a module load condition failure because
the CXL subsystem still needs access to the symbols even on systems
where the EINJ facility is disabled. In other words CXL has a module
dependency on einj.ko, but all of its entry points into that module
first check einj_initialized. So part of the fix is:

diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index fea11a35eea3..9b041415a9d0 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -883,19 +883,16 @@ static int __init einj_init(void)
        }
 
        einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops);
-       if (!einj_dev)
-               return -ENODEV;
 
-       einj_initialized = true;
+       if (einj_dev)
+               einj_initialized = true;
 
        return 0;
 }
 
 static void __exit einj_exit(void)
 {
-       if (einj_initialized)
-               faux_device_destroy(einj_dev);
-
+       faux_device_destroy(einj_dev);
 }
 
 module_init(einj_init);

However, that is not sufficient because faux_device_create() unlike
platform_driver_probe() does not suppress bind attributes which means
that einj_initialized result is not stable. I.e. somebody can unbind the
faux_driver from any faux_device at any time.

I think it is reasonable for faux_devices to only have one chance to
call ->probe() at create time:

diff --git a/drivers/base/faux.c b/drivers/base/faux.c
index 9054d346bd7f..934da77ca48b 100644
--- a/drivers/base/faux.c
+++ b/drivers/base/faux.c
@@ -86,6 +86,7 @@ static struct device_driver faux_driver = {
        .name           = "faux_driver",
        .bus            = &faux_bus_type,
        .probe_type     = PROBE_FORCE_SYNCHRONOUS,
+       .suppress_bind_attrs = true,
 };
 
 static void faux_device_release(struct device *dev)

Unless that global change is acceptable I do not think
faux_device_create() is a suitable replacement for
platform_driver_probe().

Lastly, for cases where probe failure are ok the dev_err() is too noisy,
so another change to make it behave like platform_driver_probe() would
be:

diff --git a/drivers/base/faux.c b/drivers/base/faux.c
index 9054d346bd7f..f5fbda0a9a44 100644
--- a/drivers/base/faux.c
+++ b/drivers/base/faux.c
@@ -169,7 +170,7 @@ struct faux_device *faux_device_create_with_groups(const char *name,
         * successful is almost impossible to determine by the caller.
         */
        if (!dev->driver) {
-               dev_err(dev, "probe did not succeed, tearing down the device\n");
+               dev_dbg(dev, "probe did not succeed, tearing down the device\n");
                faux_device_destroy(faux_dev);
                faux_dev = NULL;
        }

Greg, if you are ok with suppress_bind_attrs = true for faux devices I will
wrap the above into a 3 patch series to fix the regression.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-06  3:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 10:13 [PATCH 0/9] drivers: Transition to the faux device interface Sudeep Holla
2025-03-17 10:13 ` [PATCH 8/9] ACPI: APEI: EINJ: " Sudeep Holla
2025-06-06  3:35   ` Dan Williams
2025-03-17 13:01 ` [PATCH 0/9] drivers: " Greg Kroah-Hartman
2025-03-17 14:28   ` Sudeep Holla
2025-03-17 14:20 ` Mark Brown
2025-03-17 18:10 ` (subset) " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox