Auxiliary bus implementation and SOF multi-client support
Subsystems (10)
Dave Ertman
reviewerv3 cover Auxiliary bus implementation and SOF multi-client support
Brief history of Auxiliary Bus
==============================
The auxiliary bus code was originally submitted upstream as virtual bus, and was submitted through the netdev tree. This process generated up to v4. This discussion can be found here:
https://lore.kernel.org/netdev/[email protected]/#t
At this point, GregKH requested that we take the review and revision process to an internal mailing list and garner the buy-in of a respected kernel contributor.
The auxiliary bus (then known as virtual bus) was originally submitted along with implementation code for the ice driver and irdma drive, causing the complication of also having dependencies in the rdma tree. This new submission is utilizing an auxiliary bus consumer in only the sound driver tree to create the initial implementation and a single user.
Since implementation work has started on this patch set, there have been multiple inquiries about the time frame of its completion. It appears that there will be numerous consumers of this functionality.
The process of internal review and implementation using the sound drivers generated 19 internal versions. The changes, including the name change from virtual bus to auxiliary bus, from these versions can be summarized as the following:
- Fixed compilation and checkpatch errors
- Improved documentation to address the motivation for virtual bus.
- Renamed virtual bus to auxiliary bus
- increased maximum device name size
- Correct order in Kconfig and Makefile
- removed the mid-layer adev->release layer for device unregister
- pushed adev->id management to parent driver
- all error paths out of ancillary_device_register return error code
- all error paths out of ancillary_device_register use put_device
- added adev->name element
- modname in register cannot be NULL
- added KBUILD_MODNAME as prefix for match_name
- push adev->id responsibility to registering driver
- uevent now parses adev->dev name
- match_id function now parses adev->dev name
- changed drivers probe function to also take an ancillary_device_id param
- split ancillary_device_register into device_initialize and device_add
- adjusted what is done in device_initialize and device_add
- change adev to ancildev and adrv to ancildrv
- change adev to ancildev in documentation
==========================
Introduces the auxiliary bus implementation along with the example usage in the Sound Open Firmware(SOF) audio driver.
In some subsystems, the functionality of the core device (PCI/ACPI/other) may be too complex for a single device to be managed as a monolithic block or a part of the functionality might need to be exposed to a different subsystem. Splitting the functionality into smaller orthogonal devices makes it easier to manage data, power management and domain-specific communication with the hardware. Also, common auxiliary_device functionality across primary devices can be handled by a common auxiliary_device. A key requirement for such a split is that there is no dependency on a physical bus, device, register accesses or regmap support. These individual devices split from the core cannot live on the platform bus as they are not physical devices that are controlled by DT/ACPI. The same argument applies for not using MFD in this scenario as it relies on individual function devices being physical devices that are DT enumerated.
An example for this kind of requirement is the audio subsystem where a single IP handles multiple entities such as HDMI, Soundwire, local devices such as mics/speakers etc. The split for the core's functionality can be arbitrary or be defined by the DSP firmware topology and include hooks for test/debug. This allows for the audio core device to be minimal and tightly coupled with handling the hardware-specific logic and communication.
The auxiliary bus is intended to be minimal, generic and avoid domain-specific assumptions. Each auxiliary bus device represents a part of its parent functionality. The generic behavior can be extended and specialized as needed by encapsulating an auxiliary bus device within other domain-specific structures and the use of .ops callbacks.
The SOF driver adopts the auxiliary bus for implementing the multi-client support. A client in the context of the SOF driver represents a part of the core device's functionality. It is not a physical device but rather an auxiliary device that needs to communicate with the DSP via IPCs. With multi-client support,the sound card can be separated into multiple orthogonal auxiliary devices for local devices (mic/speakers etc), HDMI, sensing, probes, debug etc. In this series, we demonstrate the usage of the auxiliary bus with the help of the IPC test client which is used for testing the serialization of IPCs when multiple clients talk to the DSP at the same time.
v3 changes:
rename to auxiliary bus
move .c file to drivers/base/
split auxdev unregister flow into uninitialize and delete steps update kernel-doc on register functions for new unregister model update documentation with new name and unregister flow
remove check for release in auxiliary bus, allow core to catch Change driver register so only probe and id_table mandatory
Fix matching logic in auxillary_match_id to account for longer id->name utilize auxiliary_bus callbacks for probe, remove and shutdown
add auxiliary_find_device function
add code to ensure unique auxdrv name
shorten initialize/uninitialize in function names to init/uninit simplify looping logic in match_id
in drives/base/Kconfig changed from tristate to bool
Modified signature SOF client register/unregister API
Modified PM runtime enabling sequence in the SOF ipc test aux driver Removed driver.name from the aux driver
Added Probes client aux driver and device registration in the
SOF driver. This allows for enabling the probes functionality in the SOF firmware for audio data extraction from specific points in the audio pipeline. Without auxiliary bus, the implementation requires modifying existing 15+ machine drivers to add the probes DAI links to the sounds cards. Using the auxiliary bus allows for splitting the probes implementation from the SOF core making it easy to maintain.
v2 changes:
defined pr_fmt for kernel messages
replaced WARN_ON calls in registration with pr_err calls adding kernel-doc function comments for device_initialize and device_add fix typo in documentation
removed inaccurate line in documentation
fixed formatting in drivers/bus/Makefile
changed unwind path for sof_client_dev_alloc()
improved comments for client list and mem freeing during client unreg removed debugfs entries in sof_ipc_test_client_drv during remove changed the signature of sof_debug_ipc_flood_test()
fix a looping error in ancillary_match_id
updated error value in sof_client_dev_register()
mutex held while traversing client list when unregistering clients updated includes in sof-client.h
Dave Ertman (1):
Add auxiliary bus support
Ranjani Sridharan (9):
ASoC: SOF: Introduce descriptors for SOF client
ASoC: SOF: Create client driver for IPC test
ASoC: SOF: ops: Add ops for client registration
ASoC: SOF: Intel: Define ops for client registration
ASoC: SOF: Intel: Remove IPC flood test support in SOF core
ASoC: SOF: sof-client: Add client APIs to access probes ops
ASoC: SOF: compress: move and export sof_probe_compr_ops
ASoC: SOF: Add new client driver for probes support
ASoC: SOF: Intel: CNL: register probes client
Documentation/driver-api/auxiliary_bus.rst | 228 ++++++++++ Documentation/driver-api/index.rst | 1 + drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/auxiliary.c | 267 ++++++++++++ include/linux/auxiliary_bus.h | 78 ++++ include/linux/mod_devicetable.h | 8 + scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 8 + sound/soc/sof/Kconfig | 47 ++- sound/soc/sof/Makefile | 10 +- sound/soc/sof/compress.c | 60 +-- sound/soc/sof/compress.h | 1 + sound/soc/sof/core.c | 18 +- sound/soc/sof/debug.c | 457 --------------------- sound/soc/sof/intel/Kconfig | 9 + sound/soc/sof/intel/Makefile | 3 + sound/soc/sof/intel/apl.c | 16 + sound/soc/sof/intel/bdw.c | 16 + sound/soc/sof/intel/byt.c | 20 + sound/soc/sof/intel/cnl.c | 32 ++ sound/soc/sof/intel/hda-dai.c | 27 -- sound/soc/sof/intel/hda.h | 6 - sound/soc/sof/intel/intel-client.c | 40 ++ sound/soc/sof/intel/intel-client.h | 26 ++ sound/soc/sof/ops.h | 14 + sound/soc/sof/pcm.c | 11 - sound/soc/sof/probe.c | 124 +++--- sound/soc/sof/probe.h | 41 +- sound/soc/sof/sof-client.c | 170 ++++++++ sound/soc/sof/sof-client.h | 91 ++++ sound/soc/sof/sof-ipc-test-client.c | 321 +++++++++++++++ sound/soc/sof/sof-priv.h | 23 +- sound/soc/sof/sof-probes-client.c | 414 +++++++++++++++++++ 34 files changed, 1968 insertions(+), 626 deletions(-) create mode 100644 Documentation/driver-api/auxiliary_bus.rst create mode 100644 drivers/base/auxiliary.c create mode 100644 include/linux/auxiliary_bus.h create mode 100644 sound/soc/sof/intel/intel-client.c create mode 100644 sound/soc/sof/intel/intel-client.h create mode 100644 sound/soc/sof/sof-client.c create mode 100644 sound/soc/sof/sof-client.h create mode 100644 sound/soc/sof/sof-ipc-test-client.c create mode 100644 sound/soc/sof/sof-probes-client.c
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 1/10 Add auxiliary bus support
Add support for the Auxiliary Bus, auxiliary_device and auxiliary_driver. It enables drivers to create an auxiliary_device and bind an auxiliary_driver to it.
The bus supports probe/remove shutdown and suspend/resume callbacks. Each auxiliary_device has a unique string based id; driver binds to an auxiliary_device based on this id through the bus.
--- Documentation/driver-api/auxiliary_bus.rst | 228 ++++++++++++++++++ Documentation/driver-api/index.rst | 1 + drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/auxiliary.c | 267 +++++++++++++++++++++ include/linux/auxiliary_bus.h | 78 ++++++ include/linux/mod_devicetable.h | 8 + scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 8 + 9 files changed, 597 insertions(+) create mode 100644 Documentation/driver-api/auxiliary_bus.rst create mode 100644 drivers/base/auxiliary.c create mode 100644 include/linux/auxiliary_bus.h
Documentation/driver-api/auxiliary_bus.rst new file +228 -0
@@ -0,0 +1,228 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +============= +Auxiliary Bus +============= + +In some subsystems, the functionality of the core device (PCI/ACPI/other) is +too complex for a single device to be managed as a monolithic block or a part of +the functionality needs to be exposed to a different subsystem. Splitting the +functionality into smaller orthogonal devices would make it easier to manage +data, power management and domain-specific interaction with the hardware. A key +requirement for such a split is that there is no dependency on a physical bus, +device, register accesses or regmap support. These individual devices split from +the core cannot live on the platform bus as they are not physical devices that +are controlled by DT/ACPI. The same argument applies for not using MFD in this +scenario as MFD relies on individual function devices being physical devices. + +An example for this kind of requirement is the audio subsystem where a single +IP is handling multiple entities such as HDMI, Soundwire, local devices such as +mics/speakers etc. The split for the core's functionality can be arbitrary or +be defined by the DSP firmware topology and include hooks for test/debug. This +allows for the audio core device to be minimal and focused on hardware-specific +control and communication. + +The auxiliary bus is intended to be minimal, generic and avoid domain-specific +assumptions. Each auxiliary_device represents a part of its parent +functionality. The generic behavior can be extended and specialized as needed +by encapsulating an auxiliary_device within other domain-specific structures and +the use of .ops callbacks. Devices on the auxiliary bus do not share any +structures and the use of a communication channel with the parent is +domain-specific. + +When Should the Auxiliary Bus Be Used +===================================== + +The auxiliary bus is to be used when a driver and one or more kernel modules, +who share a common header file with the driver, need a mechanism to connect and +provide access to a shared object allocated by the auxiliary_device's +registering driver. The registering driver for the auxiliary_device(s) and the +kernel module(s) registering auxiliary_drivers can be from the same subsystem, +or from multiple subsystems. + +The emphasis here is on a common generic interface that keeps subsystem +customization out of the bus infrastructure. + +One example could be a multi-port PCI network device that is rdma-capable and +needs to export this functionality and attach to an rdma driver in another +subsystem. The PCI driver will allocate and register an auxiliary_device for +each physical function on the NIC. The rdma driver will register an +auxiliary_driver that will be matched with and probed for each of these +auxiliary_devices. This will give the rdma driver access to the shared data/ops +in the PCI drivers shared object to establish a connection with the PCI driver. + +Another use case is for the PCI device to be split out into multiple sub +functions. For each sub function an auxiliary_device will be created. A PCI +sub function driver will bind to such devices that will create its own one or +more class devices. A PCI sub function auxiliary device will likely be +contained in a struct with additional attributes such as user defined sub +function number and optional attributes such as resources and a link to the +parent device. These attributes could be used by systemd/udev; and hence should +be initialized before a driver binds to an auxiliary_device. + +Auxiliary Device +================ + +An auxiliary_device is created and registered to represent a part of its parent +device's functionality. It is given a name that, combined with the registering +drivers KBUILD_MODNAME, creates a match_name that is used for driver binding, +and an id that combined with the match_name provide a unique name to register +with the bus subsystem. + +Registering an auxiliary_device is a two-step process. First you must call +auxiliary_device_init(), which will check several aspects of the +auxiliary_device struct and perform a device_initialize(). After this step +completes, any error state must have a call to auxiliary_device_unin() in its +resolution path. The second step in registering an auxiliary_device is to +perform a call to auxiliary_device_add(), which will set the name of the device +and add the device to the bus. + +Unregistering an auxiliary_device is also a two-step process to mirror the +register process. First will be a call to auxiliary_device_delete(), then +followed by a call to auxiliary_device_unin(). + +.. code-block:: c + + struct auxiliary_device { + struct device dev; + const char *name; + u32 id; + }; + +If two auxiliary_devices both with a match_name "mod.foo" are registered onto +the bus, they must have unique id values (e.g. "x" and "y") so that the +registered devices names will be "mod.foo.x" and "mod.foo.y". If match_name + +id are not unique, then the device_add will fail and generate an error message. + +The auxiliary_device.dev.type.release or auxiliary_device.dev.release must be +populated with a non-NULL pointer to successfully register the auxiliary_device. + +The auxiliary_device.dev.parent must also be populated. + +Auxiliary Device Memory Model and Lifespan +------------------------------------------ + +When a kernel driver registers an auxiliary_device on the auxiliary bus, we will +use the nomenclature to refer to this kernel driver as a registering driver. It +is the entity that will allocate memory for the auxiliary_device and register it +on the auxiliary bus. It is important to note that, as opposed to the platform +bus, the registering driver is wholly responsible for the management for the +memory used for the driver object. + +A parent object, defined in the shared header file, will contain the +auxiliary_device. It will also contain a pointer to the shared object(s), which +will also be defined in the shared header. Both the parent object and the +shared object(s) will be allocated by the registering driver. This layout +allows the auxiliary_driver's registering module to perform a container_of() +call to go from the pointer to the auxiliary_device, that is passed during the +call to the auxiliary_driver's probe function, up to the parent object, and then +have access to the shared object(s). + +The memory for the auxiliary_device will be freed only in its release() +callback flow as defined by its registering driver. + +The memory for the shared object(s) must have a lifespan equal to, or greater +than, the lifespan of the memory for the auxiliary_device. The auxiliary_driver +should only consider that this shared object is valid as long as the +auxiliary_device is still registered on the auxiliary bus. It is up to the +registering driver to manage (e.g. free or keep available) the memory for the +shared object beyond the life of the auxiliary_device. + +Registering driver must unregister all auxiliary devices before its registering +parent device's remove() is completed. + +Auxiliary Drivers +================= + +Auxiliary drivers follow the standard driver model convention, where +discovery/enumeration is handled by the core, and drivers +provide probe() and remove() methods. They support power management +and shutdown notifications using the standard conventions. + +.. code-block:: c + + struct auxiliary_driver { + int (*probe)(struct auxiliary_device *, + const struct auxiliary_device_id *id); + int (*remove)(struct auxiliary_device *); + void (*shutdown)(struct auxiliary_device *); + int (*suspend)(struct auxiliary_device *, pm_message_t); + int (*resume)(struct auxiliary_device *); + struct device_driver driver; + const struct auxiliary_device_id *id_table; + }; + +Auxiliary drivers register themselves with the bus by calling +auxiliary_driver_register(). The id_table contains the match_names of auxiliary +devices that a driver can bind with. + +Example Usage +============= + +Auxiliary devices are created and registered by a subsystem-level core device +that needs to break up its functionality into smaller fragments. One way to +extend the scope of an auxiliary_device would be to encapsulate it within a +domain-specific structure defined by the parent device. This structure contains +the auxiliary_device and any associated shared data/callbacks needed to +establish the connection with the parent. + +An example would be: + +.. code-block:: c + + struct foo { + struct auxiliary_device auxdev; + void (*connect)(struct auxiliary_device *auxdev); + void (*disconnect)(struct auxiliary_device *auxdev); + void *data; + }; + +The parent device would then register the auxiliary_device by calling +auxiliary_device_init(), and then auxiliary_device_add(), with the pointer to +the auxdev member of the above structure. The parent would provide a name for +the auxiliary_device that, combined with the parent's KBUILD_MODNAME, will +create a match_name that will be used for matching and binding with a driver. + +Whenever an auxiliary_driver is registered, based on the match_name, the +auxiliary_driver's probe() is invoked for the matching devices. The +auxiliary_driver can also be encapsulated inside custom drivers that make the +core device's functionality extensible by adding additional domain-specific ops +as follows: + +.. code-block:: c + + struct my_ops { + void (*send)(struct auxiliary_device *auxdev); + void (*receive)(struct auxiliary_device *auxdev); + }; + + + struct my_driver { + struct auxiliary_driver auxiliary_drv; + const struct my_ops ops; + }; + +An example of this type of usage would be: + +.. code-block:: c + + const struct auxiliary_device_id my_auxiliary_id_table[] = { + { .name = "foo_mod.foo_dev" }, + { }, + }; + + const struct my_ops my_custom_ops = { + .send = my_tx, + .receive = my_rx, + }; + + const struct my_driver my_drv = { + .auxiliary_drv = { + .name = "myauxiliarydrv", + .id_table = my_auxiliary_id_table, + .probe = my_probe, + .remove = my_remove, + .shutdown = my_shutdown, + }, + .ops = my_custom_ops, + };
Documentation/driver-api/index.rst +1 -0
@@ -72,6 +72,7 @@ available subsections can be seen below. thermal/index fpga/index acpi/index + auxiliary_bus backlight/lp855x-driver.rst connector console
drivers/base/Kconfig +3 -0
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 menu "Generic Driver Options" +config AUXILIARY_BUS + bool + config UEVENT_HELPER bool "Support for uevent helper" help
drivers/base/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \ attribute_container.o transport_class.o \ topology.o container.o property.o cacheinfo.o \ swnode.o +obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o obj-y += power/ obj-$(CONFIG_ISA_BUS_API) += isa.o
drivers/base/auxiliary.c new file +267 -0
267 lines not on this page · raw message
include/linux/auxiliary_bus.h new file +78 -0
78 lines not on this page · raw message
include/linux/mod_devicetable.h +8 -0
@@ -838,4 +838,12 @@ struct mhi_device_id { kernel_ulong_t driver_data; }; +#define AUXILIARY_NAME_SIZE 32 +#define AUXILIARY_MODULE_PREFIX "auxiliary:" + +struct auxiliary_device_id { +char name[AUXILIARY_NAME_SIZE ]; +kernel_ulong_t driver_data; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */
scripts/mod/devicetable-offsets.c +3 -0
@@ -243,5 +243,8 @@ int main(void)DEVID (mhi_device_id);DEVID_FIELD (mhi_device_id, chan); +DEVID (auxiliary_device_id); +DEVID_FIELD (auxiliary_device_id, name); +return 0 ; }
scripts/mod/file2alias.c +8 -0
@@ -1364,6 +1364,13 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias) {DEF_FIELD_ADDR (symval, mhi_device_id, chan);sprintf (alias,MHI_DEVICE_MODALIAS_FMT , *chan); +return 1 ; +} + +static int do_auxiliary_entry (const char *filename,void *symval,char *alias) +{ +DEF_FIELD_ADDR (symval, auxiliary_device_id, name); +sprintf (alias,AUXILIARY_MODULE_PREFIX "%s" , *name);return 1 ; }
@@ -1442,6 +1449,7 @@ static const struct devtable devtable[] = { {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, {"mhi", SIZE_mhi_device_id, do_mhi_entry}, + {"auxiliary", SIZE_auxiliary_device_id, do_auxiliary_entry}, };/* Create MODULE_ALIAS() statements.
Signature · 1 line
2.26.2
Re: [PATCH v3 01/10] Add auxiliary bus support
Some doc fixups, and minor code feedback. Otherwise looks good to me.
Quoted 43 lines · Dave Ertman
Add support for the Auxiliary Bus,
auxiliary_deviceandauxiliary_driver. It enables drivers to create anauxiliary_deviceand bind anauxiliary_driverto it.The bus supports probe/remove shutdown and suspend/resume callbacks. Each
auxiliary_devicehas a unique string based id; driver binds to anauxiliary_devicebased on this id through the bus.Co-developed-by Kiran Patil <[email protected]>Signed-off-by Kiran Patil <[email protected]>Co-developed-by Ranjani Sridharan <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Co-developed-by Fred Oh <[email protected]>Signed-off-by Fred Oh <[email protected]>Co-developed-by Leon Romanovsky <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>Reviewed-by Shiraz Saleem <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Dave Ertman <[email protected]>--- Documentation/driver-api/auxiliary_bus.rst | 228 ++++++++++++++++++ Documentation/driver-api/index.rst | 1 + drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/auxiliary.c | 267 +++++++++++++++++++++ include/linux/auxiliary_bus.h | 78 ++++++ include/linux/mod_devicetable.h | 8 + scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 8 + 9 files changed, 597 insertions(+) create mode 100644 Documentation/driver-api/auxiliary_bus.rst create mode 100644 drivers/base/auxiliary.c create mode 100644 include/linux/auxiliary_bus.hDocumentation/driver-api/auxiliary_bus.rst new file +0
-0
Documentation/driver-api/auxiliary_bus.rst line 9
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst new file +9
-0@@ -0,0 +1,228 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +============= +Auxiliary Bus +============= + +In some subsystems, the functionality of the core device (PCI/ACPI/other) is +too complex for a single device to be managed as a monolithic block or a part of +the functionality needs to be exposed to a different subsystem.
I think there are three identified use cases for this now, so call out those examples for others to compare if aux bus is a fit for their use case.
"In some subsystems, the functionality of the core device (PCI/ACPI/other) is too complex to be handled by a monolithic driver (e.g. Sound Open Firmware), multiple devices might implement a common intersection of functionality (e.g. NICs + RDMA), or a driver may want to export an interface for another subsystem to drive (e.g. SIOV Physical Function export Virtual Function management)."
Documentation/driver-api/auxiliary_bus.rst line 12
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+ Splitting the +functionality into smaller orthogonal devices would make it easier to manage +data, power management and domain-specific interaction with the hardware.
Passive voice and I don't understand what is meant by the word "orthogonal"
"A split of the functionality into child-devices representing sub-domains of functionality makes it possible to compartmentalize, layer, and distribute domain-specific concerns via a Linux device-driver model"
Documentation/driver-api/auxiliary_bus.rst line 16
Quoted 7 lines
A key
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+requirement for such a split is that there is no dependency on a physical bus, +device, register accesses or regmap support.These individual devices split from
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+the core cannot live on the platform bus as they are not physical devices that +are controlled by DT/ACPI. The same argument applies for not using MFD in this +scenario as MFD relies on individual function devices being physical devices.
These last few sentences are confusing the justification of the existence of auxiliary bus, not the explanation of when why and how to use it.
The "When Should the Auxiliary Bus Be Used" should mention where Auxiliary bus fits relative to the platform-bus and MFD, perhaps in an explicit "When not to use Auxiliary Bus" section to direct people to platform-bus and MFD when those are a better fit.
Documentation/driver-api/auxiliary_bus.rst
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+ +An example for this kind of requirement is the audio subsystem where a single +IP is handling multiple entities such as HDMI, Soundwire, local devices such as +mics/speakers etc. The split for the core's functionality can be arbitrary or +be defined by the DSP firmware topology and include hooks for test/debug. This +allows for the audio core device to be minimal and focused on hardware-specific +control and communication. + +The auxiliary bus is intended to be minimal, generic and avoid domain-specific +assumptions.
As this file will be sitting in Documentation/ it will be too late to "intend" it either does and or it doesn't. This again feels more like justification for existence that should already be in the changelog, it can go from the Documentation.
Documentation/driver-api/auxiliary_bus.rst line 31
Quoted 6 lines
Each
auxiliary_devicerepresents a part of its parentDocumentation/driver-api/auxiliary_bus.rst new file +5
-0+functionality. The generic behavior can be extended and specialized as needed +by encapsulating an auxiliary_device within other domain-specific structures and +the use of .ops callbacks. Devices on the auxiliary bus do not share any +structures and the use of a communication channel with the parent is +domain-specific.
Should there be any guidance here on when to use ops and when to just export functions from parent driver to child. EXPORT_SYMBOL_NS() seems a perfect fit for publishing shared routines between parent and child.
Quoted 5 lines
Documentation/driver-api/auxiliary_bus.rst new file +5
-0+ +When Should the Auxiliary Bus Be Used +===================================== + +The auxiliary bus is to be used when a driver and one or more kernel modules,
Documentation/driver-api/auxiliary_bus.rst line 46
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+who share a common header file with the driver, need a mechanism to connect and +provide access to a shared object allocated by the auxiliary_device's +registering driver. The registering driver for the auxiliary_device(s) and the +kernel module(s) registering auxiliary_drivers can be from the same subsystem, +or from multiple subsystems. + +The emphasis here is on a common generic interface that keeps subsystem +customization out of the bus infrastructure. + +One example could be a multi-port PCI network device that is rdma-capable and
s/could be/is/
s/multi-port//
s/rdma-capable/RDMA-capable/
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+needs to export this functionality and attach to an rdma driver in another +subsystem.
"exports a child device to be driven by an auxiliary_driver in the RDMA subsystem"
Quoted 1 line
The PCI driver will allocate and register an
auxiliary_devicefor
Fix tense confusion:
s/will allocate and register/allocates and registers/
Quoted 1 line
+each physical function on the NIC. The rdma driver will register an
s/rdma/RDMA/
s/will register/registers/
Quoted 1 line
+auxiliary_driver that will be matched with and probed for each of these
s/that will be matched with and probed for/that claims/
Documentation/driver-api/auxiliary_bus.rst line 52
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+auxiliary_devices. This will give the rdma driver access to the shared data/ops +in the PCI drivers shared object to establish a connection with the PCI driver.
How about?
This conveys data/ops published by the parent PCI device/driver to the RDMA auxiliary_driver.
Documentation/driver-api/auxiliary_bus.rst line 61
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst new file +9
-0+ +Another use case is for the PCI device to be split out into multiple sub +functions. For each sub function an auxiliary_device will be created. A PCI +sub function driver will bind to such devices that will create its own one or +more class devices. A PCI sub function auxiliary device will likely be +contained in a struct with additional attributes such as user defined sub +function number and optional attributes such as resources and a link to the +parent device. These attributes could be used by systemd/udev; and hence should +be initialized before a driver binds to an auxiliary_device.
This does not read like an explicit example like the previous 2. Did you have something specific in mind?
Here's where the "when not to" / "MFD platform-bus" redirect section can go.
Documentation/driver-api/auxiliary_bus.rst line 66
Quoted 5 lines
Documentation/driver-api/auxiliary_bus.rst new file +5
-0+ +Auxiliary Device +================ + +An auxiliary_device is created and registered to represent a part of its parent
s/created and registered to represent/represents/
Documentation/driver-api/auxiliary_bus.rst line 72
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst new file +6
-0+device's functionality. It is given a name that, combined with the registering +drivers KBUILD_MODNAME, creates a match_name that is used for driver binding, +and an id that combined with the match_name provide a unique name to register +with the bus subsystem. + +Registering an auxiliary_device is a two-step process. First you must call
Imperative implied:
s/you must//
Documentation/driver-api/auxiliary_bus.rst line 81
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst new file +9
-0+auxiliary_device_init(), which will check several aspects of the +auxiliary_device struct and perform a device_initialize(). After this step +completes, any error state must have a call to auxiliary_device_unin() in its +resolution path. The second step in registering an auxiliary_device is to +perform a call to auxiliary_device_add(), which will set the name of the device +and add the device to the bus. + +Unregistering an auxiliary_device is also a two-step process to mirror the +register process. First will be a call to auxiliary_device_delete(), then
s/will be a call to/call/
Quoted 1 line
+followed by a call to
auxiliary_device_unin().
s/followed by a call to/call/
Quoted 14 lines
Documentation/driver-api/auxiliary_bus.rst new file +14
-0+ +.. code-block:: c + + struct auxiliary_device { + struct device dev; + const char *name; + u32 id; + }; + +If two auxiliary_devices both with a match_name "mod.foo" are registered onto +the bus, they must have unique id values (e.g. "x" and "y") so that the +registered devices names will be "mod.foo.x" and "mod.foo.y". If match_name + +id are not unique, then the device_add will fail and generate an error message. +
Documentation/driver-api/auxiliary_bus.rst
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+The auxiliary_device.dev.type.release or auxiliary_device.dev.release must be +populated with a non-NULL pointer to successfully register the auxiliary_device. + +The auxiliary_device.dev.parent must also be populated. + +Auxiliary Device Memory Model and Lifespan +------------------------------------------ + +When a kernel driver registers an auxiliary_device on the auxiliary bus, we will +use the nomenclature to refer to this kernel driver as a registering driver.
Kill this sentence, it adds nothing and has a dreaded "we". Just say:
The registering driver is the entity...
Documentation/driver-api/auxiliary_bus.rst line 112
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst new file +6
-0+is the entity that will allocate memory for the auxiliary_device and register it +on the auxiliary bus. It is important to note that, as opposed to the platform +bus, the registering driver is wholly responsible for the management for the +memory used for the driver object. + +A parent object, defined in the shared header file, will contain the
Another "will", and more below. Convert all to present tense please.
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+auxiliary_device. It will also contain a pointer to the shared object(s), which +will also be defined in the shared header. Both the parent object and the +shared object(s) will be allocated by the registering driver. This layout +allows the auxiliary_driver's registering module to perform a container_of() +call to go from the pointer to the auxiliary_device, that is passed during the +call to the auxiliary_driver's probe function, up to the parent object, and then +have access to the shared object(s). + +The memory for the auxiliary_device will be freed only in its release() +callback flow as defined by its registering driver.
Documentation/driver-api/auxiliary_bus.rst line 132
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+ +The memory for the shared object(s) must have a lifespan equal to, or greater +than, the lifespan of the memory for the auxiliary_device. The auxiliary_driver +should only consider that this shared object is valid as long as the +auxiliary_device is still registered on the auxiliary bus. It is up to the +registering driver to manage (e.g. free or keep available) the memory for the +shared object beyond the life of the auxiliary_device. + +Registering driver must unregister all auxiliary devices before its registering +parent device's remove() is completed.
Too many "registerings"
The registering driver must unregister all auxiliary devices before its own driver.remove() callback is completed.
Quoted 22 lines
Documentation/driver-api/auxiliary_bus.rst new file +22
-0+ +Auxiliary Drivers +================= + +Auxiliary drivers follow the standard driver model convention, where +discovery/enumeration is handled by the core, and drivers +provide probe() and remove() methods. They support power management +and shutdown notifications using the standard conventions. + +.. code-block:: c + + struct auxiliary_driver { + int (*probe)(struct auxiliary_device *, + const struct auxiliary_device_id *id); + int (*remove)(struct auxiliary_device *); + void (*shutdown)(struct auxiliary_device *); + int (*suspend)(struct auxiliary_device *, pm_message_t); + int (*resume)(struct auxiliary_device *); + struct device_driver driver; + const struct auxiliary_device_id *id_table; + }; +
Documentation/driver-api/auxiliary_bus.rst line 164
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+Auxiliary drivers register themselves with the bus by calling +auxiliary_driver_register(). The id_table contains the match_names of auxiliary +devices that a driver can bind with. + +Example Usage +============= + +Auxiliary devices are created and registered by a subsystem-level core device +that needs to break up its functionality into smaller fragments. One way to +extend the scope of an auxiliary_device would be to encapsulate it within a
More passive tense
s/would be/is/
Documentation/driver-api/auxiliary_bus.rst line 169
Quoted 5 lines
Documentation/driver-api/auxiliary_bus.rst new file +5
-0+domain-specific structure defined by the parent device. This structure contains +the auxiliary_device and any associated shared data/callbacks needed to +establish the connection with the parent. + +An example would be:
s/would be/is/
Documentation/driver-api/auxiliary_bus.rst line 180
Quoted 11 lines
Documentation/driver-api/auxiliary_bus.rst new file +11
-0+ +.. code-block:: c + + struct foo { + struct auxiliary_device auxdev; + void (*connect)(struct auxiliary_device *auxdev); + void (*disconnect)(struct auxiliary_device *auxdev); + void *data; + }; + +The parent device would then register the auxiliary_device by calling
again with the passive...
Quoted 15 lines
Documentation/driver-api/auxiliary_bus.rst new file +15
-0+auxiliary_device_init(), and then auxiliary_device_add(), with the pointer to +the auxdev member of the above structure. The parent would provide a name for +the auxiliary_device that, combined with the parent's KBUILD_MODNAME, will +create a match_name that will be used for matching and binding with a driver. + +Whenever an auxiliary_driver is registered, based on the match_name, the +auxiliary_driver's probe() is invoked for the matching devices. The +auxiliary_driver can also be encapsulated inside custom drivers that make the +core device's functionality extensible by adding additional domain-specific ops +as follows: + +.. code-block:: c + + struct my_ops { + void (*send)(struct auxiliary_device *auxdev);
Documentation/driver-api/auxiliary_bus.rst line 205
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+ void (*receive)(struct auxiliary_device *auxdev); + }; + + + struct my_driver { + struct auxiliary_driver auxiliary_drv; + const struct my_ops ops; + }; + +An example of this type of usage would be:
*is
Quoted 40 lines
Documentation/driver-api/auxiliary_bus.rst new file +23
-0+ +.. code-block:: c + + const struct auxiliary_device_id my_auxiliary_id_table[] = { + { .name = "foo_mod.foo_dev" }, + { }, + }; + + const struct my_ops my_custom_ops = { + .send = my_tx, + .receive = my_rx, + }; + + const struct my_driver my_drv = { + .auxiliary_drv = { + .name = "myauxiliarydrv", + .id_table = my_auxiliary_id_table, + .probe = my_probe, + .remove = my_remove, + .shutdown = my_shutdown, + }, + .ops = my_custom_ops, + };Documentation/driver-api/index.rst +1
-0@@ -72,6 +72,7 @@ available subsections can be seen below. thermal/index fpga/index acpi/index + auxiliary_bus backlight/lp855x-driver.rst connector consoledrivers/base/Kconfig +0
-0
drivers/base/Kconfig line 5
Quoted 5 lines
drivers/base/Kconfig +2
-0@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 menu "Generic Driver Options" +config AUXILIARY_BUS + bool
tristate? Unless you need non-exported symbols, might as well let this be a module.
Quoted 22 lines
drivers/base/Kconfig +1
-0+ config UEVENT_HELPER bool "Support for uevent helper" helpdrivers/base/Makefile +1
-0@@ -7,6 +7,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \ attribute_container.o transport_class.o \ topology.o container.o property.o cacheinfo.o \ swnode.o +obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o obj-y += power/ obj-$(CONFIG_ISA_BUS_API) += isa.odrivers/base/auxiliary.c new file +0
-0
drivers/base/auxiliary.c line 3
Quoted 3 lines
drivers/base/auxiliary.c new file +3
-0@@ -0,0 +1,267 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Software based bus for Auxiliary devices
I'd just remove this line, it doesn't add anything.
Quoted 112 lines
drivers/base/auxiliary.c new file +112
-0+* +* Copyright (c) 2019-2020 Intel Corporation +* +* Please see Documentation/driver-api/auxiliary_bus.rst for more information. +*/ + +#define pr_fmt (fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__ + +#include <linux/device.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/pm_domain.h> +#include <linux/pm_runtime.h> +#include <linux/string.h> +#include <linux/auxiliary_bus.h> + +static const struct auxiliary_device_id *auxiliary_match_id (const struct auxiliary_device_id *id, +const struct auxiliary_device *auxdev) +{ +for (; id->name[0 ]; id++) { +const char *p =strrchr (dev_name (&auxdev->dev),'.' ); +int match_size; + +if (!p) +continue ; + match_size = p -dev_name (&auxdev->dev); + +/* use dev_name(&auxdev->dev) prefix before last '.' char to match to */ +if (strlen (id->name) == match_size && + !strncmp (dev_name (&auxdev->dev), id->name, match_size)) +return id; + } +return NULL ; +} + +static int auxiliary_match (struct device *dev,struct device_driver *drv) +{ +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); +struct auxiliary_driver *auxdrv =to_auxiliary_drv (drv); + +return !!auxiliary_match_id (auxdrv->id_table, auxdev); +} + +static int auxiliary_uevent (struct device *dev,struct kobj_uevent_env *env) +{ +const char *name, *p; + + name =dev_name (dev); + p =strrchr (name,'.' ); + +return add_uevent_var (env,"MODALIAS=%s%.*s" ,AUXILIARY_MODULE_PREFIX , (int )(p - name), + name); +} + +static const struct dev_pm_ops auxiliary_dev_pm_ops = { + SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, pm_generic_runtime_resume, NULL) +SET_SYSTEM_SLEEP_PM_OPS (pm_generic_suspend, pm_generic_resume) +}; + +static int auxiliary_bus_probe (struct device *dev) +{ +struct auxiliary_driver *auxdrv =to_auxiliary_drv (dev->driver); +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); +int ret; + + ret =dev_pm_domain_attach (dev, true); +if (ret) { +dev_warn (dev,"Failed to attach to PM Domain : %d\n" , ret); +return ret; + } + + ret = auxdrv->probe (auxdev,auxiliary_match_id (auxdrv->id_table, auxdev)); +if (ret) +dev_pm_domain_detach (dev, true); + +return ret; +} + +static int auxiliary_bus_remove (struct device *dev) +{ +struct auxiliary_driver *auxdrv =to_auxiliary_drv (dev->driver); +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); +int ret =0 ; + +if (auxdrv->remove) + ret = auxdrv->remove (auxdev); +dev_pm_domain_detach (dev, true); + +return ret; +} + +static void auxiliary_bus_shutdown (struct device *dev) +{ +struct auxiliary_driver *auxdrv =to_auxiliary_drv (dev->driver); +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); + +if (auxdrv->shutdown) + auxdrv->shutdown (auxdev); +} + +static struct bus_type auxiliary_bus_type = { + .name ="auxiliary" , + .probe = auxiliary_bus_probe, + .remove = auxiliary_bus_remove, + .shutdown = auxiliary_bus_shutdown, + .match = auxiliary_match, + .uevent = auxiliary_uevent, + .pm = &auxiliary_dev_pm_ops, +}; + +/** +* auxiliary_device_init - check auxiliary_device and initialize
drivers/base/auxiliary.c line 125
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+* @auxdev: auxiliary device struct +* +* This is the first step in the two-step process to register an auxiliary_device. +* +* When this function returns an error code, then the device_initialize will *not* have +* been performed, and the caller will be responsible to free any memory allocated for the +* auxiliary_device in the error path directly. +* +* It returns 0 on success. On success, the device_initialize has been performed. After this +* point any error unwinding will need to include a call to auxiliary_device_init().
Whoops, you meant to say auxiliary_device_uninit().
drivers/base/auxiliary.c line 127
Quoted 2 lines
drivers/base/auxiliary.c new file +2
-0+* In this post-initialize error scenario, a call to the device's .release callback will be +* triggered by auxiliary_device_uninit(), and all memory clean-up is expected to be
with this function already mentioned above you can drop "by auxiliary_device_uninit()"
Quoted 23 lines
drivers/base/auxiliary.c new file +23
-0+* handled there. +*/ +int auxiliary_device_init (struct auxiliary_device *auxdev) +{ +struct device *dev = &auxdev->dev; + +if (!dev->parent) { +pr_err ("auxiliary_device has a NULL dev->parent\n" ); +return -EINVAL ; + } + +if (!auxdev->name) { +pr_err ("auxiliary_device has a NULL name\n" ); +return -EINVAL ; + } + + dev->bus = &auxiliary_bus_type; +device_initialize (&auxdev->dev); +return 0 ; +} +EXPORT_SYMBOL_GPL (auxiliary_device_init); + +/**
drivers/base/auxiliary.c line 160
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+* __auxiliary_device_add - add an auxiliary bus device +* @auxdev: auxiliary bus device to add to the bus +* @modname: name of the parent device's driver module +* +* This is the second step in the two-step process to register an auxiliary_device. +* +* This function must be called after a successful call to auxiliary_device_init(), which +* will perform the device_initialize. This means that if this returns an error code, then a +* call to auxiliary_device_uninit() must be performed so that the .release callback will +* be triggered to free the memory associated with the auxiliary_device.
Might want to mention the typical expectation is that users call auxiliary_device_add without underbars. Only if custom names are needed would this direct version be used.
Quoted 94 lines
drivers/base/auxiliary.c new file +94
-0+*/ +int __auxiliary_device_add (struct auxiliary_device *auxdev,const char *modname) +{ +struct device *dev = &auxdev->dev; +int ret; + +if (!modname) { +pr_err ("auxiliary device modname is NULL\n" ); +return -EINVAL ; + } + + ret =dev_set_name (dev,"%s.%s.%d" , modname, auxdev->name, auxdev->id); +if (ret) { +pr_err ("auxiliary device dev_set_name failed: %d\n" , ret); +return ret; + } + + ret =device_add (dev); +if (ret) +dev_err (dev,"adding auxiliary device failed!: %d\n" , ret); + +return ret; +} +EXPORT_SYMBOL_GPL (__auxiliary_device_add); + +/** +* auxiliary_find_device - auxiliary device iterator for locating a particular device. +* @start: Device to begin with +* @data: Data to pass to match function +* @match: Callback function to check device +* +* This function returns a reference to a device that is 'found' +* for later use, as determined by the @match callback. +* +* The callback should return 0 if the device doesn't match and non-zero +* if it does. If the callback returns non-zero, this function will +* return to the caller and not iterate over any more devices. +*/ +struct auxiliary_device * +auxiliary_find_device (struct device *start,const void *data, +int (*match)(struct device *dev,const void *data)) +{ +struct device *dev; + + dev =bus_find_device (&auxiliary_bus_type, start, data, match); +if (!dev) +return NULL ; + +return to_auxiliary_dev (dev); +} +EXPORT_SYMBOL_GPL (auxiliary_find_device); + +/** +* __auxiliary_driver_register - register a driver for auxiliary bus devices +* @auxdrv: auxiliary_driver structure +* @owner: owning module/driver +* @modname: KBUILD_MODNAME for parent driver +*/ +int __auxiliary_driver_register (struct auxiliary_driver *auxdrv,struct module *owner, +const char *modname) +{ +if (WARN_ON (!auxdrv->probe) ||WARN_ON (!auxdrv->id_table)) +return -EINVAL ; + +if (auxdrv->name) + auxdrv->driver.name =kasprintf (GFP_KERNEL ,"%s.%s" , modname, auxdrv->name); +else + auxdrv->driver.name =kasprintf (GFP_KERNEL ,"%s" , modname); +if (!auxdrv->driver.name) +return -ENOMEM ; + + auxdrv->driver.owner = owner; + auxdrv->driver.bus = &auxiliary_bus_type; + auxdrv->driver.mod_name = modname; + +return driver_register (&auxdrv->driver); +} +EXPORT_SYMBOL_GPL (__auxiliary_driver_register); + +/** +* auxiliary_driver_unregister - unregister a driver +* @auxdrv: auxiliary_driver structure +*/ +void auxiliary_driver_unregister (struct auxiliary_driver *auxdrv) +{ +driver_unregister (&auxdrv->driver); +kfree (auxdrv->driver.name); +} +EXPORT_SYMBOL_GPL (auxiliary_driver_unregister); + +static int __init auxiliary_bus_init (void ) +{ +return bus_register (&auxiliary_bus_type); +}
drivers/base/auxiliary.c line 264
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+ +static void __exit auxiliary_bus_exit(void) +{ +bus_unregister (&auxiliary_bus_type); +} + +module_init (auxiliary_bus_init); +module_exit (auxiliary_bus_exit); + +MODULE_LICENSE ("GPL" );
Per above SPDX is v2 only, so...
MODULE_LICENSE("GPL v2");
Quoted 16 lines
drivers/base/auxiliary.c new file +3
-0+MODULE_DESCRIPTION ("Auxiliary Bus" ); +MODULE_AUTHOR ("David Ertman <[email protected]>" ); +MODULE_AUTHOR ("Kiran Patil <[email protected]>" );include/linux/auxiliary_bus.h new file +7
-0@@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2019-2020 Intel Corporation +* +* Please see Documentation/driver-api/auxiliary_bus.rst for more information. +*/ +
include/linux/auxiliary_bus.h line 17
Quoted 10 lines
include/linux/auxiliary_bus.h new file +10
-0+#ifndef _AUXILIARY_BUS_H_ +#define _AUXILIARY_BUS_H_ + +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/slab.h> + +struct auxiliary_device { + struct device dev; + const char *name;
I'd say name this "suffix" since it is only a component of the name.
Quoted 120 lines
include/linux/auxiliary_bus.h new file +61
-0+u32 id; +}; + +struct auxiliary_driver { +int (*probe)(struct auxiliary_device *auxdev,const struct auxiliary_device_id *id); +int (*remove)(struct auxiliary_device *auxdev); +void (*shutdown)(struct auxiliary_device *auxdev); +int (*suspend)(struct auxiliary_device *auxdev,pm_message_t state); +int (*resume)(struct auxiliary_device *auxdev); +const char *name; +struct device_driver driver; +const struct auxiliary_device_id *id_table; +}; + +static inline struct auxiliary_device *to_auxiliary_dev (struct device *dev) +{ + return container_of(dev, struct auxiliary_device, dev); +} + +static inline struct auxiliary_driver *to_auxiliary_drv (struct device_driver *drv) +{ + return container_of(drv, struct auxiliary_driver, driver); +} + +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) + +static inline void auxiliary_device_uninit (struct auxiliary_device *auxdev) +{ +put_device (&auxdev->dev); +} + +static inline void auxiliary_device_delete (struct auxiliary_device *auxdev) +{ +device_del (&auxdev->dev); +} + +int __auxiliary_driver_register (struct auxiliary_driver *auxdrv,struct module *owner, +const char *modname); +#define auxiliary_driver_register (auxdrv) \ + __auxiliary_driver_register(auxdrv, THIS_MODULE, KBUILD_MODNAME) + +void auxiliary_driver_unregister (struct auxiliary_driver *auxdrv); + +/** +* module_auxiliary_driver() - Helper macro for registering an auxiliary driver +* @__auxiliary_driver: auxiliary driver struct +* +* Helper macro for auxiliary drivers which do not 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() +*/ +#define module_auxiliary_driver (__auxiliary_driver) \ + module_driver(__auxiliary_driver, auxiliary_driver_register, auxiliary_driver_unregister) + +struct auxiliary_device * +auxiliary_find_device (struct device *start,const void *data, +int (*match)(struct device *dev,const void *data)); + +#endif /* _AUXILIARY_BUS_H_ */ include/linux/mod_devicetable.h +8
-0@@ -838,4 +838,12 @@ struct mhi_device_id { kernel_ulong_t driver_data; }; +#define AUXILIARY_NAME_SIZE 32 +#define AUXILIARY_MODULE_PREFIX "auxiliary:" + +struct auxiliary_device_id { +char name[AUXILIARY_NAME_SIZE ]; +kernel_ulong_t driver_data; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */ scripts/mod/devicetable-offsets.c +3
-0@@ -243,5 +243,8 @@ int main(void)DEVID (mhi_device_id);DEVID_FIELD (mhi_device_id, chan); +DEVID (auxiliary_device_id); +DEVID_FIELD (auxiliary_device_id, name); +return 0 ; }scripts/mod/file2alias.c +8
-1@@ -1364,6 +1364,13 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias) {DEF_FIELD_ADDR (symval, mhi_device_id, chan);sprintf (alias,MHI_DEVICE_MODALIAS_FMT , *chan); +return 1 ; +} + +static int do_auxiliary_entry (const char *filename,void *symval,char *alias) +{ +DEF_FIELD_ADDR (symval, auxiliary_device_id, name); +sprintf (alias,AUXILIARY_MODULE_PREFIX "%s" , *name);return 1 ; }@@ -1442,6 +1449,7 @@ static const struct devtable devtable[] = { {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, {"mhi", SIZE_mhi_device_id, do_mhi_entry}, + {"auxiliary", SIZE_auxiliary_device_id, do_auxiliary_entry}, };/* Create MODULE_ALIAS() statements. -- 2.26.2
Leon Romanovsky
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
Quoted 4 lines · Dan Williams
Some doc fixups, and minor code feedback. Otherwise looks good to me.
Quoted 1 line · Dave Ertman
<...>
Quoted 6 lines
drivers/base/Kconfig line 5
Quoted 3 lines
drivers/base/Kconfig +2
-0+config AUXILIARY_BUS + booltristate? Unless you need non-exported symbols, might as well let this be a module.
I asked it to be "bool", because bus as a module is an invitation for a disaster. For example if I compile-in mlx5 which is based on this bus, and won't add auxiliary_bus as a module to initramfs, the system won't boot.
<...>
Quoted 2 lines
Per above SPDX is v2 only, so...
Isn't it default for the Linux kernel?
Quoted 2 lines
MODULE_LICENSE("GPL v2");
Thanks
Re: [PATCH v3 01/10] Add auxiliary bus support
Quoted 13 lines · Leon Romanovsky
Quoted 4 lines · Dan Williams
Some doc fixups, and minor code feedback. Otherwise looks good to me.
Quoted 1 line · Dave Ertman
<...>
Quoted 4 lines
Quoted 3 lines
drivers/base/Kconfig +2
-0+config AUXILIARY_BUS + bool
Quoted 6 lines
Quoted 2 lines
tristate? Unless you need non-exported symbols, might as well let this be a module.
I asked it to be "bool", because bus as a module is an invitation for a disaster. For example if I compile-in mlx5 which is based on this bus, and won't add
auxiliary_busas a module to initramfs, the system won't boot.
Something is broken if module dependencies don't arrange for auxiliary_bus.ko to be added to the initramfs automatically, but yes, it is another degree of freedom for something to go wrong if you build the initramfs by hand.
Quoted 7 lines
<...>
Quoted 2 lines
Per above SPDX is v2 only, so...
Isn't it default for the Linux kernel?
SPDX eliminated the need to guess a default, and MODULE_LICENSE("GPL") implies the "or later" language. The only default assumption is that the license is GPL v2 compatible, those possibilities are myriad, but v2-only is the first preference.
Leon Romanovsky
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
Quoted 17 lines · Dan Williams
Quoted 16 lines · Leon Romanovsky
Quoted 4 lines · Dan Williams
Some doc fixups, and minor code feedback. Otherwise looks good to me.
Quoted 1 line · Dave Ertman
<...>
Quoted 6 lines
drivers/base/Kconfig line 5
Quoted 3 lines
drivers/base/Kconfig +2
-0+config AUXILIARY_BUS + booltristate? Unless you need non-exported symbols, might as well let this be a module.
Quoted 8 lines
Quoted 3 lines
I asked it to be "bool", because bus as a module is an invitation for a disaster. For example if I compile-in mlx5 which is based on this bus, and won't add
auxiliary_busas a module to initramfs, the system won't boot.Something is broken if module dependencies don't arrange for auxiliary_bus.ko to be added to the initramfs automatically, but yes, it is another degree of freedom for something to go wrong if you build the initramfs by hand.
And this is something that I would like to avoid for now.
Quoted 5 lines
Quoted 5 lines
<...>
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Per above SPDX is v2 only, so...
Isn't it default for the Linux kernel?
SPDX eliminated the need to guess a default, and
MODULE_LICENSE("GPL")implies the "or later" language. The only default assumption is that the license is GPL v2 compatible, those possibilities are myriad, but v2-only is the first preference.
I mean that plain GPL == GPL v2 in the kernel.
Thanks
Re: [PATCH v3 01/10] Add auxiliary bus support
Quoted 23 lines · Leon Romanovsky
Quoted 21 lines · Dan Williams
Quoted 19 lines · Leon Romanovsky
Quoted 4 lines · Dan Williams
Some doc fixups, and minor code feedback. Otherwise looks good to me.
Quoted 1 line · Dave Ertman
<...>
Quoted 6 lines
drivers/base/Kconfig line 5
Quoted 3 lines
drivers/base/Kconfig +2
-0+config AUXILIARY_BUS + booltristate? Unless you need non-exported symbols, might as well let this be a module.
I asked it to be "bool", because bus as a module is an invitation for a disaster. For example if I compile-in mlx5 which is based on this bus, and won't add
auxiliary_busas a module to initramfs, the system won't boot.
Quoted 6 lines
Quoted 4 lines
Something is broken if module dependencies don't arrange for auxiliary_bus.ko to be added to the initramfs automatically, but yes, it is another degree of freedom for something to go wrong if you build the initramfs by hand.
And this is something that I would like to avoid for now.
Fair enough.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
<...>
Quoted 2 lines
Per above SPDX is v2 only, so...
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Isn't it default for the Linux kernel?
SPDX eliminated the need to guess a default, and
MODULE_LICENSE("GPL")implies the "or later" language. The only default assumption is that the license is GPL v2 compatible, those possibilities are myriad, but v2-only is the first preference.I mean that plain GPL == GPL v2 in the kernel.
You are right, I was wrong.
Greg KH
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
In reply to Dan WilliamsQuoted 9 lines · Dan Williams
Quoted 4 lines
Quoted 2 lines
Per above SPDX is v2 only, so...
Isn't it default for the Linux kernel?
SPDX eliminated the need to guess a default, and
MODULE_LICENSE("GPL")implies the "or later" language. The only default assumption is that the license is GPL v2 compatible, those possibilities are myriad, but v2-only is the first preference.
No, MODULE_LICENSE("GPL") does not imply "or later" at all. Please see include/linux/module.h, it means "GPL version 2".
thanks,
greg k-h
Re: [PATCH v3 01/10] Add auxiliary bus support
Quoted 7 lines · Greg KH
Quoted 5 lines · Dan Williams
Quoted 4 lines
Quoted 2 lines
Per above SPDX is v2 only, so...
Isn't it default for the Linux kernel?
Quoted 8 lines
Quoted 4 lines
SPDX eliminated the need to guess a default, and
MODULE_LICENSE("GPL")implies the "or later" language. The only default assumption is that the license is GPL v2 compatible, those possibilities are myriad, but v2-only is the first preference.No,
MODULE_LICENSE("GPL")does not imply "or later" at all. Please seeinclude/linux/module.h, it means "GPL version 2".
Oh, I did, and stopped before getting to:
"only/or later" distinction is completely irrelevant and does neither
*replace the proper license identifiers in the corresponding source file
...sorry for the noise.
Ertman, David M
reviewerRE: [PATCH v3 01/10] Add auxiliary bus support
In reply to Dan WilliamsQuoted 81 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 1:19 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; Mark Brown <[email protected]>; linux-rdma <[email protected]>; Jason Gunthorpe <[email protected]>; Doug Ledford <[email protected]>; Netdev <[email protected]>; David Miller <[email protected]>; Jakub Kicinski <[email protected]>; Greg KH <[email protected]>; Ranjani Sridharan <[email protected]>; Pierre-Louis Bossart <[email protected]>; Fred Oh <[email protected]>; Parav Pandit <[email protected]>; Saleem, Shiraz <[email protected]>; Patil, Kiran <[email protected]>; Linux Kernel Mailing List <[email protected]>; Leon Romanovsky <[email protected]>
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportSome doc fixups, and minor code feedback. Otherwise looks good to me.
Quoted 37 lines · Dave Ertman
Add support for the Auxiliary Bus,
auxiliary_deviceandauxiliary_driver. It enables drivers to create anauxiliary_deviceand bind anauxiliary_driverto it.The bus supports probe/remove shutdown and suspend/resume callbacks. Each
auxiliary_devicehas a unique string based id; driver binds to anauxiliary_devicebased on this id through the bus.Co-developed-by Kiran Patil <[email protected]>Signed-off-by Kiran Patil <[email protected]>Co-developed-by Ranjani Sridharan <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Co-developed-by Fred Oh <[email protected]>Signed-off-by Fred Oh <[email protected]>Co-developed-by Leon Romanovsky <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>Reviewed-by Shiraz Saleem <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Dave Ertman <[email protected]>--- Documentation/driver-api/auxiliary_bus.rst | 228 ++++++++++++++++++ Documentation/driver-api/index.rst | 1 + drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/auxiliary.c | 267 +++++++++++++++++++++ include/linux/auxiliary_bus.h | 78 ++++++ include/linux/mod_devicetable.h | 8 + scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 8 + 9 files changed, 597 insertions(+) create mode 100644 Documentation/driver-api/auxiliary_bus.rst create mode 100644 drivers/base/auxiliary.c create mode 100644 include/linux/auxiliary_bus.hReview
Quoted 1 line
(quoted diff) +0
-0
b/Documentation/driver-api/auxiliary_bus.rstDocumentation/driver-api/auxiliary_bus.rst line 7
Quoted 12 lines
new file mode 100644
index 000000000000..500f29692c81Documentation/driver-api/auxiliary_bus.rst new file +7
-0@@ -0,0 +1,228 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +============= +Auxiliary Bus +============= + +In some subsystems, the functionality of the core device(PCI/ACPI/other) is
Documentation/driver-api/auxiliary_bus.rst line 8
Quoted 1 line
Documentation/driver-api/auxiliary_bus.rst new file +1
-0+too complex for a single device to be managed as a monolithic block or apart of
Documentation/driver-api/auxiliary_bus.rst line 9
Quoted 1 line
Documentation/driver-api/auxiliary_bus.rst new file +1
-0+the functionality needs to be exposed to a different subsystem.I think there are three identified use cases for this now, so call out those examples for others to compare if aux bus is a fit for their use case.
Quoted 7 lines
"In some subsystems, the functionality of the core device (PCI/ACPI/other) is too complex to be handled by a monolithic driver (e.g. Sound Open Firmware), multiple devices might implement a common intersection of functionality (e.g. NICs + RDMA), or a driver may want to export an interface for another subsystem to drive (e.g. SIOV Physical Function export Virtual Function management)."
Additional example added. Thanks for the review Dan!
Quoted 4 lines
Documentation/driver-api/auxiliary_bus.rst line 11
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+ Splitting the +functionality into smaller orthogonal devices would make it easier tomanage
Documentation/driver-api/auxiliary_bus.rst line 12
Quoted 1 line
Documentation/driver-api/auxiliary_bus.rst new file +1
-0+data, power management and domain-specific interaction with the
Quoted 9 lines
hardware.
Passive voice and I don't understand what is meant by the word "orthogonal"
"A split of the functionality into child-devices representing sub-domains of functionality makes it possible to compartmentalize, layer, and distribute domain-specific concerns via a Linux device-driver model"
verbiage changed.
Quoted 12 lines
Quoted 2 lines
A key
+requirement for such a split is that there is no dependency on a physicalbus,
Quoted 3 lines
+device, register accesses or regmap support.
These individual devices split from
+the core cannot live on the platform bus as they are not physical devicesthat
Quoted 1 line
+are controlled by DT/ACPI. The same argument applies for not using MFD
in this
Quoted 1 line
+scenario as MFD relies on individual function devices being physical
devices.
Quoted 9 lines
These last few sentences are confusing the justification of the existence of auxiliary bus, not the explanation of when why and how to use it.
The "When Should the Auxiliary Bus Be Used" should mention where Auxiliary bus fits relative to the platform-bus and MFD, perhaps in an explicit "When not to use Auxiliary Bus" section to direct people to platform-bus and MFD when those are a better fit.
Moved this content into the "When to use" section.
Quoted 14 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+ +An example for this kind of requirement is the audio subsystem where asingle
Quoted 1 line
+IP is handling multiple entities such as HDMI, Soundwire, local devices
such as
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+mics/speakers etc. The split for the core's functionality can be arbitrary or +be defined by the DSP firmware topology and include hooks fortest/debug. This
Quoted 1 line
+allows for the audio core device to be minimal and focused on hardware-
specific
Documentation/driver-api/auxiliary_bus.rst
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+control and communication. + +The auxiliary bus is intended to be minimal, generic and avoid domain-specific
Quoted 7 lines
Quoted 1 line
+assumptions.
As this file will be sitting in
Documentation/it will be too late to "intend" it either does and or it doesn't. This again feels more like justification for existence that should already be in the changelog, it can go from the Documentation.
removed the sentence.
Quoted 4 lines
Quoted 2 lines
Each
auxiliary_devicerepresents a part of its parent +functionality. The generic behavior can be extended and specialized asneeded
Quoted 1 line
+by encapsulating an
auxiliary_devicewithin other domain-specific
Quoted 9 lines
structures and
Documentation/driver-api/auxiliary_bus.rst line 31
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+the use of .ops callbacks. Devices on the auxiliary bus do not share any +structures and the use of a communication channel with the parent is +domain-specific.Should there be any guidance here on when to use ops and when to just export functions from parent driver to child.
EXPORT_SYMBOL_NS()seems a perfect fit for publishing shared routines between parent and child.
I would leave this up the driver writers to determine what is best for them.
Quoted 17 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 5 lines
Documentation/driver-api/auxiliary_bus.rst new file +5
-0+ +When Should the Auxiliary Bus Be Used +===================================== + +The auxiliary bus is to be used when a driver and one or more kernelmodules,
Quoted 1 line
+who share a common header file with the driver, need a mechanism to
connect and
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+provide access to a shared object allocated by the auxiliary_device's +registering driver. The registering driver for the auxiliary_device(s) andthe
Quoted 1 line
+kernel module(s) registering
auxiliary_driverscan be from the samesubsystem,
Documentation/driver-api/auxiliary_bus.rst
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+or from multiple subsystems. + +The emphasis here is on a common generic interface that keepssubsystem
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+customization out of the bus infrastructure. + +One example could be a multi-port PCI network device that is rdma-capable and
s/could be/is/
s/multi-port//
s/rdma-capable/RDMA-capable/
Changes made
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+needs to export this functionality and attach to an rdma driver in another +subsystem."exports a child device to be driven by an
auxiliary_driverin the RDMA subsystem"
Change made
Quoted 6 lines
Quoted 1 line
The PCI driver will allocate and register an
auxiliary_deviceforFix tense confusion:
s/will allocate and register/allocates and registers/
Change made.
Quoted 5 lines
Quoted 1 line
+each physical function on the NIC. The rdma driver will register an
s/rdma/RDMA/
s/will register/registers/
Change made
Quoted 4 lines
Quoted 1 line
+auxiliary_driver that will be matched with and probed for each of these
s/that will be matched with and probed for/that claims/
Change made
Quoted 10 lines
Quoted 1 line
+auxiliary_devices. This will give the rdma driver access to the shared
data/ops
Quoted 1 line
+in the PCI drivers shared object to establish a connection with the PCI
driver.
How about?
This conveys data/ops published by the parent PCI device/driver to the RDMA
auxiliary_driver.
Change made
Quoted 8 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 7 lines
Documentation/driver-api/auxiliary_bus.rst new file +7
-0+ +Another use case is for the PCI device to be split out into multiple sub +functions. For each sub function an auxiliary_device will be created. A PCI +sub function driver will bind to such devices that will create its own one or +more class devices. A PCI sub function auxiliary device will likely be +contained in a struct with additional attributes such as user defined sub +function number and optional attributes such as resources and a link tothe
Quoted 7 lines
Quoted 1 line
+parent device. These attributes could be used by systemd/udev; and
hence should
Quoted 1 line
+be initialized before a driver binds to an
auxiliary_device.This does not read like an explicit example like the previous 2. Did you have something specific in mind?
This was added by request of Parav.
Quoted 3 lines
Here's where the "when not to" / "MFD platform-bus" redirect section can go.
Content moved to this location
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 5 lines
Documentation/driver-api/auxiliary_bus.rst new file +5
-0+ +Auxiliary Device +================ + +An auxiliary_device is created and registered to represent a part of itsparent
s/created and registered to represent/represents/
Change made.
Quoted 5 lines
Quoted 1 line
+device's functionality. It is given a name that, combined with the
registering
Quoted 1 line
+drivers
KBUILD_MODNAME, creates amatch_namethat is used for driverbinding,
Quoted 1 line
+and an id that combined with the
match_nameprovide a unique name to
Quoted 9 lines
register
Documentation/driver-api/auxiliary_bus.rst line 72
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+with the bus subsystem. + +Registering an auxiliary_device is a two-step process. First you must callImperative implied:
s/you must//
Removed.
Quoted 8 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 4 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+auxiliary_device_init(), which will check several aspects of the +auxiliary_device struct and perform a device_initialize(). After this step +completes, any error state must have a call to auxiliary_device_unin() inits
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+resolution path. The second step in registering an auxiliary_device is to +perform a call to auxiliary_device_add(), which will set the name of thedevice
Quoted 7 lines
Documentation/driver-api/auxiliary_bus.rst line 81
Quoted 4 lines
Documentation/driver-api/auxiliary_bus.rst new file +4
-0+and add the device to the bus. + +Unregistering an auxiliary_device is also a two-step process to mirror the +register process. First will be a call to auxiliary_device_delete(), thens/will be a call to/call/
changed
Quoted 4 lines
Quoted 1 line
+followed by a call to
auxiliary_device_unin().s/followed by a call to/call/
changed. also fixed typo s/device_unin/device_uninit/
Quoted 29 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+ +.. code-block:: c + + struct auxiliary_device { + struct device dev; + const char *name; + u32 id; + }; + +If two auxiliary_devices both with a match_name "mod.foo" areregistered onto
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+the bus, they must have unique id values (e.g. "x" and "y") so that the +registered devices names will be "mod.foo.x" and "mod.foo.y". If
match_name+Quoted 1 line
+id are not unique, then the
device_addwill fail and generate an errormessage.
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+ +The auxiliary_device.dev.type.release or auxiliary_device.dev.releasemust be
Quoted 1 line
+populated with a non-NULL pointer to successfully register the
auxiliary_device.Documentation/driver-api/auxiliary_bus.rst
Quoted 7 lines
Documentation/driver-api/auxiliary_bus.rst new file +7
-0+ +The auxiliary_device.dev.parent must also be populated. + +Auxiliary Device Memory Model and Lifespan +------------------------------------------ + +When a kernel driver registers an auxiliary_device on the auxiliary bus, wewill
Quoted 5 lines
Quoted 1 line
+use the nomenclature to refer to this kernel driver as a registering driver.
Kill this sentence, it adds nothing and has a dreaded "we". Just say:
The registering driver is the entity...
Killed sentence and changed.
Quoted 4 lines
Quoted 2 lines
+is the entity that will allocate memory for the
auxiliary_deviceand registerit
Quoted 1 line
+on the auxiliary bus. It is important to note that, as opposed to the
Quoted 9 lines
platform
Quoted 1 line
+bus, the registering driver is wholly responsible for the management for
the
Documentation/driver-api/auxiliary_bus.rst line 112
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+memory used for the driver object. + +A parent object, defined in the shared header file, will contain theAnother "will", and more below. Convert all to present tense please.
Changed many instances of will.
Quoted 27 lines
Quoted 1 line
+auxiliary_device. It will also contain a pointer to the shared object(s),
which
Documentation/driver-api/auxiliary_bus.rst
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+will also be defined in the shared header. Both the parent object and the +shared object(s) will be allocated by the registering driver. This layout +allows the auxiliary_driver's registering module to perform a
container_of()Quoted 1 line
+call to go from the pointer to the
auxiliary_device, that is passed duringthe
Quoted 1 line
+call to the auxiliary_driver's probe function, up to the parent object, and
then
Documentation/driver-api/auxiliary_bus.rst
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst new file +6
-0+have access to the shared object(s). + +The memory for the auxiliary_device will be freed only in its release() +callback flow as defined by its registering driver. + +The memory for the shared object(s) must have a lifespan equal to, orgreater
Quoted 1 line
+than, the lifespan of the memory for the
auxiliary_device. The
auxiliary_driverDocumentation/driver-api/auxiliary_bus.rst
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+should only consider that this shared object is valid as long as the +auxiliary_device is still registered on the auxiliary bus. It is up to the +registering driver to manage (e.g. free or keep available) the memory forthe
Documentation/driver-api/auxiliary_bus.rst
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+shared object beyond the life of the auxiliary_device. + +Registering driver must unregister all auxiliary devices before itsregistering
Quoted 7 lines
Quoted 1 line
+parent device's
remove()is completed.Too many "registerings"
The registering driver must unregister all auxiliary devices before its own
driver.remove()callback is completed.
Changed.
Quoted 33 lines
Documentation/driver-api/auxiliary_bus.rst
Quoted 7 lines
Documentation/driver-api/auxiliary_bus.rst new file +7
-0+ +Auxiliary Drivers +================= + +Auxiliary drivers follow the standard driver model convention, where +discovery/enumeration is handled by the core, and drivers +provide probe() and remove() methods. They support powermanagement
Quoted 7 lines
Documentation/driver-api/auxiliary_bus.rst new file +7
-0+and shutdown notifications using the standard conventions. + +.. code-block:: c + + struct auxiliary_driver { + int (*probe)(struct auxiliary_device *, + const struct auxiliary_device_id *id);Documentation/driver-api/auxiliary_bus.rst
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+ int (*remove)(struct auxiliary_device *); + void (*shutdown)(struct auxiliary_device *); + int (*suspend)(struct auxiliary_device *, pm_message_t); + int (*resume)(struct auxiliary_device *); + struct device_driver driver; + const struct auxiliary_device_id *id_table; + }; + +Auxiliary drivers register themselves with the bus by calling +auxiliary_driver_register(). The id_table contains the match_names ofauxiliary
Documentation/driver-api/auxiliary_bus.rst
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst new file +6
-0+devices that a driver can bind with. + +Example Usage +============= + +Auxiliary devices are created and registered by a subsystem-level coredevice
Quoted 9 lines
Quoted 1 line
+that needs to break up its functionality into smaller fragments. One way
to
Quoted 1 line
+extend the scope of an
auxiliary_devicewould be to encapsulate it withina
More passive tense
s/would be/is/
Changed.
Quoted 9 lines
Quoted 1 line
+domain-specific structure defined by the parent device. This structure
contains
Documentation/driver-api/auxiliary_bus.rst line 169
Quoted 4 lines
Documentation/driver-api/auxiliary_bus.rst new file +4
-0+the auxiliary_device and any associated shared data/callbacks needed to +establish the connection with the parent. + +An example would be:s/would be/is/
Changed.
Quoted 5 lines
Quoted 5 lines
Documentation/driver-api/auxiliary_bus.rst new file +5
-0+ +.. code-block:: c + + struct foo { + struct auxiliary_device auxdev;
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst line 180
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst new file +6
-0+ void (*connect)(struct auxiliary_device *auxdev); + void (*disconnect)(struct auxiliary_device *auxdev); + void *data; + }; + +The parent device would then register the auxiliary_device by callingagain with the passive...
Changed. Also changed the one below.
Quoted 26 lines
Quoted 1 line
+auxiliary_device_init(), and then
auxiliary_device_add(), with the pointerto
Quoted 1 line
+the auxdev member of the above structure. The parent would provide a
name for
Quoted 1 line
+the
auxiliary_devicethat, combined with the parent's
KBUILD_MODNAME, willQuoted 1 line
+create a
match_namethat will be used for matching and binding with adriver.
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+ +Whenever an auxiliary_driver is registered, based on the match_name,the
Documentation/driver-api/auxiliary_bus.rst
Quoted 2 lines
Documentation/driver-api/auxiliary_bus.rst new file +2
-0+auxiliary_driver's probe() is invoked for the matching devices. The +auxiliary_driver can also be encapsulated inside custom drivers that makethe
Quoted 1 line
+core device's functionality extensible by adding additional domain-specific
ops
Quoted 10 lines
Documentation/driver-api/auxiliary_bus.rst new file +10
-0+as follows: + +.. code-block:: c + + struct my_ops { + void (*send)(struct auxiliary_device *auxdev); + void (*receive)(struct auxiliary_device *auxdev); + }; + +
Quoted 9 lines
Documentation/driver-api/auxiliary_bus.rst line 205
Quoted 6 lines
Documentation/driver-api/auxiliary_bus.rst new file +6
-0+ struct my_driver { + struct auxiliary_driver auxiliary_drv; + const struct my_ops ops; + }; + +An example of this type of usage would be:*is
Changed
Quoted 44 lines
Documentation/driver-
Quoted 24 lines
Documentation/driver-api/auxiliary_bus.rst new file +23
-0+ +.. code-block:: c + + const struct auxiliary_device_id my_auxiliary_id_table[] = { + { .name = "foo_mod.foo_dev" }, + { }, + }; + + const struct my_ops my_custom_ops = { + .send = my_tx, + .receive = my_rx, + }; + + const struct my_driver my_drv = { + .auxiliary_drv = { + .name = "myauxiliarydrv", + .id_table = my_auxiliary_id_table, + .probe = my_probe, + .remove = my_remove, + .shutdown = my_shutdown, + }, + .ops = my_custom_ops, + };Documentation/driver- renamed from Documentation/driver-api/index.rst +0
-0
api/index.rstQuoted 19 lines
index
987d6e74ea6a..af206dc816ca100644Documentation/driver-api/index.rst +1
-0@@ -72,6 +72,7 @@ available subsections can be seen below. thermal/index fpga/index acpi/index + auxiliary_bus backlight/lp855x-driver.rst connector consoledrivers/base/Kconfig +0
-0@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 menu "Generic Driver Options"
Quoted 6 lines
drivers/base/Kconfig line 5
Quoted 2 lines
drivers/base/Kconfig +2
-0+config AUXILIARY_BUS + booltristate? Unless you need non-exported symbols, might as well let this be a module.
As per Leon's response - leaving this as bool.
Quoted 20 lines
drivers/base/Makefile obj-y := component.o core.o bus.o dd.o
Quoted 9 lines
drivers/base/Kconfig +1
-0+ config UEVENT_HELPER bool "Support for uevent helper" helpdrivers/base/Makefile +0
-0@@ -7,6 +7,7 @@ obj-y := component.o core.o bus.o dd.osyscore.o \
Quoted 10 lines
drivers/base/Makefile +1
-0attribute_container.o transport_class.o \ topology.o container.o property.o cacheinfo.o \ swnode.o +obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o obj-y += power/ obj-$(CONFIG_ISA_BUS_API) += isa.odrivers/base/auxiliary.c new file +0
-0
Quoted 9 lines
drivers/base/auxiliary.c line 3
Quoted 6 lines
drivers/base/auxiliary.c new file +3
-0@@ -0,0 +1,267 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Software based bus for Auxiliary devices I'd just remove this line, it doesn't add anything.
Removed.
Quoted 129 lines
drivers/base/auxiliary.c
Quoted 4 lines
drivers/base/auxiliary.c new file +4
-0+* +* Copyright (c) 2019-2020 Intel Corporation +* +* Please see Documentation/driver-api/auxiliary_bus.rst for more information.
drivers/base/auxiliary.c
Quoted 13 lines
drivers/base/auxiliary.c new file +13
-0+*/ + +#define pr_fmt (fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__ + +#include <linux/device.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/pm_domain.h> +#include <linux/pm_runtime.h> +#include <linux/string.h> +#include <linux/auxiliary_bus.h> + +static const struct auxiliary_device_id *auxiliary_match_id(const struct
auxiliary_device_id*id,drivers/base/auxiliary.c
Quoted 11 lines
drivers/base/auxiliary.c new file +11
-0+ const struct auxiliary_device *auxdev) +{ +for (; id->name[0 ]; id++) { +const char *p =strrchr (dev_name (&auxdev->dev),'.' ); +int match_size; + +if (!p) +continue ; + match_size = p -dev_name (&auxdev->dev); + +/* use dev_name(&auxdev->dev) prefix before last '.' char to match to */
Quoted 6 lines
drivers/base/auxiliary.c new file +6
-0+if (strlen (id->name) == match_size && + !strncmp (dev_name (&auxdev->dev), id->name, match_size)) +return id; + } +return NULL ; +}drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+ +static int auxiliary_match (struct device *dev,struct device_driver *drv) +{ +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); +struct auxiliary_driver *auxdrv =to_auxiliary_drv (drv); + +return !!auxiliary_match_id (auxdrv->id_table, auxdev); +} + +static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env*env)
drivers/base/auxiliary.c
Quoted 7 lines
drivers/base/auxiliary.c new file +7
-0+{ +const char *name, *p; + + name =dev_name (dev); + p =strrchr (name,'.' ); + + return add_uevent_var(env, "MODALIAS=%s%.*s",
AUXILIARY_MODULE_PREFIX, (int)(p - name),drivers/base/auxiliary.c
Quoted 5 lines
drivers/base/auxiliary.c new file +5
-0+ name); +} + +static const struct dev_pm_ops auxiliary_dev_pm_ops = { + SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend,
pm_generic_runtime_resume, NULL)drivers/base/auxiliary.c line 60
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+ SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend,
pm_generic_resume)Quoted 5 lines
drivers/base/auxiliary.c new file +5
-0+}; + +static int auxiliary_bus_probe (struct device *dev) +{ +struct auxiliary_driver *auxdrv =to_auxiliary_drv (dev->driver);drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+struct auxiliary_device *auxdev =to_auxiliary_dev (dev); +int ret; + + ret =dev_pm_domain_attach (dev, true); +if (ret) { +dev_warn (dev,"Failed to attach to PM Domain : %d\n" , ret); +return ret; + } + + ret = auxdrv->probe(auxdev, auxiliary_match_id(auxdrv->id_table,auxdev));
Quoted 33 lines
drivers/base/auxiliary.c new file +33
-0+if (ret) +dev_pm_domain_detach (dev, true); + +return ret; +} + +static int auxiliary_bus_remove (struct device *dev) +{ +struct auxiliary_driver *auxdrv =to_auxiliary_drv (dev->driver); +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); +int ret =0 ; + +if (auxdrv->remove) + ret = auxdrv->remove (auxdev); +dev_pm_domain_detach (dev, true); + +return ret; +} + +static void auxiliary_bus_shutdown (struct device *dev) +{ +struct auxiliary_driver *auxdrv =to_auxiliary_drv (dev->driver); +struct auxiliary_device *auxdev =to_auxiliary_dev (dev); + +if (auxdrv->shutdown) + auxdrv->shutdown (auxdev); +} + +static struct bus_type auxiliary_bus_type = { + .name ="auxiliary" , + .probe = auxiliary_bus_probe, + .remove = auxiliary_bus_remove, + .shutdown = auxiliary_bus_shutdown,drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+ .match = auxiliary_match, + .uevent = auxiliary_uevent, + .pm = &auxiliary_dev_pm_ops, +}; + +/** +* auxiliary_device_init - check auxiliary_device and initialize +* @auxdev: auxiliary device struct +* +* This is the first step in the two-step process to register an
auxiliary_device.drivers/base/auxiliary.c line 120
Quoted 2 lines
drivers/base/auxiliary.c new file +2
-0+* +* When this function returns an error code, then the device_initialize will *not* have
drivers/base/auxiliary.c line 121
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* been performed, and the caller will be responsible to free any memory allocated for the
Quoted 9 lines
drivers/base/auxiliary.c
Quoted 3 lines
drivers/base/auxiliary.c new file +3
-0+* auxiliary_device in the error path directly. +* +* It returns 0 on success. On success, the device_initialize has been performed. After this
drivers/base/auxiliary.c line 125
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* point any error unwinding will need to include a call to
auxiliary_device_init().Whoops, you meant to say
auxiliary_device_uninit().
yikes - yes I did! Changed.
Quoted 8 lines
drivers/base/auxiliary.c line 126
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* In this post-initialize error scenario, a call to the device's .release callback will be
drivers/base/auxiliary.c line 127
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* triggered by auxiliary_device_uninit(), and all memory clean-up is expected to be
with this function already mentioned above you can drop "by
auxiliary_device_uninit()"
dropped.
Quoted 33 lines
Quoted 18 lines
drivers/base/auxiliary.c new file +18
-0+* handled there. +*/ +int auxiliary_device_init (struct auxiliary_device *auxdev) +{ +struct device *dev = &auxdev->dev; + +if (!dev->parent) { +pr_err ("auxiliary_device has a NULL dev->parent\n" ); +return -EINVAL ; + } + +if (!auxdev->name) { +pr_err ("auxiliary_device has a NULL name\n" ); +return -EINVAL ; + } + + dev->bus = &auxiliary_bus_type; +device_initialize (&auxdev->dev);drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+return 0 ; +} +EXPORT_SYMBOL_GPL (auxiliary_device_init); + +/** +* __auxiliary_device_add - add an auxiliary bus device +* @auxdev: auxiliary bus device to add to the bus +* @modname: name of the parent device's driver module +* +* This is the second step in the two-step process to register an
auxiliary_device.drivers/base/auxiliary.c line 157
Quoted 2 lines
drivers/base/auxiliary.c new file +2
-0+* +* This function must be called after a successful call to
auxiliary_device_init(), whichdrivers/base/auxiliary.c line 158
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* will perform the device_initialize. This means that if this returns an
Quoted 9 lines
error code, then a
drivers/base/auxiliary.c line 159
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* call to auxiliary_device_uninit() must be performed so that the .release callback will
drivers/base/auxiliary.c line 160
Quoted 1 line
drivers/base/auxiliary.c new file +1
-0+* be triggered to free the memory associated with the auxiliary_device. Might want to mention the typical expectation is that users call
auxiliary_device_addwithout underbars. Only if custom names are needed would this direct version be used.
Added in verbiage to that effect.
Quoted 112 lines
drivers/base/auxiliary.c line 162
Quoted 2 lines
drivers/base/auxiliary.c new file +2
-0+*/ +int __auxiliary_device_add(struct auxiliary_device *auxdev, const char*modname)
drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+{ +struct device *dev = &auxdev->dev; +int ret; + +if (!modname) { +pr_err ("auxiliary device modname is NULL\n" ); +return -EINVAL ; + } + + ret = dev_set_name(dev, "%s.%s.%d", modname, auxdev->name,
auxdev->id);Quoted 5 lines
drivers/base/auxiliary.c new file +5
-0+if (ret) { +pr_err ("auxiliary device dev_set_name failed: %d\n" , ret); +return ret; + } +drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+ ret =device_add (dev); +if (ret) +dev_err (dev,"adding auxiliary device failed!: %d\n" , ret); + +return ret; +} +EXPORT_SYMBOL_GPL (__auxiliary_device_add); + +/** +* auxiliary_find_device - auxiliary device iterator for locating a particular device.
Quoted 22 lines
drivers/base/auxiliary.c new file +22
-0+* @start: Device to begin with +* @data: Data to pass to match function +* @match: Callback function to check device +* +* This function returns a reference to a device that is 'found' +* for later use, as determined by the @match callback. +* +* The callback should return 0 if the device doesn't match and non-zero +* if it does. If the callback returns non-zero, this function will +* return to the caller and not iterate over any more devices. +*/ +struct auxiliary_device * +auxiliary_find_device (struct device *start,const void *data, +int (*match)(struct device *dev,const void *data)) +{ +struct device *dev; + + dev =bus_find_device (&auxiliary_bus_type, start, data, match); +if (!dev) +return NULL ; + +return to_auxiliary_dev (dev);drivers/base/auxiliary.c
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+} +EXPORT_SYMBOL_GPL (auxiliary_find_device); + +/** +* __auxiliary_driver_register - register a driver for auxiliary bus devices +* @auxdrv: auxiliary_driver structure +* @owner: owning module/driver +* @modname: KBUILD_MODNAME for parent driver +*/ +int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, structmodule *owner,
drivers/base/auxiliary.c
Quoted 7 lines
drivers/base/auxiliary.c new file +7
-0+ const char *modname) +{ +if (WARN_ON (!auxdrv->probe) ||WARN_ON (!auxdrv->id_table)) +return -EINVAL ; + +if (auxdrv->name) + auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s.%s",modname,
auxdrv->name);Quoted 28 lines
drivers/base/auxiliary.c new file +28
-0+else + auxdrv->driver.name =kasprintf (GFP_KERNEL ,"%s" , modname); +if (!auxdrv->driver.name) +return -ENOMEM ; + + auxdrv->driver.owner = owner; + auxdrv->driver.bus = &auxiliary_bus_type; + auxdrv->driver.mod_name = modname; + +return driver_register (&auxdrv->driver); +} +EXPORT_SYMBOL_GPL (__auxiliary_driver_register); + +/** +* auxiliary_driver_unregister - unregister a driver +* @auxdrv: auxiliary_driver structure +*/ +void auxiliary_driver_unregister (struct auxiliary_driver *auxdrv) +{ +driver_unregister (&auxdrv->driver); +kfree (auxdrv->driver.name); +} +EXPORT_SYMBOL_GPL (auxiliary_driver_unregister); + +static int __init auxiliary_bus_init (void ) +{ +return bus_register (&auxiliary_bus_type); +}drivers/base/auxiliary.c line 264
Quoted 10 lines
drivers/base/auxiliary.c new file +10
-0+ +static void __exit auxiliary_bus_exit(void) +{ +bus_unregister (&auxiliary_bus_type); +} + +module_init (auxiliary_bus_init); +module_exit (auxiliary_bus_exit); + +MODULE_LICENSE ("GPL" );Per above SPDX is v2 only, so...
Quoted 2 lines
MODULE_LICENSE("GPL v2");
added v2.
Quoted 15 lines
Quoted 9 lines
drivers/base/auxiliary.c new file +3
-0+MODULE_DESCRIPTION ("Auxiliary Bus" ); +MODULE_AUTHOR ("David Ertman <[email protected]>" ); +MODULE_AUTHOR ("Kiran Patil <[email protected]>" );include/linux/auxiliary_bus.h new file +0
-0include/linux/auxiliary_bus.h line 5
Quoted 5 lines
include/linux/auxiliary_bus.h new file +5
-0@@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2019-2020 Intel Corporation +* +* Please see Documentation/driver-api/auxiliary_bus.rst for more information.
Quoted 15 lines
include/linux/auxiliary_bus.h line 17
Quoted 12 lines
include/linux/auxiliary_bus.h new file +12
-0+*/ + +#ifndef _AUXILIARY_BUS_H_ +#define _AUXILIARY_BUS_H_ + +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/slab.h> + +struct auxiliary_device { + struct device dev; + const char *name;I'd say name this "suffix" since it is only a component of the name.
This is a mandatory field though, and suffix lends itself to be considered optional. Also, name is more intuitive in its meaning than suffix would be.
Quoted 131 lines
include/linux/auxiliary_bus.h line 22
Quoted 5 lines
include/linux/auxiliary_bus.h new file +5
-0+u32 id; +}; + +struct auxiliary_driver { + int (*probe)(struct auxiliary_device *auxdev, const struct
auxiliary_device_id*id);include/linux/auxiliary_bus.h
Quoted 3 lines
include/linux/auxiliary_bus.h new file +3
-0+int (*remove)(struct auxiliary_device *auxdev); +void (*shutdown)(struct auxiliary_device *auxdev); + int (*suspend)(struct auxiliary_device *auxdev, pm_message_tstate);
include/linux/auxiliary_bus.h
Quoted 12 lines
include/linux/auxiliary_bus.h new file +12
-0+int (*resume)(struct auxiliary_device *auxdev); +const char *name; +struct device_driver driver; +const struct auxiliary_device_id *id_table; +}; + +static inline struct auxiliary_device *to_auxiliary_dev (struct device *dev) +{ + return container_of(dev, struct auxiliary_device, dev); +} + +static inline struct auxiliary_driver *to_auxiliary_drv(struct device_driver*drv)
include/linux/auxiliary_bus.h
Quoted 6 lines
include/linux/auxiliary_bus.h new file +6
-0+{ + return container_of(drv, struct auxiliary_driver, driver); +} + +int auxiliary_device_init (struct auxiliary_device *auxdev); +int __auxiliary_device_add(struct auxiliary_device *auxdev, const char*modname);
include/linux/auxiliary_bus.h line 44
Quoted 1 line
include/linux/auxiliary_bus.h new file +1
-0+#define auxiliary_device_add (auxdev) __auxiliary_device_add(auxdev,
KBUILD_MODNAME)include/linux/auxiliary_bus.h
Quoted 12 lines
include/linux/auxiliary_bus.h new file +12
-0+ +static inline void auxiliary_device_uninit (struct auxiliary_device *auxdev) +{ +put_device (&auxdev->dev); +} + +static inline void auxiliary_device_delete (struct auxiliary_device *auxdev) +{ +device_del (&auxdev->dev); +} + +int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, structmodule *owner,
include/linux/auxiliary_bus.h
Quoted 3 lines
include/linux/auxiliary_bus.h new file +3
-0+ const char *modname); +#define auxiliary_driver_register (auxdrv) \ + __auxiliary_driver_register(auxdrv, THIS_MODULE,
KBUILD_MODNAME)include/linux/auxiliary_bus.h
Quoted 5 lines
include/linux/auxiliary_bus.h new file +5
-0+ +void auxiliary_driver_unregister (struct auxiliary_driver *auxdrv); + +/** +* module_auxiliary_driver() - Helper macro for registering an auxiliary driver
include/linux/auxiliary_bus.h
Quoted 4 lines
include/linux/auxiliary_bus.h new file +4
-0+* @__auxiliary_driver: auxiliary driver struct +* +* Helper macro for auxiliary drivers which do not do anything special in +* module init/exit. This eliminates a lot of boilerplate. Each module may only
include/linux/auxiliary_bus.h line 69
Quoted 1 line
include/linux/auxiliary_bus.h new file +1
-0+* use this macro once, and calling it replaces module_init() and
module_exit()include/linux/auxiliary_bus.h
Quoted 3 lines
include/linux/auxiliary_bus.h new file +3
-0+*/ +#define module_auxiliary_driver (__auxiliary_driver) \ + module_driver(__auxiliary_driver, auxiliary_driver_register,
auxiliary_driver_unregister)Review
Quoted 7 lines
include/linux/auxiliary_bus.h new file +6
-0+ +struct auxiliary_device * +auxiliary_find_device (struct device *start,const void *data, +int (*match)(struct device *dev,const void *data)); + +#endif /* _AUXILIARY_BUS_H_ */ (quoted diff) +0
-0
b/include/linux/mod_devicetable.hscripts/mod/devicetable-
Quoted 17 lines
index
5b08a473cdba..c425290b21e2100644include/linux/mod_devicetable.h +8
-0@@ -838,4 +838,12 @@ struct mhi_device_id { kernel_ulong_t driver_data; }; +#define AUXILIARY_NAME_SIZE 32 +#define AUXILIARY_MODULE_PREFIX "auxiliary:" + +struct auxiliary_device_id { +char name[AUXILIARY_NAME_SIZE ]; +kernel_ulong_t driver_data; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */ scripts/mod/devicetable- renamed from scripts/mod/devicetable-offsets.c +0
-0
offsets.cscripts/mod/file2alias.c static int do_mhi_entry(const char *filename,
Quoted 17 lines
index
27007c18e754..e377f52dbfa3100644scripts/mod/devicetable-offsets.c +3
-0@@ -243,5 +243,8 @@ int main(void)DEVID (mhi_device_id);DEVID_FIELD (mhi_device_id, chan); +DEVID (auxiliary_device_id); +DEVID_FIELD (auxiliary_device_id, name); +return 0 ; }scripts/mod/file2alias.c +0
-0@@ -1364,6 +1364,13 @@ static int do_mhi_entry(const char *filename,void *symval, char *alias)
scripts/mod/file2alias.c static int do_mhi_entry(const char *filename, void *symval, char *alias)
Quoted 7 lines
scripts/mod/file2alias.c +4
-0{DEF_FIELD_ADDR (symval, mhi_device_id, chan);sprintf (alias,MHI_DEVICE_MODALIAS_FMT , *chan); +return 1 ; +} + +static int do_auxiliary_entry(const char *filename, void *symval, char*alias)
Quoted 13 lines
scripts/mod/file2alias.c +4
-0+{ +DEF_FIELD_ADDR (symval, auxiliary_device_id, name); +sprintf (alias,AUXILIARY_MODULE_PREFIX "%s" , *name);return 1 ; }@@ -1442,6 +1449,7 @@ static const struct devtable devtable[] = { {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, {"mhi", SIZE_mhi_device_id, do_mhi_entry}, + {"auxiliary", SIZE_auxiliary_device_id, do_auxiliary_entry}, };
Quoted 4 lines
Quoted 4 lines
scripts/mod/file2alias.c +0
-1/* Create MODULE_ALIAS() statements. -- 2.26.2
Again, thanks for the review Dan. Changes will be in next release (v4) once I give stake-holders a little time to respond.
-DaveE
Re: [PATCH v3 01/10] Add auxiliary bus support
Quoted 8 lines
Quoted 8 lines
drivers/base/auxiliary.c line 264
Quoted 5 lines
drivers/base/auxiliary.c new file +4
-0+module_init (auxiliary_bus_init); +module_exit (auxiliary_bus_exit); + +MODULE_LICENSE ("GPL" );Per above SPDX is v2 only, so...
Quoted 4 lines
Quoted 2 lines
MODULE_LICENSE("GPL v2");added v2.
"GPL v2" is the same as "GPL" here, it does not have any additional meaning.
https://www.kernel.org/doc/html/latest/process/license-rules.html
“GPL” Module is licensed under GPL version 2. This does not express any distinction between GPL-2.0-only or GPL-2.0-or-later. The exact license information can only be determined via the license information in the corresponding source files.
“GPL v2” Same as “GPL”. It exists for historic reasons.
Leon Romanovsky
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
Quoted 13 lines · Pierre-Louis Bossart
Quoted 8 lines
Quoted 8 lines
drivers/base/auxiliary.c line 264
Quoted 5 lines
drivers/base/auxiliary.c new file +4
-0+module_init (auxiliary_bus_init); +module_exit (auxiliary_bus_exit); + +MODULE_LICENSE ("GPL" );Per above SPDX is v2 only, so...
Quoted 4 lines
Quoted 2 lines
MODULE_LICENSE("GPL v2");added v2.
Quoted 8 lines
"GPL v2" is the same as "GPL" here, it does not have any additional meaning.
https://www.kernel.org/doc/html/latest/process/license-rules.html
“GPL” Module is licensed under GPL version 2. This does not express any
distinction between GPL-2.0-only or GPL-2.0-or-later. The exact license information can only be determined via the license information in the corresponding source files.
+1,
https://lore.kernel.org/lkml/20201105193009.GA5475@unreal
Quoted 3 lines
“GPL v2” Same as “GPL”. It exists for historic reasons.
Leon Romanovsky
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
In reply to Ertman, David MQuoted 21 lines · David M
Quoted 21 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 1:19 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; Mark Brown <[email protected]>; linux-rdma <[email protected]>; Jason Gunthorpe <[email protected]>; Doug Ledford <[email protected]>; Netdev <[email protected]>; David Miller <[email protected]>; Jakub Kicinski <[email protected]>; Greg KH <[email protected]>; Ranjani Sridharan <[email protected]>; Pierre-Louis Bossart <[email protected]>; Fred Oh <[email protected]>; Parav Pandit <[email protected]>; Saleem, Shiraz <[email protected]>; Patil, Kiran <[email protected]>; Linux Kernel Mailing List <[email protected]>; Leon Romanovsky <[email protected]>
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportSome doc fixups, and minor code feedback. Otherwise looks good to me.
On Thu, Oct 22, 2020 at 5:35 PM Dave Ertman <[email protected]> wrote:
<...>
Quoted 3 lines
Again, thanks for the review Dan. Changes will be in next release (v4) once I give stake-holders a little time to respond.
Everything here can go as a Fixes, the review comments are valuable and need to be fixed, but they don't change anything dramatically that prevent from merging v3.
Thanks
Quoted 2 lines
-DaveE
Ertman, David M
reviewerRE: [PATCH v3 01/10] Add auxiliary bus support
Quoted 49 lines
-----Original Message-----
From: Leon Romanovsky <[email protected]>
Sent: Thursday, November 5, 2020 11:35 AM
To: Ertman, David M <[email protected]>
Cc: Williams, Dan J <[email protected]>; [email protected]; Takashi Iwai <[email protected]>; Mark Brown <[email protected]>; linux- rdma <[email protected]>; Jason Gunthorpe <[email protected]>; Doug Ledford <[email protected]>; Netdev <[email protected]>; David Miller <[email protected]>; Jakub Kicinski <[email protected]>; Greg KH <[email protected]>; Ranjani Sridharan <[email protected]>; Pierre-Louis Bossart <pierre- [email protected]>; Fred Oh <[email protected]>; Parav Pandit <[email protected]>; Saleem, Shiraz <[email protected]>; Patil, Kiran <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportQuoted 5 lines · David M
Quoted 5 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 1:19 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; MarkBrown
Quoted 3 lines
Quoted 3 lines
<[email protected]>; linux-rdma <[email protected]>; Jason Gunthorpe <[email protected]>; Doug Ledford <[email protected]>; Netdev <[email protected]>; David Miller
Quoted 1 line
Quoted 1 line
Jakub Kicinski <[email protected]>; Greg KH
Quoted 1 line
Quoted 1 line
Ranjani Sridharan <[email protected]>; Pierre-Louis
Bossart
Quoted 1 line
Quoted 1 line
<[email protected]>; Fred Oh
Quoted 9 lines
Quoted 9 lines
Parav Pandit <[email protected]>; Saleem, Shiraz <[email protected]>; Patil, Kiran <[email protected]>; Linux Kernel Mailing List <[email protected]>; Leon Romanovsky <[email protected]>
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportSome doc fixups, and minor code feedback. Otherwise looks good to me.
On Thu, Oct 22, 2020 at 5:35 PM Dave Ertman
Quoted 1 line
Quoted 1 line
wrote:
<...>
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Again, thanks for the review Dan. Changes will be in next release (v4) once
I give
Quoted 1 line
stake-holders a little time to respond.
Everything here can go as a Fixes, the review comments are valuable and need
to be fixed, but they don't change anything dramatically that prevent from merging v3.
This works for me - I have the changes saved into an add-on patch that I haven't squashed into the main patch yet.
Quoted 4 lines
Thanks
Quoted 2 lines
-DaveE
RE: [PATCH v3 01/10] Add auxiliary bus support
In reply to Ertman, David MQuoted 10 lines
From: Ertman, David M <[email protected]>
Sent: Friday, November 6, 2020 12:58 AM
Subject: RE: [PATCH v3 01/10] Add auxiliary bus supportQuoted 4 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 1:19 AM
[..]
Quoted 10 lines
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ +Another use case is for the PCI device to be split out into +multiple sub functions. For each sub function an auxiliary_device +will be created. A PCI sub function driver will bind to such +devices that will create its own one or more class devices. A PCI +sub function auxiliary device will likely be contained in a struct +with additional attributes such as user defined sub function number +and optional attributes such as resources and a link tothe
Quoted 1 line
+parent device. These attributes could be used by systemd/udev; and
Quoted 9 lines
Quoted 6 lines
hence should
Quoted 1 line
+be initialized before a driver binds to an
auxiliary_device.This does not read like an explicit example like the previous 2. Did you have something specific in mind?
This was added by request of Parav.
This example describes the mlx5 PCI subfunction use case. I didn't follow your question about 'explicit example'. What part is missing to identify it as explicit example?
Re: [PATCH v3 01/10] Add auxiliary bus support
Quoted 30 lines · Parav Pandit
Quoted 11 lines
From: Ertman, David M <[email protected]>
Sent: Friday, November 6, 2020 12:58 AM
Subject: RE: [PATCH v3 01/10] Add auxiliary bus supportQuoted 4 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 1:19 AM[..]
Quoted 17 lines
Quoted 16 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ +Another use case is for the PCI device to be split out into +multiple sub functions. For each sub function an auxiliary_device +will be created. A PCI sub function driver will bind to such +devices that will create its own one or more class devices. A PCI +sub function auxiliary device will likely be contained in a struct +with additional attributes such as user defined sub function number +and optional attributes such as resources and a link tothe
Quoted 1 line
+parent device. These attributes could be used by systemd/udev; and
hence should
Quoted 1 line
+be initialized before a driver binds to an
auxiliary_device.This does not read like an explicit example like the previous 2. Did you have something specific in mind?
Quoted 5 lines
Quoted 2 lines
This was added by request of Parav.
This example describes the mlx5 PCI subfunction use case. I didn't follow your question about 'explicit example'. What part is missing to identify it as explicit example?
Specifically listing "mlx5" so if someone reading this document thinks to themselves "hey mlx5 sounds like my use case" they can go grep for that.
RE: [PATCH v3 01/10] Add auxiliary bus support
Quoted 38 lines
From: Dan Williams <[email protected]>
Sent: Friday, November 6, 2020 1:56 AMQuoted 32 lines · Parav Pandit
Quoted 11 lines
From: Ertman, David M <[email protected]>
Sent: Friday, November 6, 2020 12:58 AM
Subject: RE: [PATCH v3 01/10] Add auxiliary bus supportQuoted 4 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 1:19 AM[..]
Quoted 19 lines
Quoted 18 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ +Another use case is for the PCI device to be split out into +multiple sub functions. For each sub function an +auxiliary_device will be created. A PCI sub function driver +will bind to such devices that will create its own one or more +class devices. A PCI sub function auxiliary device will likely +be contained in a struct with additional attributes such as +user defined sub function number and optional attributes such +as resources and a link tothe
Review
Quoted 2 lines
(quoted diff) +2
-0+parent device. These attributes could be used by systemd/udev; +andhence should
Quoted 1 line
+be initialized before a driver binds to an
auxiliary_device.This does not read like an explicit example like the previous 2. Did you have something specific in mind?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This was added by request of Parav.
This example describes the mlx5 PCI subfunction use case. I didn't follow your question about 'explicit example'. What part is missing to identify it as explicit example?
Specifically listing "mlx5" so if someone reading this document thinks to themselves "hey mlx5 sounds like my use case" they can go grep for that.
Ah, I see.
"mlx5" is not listed explicitly, because it is not included in this patchset.
In various previous discussions in this thread, mlx5 subfunction use case is described that justifies the existence of the bus. I will be happy to update this documentation once mlx5 subfunction will be part of kernel so that grep actually shows valid output. (waiting to post them as it uses auxiliary bus :-)).
Mark Brown
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
Quoted 4 lines · Parav Pandit
Quoted 3 lines
Quoted 3 lines
This example describes the mlx5 PCI subfunction use case. I didn't follow your question about 'explicit example'. What part is missing to identify it as explicit example?
Quoted 8 lines
Quoted 2 lines
Specifically listing "mlx5" so if someone reading this document thinks to themselves "hey mlx5 sounds like my use case" they can go grep for that.
Ah, I see.
"mlx5" is not listed explicitly, because it is not included in this patchset.
In various previous discussions in this thread, mlx5 subfunction use case is described that justifies the existence of the bus. I will be happy to update this documentation once mlx5 subfunction will be part of kernel so that grep actually shows valid output. (waiting to post them as it uses auxiliary bus :-)).
For ease of review if there's a new version it might be as well to just reference it anyway, hopefully the mlx5 code will be merged fairly quickly once the bus itself is merged. It's probably easier all round than adding the reference later, it seems more likely that mlx5 will get merged than that it'll fall by the wayside.
Re: [PATCH v3 01/10] Add auxiliary bus support
Quoted 15 lines · Mark Brown
Quoted 4 lines · Parav Pandit
Quoted 3 lines
Quoted 3 lines
This example describes the mlx5 PCI subfunction use case. I didn't follow your question about 'explicit example'. What part is missing to identify it as explicit example?
Quoted 8 lines
Quoted 2 lines
Specifically listing "mlx5" so if someone reading this document thinks to themselves "hey mlx5 sounds like my use case" they can go grep for that.
Ah, I see.
"mlx5" is not listed explicitly, because it is not included in this patchset.
In various previous discussions in this thread, mlx5 subfunction use case is described that justifies the existence of the bus. I will be happy to update this documentation once mlx5 subfunction will be part of kernel so that grep actually shows valid output. (waiting to post them as it uses auxiliary bus :-)).
Quoted 5 lines
For ease of review if there's a new version it might be as well to just reference it anyway, hopefully the mlx5 code will be merged fairly quickly once the bus itself is merged. It's probably easier all round than adding the reference later, it seems more likely that mlx5 will get merged than that it'll fall by the wayside.
Another use-case for this patch-set is going to be the habanalabs driver. The GAUDI ASIC is a PCI H/W accelerator for deep-learning which also exposes network ports.We are going to use this auxiliary-bus feature to separate our monolithic driver into several parts that will reside in different subsystems and communicate between them through the bus.
Thanks,
Oded
Re: [PATCH v3 01/10] Add auxiliary bus support
In reply to Ertman, David MOn Thu, Nov 5, 2020 at 11:28 AM Ertman, David M
<[email protected]> wrote:
[..]
Quoted 14 lines
Quoted 4 lines
Quoted 2 lines
Each
auxiliary_devicerepresents a part of its parent +functionality. The generic behavior can be extended and specialized asneeded
Quoted 1 line
+by encapsulating an
auxiliary_devicewithin other domain-specificQuoted 9 lines
structures and
Documentation/driver-api/auxiliary_bus.rst line 31
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+the use of .ops callbacks. Devices on the auxiliary bus do not share any +structures and the use of a communication channel with the parent is +domain-specific.Should there be any guidance here on when to use ops and when to just export functions from parent driver to child.
EXPORT_SYMBOL_NS()seems a perfect fit for publishing shared routines between parent and child.
Quoted 1 line
I would leave this up the driver writers to determine what is best for them.
I think there is a pathological case that can be avoided with a statement like the following:
"Note that ops are intended as a way to augment instance behavior within a class of auxiliary devices, it is not the mechanism for exporting common infrastructure from the parent. Consider EXPORT_SYMBOL_NS() to convey infrastructure from the parent module to the auxiliary module(s)."
As for your other dispositions of the feedback, looks good to me.
Ertman, David M
reviewerRE: [PATCH v3 01/10] Add auxiliary bus support
Quoted 40 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Thursday, November 5, 2020 2:00 PM
To: Ertman, David M <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; Mark Brown <[email protected]>; linux-rdma <[email protected]>; Jason Gunthorpe <[email protected]>; Doug Ledford <[email protected]>; Netdev <[email protected]>; David Miller <[email protected]>; Jakub Kicinski <[email protected]>; Greg KH <[email protected]>; Ranjani Sridharan <[email protected]>; Pierre-Louis Bossart <[email protected]>; Fred Oh <[email protected]>; Parav Pandit <[email protected]>; Saleem, Shiraz <[email protected]>; Patil, Kiran <[email protected]>; Linux Kernel Mailing List <[email protected]>; Leon Romanovsky <[email protected]>
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportOn Thu, Nov 5, 2020 at 11:28 AM Ertman, David M
<[email protected]> wrote:
[..]Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Each
auxiliary_devicerepresents a part of its parent +functionality. The generic behavior can be extended and specialized asneeded
Quoted 1 line
+by encapsulating an
auxiliary_devicewithin other domain-specificstructures and
Documentation/driver-api/auxiliary_bus.rst line 31
Quoted 3 lines
Documentation/driver-api/auxiliary_bus.rst new file +3
-0+the use of .ops callbacks. Devices on the auxiliary bus do not share any +structures and the use of a communication channel with the parent is +domain-specific.Should there be any guidance here on when to use ops and when to just export functions from parent driver to child.
EXPORT_SYMBOL_NS()seems
Quoted 4 lines
Quoted 2 lines
a perfect fit for publishing shared routines between parent and child.
I would leave this up the driver writers to determine what is best for them.
I think there is a pathological case that can be avoided with a statement like the following:
Quoted 7 lines
"Note that ops are intended as a way to augment instance behavior within a class of auxiliary devices, it is not the mechanism for exporting common infrastructure from the parent. Consider
EXPORT_SYMBOL_NS()to convey infrastructure from the parent module to the auxiliary module(s)."As for your other dispositions of the feedback, looks good to me.
I will add this in.
-DaveE
Greg KH
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
In reply to Dave ErtmanQuoted 21 lines · Dave Ertman
Add support for the Auxiliary Bus,
auxiliary_deviceandauxiliary_driver. It enables drivers to create anauxiliary_deviceand bind anauxiliary_driverto it.The bus supports probe/remove shutdown and suspend/resume callbacks. Each
auxiliary_devicehas a unique string based id; driver binds to anauxiliary_devicebased on this id through the bus.Co-developed-by Kiran Patil <[email protected]>Signed-off-by Kiran Patil <[email protected]>Co-developed-by Ranjani Sridharan <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Co-developed-by Fred Oh <[email protected]>Signed-off-by Fred Oh <[email protected]>Co-developed-by Leon Romanovsky <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>Reviewed-by Shiraz Saleem <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Dave Ertman <[email protected]>
Quoted 1 line
---
Is this really the "latest" version of this patch submission?
I see a number of comments on it already, have you sent out a newer one, or is this the same one that the mlx5 driver conversion was done on top of?
thanks,
greg k-h
Ertman, David M
reviewerRE: [PATCH v3 01/10] Add auxiliary bus support
Quoted 40 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Friday, November 13, 2020 7:50 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Saleem, Shiraz <[email protected]>; Williams, Dan J <[email protected]>; Patil, Kiran <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportQuoted 21 lines · Dave Ertman
Add support for the Auxiliary Bus,
auxiliary_deviceandauxiliary_driver. It enables drivers to create anauxiliary_deviceand bind anauxiliary_driverto it.The bus supports probe/remove shutdown and suspend/resume callbacks. Each
auxiliary_devicehas a unique string based id; driver binds to anauxiliary_devicebased on this id through the bus.Co-developed-by Kiran Patil <[email protected]>Signed-off-by Kiran Patil <[email protected]>Co-developed-by Ranjani Sridharan <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Co-developed-by Fred Oh <[email protected]>Signed-off-by Fred Oh <[email protected]>Co-developed-by Leon Romanovsky <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>Reviewed-by Shiraz Saleem <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Dave Ertman <[email protected]>Quoted 1 line
---
Is this really the "latest" version of this patch submission?
Quoted 7 lines
I see a number of comments on it already, have you sent out a newer one, or is this the same one that the mlx5 driver conversion was done on top of?
thanks,
greg k-h
V3 is the latest sent so far. There was a suggestion that v3 might be merged and the documentation changes could be in a follow up patch. I have those changes done and ready though, so no reason not to merge them in and do a resend.
Please expect v4 in just a little while.
Thanks,
-DaveE
Greg KH
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
Quoted 46 lines · David M
Quoted 46 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Friday, November 13, 2020 7:50 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Saleem, Shiraz <[email protected]>; Williams, Dan J <[email protected]>; Patil, Kiran <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportQuoted 21 lines · Dave Ertman
Add support for the Auxiliary Bus,
auxiliary_deviceandauxiliary_driver. It enables drivers to create anauxiliary_deviceand bind anauxiliary_driverto it.The bus supports probe/remove shutdown and suspend/resume callbacks. Each
auxiliary_devicehas a unique string based id; driver binds to anauxiliary_devicebased on this id through the bus.Co-developed-by Kiran Patil <[email protected]>Signed-off-by Kiran Patil <[email protected]>Co-developed-by Ranjani Sridharan <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Co-developed-by Fred Oh <[email protected]>Signed-off-by Fred Oh <[email protected]>Co-developed-by Leon Romanovsky <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>Reviewed-by Shiraz Saleem <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Dave Ertman <[email protected]>Quoted 1 line
---
Is this really the "latest" version of this patch submission?
I see a number of comments on it already, have you sent out a newer one, or is this the same one that the mlx5 driver conversion was done on top of?
thanks,
Quoted 7 lines
Quoted 1 line
greg k-h
V3 is the latest sent so far. There was a suggestion that v3 might be merged and the documentation changes could be in a follow up patch. I have those changes done and ready though, so no reason not to merge them in and do a resend.
Please expect v4 in just a little while.
Thank you, follow-up patches aren't usually a good idea :)
Leon Romanovsky
maintainerRe: [PATCH v3 01/10] Add auxiliary bus support
Quoted 49 lines · Greg KH
Quoted 48 lines · David M
Quoted 47 lines
-----Original Message-----
From: Greg KH <[email protected]>
Sent: Friday, November 13, 2020 7:50 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Saleem, Shiraz <[email protected]>; Williams, Dan J <[email protected]>; Patil, Kiran <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v3 01/10] Add auxiliary bus supportQuoted 21 lines · Dave Ertman
Add support for the Auxiliary Bus,
auxiliary_deviceandauxiliary_driver. It enables drivers to create anauxiliary_deviceand bind anauxiliary_driverto it.The bus supports probe/remove shutdown and suspend/resume callbacks. Each
auxiliary_devicehas a unique string based id; driver binds to anauxiliary_devicebased on this id through the bus.Co-developed-by Kiran Patil <[email protected]>Signed-off-by Kiran Patil <[email protected]>Co-developed-by Ranjani Sridharan <[email protected]>Signed-off-by Ranjani Sridharan <[email protected]>Co-developed-by Fred Oh <[email protected]>Signed-off-by Fred Oh <[email protected]>Co-developed-by Leon Romanovsky <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Pierre-Louis Bossart <[email protected]>Reviewed-by Shiraz Saleem <[email protected]>Reviewed-by Parav Pandit <[email protected]>Reviewed-by Dan Williams <[email protected]>Signed-off-by Dave Ertman <[email protected]>Quoted 1 line
---
Is this really the "latest" version of this patch submission?
I see a number of comments on it already, have you sent out a newer one, or is this the same one that the mlx5 driver conversion was done on top of?
thanks,
greg k-h
Quoted 7 lines
Quoted 5 lines
V3 is the latest sent so far. There was a suggestion that v3 might be merged and the documentation changes could be in a follow up patch. I have those changes done and ready though, so no reason not to merge them in and do a resend.
Please expect v4 in just a little while.
Thank you, follow-up patches aren't usually a good idea :)
The changes were in documentation area that will be changed anyway after dust will settle and we all see real users and more or less stable in-kernel API.
Thanks
Dave Ertman
reviewerPATCH v3 2/10 ASoC: SOF: Introduce descriptors for SOF client
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
A client in the SOF (Sound Open Firmware) context is a device that needs to communicate with the DSP via IPC messages. The SOF core is responsible for serializing the IPC messages to the DSP from the different clients. One example of an SOF client would be an IPC test client that floods the DSP with test IPC messages to validate if the serialization works as expected. Multi-client support will also add the ability to split the existing audio cards into multiple ones, so as to e.g. to deal with HDMI with a dedicated client instead of adding HDMI to all cards.
This patch introduces descriptors for SOF client driver and SOF client device along with APIs for registering and unregistering a SOF client driver, sending IPCs from a client device and accessing the SOF core debugfs root entry.
Along with this, add a couple of new members to struct snd_sof_dev that will be used for maintaining the list of clients.
--- sound/soc/sof/Kconfig | 19 ++++++ sound/soc/sof/Makefile | 3 + sound/soc/sof/core.c | 2 + sound/soc/sof/sof-client.c | 115 +++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-client.h | 66 +++++++++++++++++++++ sound/soc/sof/sof-priv.h | 9 +++ 6 files changed, 214 insertions(+) create mode 100644 sound/soc/sof/sof-client.c create mode 100644 sound/soc/sof/sof-client.h
sound/soc/sof/Kconfig +19 -0
@@ -50,6 +50,24 @@ config SND_SOC_SOF_DEBUG_PROBES Say Y if you want to enable probes. If unsure, select "N". +config SND_SOC_SOF_CLIENT + tristate + select AUXILIARY_BUS + help + This option is not user-selectable but automagically handled by + 'select' statements at a higher level. + +config SND_SOC_SOF_CLIENT_SUPPORT + bool "SOF enable clients" + depends on SND_SOC_SOF + help + This adds support for auxiliary client devices to separate out the debug + functionality for IPC tests, probes etc. into separate devices. This + option would also allow adding client devices based on DSP firmware + capabilities and ACPI/OF device information. + Say Y if you want to enable clients with SOF. + If unsure select "N". + config SND_SOC_SOF_DEVELOPER_SUPPORT bool "SOF developer options support" depends on EXPERT
@@ -186,6 +204,7 @@ endif ## SND_SOC_SOF_DEVELOPER_SUPPORT config SND_SOC_SOF tristate + select SND_SOC_SOF_CLIENT if SND_SOC_SOF_CLIENT_SUPPORT select SND_SOC_TOPOLOGY select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_SUPPORT help
sound/soc/sof/Makefile +3 -0
@@ -2,6 +2,7 @@ snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ control.o trace.o utils.o sof-audio.o +snd-sof-client-objs := sof-client.o snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += probe.o compress.o snd-sof-pci-objs := sof-pci-dev.o
@@ -18,6 +19,8 @@ obj-$(CONFIG_SND_SOC_SOF_ACPI) += snd-sof-acpi.o obj-$(CONFIG_SND_SOC_SOF_OF) += snd-sof-of.o obj-$(CONFIG_SND_SOC_SOF_PCI) += snd-sof-pci.o +obj-$(CONFIG_SND_SOC_SOF_CLIENT) += snd-sof-client.o + obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/ obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/ obj-$(CONFIG_SND_SOC_SOF_XTENSA) += xtensa/
sound/soc/sof/core.c +2 -0
@@ -314,8 +314,10 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)INIT_LIST_HEAD (&sdev->widget_list);INIT_LIST_HEAD (&sdev->dai_list);INIT_LIST_HEAD (&sdev->route_list); +INIT_LIST_HEAD (&sdev->client_list);spin_lock_init (&sdev->ipc_lock);spin_lock_init (&sdev->hw_lock); +mutex_init (&sdev->client_mutex);if (IS_ENABLED (CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE ))INIT_WORK (&sdev->probe_work, sof_probe_work);
sound/soc/sof/sof-client.c new file +115 -0
115 lines not on this page · raw message
sound/soc/sof/sof-client.h new file +66 -0
66 lines not on this page · raw message
sound/soc/sof/sof-priv.h +9 -0
@@ -442,6 +442,15 @@ struct snd_sof_dev {bool msi_enabled; +/* +* Used to keep track of registered client devices so that they can be removed when the +* parent SOF module is removed. +*/ +struct list_head client_list; + +/* mutex to protect client list */ +struct mutex client_mutex; +void *private;/* core does not touch this */ };
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 3/10 ASoC: SOF: Create client driver for IPC test
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Create an SOF client driver for IPC flood test. This driver is used to set up the debugfs entries and the read/write ops for initiating the IPC flood test that would be used to measure the min/max/avg response times for sending IPCs to the DSP. The debugfs ops definitions in the driver is existing code that has been copied from the core. These will be removed from the SOF core making is less monolithic and easier to maintain.
--- sound/soc/sof/Kconfig | 10 + sound/soc/sof/Makefile | 4 + sound/soc/sof/sof-ipc-test-client.c | 321 ++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+) create mode 100644 sound/soc/sof/sof-ipc-test-client.c
sound/soc/sof/Kconfig +10 -0
@@ -190,6 +190,16 @@ config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST Say Y if you want to enable IPC flood test. If unsure, select "N". +config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT + tristate "SOF enable IPC flood test client" + depends on SND_SOC_SOF_CLIENT + help + This option enables a separate client device for IPC flood test + which can be used to flood the DSP with test IPCs and gather stats + about response times. + Say Y if you want to enable IPC flood test. + If unsure, select "N". + config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT bool "SOF retain DSP context on any FW exceptions" help
sound/soc/sof/Makefile +4 -0
@@ -9,6 +9,8 @@ snd-sof-pci-objs := sof-pci-dev.o snd-sof-acpi-objs := sof-acpi-dev.o snd-sof-of-objs := sof-of-dev.o +snd-sof-ipc-test-objs := sof-ipc-test-client.o + snd-sof-nocodec-objs := nocodec.o obj-$(CONFIG_SND_SOC_SOF) += snd-sof.o
@@ -21,6 +23,8 @@ obj-$(CONFIG_SND_SOC_SOF_PCI) += snd-sof-pci.o obj-$(CONFIG_SND_SOC_SOF_CLIENT) += snd-sof-client.o +obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) += snd-sof-ipc-test.o + obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/ obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/ obj-$(CONFIG_SND_SOC_SOF_XTENSA) += xtensa/
sound/soc/sof/sof-ipc-test-client.c new file +321 -0
321 lines not on this page · raw message
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 4/10 ASoC: SOF: ops: Add ops for client registration
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Add new ops for registering/unregistering clients based on DSP capabilities and/or DT information.
--- sound/soc/sof/core.c | 10 ++++++++++ sound/soc/sof/ops.h | 14 ++++++++++++++ sound/soc/sof/sof-priv.h | 4 ++++ 3 files changed, 28 insertions(+)
sound/soc/sof/core.c +10 -0
@@ -246,8 +246,17 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)if (plat_data->sof_probe_complete) plat_data->sof_probe_complete (sdev->dev); +/* If registering certain clients fails, unregister the previously registered clients. */ + ret =snd_sof_register_clients (sdev); +if (ret <0 ) { +dev_err (sdev->dev,"error: failed to register clients %d\n" , ret); + goto client_reg_err; + } +return 0 ; +client_reg_err: +snd_sof_unregister_clients (sdev); fw_trace_err:snd_sof_free_trace (sdev); fw_run_err:
@@ -356,6 +365,7 @@ int snd_sof_device_remove(struct device *dev)dev_warn (dev,"error: %d failed to prepare DSP for device removal" , ret); +snd_sof_unregister_clients (sdev);snd_sof_fw_unload (sdev);snd_sof_ipc_free (sdev);snd_sof_free_debug (sdev);
sound/soc/sof/ops.h +14 -0
@@ -470,6 +470,20 @@ snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach,sof_ops (sdev)->set_mach_params (mach, dev); } +static inline int snd_sof_register_clients (struct snd_sof_dev *sdev) +{ +if (sof_ops (sdev) &&sof_ops (sdev)->register_clients) +return sof_ops (sdev)->register_clients (sdev); + +return 0 ; +} + +static inline void snd_sof_unregister_clients (struct snd_sof_dev *sdev) +{ +if (sof_ops (sdev) &&sof_ops (sdev)->unregister_clients) +sof_ops (sdev)->unregister_clients (sdev); +} +static inline const struct snd_sof_dsp_ops *sof_get_ops (const struct sof_dev_desc *d,const struct sof_ops_table mach_ops[],int asize)
sound/soc/sof/sof-priv.h +4 -0
@@ -252,6 +252,10 @@ struct snd_sof_dsp_ops {void (*set_mach_params)(const struct snd_soc_acpi_mach *mach,struct device *dev);/* optional */ +/* client ops */ +int (*register_clients)(struct snd_sof_dev *sdev);/* optional */ +void (*unregister_clients)(struct snd_sof_dev *sdev);/* optional */ +/* DAI ops */ struct snd_soc_dai_driver *drv;int num_drv;
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 5/10 ASoC: SOF: Intel: Define ops for client registration
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Define client ops for Intel platforms. For now, we only add 2 IPC test clients that will be used for run tandem IPC flood tests for.
For ACPI platforms, change the Kconfig to select SND_SOC_SOF_PROBE_WORK_QUEUE to allow the ancillary driver to probe when the client is registered.
--- sound/soc/sof/intel/Kconfig | 9 +++++++ sound/soc/sof/intel/Makefile | 3 +++ sound/soc/sof/intel/apl.c | 16 ++++++++++++ sound/soc/sof/intel/bdw.c | 16 ++++++++++++ sound/soc/sof/intel/byt.c | 20 +++++++++++++++ sound/soc/sof/intel/cnl.c | 16 ++++++++++++ sound/soc/sof/intel/intel-client.c | 40 ++++++++++++++++++++++++++++++ sound/soc/sof/intel/intel-client.h | 26 +++++++++++++++++++ 8 files changed, 146 insertions(+) create mode 100644 sound/soc/sof/intel/intel-client.c create mode 100644 sound/soc/sof/intel/intel-client.h
sound/soc/sof/intel/Kconfig +9 -0
@@ -13,6 +13,8 @@ config SND_SOC_SOF_INTEL_ACPI def_tristate SND_SOC_SOF_ACPI select SND_SOC_SOF_BAYTRAIL if SND_SOC_SOF_BAYTRAIL_SUPPORT select SND_SOC_SOF_BROADWELL if SND_SOC_SOF_BROADWELL_SUPPORT + select SND_SOC_SOF_PROBE_WORK_QUEUE if SND_SOC_SOF_CLIENT + select SND_SOC_SOF_INTEL_CLIENT if SND_SOC_SOF_CLIENT help This option is not user-selectable but automagically handled by 'select' statements at a higher level
@@ -29,6 +31,7 @@ config SND_SOC_SOF_INTEL_PCI select SND_SOC_SOF_TIGERLAKE if SND_SOC_SOF_TIGERLAKE_SUPPORT select SND_SOC_SOF_ELKHARTLAKE if SND_SOC_SOF_ELKHARTLAKE_SUPPORT select SND_SOC_SOF_JASPERLAKE if SND_SOC_SOF_JASPERLAKE_SUPPORT + select SND_SOC_SOF_INTEL_CLIENT if SND_SOC_SOF_CLIENT help This option is not user-selectable but automagically handled by 'select' statements at a higher level
@@ -57,6 +60,12 @@ config SND_SOC_SOF_INTEL_COMMON This option is not user-selectable but automagically handled by 'select' statements at a higher level +config SND_SOC_SOF_INTEL_CLIENT + tristate + help + This option is not user-selectable but automagically handled by + 'select' statements at a higher level. + if SND_SOC_SOF_INTEL_ACPI config SND_SOC_SOF_BAYTRAIL_SUPPORT
sound/soc/sof/intel/Makefile +3 -0
@@ -5,6 +5,8 @@ snd-sof-intel-bdw-objs := bdw.o snd-sof-intel-ipc-objs := intel-ipc.o +snd-sof-intel-client-objs := intel-client.o + snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \ hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \ hda-dai.o hda-bus.o \
@@ -18,3 +20,4 @@ obj-$(CONFIG_SND_SOC_SOF_BROADWELL) += snd-sof-intel-bdw.o obj-$(CONFIG_SND_SOC_SOF_INTEL_HIFI_EP_IPC) += snd-sof-intel-ipc.o obj-$(CONFIG_SND_SOC_SOF_HDA_COMMON) += snd-sof-intel-hda-common.o obj-$(CONFIG_SND_SOC_SOF_HDA) += snd-sof-intel-hda.o +obj-$(CONFIG_SND_SOC_SOF_INTEL_CLIENT) += snd-sof-intel-client.o
sound/soc/sof/intel/apl.c +16 -0
@@ -18,6 +18,7 @@#include "../sof-priv.h" #include "hda.h" #include "../sof-audio.h" +#include "intel-client.h" static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = { {"hda" ,HDA_DSP_HDA_BAR ,0 ,0x4000 ,SOF_DEBUGFS_ACCESS_ALWAYS },
@@ -25,6 +26,16 @@ static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = { {"dsp", HDA_DSP_BAR, 0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS}, }; +static int apl_register_clients (struct snd_sof_dev *sdev) +{ +return intel_register_ipc_test_clients (sdev); +} + +static void apl_unregister_clients (struct snd_sof_dev *sdev) +{ +intel_unregister_ipc_test_clients (sdev); +} +/* apollolake ops */ const struct snd_sof_dsp_ops sof_apl_ops = { /* probe and remove */
@@ -101,6 +112,10 @@ const struct snd_sof_dsp_ops sof_apl_ops = { .trace_release = hda_dsp_trace_release, .trace_trigger = hda_dsp_trace_trigger, +/* client ops */ + .register_clients = apl_register_clients, + .unregister_clients = apl_unregister_clients, +/* DAI drivers */ .drv = skl_dai, .num_drv = SOF_SKL_NUM_DAIS,
@@ -140,3 +155,4 @@ const struct sof_intel_dsp_desc apl_chip_info = { .ssp_base_offset = APL_SSP_BASE_OFFSET, };EXPORT_SYMBOL_NS (apl_chip_info,SND_SOC_SOF_INTEL_HDA_COMMON ); +MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_CLIENT );
sound/soc/sof/intel/bdw.c +16 -0
@@ -18,6 +18,7 @@#include "../ops.h" #include "shim.h" #include "../sof-audio.h" +#include "intel-client.h" /* BARs */ #define BDW_DSP_BAR 0
@@ -563,6 +564,16 @@ static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach, mach_params->platform =dev_name (dev); } +static int bdw_register_clients (struct snd_sof_dev *sdev) +{ +return intel_register_ipc_test_clients (sdev); +} + +static void bdw_unregister_clients (struct snd_sof_dev *sdev) +{ +intel_unregister_ipc_test_clients (sdev); +} +/* Broadwell DAIs */ static struct snd_soc_dai_driver bdw_dai[] = { {
@@ -638,6 +649,10 @@ const struct snd_sof_dsp_ops sof_bdw_ops = {/*Firmware loading */ .load_firmware = snd_sof_load_firmware_memcpy, +/* client ops */ + .register_clients = bdw_register_clients, + .unregister_clients = bdw_unregister_clients, +/* DAI drivers */ .drv = bdw_dai, .num_drv = ARRAY_SIZE(bdw_dai),
@@ -662,3 +677,4 @@ EXPORT_SYMBOL_NS(bdw_chip_info, SND_SOC_SOF_BROADWELL);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_HIFI_EP_IPC );MODULE_IMPORT_NS (SND_SOC_SOF_XTENSA ); +MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_CLIENT );
sound/soc/sof/intel/byt.c +20 -0
@@ -19,6 +19,7 @@#include "shim.h" #include "../sof-audio.h" #include "../../intel/common/soc-intel-quirks.h" +#include "intel-client.h" /* DSP memories */ #define IRAM_OFFSET 0x0C0000
@@ -821,6 +822,16 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev)return ret; } +static int byt_register_clients (struct snd_sof_dev *sdev) +{ +return intel_register_ipc_test_clients (sdev); +} + +static void byt_unregister_clients (struct snd_sof_dev *sdev) +{ +intel_unregister_ipc_test_clients (sdev); +} +/* baytrail ops */ const struct snd_sof_dsp_ops sof_byt_ops = {/* device init */
@@ -879,6 +890,10 @@ const struct snd_sof_dsp_ops sof_byt_ops = { .suspend = byt_suspend, .resume = byt_resume, +/* client ops */ + .register_clients = byt_register_clients, + .unregister_clients = byt_unregister_clients, +/* DAI drivers */ .drv = byt_dai, .num_drv = 3, /* we have only 3 SSPs on byt*/
@@ -958,6 +973,10 @@ const struct snd_sof_dsp_ops sof_cht_ops = { .suspend = byt_suspend, .resume = byt_resume, +/* client ops */ + .register_clients = byt_register_clients, + .unregister_clients = byt_unregister_clients, +/* DAI drivers */ .drv = byt_dai,/* all 6 SSPs may be available for cherrytrail */
@@ -985,3 +1004,4 @@ EXPORT_SYMBOL_NS(cht_chip_info, SND_SOC_SOF_BAYTRAIL);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_HIFI_EP_IPC );MODULE_IMPORT_NS (SND_SOC_SOF_XTENSA ); +MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_CLIENT );
sound/soc/sof/intel/cnl.c +16 -0
@@ -19,6 +19,7 @@#include "hda.h" #include "hda-ipc.h" #include "../sof-audio.h" +#include "intel-client.h" static const struct snd_sof_debugfs_map cnl_dsp_debugfs[] = { {"hda" ,HDA_DSP_HDA_BAR ,0 ,0x4000 ,SOF_DEBUGFS_ACCESS_ALWAYS },
@@ -230,6 +231,16 @@ void cnl_ipc_dump(struct snd_sof_dev *sdev) hipcida, hipctdr, hipcctl); } +static int cnl_register_clients (struct snd_sof_dev *sdev) +{ +return intel_register_ipc_test_clients (sdev); +} + +static void cnl_unregister_clients (struct snd_sof_dev *sdev) +{ +intel_unregister_ipc_test_clients (sdev); +} +/* cannonlake ops */ const struct snd_sof_dsp_ops sof_cnl_ops = {/* probe and remove */
@@ -306,6 +317,10 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { .trace_release = hda_dsp_trace_release, .trace_trigger = hda_dsp_trace_trigger, +/* client ops */ + .register_clients = cnl_register_clients, + .unregister_clients = cnl_unregister_clients, +/* DAI drivers */ .drv = skl_dai, .num_drv = SOF_SKL_NUM_DAIS,
@@ -393,3 +408,4 @@ const struct sof_intel_dsp_desc jsl_chip_info = { .ssp_base_offset = CNL_SSP_BASE_OFFSET, };EXPORT_SYMBOL_NS (jsl_chip_info,SND_SOC_SOF_INTEL_HDA_COMMON ); +MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_CLIENT );
sound/soc/sof/intel/intel-client.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2020 Intel Corporation. All rights reserved. +// +// Author: Ranjani Sridharan <[email protected]> +// + +#include <linux/module.h> +#include "../sof-priv.h" +#include "../sof-client.h" +#include "intel-client.h" + +#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT ) +int intel_register_ipc_test_clients (struct snd_sof_dev *sdev) +{ +int ret; + +/* +* Register 2 IPC clients to facilitate tandem flood test. The device name below is +* appended with the device ID assigned automatically when the auxiliary device is +* registered making them unique. +*/ + ret =sof_client_dev_register (sdev,"ipc_test" ,0 ); +if (ret <0 ) +return ret; + +return sof_client_dev_register (sdev,"ipc_test" ,1 ); +} +EXPORT_SYMBOL_NS_GPL (intel_register_ipc_test_clients,SND_SOC_SOF_INTEL_CLIENT ); + +void intel_unregister_ipc_test_clients (struct snd_sof_dev *sdev) +{ +sof_client_dev_unregister (sdev,"ipc_test" ,0 ); +sof_client_dev_unregister (sdev,"ipc_test" ,1 ); +} +EXPORT_SYMBOL_NS_GPL (intel_unregister_ipc_test_clients,SND_SOC_SOF_INTEL_CLIENT ); +#endif + +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS (SND_SOC_SOF_CLIENT );
sound/soc/sof/intel/intel-client.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* Copyright(c) 2020 Intel Corporation. All rights reserved. +* +* Author: Ranjani Sridharan <[email protected]> +*/ + +#ifndef __INTEL_CLIENT_H +#define __INTEL_CLIENT_H + +#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT ) +int intel_register_ipc_test_clients (struct snd_sof_dev *sdev); +void intel_unregister_ipc_test_clients (struct snd_sof_dev *sdev); +#else +static inline int intel_register_ipc_test_clients (struct snd_sof_dev *sdev) +{ +return 0 ; +} + +static void intel_unregister_ipc_test_clients (struct snd_sof_dev *sdev) {} +#endif + +#endif
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 6/10 ASoC: SOF: Intel: Remove IPC flood test support in SOF core
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Remove the IPC flood test support in the SOF core as it is now added in the IPC flood test client.
--- sound/soc/sof/Kconfig | 8 -- sound/soc/sof/debug.c | 230 --------------------------------------- sound/soc/sof/sof-priv.h | 6 +- 3 files changed, 1 insertion(+), 243 deletions(-)
sound/soc/sof/Kconfig +0 -8
@@ -182,14 +182,6 @@ config SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE module parameter (similar to dynamic debug) If unsure, select "N". -config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST - bool "SOF enable IPC flood test" - help - This option enables the IPC flood test which can be used to flood - the DSP with test IPCs and gather stats about response times. - Say Y if you want to enable IPC flood test. - If unsure, select "N". - config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT tristate "SOF enable IPC flood test client" depends on SND_SOC_SOF_CLIENT
sound/soc/sof/debug.c +0 -230
264 lines not on this page · raw message
sound/soc/sof/sof-priv.h +1 -5
@@ -50,10 +50,6 @@ extern int sof_core_debug;#define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT) -#define ENABLE_DEBUGFS_CACHEBUF \ - (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \ - IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST)) -/* So far the primary core on all DSPs has ID 0 */ #define SOF_DSP_PRIMARY_CORE 0
@@ -301,7 +297,7 @@ struct snd_sof_dfsentry {* or if it is accessible only when the DSP is in D0. */ enum sof_debugfs_access_type access_type; -#if ENABLE_DEBUGFS_CACHEBUF +#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE )char *cache_buf;/* buffer to cache the contents of debugfs memory */ #endif struct snd_sof_dev *sdev;
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 7/10 ASoC: SOF: sof-client: Add client APIs to access probes ops
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Add client APIs to invoke the platform-specific DSP probes ops. Also, add a new API to get the SOF core device pointer which will be used for DMA buffer allocation.
--- sound/soc/sof/sof-client.c | 55 ++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-client.h | 25 +++++++++++++++++ 2 files changed, 80 insertions(+)
sound/soc/sof/sof-client.c +55 -0
@@ -11,6 +11,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/slab.h> +#include "ops.h" #include "sof-client.h" #include "sof-priv.h"
@@ -112,4 +113,58 @@ struct dentry *sof_client_get_debugfs_root(struct sof_client_dev *cdev) }EXPORT_SYMBOL_NS_GPL (sof_client_get_debugfs_root,SND_SOC_SOF_CLIENT ); +#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES_CLIENT ) +int sof_client_probe_compr_assign (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_soc_dai *dai) +{ +return snd_sof_probe_compr_assign (cdev->sdev, cstream, dai); +} +EXPORT_SYMBOL_NS_GPL (sof_client_probe_compr_assign,SND_SOC_SOF_CLIENT ); + +int sof_client_probe_compr_free (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_soc_dai *dai) +{ +return snd_sof_probe_compr_free (cdev->sdev, cstream, dai); +} +EXPORT_SYMBOL_NS_GPL (sof_client_probe_compr_free,SND_SOC_SOF_CLIENT ); + +int sof_client_probe_compr_set_params (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_compr_params *params, +struct snd_soc_dai *dai) +{ +return snd_sof_probe_compr_set_params (cdev->sdev, cstream, params, dai); +} +EXPORT_SYMBOL_NS_GPL (sof_client_probe_compr_set_params,SND_SOC_SOF_CLIENT ); + +int sof_client_probe_compr_trigger (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream,int cmd, +struct snd_soc_dai *dai) +{ +return snd_sof_probe_compr_trigger (cdev->sdev, cstream, cmd, dai); +} +EXPORT_SYMBOL_NS_GPL (sof_client_probe_compr_trigger,SND_SOC_SOF_CLIENT ); + +int sof_client_probe_compr_pointer (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_compr_tstamp *tstamp, +struct snd_soc_dai *dai) +{ +return snd_sof_probe_compr_pointer (cdev->sdev, cstream, tstamp, dai); +} +EXPORT_SYMBOL_NS_GPL (sof_client_probe_compr_pointer,SND_SOC_SOF_CLIENT ); +#endif + +/* +* DMA buffer alloc fails when using the client device. Use the SOF core device instead. +* This will be needed for clients other than the probes client device as well. +*/ +struct device *sof_client_get_dma_dev (struct sof_client_dev *cdev) +{ +return cdev->sdev->dev; +} +EXPORT_SYMBOL_NS_GPL (sof_client_get_dma_dev,SND_SOC_SOF_CLIENT ); +MODULE_LICENSE ("GPL" );
sound/soc/sof/sof-client.h +25 -0
@@ -7,6 +7,10 @@#include <linux/device.h> #include <linux/idr.h> #include <linux/list.h> +#include <sound/compress_offload.h> +#include <sound/compress_driver.h> +#include <sound/soc.h> +#include <sound/soc-dai.h> #define SOF_CLIENT_PROBE_TIMEOUT_MS 2000
@@ -50,6 +54,27 @@ int sof_client_ipc_tx_message(struct sof_client_dev *cdev, u32 header, void *msg size_t msg_bytes, void *reply_data, size_t reply_bytes);struct dentry *sof_client_get_debugfs_root (struct sof_client_dev *cdev); +struct device *sof_client_get_dma_dev (struct sof_client_dev *cdev); + +#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES_CLIENT ) +int sof_client_probe_compr_assign (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_soc_dai *dai); +int sof_client_probe_compr_free (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_soc_dai *dai); +int sof_client_probe_compr_set_params (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_compr_params *params, +struct snd_soc_dai *dai); +int sof_client_probe_compr_trigger (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream,int cmd, +struct snd_soc_dai *dai); +int sof_client_probe_compr_pointer (struct sof_client_dev *cdev, +struct snd_compr_stream *cstream, +struct snd_compr_tstamp *tstamp, +struct snd_soc_dai *dai); +#endif /** * module_sof_client_driver() - Helper macro for registering an SOF Client
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 8/10 ASoC: SOF: compress: move and export sof_probe_compr_ops
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
sof_probe_compr_ops are not platform-specific. So move it to common compress code and export the symbol. The compilation of the common compress code is already dependent on the selection of CONFIG_SND_SOC_SOF_DEBUG_PROBES, so no need to check the Kconfig section for defining sof_probe_compr_ops again.
--- sound/soc/sof/compress.c | 9 +++++++++ sound/soc/sof/compress.h | 1 + sound/soc/sof/intel/hda-dai.c | 12 ------------ 3 files changed, 10 insertions(+), 12 deletions(-)
sound/soc/sof/compress.c +9 -0
@@ -13,6 +13,15 @@#include "ops.h" #include "probe.h" +struct snd_soc_cdai_ops sof_probe_compr_ops = { + .startup = sof_probe_compr_open, + .shutdown = sof_probe_compr_free, + .set_params = sof_probe_compr_set_params, + .trigger = sof_probe_compr_trigger, + .pointer = sof_probe_compr_pointer, +}; +EXPORT_SYMBOL (sof_probe_compr_ops); +struct snd_compress_ops sof_probe_compressed_ops = { .copy = sof_probe_compr_copy, };
sound/soc/sof/compress.h +1 -0
@@ -13,6 +13,7 @@#include <sound/compress_driver.h> +extern struct snd_soc_cdai_ops sof_probe_compr_ops;extern struct snd_compress_ops sof_probe_compressed_ops; int sof_probe_compr_open(struct snd_compr_stream *cstream,
sound/soc/sof/intel/hda-dai.c +0 -12
@@ -400,18 +400,6 @@ static const struct snd_soc_dai_ops hda_link_dai_ops = { .prepare = hda_link_pcm_prepare, }; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_PROBES ) -#include "../compress.h" - -static struct snd_soc_cdai_ops sof_probe_compr_ops = { - .startup = sof_probe_compr_open, - .shutdown = sof_probe_compr_free, - .set_params = sof_probe_compr_set_params, - .trigger = sof_probe_compr_trigger, - .pointer = sof_probe_compr_pointer, -}; - -#endif #endif /*
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 9/10 ASoC: SOF: Add new client driver for probes support
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Add a new client driver for probes support and move all the probes-related code from the core to the client driver.
The probes client driver registers a component driver with one CPU DAI driver for extraction and creates a new sound card with one DUMMY DAI link with a dummy codec that will be used for extracting audio data from specific points in the audio pipeline.
The probes debugfs ops are based on the initial implementation by Cezary Rojewski and have been moved out of the SOF core into the client driver making it easier to maintain. This change will make it easier for the probes functionality to be added for all platforms without having the need to modify the existing(15+) machine drivers.
--- sound/soc/sof/Kconfig | 18 +- sound/soc/sof/Makefile | 3 +- sound/soc/sof/compress.c | 51 ++-- sound/soc/sof/core.c | 6 - sound/soc/sof/debug.c | 227 ---------------- sound/soc/sof/intel/hda-dai.c | 15 -- sound/soc/sof/intel/hda.h | 6 - sound/soc/sof/pcm.c | 11 - sound/soc/sof/probe.c | 124 ++++----- sound/soc/sof/probe.h | 41 +-- sound/soc/sof/sof-priv.h | 4 - sound/soc/sof/sof-probes-client.c | 414 ++++++++++++++++++++++++++++++ 12 files changed, 545 insertions(+), 375 deletions(-) create mode 100644 sound/soc/sof/sof-probes-client.c
sound/soc/sof/Kconfig +13 -5
@@ -42,13 +42,11 @@ config SND_SOC_SOF_OF Say Y if you need this option. If unsure select "N". config SND_SOC_SOF_DEBUG_PROBES - bool "SOF enable data probing" + bool select SND_SOC_COMPRESS help - This option enables the data probing feature that can be used to - gather data directly from specific points of the audio pipeline. - Say Y if you want to enable probes. - If unsure, select "N". + This option is not user-selectable but automagically handled by + 'select' statements at a higher level. config SND_SOC_SOF_CLIENT tristate
@@ -192,6 +190,15 @@ config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT Say Y if you want to enable IPC flood test. If unsure, select "N". +config SND_SOC_SOF_DEBUG_PROBES_CLIENT + tristate "SOF enable data probing" + depends on SND_SOC_SOF_CLIENT + help + This option enables the data probing feature that can be used to + gather data directly from specific points of the audio pipeline. + Say Y if you want to enable probes. + If unsure, select "N". + config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT bool "SOF retain DSP context on any FW exceptions" help
@@ -207,6 +214,7 @@ endif ## SND_SOC_SOF_DEVELOPER_SUPPORT config SND_SOC_SOF tristate select SND_SOC_SOF_CLIENT if SND_SOC_SOF_CLIENT_SUPPORT + select SND_SOC_SOF_DEBUG_PROBES if SND_SOC_SOF_DEBUG_PROBES_CLIENT select SND_SOC_TOPOLOGY select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_SUPPORT help
sound/soc/sof/Makefile +2 -1
@@ -3,7 +3,7 @@ snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ control.o trace.o utils.o sof-audio.o snd-sof-client-objs := sof-client.o -snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += probe.o compress.o +snd-sof-probes-objs := probe.o compress.o sof-probes-client.o snd-sof-pci-objs := sof-pci-dev.o snd-sof-acpi-objs := sof-acpi-dev.o
@@ -24,6 +24,7 @@ obj-$(CONFIG_SND_SOC_SOF_PCI) += snd-sof-pci.o obj-$(CONFIG_SND_SOC_SOF_CLIENT) += snd-sof-client.o obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_CLIENT) += snd-sof-ipc-test.o +obj-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES_CLIENT) += snd-sof-probes.o obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/ obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/
sound/soc/sof/compress.c +27 -24
127 lines not on this page · raw message
sound/soc/sof/core.c +0 -6
@@ -14,9 +14,6 @@#include <sound/sof.h> #include "sof-priv.h" #include "ops.h" -#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES ) -#include "probe.h" -#endif /* see SOF_DBG_ flags */ int sof_core_debug;
@@ -305,9 +302,6 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) sdev->pdata = plat_data; sdev->first_boot = true; sdev->fw_state =SOF_FW_BOOT_NOT_STARTED ; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES ) - sdev->extractor_stream_tag =SOF_PROBE_INVALID_NODE_ID ; -#endif dev_set_drvdata (dev, sdev);/* check all mandatory ops */
sound/soc/sof/debug.c +0 -227
239 lines not on this page · raw message
sound/soc/sof/intel/hda-dai.c +0 -15
@@ -557,20 +557,5 @@ struct snd_soc_dai_driver skl_dai[] = { .channels_max = 16, }, }, -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES) -{ - .name = "Probe Extraction CPU DAI", - .compress_new = snd_soc_new_compress, - .cops = &sof_probe_compr_ops, - .capture = { - .stream_name = "Probe Extraction", - .channels_min = 1, - .channels_max = 8, - .rates = SNDRV_PCM_RATE_48000, - .rate_min = 48000, - .rate_max = 48000, - }, -}, -#endif#endif };
sound/soc/sof/intel/hda.h +0 -6
@@ -352,13 +352,7 @@/* Number of DAIs */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) - -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_PROBES ) -#define SOF_SKL_NUM_DAIS 16 -#else #define SOF_SKL_NUM_DAIS 15 -#endif -#else #define SOF_SKL_NUM_DAIS 8#endif
sound/soc/sof/pcm.c +0 -11
@@ -16,9 +16,6 @@#include "sof-priv.h" #include "sof-audio.h" #include "ops.h" -#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES ) -#include "compress.h" -#endif /* Create DMA buffer page table for DSP */ static int create_page_table(struct snd_soc_component *component,
@@ -801,14 +798,6 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev) pd->hw_free = sof_pcm_hw_free; pd->trigger = sof_pcm_trigger; pd->pointer = sof_pcm_pointer; - -#if IS_ENABLED (CONFIG_SND_SOC_SOF_COMPRESS ) - pd->compress_ops = &sof_compressed_ops; -#endif -#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES ) -/* override cops when probe support is enabled */ - pd->compress_ops = &sof_probe_compressed_ops; -#endif pd->pcm_construct = sof_pcm_new; pd->ignore_machine = drv_name; pd->be_hw_params_fixup = sof_pcm_dai_link_fixup;
sound/soc/sof/probe.c +65 -59
259 lines not on this page · raw message
sound/soc/sof/probe.h +24 -17
52 lines not on this page · raw message
sound/soc/sof/sof-priv.h +0 -4
@@ -425,10 +425,6 @@ struct snd_sof_dev {int ipc_timeout;int boot_timeout; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_PROBES ) -unsigned int extractor_stream_tag; -#endif -/* DMA for Trace */ struct snd_dma_buffer dmatb;struct snd_dma_buffer dmatp;
sound/soc/sof/sof-probes-client.c new file +414 -0
414 lines not on this page · raw message
Signature · 1 line
2.26.2
Dave Ertman
reviewerPATCH v3 10/10 ASoC: SOF: Intel: CNL: register probes client
In reply to Dave ErtmanFrom: Ranjani Sridharan <[email protected]>
Register the client device for probes support on the CNL platform. Creating this client device alleviates the need for modifying the sound card definitions in the existing machine drivers to add support for the new probes feature in the FW. This will result in the creation of a separate sound card that can be used for audio data extraction from user specified points in the audio pipeline.
--- sound/soc/sof/intel/cnl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
sound/soc/sof/intel/cnl.c +17 -1
@@ -19,6 +19,7 @@#include "hda.h" #include "hda-ipc.h" #include "../sof-audio.h" +#include "../sof-client.h" #include "intel-client.h" static const struct snd_sof_debugfs_map cnl_dsp_debugfs[] = {
@@ -233,12 +234,26 @@ void cnl_ipc_dump(struct snd_sof_dev *sdev)static int cnl_register_clients (struct snd_sof_dev *sdev) { -return intel_register_ipc_test_clients (sdev); +int ret; + + ret =intel_register_ipc_test_clients (sdev); +if (ret <0 ) +return ret; + +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_PROBES ) +return sof_client_dev_register (sdev,"probes" ,0 ); +#endif + +return 0 ; }static void cnl_unregister_clients (struct snd_sof_dev *sdev) {intel_unregister_ipc_test_clients (sdev); + +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_PROBES ) +sof_client_dev_unregister (sdev,"probes" ,0 ); +#endif }/* cannonlake ops */
@@ -409,3 +424,4 @@ const struct sof_intel_dsp_desc jsl_chip_info = { };EXPORT_SYMBOL_NS (jsl_chip_info,SND_SOC_SOF_INTEL_HDA_COMMON );MODULE_IMPORT_NS (SND_SOC_SOF_INTEL_CLIENT ); +MODULE_IMPORT_NS (SND_SOC_SOF_CLIENT );
Signature · 1 line
2.26.2
Leon Romanovsky
maintainerOn Thu, Oct 22, 2020 at 05:33:28PM -0700, Dave Ertman wrote:
<...>
Quoted 2 lines
Dave Ertman (1):
Add auxiliary bus support
We are in merge window now and both netdev and RDMA are closed for submissions. So I'll send my mlx5 conversion patches once -rc1 will be tagged.
However, It is important that this "auxiliary bus" patch will be applied to some topic branch based on Linus's -rcX. It will give us an ability to pull this patch to RDMA, VDPA and netdev subsystems at the same time.
Thanks
Greg KH
maintainerQuoted 7 lines · Leon Romanovsky
On Thu, Oct 22, 2020 at 05:33:28PM -0700, Dave Ertman wrote:
<...>
Quoted 2 lines
Dave Ertman (1):
Add auxiliary bus support
Quoted 7 lines
We are in merge window now and both netdev and RDMA are closed for submissions. So I'll send my mlx5 conversion patches once -rc1 will be tagged.
However, It is important that this "auxiliary bus" patch will be applied to some topic branch based on Linus's -rcX. It will give us an ability to pull this patch to RDMA, VDPA and netdev subsystems at the same time.
I will do that, but as you said, it's the middle of the merge window and I can't do anything until after -rc1 is out. Give us some time to catch up after that...
greg k-h
Leon Romanovsky
maintainerQuoted 12 lines · Greg KH
Quoted 11 lines · Leon Romanovsky
On Thu, Oct 22, 2020 at 05:33:28PM -0700, Dave Ertman wrote:
<...>
Quoted 2 lines
Dave Ertman (1):
Add auxiliary bus supportWe are in merge window now and both netdev and RDMA are closed for submissions. So I'll send my mlx5 conversion patches once -rc1 will be tagged.
Quoted 6 lines
Quoted 3 lines
However, It is important that this "auxiliary bus" patch will be applied to some topic branch based on Linus's -rcX. It will give us an ability to pull this patch to RDMA, VDPA and netdev subsystems at the same time.
I will do that, but as you said, it's the middle of the merge window and I can't do anything until after -rc1 is out.
Thanks a lot.