Skip to contentSkip to conversation

mfd: core: Support auxiliary device

PATCH Superseded Raag Jadav 5 participants 18 messages Apr 3, 2025 – Apr 4, 2025

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH 1/1 mfd: core: Support auxiliary device

Extend MFD subsystem to support auxiliary child device. This is useful for MFD usecases where parent device is on a discoverable bus and doesn't fit into the platform device criteria. Current support is limited to just PCI devices, but this can be further extended to support other types like USB in the future.

---

I've been cooking this on my spare time during merge window. I'm not very confident about this but thought I'd share it. It might be controversial since I stole quite a bit from platform infrastructure, so please consider this an RFC and let's discuss how to approach this.

More discussion at [*].
[*] https://lore.kernel.org/r/2025032609-query-limit-491b@gregkh

A few things that are still open,

1. Since we're doing it for PCI devices (Greg's recommendation), how do we force the existing ones to use their original platform path?

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

 drivers/base/auxiliary.c      |  23 ++++++
 drivers/mfd/mfd-core.c        | 137 +++++++++++++++++++++++++++++++---
 include/linux/auxiliary_bus.h |   7 ++
 3 files changed, 156 insertions(+), 11 deletions(-)
drivers/base/auxiliary.c +23 -0
index afa4df4c5a3f..16cfb615ac2b 100644
@@ -335,6 +335,29 @@ int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname)
 }
 EXPORT_SYMBOL_GPL(__auxiliary_device_add);
 
+/**
+ * auxiliary_get_resource - get a resource for a device
+ * @auxdev: auxiliary device
+ * @type: resource type
+ * @num: resource index
+ *
+ * Return: a pointer to the resource or NULL on failure.
+ */
+struct resource *auxiliary_get_resource(struct auxiliary_device *auxdev, unsigned int type,
+					unsigned int num)
+{
+	u32 i;
+
+	for (i = 0; i < auxdev->num_resources; i++) {
+		struct resource *r = &auxdev->resource[i];
+
+		if (type == resource_type(r) && num-- == 0)
+			return r;
+	}
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(auxiliary_get_resource);
+
 /**
  * __auxiliary_driver_register - register a driver for auxiliary bus devices
  * @auxdrv: auxiliary_driver structure
drivers/mfd/mfd-core.c +126 -11

185 lines not on this page · raw message

include/linux/auxiliary_bus.h +7 -0
index 65dd7f154374..11c058e49a3c 100644
@@ -148,6 +148,8 @@ struct auxiliary_device {
 		struct mutex lock; /* Synchronize irq sysfs creation */
 		bool irq_dir_exists;
 	} sysfs;
+	u32 num_resources;
+	struct resource	*resource;
 };
 
 /**
@@ -220,6 +222,8 @@ static inline const struct auxiliary_driver *to_auxiliary_drv(const struct devic
 int auxiliary_device_init(struct auxiliary_device *auxdev);
 int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname);
 #define auxiliary_device_add(auxdev) __auxiliary_device_add(auxdev, KBUILD_MODNAME)
+struct resource *auxiliary_get_resource(struct auxiliary_device *auxdev, unsigned int type,
+					unsigned int num);
 
 #ifdef CONFIG_SYSFS
 int auxiliary_device_sysfs_irq_add(struct auxiliary_device *auxdev, int irq);
@@ -238,6 +242,9 @@ auxiliary_device_sysfs_irq_remove(struct auxiliary_device *auxdev, int irq) {}
 
 static inline void auxiliary_device_uninit(struct auxiliary_device *auxdev)
 {
+	if (auxdev->resource)
+		kfree(auxdev->resource);
+
 	mutex_destroy(&auxdev->sysfs.lock);
 	put_device(&auxdev->dev);
 }
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 14 lines · Raag Jadav

Extend MFD subsystem to support auxiliary child device. This is useful for MFD usecases where parent device is on a discoverable bus and doesn't fit into the platform device criteria. Current support is limited to just PCI devices, but this can be further extended to support other types like USB in the future.

---

I've been cooking this on my spare time during merge window. I'm not very confident about this but thought I'd share it. It might be controversial since I stole quite a bit from platform infrastructure, so please consider this an RFC and let's discuss how to approach this.

Quoted 7 lines

More discussion at [*].
[*] https://lore.kernel.org/r/2025032609-query-limit-491b@gregkh

A few things that are still open,

1. Since we're doing it for PCI devices (Greg's recommendation), how do we force the existing ones to use their original platform path?

That's up to you all, but I wouldn't recommend forcing everything to change for existing drivers. So make it "opt-in" somehow? I would love to make it change for existing drivers, but I don't know what that might break (it _should_ not break anything, but we've already found breakages when moving some platform devices over to other busses like faux due to bugs in userspace scripts.)

Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

thanks,

greg k-h

#2 lore raw
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

I think we should simply enforce the requirement that MFD on AUX bus must use regmap. This will solve the serialisation and common access to the resources.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

I think we should simply enforce the requirement that MFD on AUX bus must use regmap. This will solve the serialisation and common access to the resources.

That said, make an additional API call like

dev_mfd_add_aux_devices() which should enforce new infrastructure and convert drivers one by one. Also with that you may add a warning to the existing (PCI) drivers that are using old API

	if (dev_is_pci(parent))
		dev_warn(parent, "Uses old API, please switch to ...\n");
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw
Quoted 18 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

I think we should simply enforce the requirement that MFD on AUX bus must use regmap. This will solve the serialisation and common access to the resources.

Quoted 8 lines

That said, make an additional API call like

dev_mfd_add_aux_devices() which should enforce new infrastructure and convert drivers one by one. Also with that you may add a warning to the existing (PCI) drivers that are using old API

	if (dev_is_pci(parent))
		dev_warn(parent, "Uses old API, please switch to ...\n");

Don't add "warnings" like this if you aren't also going to actually convert the code. Just convert it, otherwise you pester users with problems that they have no idea how to fix.

thanks,

greg k-h

#5 lore raw
Quoted 4 lines · Greg KH
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

I think we should simply enforce the requirement that MFD on AUX bus must use regmap. This will solve the serialisation and common access to the resources.

That said, make an additional API call like

dev_mfd_add_aux_devices() which should enforce new infrastructure and convert drivers one by one. Also with that you may add a warning to the existing (PCI) drivers that are using old API

Quoted 6 lines
Quoted 2 lines
	if (dev_is_pci(parent))
		dev_warn(parent, "Uses old API, please switch to ...\n");

Don't add "warnings" like this if you aren't also going to actually convert the code. Just convert it, otherwise you pester users with problems that they have no idea how to fix.

Good point. I'm wondering how many actually we have PCI MFD (ab)users right now? 30? 100? More?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#6 lore raw
Quoted 29 lines · Andy Shevchenko
Quoted 4 lines · Greg KH
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 21 lines
Quoted 20 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

I think we should simply enforce the requirement that MFD on AUX bus must use regmap. This will solve the serialisation and common access to the resources.

That said, make an additional API call like

dev_mfd_add_aux_devices() which should enforce new infrastructure and convert drivers one by one. Also with that you may add a warning to the existing (PCI) drivers that are using old API

	if (dev_is_pci(parent))
		dev_warn(parent, "Uses old API, please switch to ...\n");
Quoted 6 lines
Quoted 3 lines

Don't add "warnings" like this if you aren't also going to actually convert the code. Just convert it, otherwise you pester users with problems that they have no idea how to fix.

Good point. I'm wondering how many actually we have PCI MFD (ab)users right now? 30? 100? More?

$ git grep "struct pci_driver" drivers/mfd/ | wc -l
12

Raag

author
#7 lore raw
In reply to Greg KH
Quoted 6 lines · Greg KH
Quoted 5 lines · Raag Jadav

Extend MFD subsystem to support auxiliary child device. This is useful for MFD usecases where parent device is on a discoverable bus and doesn't fit into the platform device criteria. Current support is limited to just PCI devices, but this can be further extended to support other types like USB in the future.

...

Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

Can't we still have a struct resource that is unique to that specific auxiliary device?

Raag

#8 lore raw
Quoted 2 lines · Raag Jadav
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

I don't think we want a flag day. If anything, it should be a new call.

Quoted 2 lines

Can't we still have a struct resource that is unique to that specific auxiliary device?

Oh, believe me, you won't do that. Save yourself from _a lot_ of troubles with different cases when the shared resources are required.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#9 lore raw
Quoted 13 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

I don't think we want a flag day. If anything, it should be a new call.

Yes, I mean in mfd_add_auxiliary_device() (as in this patch).

Quoted 5 lines
Quoted 2 lines

Can't we still have a struct resource that is unique to that specific auxiliary device?

Oh, believe me, you won't do that. Save yourself from _a lot_ of troubles with different cases when the shared resources are required.

I think we already have ignore_resource_conflicts flag as part of mfd_cell, no?

Raag

#10 lore raw
Quoted 4 lines · Raag Jadav
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

I don't think we want a flag day. If anything, it should be a new call.

Yes, I mean in mfd_add_auxiliary_device() (as in this patch).

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Can't we still have a struct resource that is unique to that specific auxiliary device?

Oh, believe me, you won't do that. Save yourself from _a lot_ of troubles with different cases when the shared resources are required.

I think we already have ignore_resource_conflicts flag as part of mfd_cell, no?

It's not so easy, and it's not the only thing that's needed. You can dive into it and see how the request of the resource work. Also note the hardware that has common registers. Again, using regmap solves most of these issues if not all.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#11 lore raw
Quoted 30 lines · Andy Shevchenko
Quoted 4 lines · Raag Jadav
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

I don't think we want a flag day. If anything, it should be a new call.

Yes, I mean in mfd_add_auxiliary_device() (as in this patch).

Quoted 5 lines
Quoted 2 lines

Can't we still have a struct resource that is unique to that specific auxiliary device?

Oh, believe me, you won't do that. Save yourself from _a lot_ of troubles with different cases when the shared resources are required.

Quoted 6 lines
Quoted 2 lines

I think we already have ignore_resource_conflicts flag as part of mfd_cell, no?

It's not so easy, and it's not the only thing that's needed. You can dive into it and see how the request of the resource work. Also note the hardware that has common registers. Again, using regmap solves most of these issues if not all.

What if there are multiple types of resources including multiple ones of same type?

I know it's not common but we have such cases already in place.

Raag

#12 lore raw
Quoted 6 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Raag Jadav
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

I don't think we want a flag day. If anything, it should be a new call.

Yes, I mean in mfd_add_auxiliary_device() (as in this patch).

Quoted 5 lines
Quoted 2 lines

Can't we still have a struct resource that is unique to that specific auxiliary device?

Oh, believe me, you won't do that. Save yourself from _a lot_ of troubles with different cases when the shared resources are required.

I think we already have ignore_resource_conflicts flag as part of mfd_cell, no?

Quoted 8 lines
Quoted 3 lines

It's not so easy, and it's not the only thing that's needed. You can dive into it and see how the request of the resource work. Also note the hardware that has common registers. Again, using regmap solves most of these issues if not all.

What if there are multiple types of resources including multiple ones of same type?

I know it's not common but we have such cases already in place.

Don't solve the problems that do not exist. Let's make it simple (following KISS principle).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#13 lore raw
Quoted 39 lines · Andy Shevchenko
Quoted 6 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Raag Jadav
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Quoted 1 line · Greg KH

On Thu, Apr 03, 2025 at 04:30:53PM +0530, Raag Jadav wrote:

...

Quoted 29 lines
Quoted 28 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

The resources are all shared by the "parent" device, that's what makes aux drivers work, they need to handle this as there is no unique way to carve up the resources here.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't know how you would do this, sorry.

Perhaps we can carve it up in mfd_add_devices() using start and end members and error out if they overlap.

I don't think we want a flag day. If anything, it should be a new call.

Yes, I mean in mfd_add_auxiliary_device() (as in this patch).

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Can't we still have a struct resource that is unique to that specific auxiliary device?

Oh, believe me, you won't do that. Save yourself from _a lot_ of troubles with different cases when the shared resources are required.

I think we already have ignore_resource_conflicts flag as part of mfd_cell, no?

It's not so easy, and it's not the only thing that's needed. You can dive into it and see how the request of the resource work. Also note the hardware that has common registers. Again, using regmap solves most of these issues if not all.

Quoted 7 lines
Quoted 4 lines

What if there are multiple types of resources including multiple ones of same type?

I know it's not common but we have such cases already in place.

Don't solve the problems that do not exist. Let's make it simple (following KISS principle).

Agree, but that is just additional burden of revamping leaf drivers that may or may not be possible depending on how other devices are already using them.

Raag

#14 lore raw
In reply to Raag Jadav
kernel test robot noticed the following build warnings:

Hi Raag,

kernel test robot noticed the following build warnings:

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on driver-core/driver-core-next driver-core/driver-core-linus lee-mfd/for-mfd-next lee-leds/for-leds-next linus/master v6.14 next-20250403] [cannot apply to lee-mfd/for-mfd-fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/mfd-core-Support-auxiliary-device/20250403-190322
base:   driver-core/driver-core-testing
patch link:    https://lore.kernel.org/r/20250403110053.1274521-1-raag.jadav%40intel.com
patch subject: [PATCH v1] mfd: core: Support auxiliary device
config: arm-randconfig-002-20250403 (https://download.01.org/0day-ci/archive/20250403/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250403/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from drivers/peci/cpu.c:4:
include/linux/auxiliary_bus.h: In function 'auxiliary_device_uninit':
include/linux/auxiliary_bus.h:246:3: error: implicit declaration of function 'kfree'; did you mean 'ida_free'? [-Werror=implicit-function-declaration]

      kfree(auxdev->resource);
      ^~~~~
      ida_free
   In file included from drivers/peci/cpu.c:8:
   include/linux/slab.h: At top level:
>> include/linux/slab.h:472:6: warning: conflicting types for 'kfree'
    void kfree(const void *objp);
         ^~~~~
   In file included from drivers/peci/cpu.c:4:
   include/linux/auxiliary_bus.h:246:3: note: previous implicit declaration of 'kfree' was here
      kfree(auxdev->resource);
      ^~~~~

cc1: some warnings being treated as errors

vim +/kfree +472 include/linux/slab.h

7bd230a26648ac Suren Baghdasaryan 2024-03-21 471

72d67229f522e3 Kees Cook          2021-11-05 @472  void kfree(const void *objp);
72d67229f522e3 Kees Cook          2021-11-05  473  void kfree_sensitive(const void *objp);
72d67229f522e3 Kees Cook          2021-11-05  474  size_t __ksize(const void *objp);
05a940656e1eb2 Kees Cook          2022-09-23  475  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#15 lore raw
In reply to Raag Jadav
kernel test robot noticed the following build errors:

Hi Raag,

kernel test robot noticed the following build errors:

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus lee-mfd/for-mfd-next lee-leds/for-leds-next linus/master v6.14 next-20250403] [cannot apply to lee-mfd/for-mfd-fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/mfd-core-Support-auxiliary-device/20250403-190322
base:   driver-core/driver-core-testing
patch link:    https://lore.kernel.org/r/20250403110053.1274521-1-raag.jadav%40intel.com
patch subject: [PATCH v1] mfd: core: Support auxiliary device
config: csky-randconfig-001-20250403 (https://download.01.org/0day-ci/archive/20250403/[email protected]/config)
compiler: csky-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250403/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from drivers/base/auxiliary_sysfs.c:6:
include/linux/auxiliary_bus.h: In function 'auxiliary_device_uninit':

>> include/linux/auxiliary_bus.h:246:17: error: implicit declaration of function 'kfree' [-Wimplicit-function-declaration]
     246 |                 kfree(auxdev->resource);
         |                 ^~~~~
   In file included from drivers/base/auxiliary_sysfs.c:7:
   include/linux/slab.h: At top level:
>> include/linux/slab.h:472:6: warning: conflicting types for 'kfree'; have 'void(const void *)'
     472 | void kfree(const void *objp);
         |      ^~~~~
   include/linux/auxiliary_bus.h:246:17: note: previous implicit declaration of 'kfree' with type 'void(const void *)'
     246 |                 kfree(auxdev->resource);
         |                 ^~~~~

vim +/kfree +246 include/linux/auxiliary_bus.h

242
243 static inline void auxiliary_device_uninit(struct auxiliary_device *auxdev)
244 {
245 if (auxdev->resource)

 > 246			kfree(auxdev->resource);

247
248 mutex_destroy(&auxdev->sysfs.lock);
249 put_device(&auxdev->dev);
250 }
251

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#16 lore raw
In reply to Raag Jadav
kernel test robot noticed the following build errors:

Hi Raag,

kernel test robot noticed the following build errors:

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus lee-mfd/for-mfd-next lee-leds/for-leds-next linus/master v6.14 next-20250403] [cannot apply to lee-mfd/for-mfd-fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/mfd-core-Support-auxiliary-device/20250403-190322
base:   driver-core/driver-core-testing
patch link:    https://lore.kernel.org/r/20250403110053.1274521-1-raag.jadav%40intel.com
patch subject: [PATCH v1] mfd: core: Support auxiliary device
config: arm64-randconfig-003-20250403 (https://download.01.org/0day-ci/archive/20250404/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250404/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: auxiliary_device_init
   >>> referenced by mfd-core.c
   >>>               drivers/mfd/mfd-core.o:(mfd_add_devices) in archive vmlinux.a
--
>> ld.lld: error: undefined symbol: __auxiliary_device_add
   >>> referenced by mfd-core.c
   >>>               drivers/mfd/mfd-core.o:(mfd_add_devices) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#17 lore raw
In reply to Raag Jadav
Quoted 22 lines · Raag Jadav

Extend MFD subsystem to support auxiliary child device. This is useful for MFD usecases where parent device is on a discoverable bus and doesn't fit into the platform device criteria. Current support is limited to just PCI devices, but this can be further extended to support other types like USB in the future.

---

I've been cooking this on my spare time during merge window. I'm not very confident about this but thought I'd share it. It might be controversial since I stole quite a bit from platform infrastructure, so please consider this an RFC and let's discuss how to approach this.

More discussion at [*].
[*] https://lore.kernel.org/r/2025032609-query-limit-491b@gregkh

A few things that are still open,

1. Since we're doing it for PCI devices (Greg's recommendation), how do we force the existing ones to use their original platform path?

Quoted 7 lines

2. Should we allow auxiliary drivers to manage their own resources (MEM, IO, IRQ etc)?

 drivers/base/auxiliary.c      |  23 ++++++
 drivers/mfd/mfd-core.c        | 137 +++++++++++++++++++++++++++++++---
 include/linux/auxiliary_bus.h |   7 ++
 3 files changed, 156 insertions(+), 11 deletions(-)

Honestly, I thought I was going to hate this more than I do.

Besides the obvious duplication of existing code, I think the premise is okay.

I have always viewed the auxiliary bus as an alternative to MFD, rather than an alternative to platform, but I see where you're coming from with this.

Signature · 1 line
Lee Jones [李琼斯]