soundwire: intel: implement new ASoC interfaces
Subsystems (3)
v5 cover soundwire: intel: implement new ASoC interfaces
This patchset applies on top of soundwire/next, now that the interface definitions are merged.
The changes are essentially a removal of the platform devices, replaced by explicit device(s)/driver for the SoundWire Master(s), and the implementation of the new interfaces required to scan the ACPI tables, probe the links and start them.
The missing prepare, trigger and setup ASoC callbacks are also implemented. The hw_params and free callbacks use the new interfaces as well.
While there are quite a few lines of code changed, this is mostly about interface changes. The next series will contain more functional changes and deal with race conditions on probe, enumeration and suspend/resume issues.
Thanks to Vinod Kould and GregKH for the reviews on previous versions, much appreciated.
Changes since v4: (feedback from GregKH except last point flagged by Intel validation)
Clarified error handling with uevents
Added better commit messages and rationale behind exposing a Master Device. Used 'master_device' instead of 'md' when possible (kept the shortcut with really long function names)
Added namespace check support for Intel code (the Cadence and core stuff should be done in a separate patchset).
Fixed GPLv2 license/EXPORT_SYMBOL_GPL error for the Master Device code. Fixed missing error handling in sdw_md_add
Added kerneldoc comments for sdw_md_driver structure (with explanation on what 'md' stands for)
Fixed NULL pointer assignment leading to issues with driver_unregister
Changes since v3:
One line change to re-add EXPORT_SYMBOL
Add missing driver_registration
Changes since v2:
moved uevent handling to slave_type (Vinod)
Changes since v1:
fix typo (Vinod)
removed uevent open for Master (Vinod)
clarified commit messages (Cezary)
no functionality change
Bard Liao (1):
soundwire: register master device driver
Pierre-Louis Bossart (13):
soundwire: renames to prepare support for master drivers/devices
soundwire: rename dev_to_sdw_dev macro
soundwire: rename drv_to_sdw_slave_driver macro
soundwire: bus_type: rename sdw_drv_ to sdw_slave_drv
soundwire: intel: rename res field as link_res
soundwire: add support for sdw_slave_type
soundwire: slave: move uevent handling to slave device level
soundwire: add initial definitions for sdw_master_device
soundwire: intel: remove platform devices and use 'Master Devices'
instead
soundwire: intel: free all resources on hw_free()
soundwire: intel_init: add implementation of sdw_intel_enable_irq()
soundwire: intel_init: use EXPORT_SYMBOL_NS
soundwire: intel: use EXPORT_SYMBOL_NS
Rander Wang (3):
soundwire: intel: add prepare support in sdw dai driver
soundwire: intel: add trigger support in sdw dai driver
soundwire: intel: add sdw_stream_setup helper for .startup callback
drivers/base/regmap/regmap-sdw.c | 4 +- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus.c | 2 +- drivers/soundwire/bus.h | 2 + drivers/soundwire/bus_type.c | 70 ++++--- drivers/soundwire/intel.c | 281 +++++++++++++++++++++----- drivers/soundwire/intel.h | 8 +- drivers/soundwire/intel_init.c | 312 ++++++++++++++++++++++------- drivers/soundwire/master.c | 64 ++++++ drivers/soundwire/slave.c | 10 +- include/linux/soundwire/sdw.h | 42 +++- include/linux/soundwire/sdw_type.h | 34 +++- 12 files changed, 668 insertions(+), 163 deletions(-) create mode 100644 drivers/soundwire/master.c
Signature · 6 lines
2.20.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v5 1/17 soundwire: renames to prepare support for master drivers/devices
Add clearer references to sdw_slave_driver for internal macros
No change for sdw_driver and module_sdw_driver to avoid compatibility issues with existing codec devices
No functionality change.
--- drivers/soundwire/bus_type.c | 21 +++++++++++---------- include/linux/soundwire/sdw_type.h | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 18 deletions(-)
drivers/soundwire/bus_type.c +11 -10
@@ -34,7 +34,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) {struct sdw_slave *slave =dev_to_sdw_dev (dev); -struct sdw_driver *drv =drv_to_sdw_driver (ddrv); +struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv);return !!sdw_get_device_id (slave, drv); }
@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(sdw_bus_type);static int sdw_drv_probe (struct device *dev) {struct sdw_slave *slave =dev_to_sdw_dev (dev); -struct sdw_driver *drv =drv_to_sdw_driver (dev->driver); +struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);const struct sdw_device_id *id;int ret;
@@ -116,7 +116,7 @@ static int sdw_drv_probe(struct device *dev)static int sdw_drv_remove (struct device *dev) {struct sdw_slave *slave =dev_to_sdw_dev (dev); -struct sdw_driver *drv =drv_to_sdw_driver (dev->driver); +struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);int ret =0 ;if (drv->remove)
@@ -130,20 +130,21 @@ static int sdw_drv_remove(struct device *dev)static void sdw_drv_shutdown (struct device *dev) {struct sdw_slave *slave =dev_to_sdw_dev (dev); -struct sdw_driver *drv =drv_to_sdw_driver (dev->driver); +struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);if (drv->shutdown) drv->shutdown (slave); }/** -* __sdw_register_driver() - register a SoundWire Slave driver +* __sdw_register_slave_driver() - register a SoundWire Slave driver * @drv: driver to register * @owner: owning module/driver * * Return: zero on success, else a negative error code. */ -int __sdw_register_driver (struct sdw_driver *drv,struct module *owner) +int __sdw_register_slave_driver (struct sdw_driver *drv, +struct module *owner) { drv->driver.bus = &sdw_bus_type;
@@ -164,17 +165,17 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner)return driver_register (&drv->driver); } -EXPORT_SYMBOL_GPL (__sdw_register_driver); +EXPORT_SYMBOL_GPL (__sdw_register_slave_driver);/** -* sdw_unregister_driver() - unregisters the SoundWire Slave driver +* sdw_unregister_slave_driver() - unregisters the SoundWire Slave driver * @drv: driver to unregister */ -void sdw_unregister_driver (struct sdw_driver *drv) +void sdw_unregister_slave_driver (struct sdw_driver *drv) {driver_unregister (&drv->driver); } -EXPORT_SYMBOL_GPL (sdw_unregister_driver); +EXPORT_SYMBOL_GPL (sdw_unregister_slave_driver);static int __init sdw_bus_init (void ) {
include/linux/soundwire/sdw_type.h +10 -8
@@ -6,13 +6,15 @@extern struct bus_type sdw_bus_type; -#define drv_to_sdw_driver (_drv) container_of(_drv, struct sdw_driver, driver) +#define drv_to_sdw_slave_driver (_drv) \ + container_of(_drv, struct sdw_driver, driver) -#define sdw_register_driver (drv) \ - __sdw_register_driver(drv, THIS_MODULE) +#define sdw_register_slave_driver (drv) \ + __sdw_register_slave_driver(drv, THIS_MODULE) -int __sdw_register_driver (struct sdw_driver *drv,struct module *owner); -void sdw_unregister_driver (struct sdw_driver *drv); +int __sdw_register_slave_driver (struct sdw_driver *drv, +struct module *owner); +void sdw_unregister_slave_driver (struct sdw_driver *drv);int sdw_slave_modalias (const struct sdw_slave *slave,char *buf,size_t size);
@@ -24,7 +26,7 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size);* 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_sdw_driver (__sdw_driver) \ - module_driver(__sdw_driver, sdw_register_driver, \ - sdw_unregister_driver) +#define module_sdw_driver (__sdw_slave_driver) \ + module_driver(__sdw_slave_driver, sdw_register_slave_driver, \ + sdw_unregister_slave_driver)#endif /* __SOUNDWIRE_TYPES_H */
Signature · 1 line
2.20.1
PATCH v5 2/17 soundwire: rename dev_to_sdw_dev macro
In reply to Pierre-Louis BossartSince we want to introduce master devices, rename macro so that we have consistency between slave and master device access.
--- drivers/base/regmap/regmap-sdw.c | 4 ++-- drivers/soundwire/bus.c | 2 +- drivers/soundwire/bus_type.c | 11 ++++++----- drivers/soundwire/slave.c | 2 +- include/linux/soundwire/sdw.h | 3 ++- 5 files changed, 12 insertions(+), 10 deletions(-)
drivers/base/regmap/regmap-sdw.c +2 -2
@@ -10,7 +10,7 @@static int regmap_sdw_write (void *context,unsigned int reg,unsigned int val) {struct device *dev = context; -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);return sdw_write (slave, reg, val); }
@@ -18,7 +18,7 @@ static int regmap_sdw_write(void *context, unsigned int reg, unsigned int val)static int regmap_sdw_read (void *context,unsigned int reg,unsigned int *val) {struct device *dev = context; -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);int read; read =sdw_read (slave, reg);
drivers/soundwire/bus.c +1 -1
@@ -110,7 +110,7 @@ EXPORT_SYMBOL(sdw_add_bus_master);static int sdw_delete_slave (struct device *dev,void *data) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_bus *bus = slave->bus;sdw_slave_debugfs_exit (slave);
drivers/soundwire/bus_type.c +6 -5
@@ -33,7 +33,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv);return !!sdw_get_device_id (slave, drv);
@@ -49,7 +49,7 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)static int sdw_uevent (struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);char modalias[32 ];sdw_slave_modalias (slave, modalias,sizeof (modalias));
@@ -69,7 +69,7 @@ EXPORT_SYMBOL_GPL(sdw_bus_type);static int sdw_drv_probe (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);const struct sdw_device_id *id;int ret;
@@ -115,8 +115,9 @@ static int sdw_drv_probe(struct device *dev)static int sdw_drv_remove (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver); +int ret =0 ;if (drv->remove)
@@ -129,7 +130,7 @@ static int sdw_drv_remove(struct device *dev)static void sdw_drv_shutdown (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);if (drv->shutdown)
drivers/soundwire/slave.c +1 -1
@@ -9,7 +9,7 @@static void sdw_slave_release (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);kfree (slave); }
include/linux/soundwire/sdw.h +2 -1
@@ -582,7 +582,8 @@ struct sdw_slave {u32 unattach_request; }; -#define dev_to_sdw_dev (_dev) container_of(_dev, struct sdw_slave, dev) +#define to_sdw_slave_device (d) \ + container_of(d, struct sdw_slave, dev)struct sdw_driver {const char *name;
Signature · 1 line
2.20.1
Vinod Koul
maintainerRe: [PATCH v5 02/17] soundwire: rename dev_to_sdw_dev macro
Quoted 6 lines · Pierre-Louis Bossart
Since we want to introduce master devices, rename macro so that we have consistency between slave and master device access.
Signed-off-by Pierre-Louis Bossart <[email protected]>--- drivers/base/regmap/regmap-sdw.c | 4 ++--
need ack from Mark on this...
Quoted 121 lines
drivers/soundwire/bus.c | 2 +- drivers/soundwire/bus_type.c | 11 ++++++----- drivers/soundwire/slave.c | 2 +- include/linux/soundwire/sdw.h | 3 ++- 5 files changed, 12 insertions(+), 10 deletions(-)drivers/base/regmap/regmap-sdw.c +2
-2@@ -10,7 +10,7 @@static int regmap_sdw_write (void *context,unsigned int reg,unsigned int val) {struct device *dev = context; -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);return sdw_write (slave, reg, val); }@@ -18,7 +18,7 @@ static int regmap_sdw_write(void *context, unsigned int reg, unsigned int val)static int regmap_sdw_read (void *context,unsigned int reg,unsigned int *val) {struct device *dev = context; -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);int read; read =sdw_read (slave, reg);drivers/soundwire/bus.c +1
-1@@ -110,7 +110,7 @@ EXPORT_SYMBOL(sdw_add_bus_master);static int sdw_delete_slave (struct device *dev,void *data) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_bus *bus = slave->bus;sdw_slave_debugfs_exit (slave);drivers/soundwire/bus_type.c +6
-5@@ -33,7 +33,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv);return !!sdw_get_device_id (slave, drv);@@ -49,7 +49,7 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)static int sdw_uevent (struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);char modalias[32 ];sdw_slave_modalias (slave, modalias,sizeof (modalias));@@ -69,7 +69,7 @@ EXPORT_SYMBOL_GPL(sdw_bus_type);static int sdw_drv_probe (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);const struct sdw_device_id *id;int ret;@@ -115,8 +115,9 @@ static int sdw_drv_probe(struct device *dev)static int sdw_drv_remove (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver); +int ret =0 ;if (drv->remove)@@ -129,7 +130,7 @@ static int sdw_drv_remove(struct device *dev)static void sdw_drv_shutdown (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver);if (drv->shutdown)drivers/soundwire/slave.c +1
-1@@ -9,7 +9,7 @@static void sdw_slave_release (struct device *dev) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +struct sdw_slave *slave =to_sdw_slave_device (dev);kfree (slave); }include/linux/soundwire/sdw.h +2
-1@@ -582,7 +582,8 @@ struct sdw_slave {u32 unattach_request; }; -#define dev_to_sdw_dev (_dev) container_of(_dev, struct sdw_slave, dev) +#define to_sdw_slave_device (d) \ + container_of(d, struct sdw_slave, dev)struct sdw_driver {const char *name;Signature · 1 line
2.20.1
Signature · 1 line
~Vinod
PATCH v5 3/17 soundwire: rename drv_to_sdw_slave_driver macro
In reply to Pierre-Louis BossartAlign with previous renames and shorten macro
No functionality change
--- drivers/soundwire/bus_type.c | 9 ++++----- include/linux/soundwire/sdw_type.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/soundwire/bus_type.c +4 -5
@@ -34,7 +34,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv); +struct sdw_driver *drv =to_sdw_slave_driver (ddrv);return !!sdw_get_device_id (slave, drv); }
@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(sdw_bus_type);static int sdw_drv_probe (struct device *dev) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver); +struct sdw_driver *drv =to_sdw_slave_driver (dev->driver);const struct sdw_device_id *id;int ret;
@@ -116,8 +116,7 @@ static int sdw_drv_probe(struct device *dev)static int sdw_drv_remove (struct device *dev) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver); - +struct sdw_driver *drv =to_sdw_slave_driver (dev->driver);int ret =0 ;if (drv->remove)
@@ -131,7 +130,7 @@ static int sdw_drv_remove(struct device *dev)static void sdw_drv_shutdown (struct device *dev) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (dev->driver); +struct sdw_driver *drv =to_sdw_slave_driver (dev->driver);if (drv->shutdown) drv->shutdown (slave);
include/linux/soundwire/sdw_type.h +2 -1
@@ -6,7 +6,7 @@extern struct bus_type sdw_bus_type; -#define drv_to_sdw_slave_driver (_drv) \ +#define to_sdw_slave_driver (_drv) \ container_of(_drv, struct sdw_driver, driver)#define sdw_register_slave_driver (drv) \
@@ -29,4 +29,5 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size);#define module_sdw_driver (__sdw_slave_driver) \ module_driver(__sdw_slave_driver, sdw_register_slave_driver, \ sdw_unregister_slave_driver) +#endif /* __SOUNDWIRE_TYPES_H */
Signature · 1 line
2.20.1
Vinod Koul
maintainerRe: [PATCH v5 03/17] soundwire: rename drv_to_sdw_slave_driver macro
Quoted 15 lines · Pierre-Louis Bossart
Align with previous renames and shorten macro
No functionality change
Signed-off-by Pierre-Louis Bossart <[email protected]>--- drivers/soundwire/bus_type.c | 9 ++++----- include/linux/soundwire/sdw_type.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/soundwire/bus_type.c +0
-0
drivers/soundwire/bus_type.c sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv) · line 37
Quoted 5 lines
drivers/soundwire/bus_type.c +1
-1@@ -34,7 +34,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv); +struct sdw_driver *drv =to_sdw_slave_driver (ddrv);
so patch 1 does:
- struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
+ struct sdw_driver *drv = drv_to_sdw_slave_driver(dev->driver);
and here we move drv_to_sdw_slave_driver to to_sdw_slave_driver... why not do this in first patch and save step1... or did i miss something??
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 03/17] soundwire: rename drv_to_sdw_slave_driver macro
Quoted 27 lines · Vinod Koul
Quoted 15 lines · Pierre-Louis Bossart
Align with previous renames and shorten macro
No functionality change
Signed-off-by Pierre-Louis Bossart <[email protected]>--- drivers/soundwire/bus_type.c | 9 ++++----- include/linux/soundwire/sdw_type.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/soundwire/bus_type.c +0
-0drivers/soundwire/bus_type.c sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv) · line 37
Quoted 5 lines
drivers/soundwire/bus_type.c +1
-1@@ -34,7 +34,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv); +struct sdw_driver *drv =to_sdw_slave_driver (ddrv);so patch 1 does:
(quoted diff) +1
-1- struct sdw_driver *drv = drv_to_sdw_driver(dev->driver); + struct sdw_driver *drv = drv_to_sdw_slave_driver(dev->driver);
Quoted 2 lines
and here we move
drv_to_sdw_slave_drivertoto_sdw_slave_driver... why not do this in first patch and save step1... or did i miss something??
because patch1 introduces replaces 'sdw_' by 'sdw_slave_' in several places, not just for drv_to_sdw_driver()
I can squash all these patches if you want to but then you'll tell me one step at a time...
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 03/17] soundwire: rename drv_to_sdw_slave_driver macro
Quoted 30 lines · Pierre-Louis Bossart
Quoted 27 lines · Vinod Koul
Quoted 15 lines · Pierre-Louis Bossart
Align with previous renames and shorten macro
No functionality change
Signed-off-by Pierre-Louis Bossart <[email protected]>--- drivers/soundwire/bus_type.c | 9 ++++----- include/linux/soundwire/sdw_type.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/soundwire/bus_type.c +0
-0drivers/soundwire/bus_type.c sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv) · line 37
Quoted 5 lines
drivers/soundwire/bus_type.c +1
-1@@ -34,7 +34,7 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)static int sdw_bus_match (struct device *dev,struct device_driver *ddrv) {struct sdw_slave *slave =to_sdw_slave_device (dev); -struct sdw_driver *drv =drv_to_sdw_slave_driver (ddrv); +struct sdw_driver *drv =to_sdw_slave_driver (ddrv);so patch 1 does:
(quoted diff) +1
-1- struct sdw_driver *drv = drv_to_sdw_driver(dev->driver); + struct sdw_driver *drv = drv_to_sdw_slave_driver(dev->driver);
Quoted 8 lines
Quoted 2 lines
and here we move
drv_to_sdw_slave_drivertoto_sdw_slave_driver... why not do this in first patch and save step1... or did i miss something??because patch1 introduces replaces '
sdw_' by 'sdw_slave_' in several places, not just fordrv_to_sdw_driver()I can squash all these patches if you want to but then you'll tell me one step at a time...
Yes but that does not mean we add an intermediate step just to remove it later... So please remove the instances of drv_to_sdw_slave_driver() in patch1 and move them to patch3 (this) and convert to to_sdw_slave_driver()
Thanks
Signature · 1 line
~Vinod
PATCH v5 4/17 soundwire: bus_type: rename sdw_drv_ to sdw_slave_drv
In reply to Pierre-Louis BossartBefore we add master driver support, make sure there is no ambiguity and no occurrences of sdw_drv_ functions.
No functionality change.
--- drivers/soundwire/bus_type.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/soundwire/bus_type.c +6 -6
@@ -67,7 +67,7 @@ struct bus_type sdw_bus_type = { };EXPORT_SYMBOL_GPL (sdw_bus_type); -static int sdw_drv_probe (struct device *dev) +static int sdw_slave_drv_probe (struct device *dev) {struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =to_sdw_slave_driver (dev->driver);
@@ -113,7 +113,7 @@ static int sdw_drv_probe(struct device *dev)return 0 ; } -static int sdw_drv_remove (struct device *dev) +static int sdw_slave_drv_remove (struct device *dev) {struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =to_sdw_slave_driver (dev->driver);
@@ -127,7 +127,7 @@ static int sdw_drv_remove(struct device *dev)return ret; } -static void sdw_drv_shutdown (struct device *dev) +static void sdw_slave_drv_shutdown (struct device *dev) {struct sdw_slave *slave =to_sdw_slave_device (dev);struct sdw_driver *drv =to_sdw_slave_driver (dev->driver);
@@ -155,13 +155,13 @@ int __sdw_register_slave_driver(struct sdw_driver *drv, } drv->driver.owner = owner; - drv->driver.probe = sdw_drv_probe; + drv->driver.probe = sdw_slave_drv_probe;if (drv->remove) - drv->driver.remove = sdw_drv_remove; + drv->driver.remove = sdw_slave_drv_remove;if (drv->shutdown) - drv->driver.shutdown = sdw_drv_shutdown; + drv->driver.shutdown = sdw_slave_drv_shutdown;return driver_register (&drv->driver); }
Signature · 1 line
2.20.1
PATCH v5 5/17 soundwire: intel: rename res field as link_res
In reply to Pierre-Louis BossartThere are too many fields called 'res' so add prefix to make it easier to track what the structures are.
Pure rename, no functionality change
--- drivers/soundwire/intel.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/soundwire/intel.c +19 -18
@@ -103,7 +103,7 @@ enum intel_pdi_type {struct sdw_intel {struct sdw_cdns cdns;int instance; -struct sdw_intel_link_res *res; +struct sdw_intel_link_res *link_res;#ifdef CONFIG_DEBUG_FS struct dentry *debugfs;#endif
@@ -193,8 +193,8 @@ static ssize_t intel_sprintf(void __iomem *mem, bool l,static int intel_reg_show (struct seq_file *s_file,void *data) {struct sdw_intel *sdw = s_file->private; -void __iomem *s = sdw->res->shim; -void __iomem *a = sdw->res->alh; +void __iomem *s = sdw->link_res->shim; +void __iomem *a = sdw->link_res->alh;char *buf;ssize_t ret;int i, j;
@@ -289,7 +289,7 @@ static void intel_debugfs_exit(struct sdw_intel *sdw) {}static int intel_link_power_up (struct sdw_intel *sdw) {unsigned int link_id = sdw->instance; -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;int spa_mask, cpa_mask;int link_control, ret;
@@ -309,7 +309,7 @@ static int intel_link_power_up(struct sdw_intel *sdw)static int intel_shim_init (struct sdw_intel *sdw) { -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;unsigned int link_id = sdw->instance;int sync_reg, ret;u16 ioctl =0 , act =0 ;
@@ -370,7 +370,7 @@ static int intel_shim_init(struct sdw_intel *sdw)static void intel_pdi_init (struct sdw_intel *sdw,struct sdw_cdns_stream_config *config) { -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;unsigned int link_id = sdw->instance;int pcm_cap, pdm_cap;
@@ -404,7 +404,7 @@ static void intel_pdi_init(struct sdw_intel *sdw,static int intel_pdi_get_ch_cap (struct sdw_intel *sdw,unsigned int pdi_num,bool pcm) { -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;unsigned int link_id = sdw->instance;int count;
@@ -476,7 +476,7 @@ static int intel_pdi_ch_update(struct sdw_intel *sdw)static void intel_pdi_shim_configure (struct sdw_intel *sdw,struct sdw_cdns_pdi *pdi) { -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;unsigned int link_id = sdw->instance;int pdi_conf =0 ;
@@ -508,7 +508,7 @@ intel_pdi_shim_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)static void intel_pdi_alh_configure (struct sdw_intel *sdw,struct sdw_cdns_pdi *pdi) { -void __iomem *alh = sdw->res->alh; +void __iomem *alh = sdw->link_res->alh;unsigned int link_id = sdw->instance;unsigned int conf;
@@ -535,7 +535,7 @@ static int intel_params_stream(struct sdw_intel *sdw,struct snd_pcm_hw_params *hw_params, int link_id, int alh_stream_id) { - struct sdw_intel_link_res *res = sdw->res; + struct sdw_intel_link_res *res = sdw->link_res;struct sdw_intel_stream_params_data params_data; params_data.substream = substream;
@@ -558,7 +558,7 @@ static int intel_pre_bank_switch(struct sdw_bus *bus) {struct sdw_cdns *cdns =bus_to_cdns (bus);struct sdw_intel *sdw =cdns_to_intel (cdns); -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;int sync_reg;/* Write to register only for multi-link */
@@ -577,7 +577,7 @@ static int intel_post_bank_switch(struct sdw_bus *bus) {struct sdw_cdns *cdns =bus_to_cdns (bus);struct sdw_intel *sdw =cdns_to_intel (cdns); -void __iomem *shim = sdw->res->shim; +void __iomem *shim = sdw->link_res->shim;int sync_reg, ret;/* Write to register only for multi-link */
@@ -934,9 +934,9 @@ static int intel_probe(struct platform_device *pdev)return -ENOMEM ; sdw->instance = pdev->id; - sdw->res =dev_get_platdata (&pdev->dev); + sdw->link_res =dev_get_platdata (&pdev->dev); sdw->cdns.dev = &pdev->dev; - sdw->cdns.registers = sdw->res->registers; + sdw->cdns.registers = sdw->link_res->registers; sdw->cdns.instance = sdw->instance; sdw->cdns.msg_count =0 ; sdw->cdns.bus.dev = &pdev->dev;
@@ -976,11 +976,12 @@ static int intel_probe(struct platform_device *pdev)intel_pdi_ch_update (sdw);/* Acquire IRQ */ - ret =request_threaded_irq (sdw->res->irq, sdw_cdns_irq, sdw_cdns_thread, + ret =request_threaded_irq (sdw->link_res->irq, + sdw_cdns_irq, sdw_cdns_thread,IRQF_SHARED ,KBUILD_MODNAME , &sdw->cdns);if (ret <0 ) {dev_err (sdw->cdns.dev,"unable to grab IRQ %d, disabling device\n" , - sdw->res->irq); + sdw->link_res->irq); goto err_init; }
@@ -1010,7 +1011,7 @@ static int intel_probe(struct platform_device *pdev) err_interrupt:sdw_cdns_enable_interrupt (&sdw->cdns, false); -free_irq (sdw->res->irq, sdw); +free_irq (sdw->link_res->irq, sdw); err_init:sdw_delete_bus_master (&sdw->cdns.bus);return ret;
@@ -1025,7 +1026,7 @@ static int intel_remove(struct platform_device *pdev)if (!sdw->cdns.bus.prop.hw_disabled) {intel_debugfs_exit (sdw);sdw_cdns_enable_interrupt (&sdw->cdns, false); -free_irq (sdw->res->irq, sdw); +free_irq (sdw->link_res->irq, sdw);snd_soc_unregister_component (sdw->cdns.dev); }sdw_delete_bus_master (&sdw->cdns.bus);
Signature · 1 line
2.20.1
PATCH v5 6/17 soundwire: add support for sdw_slave_type
In reply to Pierre-Louis BossartIn the existing SoundWire code, the bus does not have any explicit representation for Master Devices - only SoundWire Slaves are exposed.
In SoundWire, the Master Device provides the clock, synchronization information and command/control channels. When multiple links are supported, a Controller may expose more than one Master Device; they are typically embedded inside a larger audio cluster (be it in an SOC/chipset or an external audio codec), and we need to describe it using the Linux device and driver model. This will allow for configuration functions to account for external dependencies such as power rails, clock sources or wake-up mechanisms. This transition will also allow for better sysfs support without the reference count issues mentioned in the initial reviews.
In this patch, we first convert the existing code to use an explicit sdw_slave_type and add error checks if this type is not set.
In follow-up patches we can add support for the sdw_master_type.
--- drivers/soundwire/bus_type.c | 23 ++++++++++++++++++----- drivers/soundwire/slave.c | 7 ++++++- include/linux/soundwire/sdw_type.h | 6 ++++++ 3 files changed, 30 insertions(+), 6 deletions(-)
drivers/soundwire/bus_type.c +18 -5
@@ -49,13 +49,26 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)static int sdw_uevent (struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =to_sdw_slave_device (dev); +struct sdw_slave *slave;char modalias[32 ]; -sdw_slave_modalias (slave, modalias,sizeof (modalias)); - -if (add_uevent_var (env,"MODALIAS=%s" , modalias)) -return -ENOMEM ; +if (is_sdw_slave (dev)) { + slave =to_sdw_slave_device (dev); + +sdw_slave_modalias (slave, modalias,sizeof (modalias)); + +if (add_uevent_var (env,"MODALIAS=%s" , modalias)) +return -ENOMEM ; + }else { +/* +* We only need to handle uevents for the Slave device +* type. This error cannot happen unless the .uevent +* callback is set to use this function for a +* different device type (e.g. Master or Monitor) +*/ +dev_err (dev,"uevent for unknown Soundwire type\n" ); +return -EINVAL ; + }return 0 ; }
drivers/soundwire/slave.c +6 -1
@@ -14,6 +14,11 @@ static void sdw_slave_release(struct device *dev)kfree (slave); } +struct device_type sdw_slave_type = { + .name ="sdw_slave" , + .release = sdw_slave_release, +}; +static int sdw_slave_add (struct sdw_bus *bus,struct sdw_slave_id *id,struct fwnode_handle *fwnode) {
@@ -41,9 +46,9 @@ static int sdw_slave_add(struct sdw_bus *bus, id->class_id, id->unique_id); } - slave->dev.release = sdw_slave_release; slave->dev.bus = &sdw_bus_type; slave->dev.of_node =of_node_get (to_of_node (fwnode)); + slave->dev.type = &sdw_slave_type; slave->bus = bus; slave->status =SDW_SLAVE_UNATTACHED ; slave->dev_num =0 ;
include/linux/soundwire/sdw_type.h +6 -0
@@ -5,6 +5,12 @@#define __SOUNDWIRE_TYPES_Hextern struct bus_type sdw_bus_type; +extern struct device_type sdw_slave_type; + +static inline int is_sdw_slave (const struct device *dev) +{ +return dev->type == &sdw_slave_type; +}#define to_sdw_slave_driver (_drv) \ container_of(_drv, struct sdw_driver, driver)
Signature · 1 line
2.20.1
Vinod Koul
maintainerRe: [PATCH v5 06/17] soundwire: add support for sdw_slave_type
Quoted 48 lines · Pierre-Louis Bossart
In the existing SoundWire code, the bus does not have any explicit representation for Master Devices - only SoundWire Slaves are exposed.
In SoundWire, the Master Device provides the clock, synchronization information and command/control channels. When multiple links are supported, a Controller may expose more than one Master Device; they are typically embedded inside a larger audio cluster (be it in an SOC/chipset or an external audio codec), and we need to describe it using the Linux device and driver model. This will allow for configuration functions to account for external dependencies such as power rails, clock sources or wake-up mechanisms. This transition will also allow for better sysfs support without the reference count issues mentioned in the initial reviews.
In this patch, we first convert the existing code to use an explicit
sdw_slave_typeand add error checks if this type is not set.In follow-up patches we can add support for the
sdw_master_type.Signed-off-by Pierre-Louis Bossart <[email protected]>--- drivers/soundwire/bus_type.c | 23 ++++++++++++++++++----- drivers/soundwire/slave.c | 7 ++++++- include/linux/soundwire/sdw_type.h | 6 ++++++ 3 files changed, 30 insertions(+), 6 deletions(-)drivers/soundwire/bus_type.c +7
-5@@ -49,13 +49,26 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)static int sdw_uevent (struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =to_sdw_slave_device (dev); +struct sdw_slave *slave;char modalias[32 ]; -sdw_slave_modalias (slave, modalias,sizeof (modalias)); - -if (add_uevent_var (env,"MODALIAS=%s" , modalias)) -return -ENOMEM ; +if (is_sdw_slave (dev)) { + slave =to_sdw_slave_device (dev); + +sdw_slave_modalias (slave, modalias,sizeof (modalias)); + +if (add_uevent_var (env,"MODALIAS=%s" , modalias))
drivers/soundwire/bus_type.c int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) · line 70
Quoted 10 lines
drivers/soundwire/bus_type.c +10
-0+return -ENOMEM ; + }else { +/* +* We only need to handle uevents for the Slave device +* type. This error cannot happen unless the .uevent +* callback is set to use this function for a +* different device type (e.g. Master or Monitor) +*/ +dev_err (dev,"uevent for unknown Soundwire type\n" ); +return -EINVAL ;
At this point and after next patch, the above code would be a no-op, do we want this here, if so why?
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 06/17] soundwire: add support for sdw_slave_type
Quoted 22 lines
Quoted 22 lines
static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) {drivers/soundwire/bus_type.c +12
-5-struct sdw_slave *slave =to_sdw_slave_device (dev); +struct sdw_slave *slave;char modalias[32 ]; -sdw_slave_modalias (slave, modalias,sizeof (modalias)); - -if (add_uevent_var (env,"MODALIAS=%s" , modalias)) -return -ENOMEM ; +if (is_sdw_slave (dev)) { + slave =to_sdw_slave_device (dev); + +sdw_slave_modalias (slave, modalias,sizeof (modalias)); + +if (add_uevent_var (env,"MODALIAS=%s" , modalias)) +return -ENOMEM ; + }else { +/* +* We only need to handle uevents for the Slave device +* type. This error cannot happen unless the .uevent
Quoted 8 lines
drivers/soundwire/bus_type.c int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) · line 70
Quoted 5 lines
drivers/soundwire/bus_type.c +5
-0+* callback is set to use this function for a +* different device type (e.g. Master or Monitor) +*/ +dev_err (dev,"uevent for unknown Soundwire type\n" ); +return -EINVAL ;At this point and after next patch, the above code would be a no-op, do we want this here, if so why?
to be future proof if someone wants to add support for a monitor, as explained above. I can remove this if you don't want it.
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 06/17] soundwire: add support for sdw_slave_type
Quoted 30 lines · Pierre-Louis Bossart
Quoted 21 lines
Quoted 21 lines
static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) {drivers/soundwire/bus_type.c +12
-5-struct sdw_slave *slave =to_sdw_slave_device (dev); +struct sdw_slave *slave;char modalias[32 ]; -sdw_slave_modalias (slave, modalias,sizeof (modalias)); - -if (add_uevent_var (env,"MODALIAS=%s" , modalias)) -return -ENOMEM ; +if (is_sdw_slave (dev)) { + slave =to_sdw_slave_device (dev); + +sdw_slave_modalias (slave, modalias,sizeof (modalias)); + +if (add_uevent_var (env,"MODALIAS=%s" , modalias)) +return -ENOMEM ; + }else { +/* +* We only need to handle uevents for the Slave device +* type. This error cannot happen unless the .uevent Quoted 8 lines
drivers/soundwire/bus_type.c int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) · line 70
Quoted 5 lines
drivers/soundwire/bus_type.c +5
-0+* callback is set to use this function for a +* different device type (e.g. Master or Monitor) +*/ +dev_err (dev,"uevent for unknown Soundwire type\n" ); +return -EINVAL ;At this point and after next patch, the above code would be a no-op, do we want this here, if so why?
Quoted 3 lines
to be future proof if someone wants to add support for a monitor, as explained above.
I can remove this if you don't want it.
It can be added with monitor support whenever that comes. We dont like dead code in kernel, the piece can come when future arrives :)
Signature · 5 lines
~Vinod _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v5 7/17 soundwire: slave: move uevent handling to slave device level
In reply to Pierre-Louis BossartCurrently the .uevent callback is set at the bus level. This is not necessary, we only really need to deal with uevents for the Slave device, so move the uevent handling at that level.
--- drivers/soundwire/bus.h | 2 ++ drivers/soundwire/bus_type.c | 3 +-- drivers/soundwire/slave.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/soundwire/bus.h +2 -0
@@ -6,6 +6,8 @@#define DEFAULT_BANK_SWITCH_TIMEOUT 3000 +int sdw_uevent (struct device *dev,struct kobj_uevent_env *env); +#if IS_ENABLED (CONFIG_ACPI )int sdw_acpi_find_slaves (struct sdw_bus *bus);#else
drivers/soundwire/bus_type.c +1 -2
@@ -47,7 +47,7 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) slave->id.mfg_id, slave->id.part_id); } -static int sdw_uevent (struct device *dev,struct kobj_uevent_env *env) +int sdw_uevent (struct device *dev,struct kobj_uevent_env *env) {struct sdw_slave *slave;char modalias[32 ];
@@ -76,7 +76,6 @@ static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)struct bus_type sdw_bus_type = { .name ="soundwire" , .match = sdw_bus_match, - .uevent = sdw_uevent, };EXPORT_SYMBOL_GPL (sdw_bus_type);
drivers/soundwire/slave.c +1 -0
@@ -17,6 +17,7 @@ static void sdw_slave_release(struct device *dev)struct device_type sdw_slave_type = { .name ="sdw_slave" , .release = sdw_slave_release, + .uevent = sdw_uevent, }; static int sdw_slave_add(struct sdw_bus *bus,
Signature · 1 line
2.20.1
PATCH v5 8/17 soundwire: add initial definitions for sdw_master_device
In reply to Pierre-Louis BossartSince we want an explicit support for the SoundWire Master device, add the definitions, following the Greybus example of a 'Host Device'.
A parent (such as the Intel audio controller) would use sdw_md_add() to create the device, passing a driver as a parameter. The sdw_md_release() would be called when put_device() is invoked by the parent. We use the shortcut 'md' for 'master device' to avoid very long function names.
The 'Master Device' driver exposes interfaces for probe/startup/shutdown/remove and a placeholder for autonomous clock stop support (when the bus control is handed over to a lower-power solution, typically in D0ix modes).
Module namespace support is added in a separate patch.
--- drivers/soundwire/Makefile | 2 +- drivers/soundwire/bus_type.c | 5 ++- drivers/soundwire/master.c | 63 ++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 38 ++++++++++++++++++ include/linux/soundwire/sdw_type.h | 9 +++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 drivers/soundwire/master.c
drivers/soundwire/Makefile +1 -1
@@ -4,7 +4,7 @@ # #Bus Objs -soundwire-bus-objs := bus_type.o bus.o slave.o mipi_disco.o stream.o +soundwire-bus-objs := bus_type.o bus.o master.o slave.o mipi_disco.o stream.o obj-$(CONFIG_SOUNDWIRE) += soundwire-bus.o ifdef CONFIG_DEBUG_FS
drivers/soundwire/bus_type.c +4 -1
@@ -66,7 +66,10 @@ int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)* callback is set to use this function for a * different device type (e.g. Master or Monitor) */ -dev_err (dev,"uevent for unknown Soundwire type\n" ); +if (is_sdw_master_device (dev)) +dev_err (dev,"uevent for SoundWire Master type\n" ); +else +dev_err (dev,"uevent for unknown Soundwire type\n" );return -EINVAL ; }
drivers/soundwire/master.c new file +63 -0
63 lines not on this page · raw message
include/linux/soundwire/sdw.h +38 -0
@@ -585,6 +585,16 @@ struct sdw_slave {#define to_sdw_slave_device (d) \ container_of(d, struct sdw_slave, dev) +struct sdw_master_device { +struct device dev; +int link_id; +struct sdw_md_driver *driver; +void *pdata; +}; + +#define to_sdw_master_device (d) \ + container_of(d, struct sdw_master_device, dev) +struct sdw_driver {const char *name;
@@ -599,6 +609,29 @@ struct sdw_driver {struct device_driver driver; }; +/** +* struct sdw_md_driver - SoundWire 'Master Device' driver +* +* @probe: initializations and allocation (hardware may not be enabled yet) +* @startup: initialization handled after the hardware is enabled, all +* clock/power dependencies are available +* @shutdown: cleanups before hardware is disabled (optional) +* @free: free all remaining resources +* @autonomous_clock_stop_enable: enable/disable driver control while +* in clock-stop mode, typically in always-on/D0ix modes. When the driver +* yields control, another entity in the system (typically firmware +* running on an always-on microprocessor) is responsible to tracking +* Slave-initiated wakes +*/ +struct sdw_md_driver { +int (*probe)(struct sdw_master_device *md,void *link_ctx); +int (*startup)(struct sdw_master_device *md); +int (*shutdown)(struct sdw_master_device *md); +int (*remove)(struct sdw_master_device *md); +int (*autonomous_clock_stop_enable)(struct sdw_master_device *md, +bool state); +}; +#define SDW_SLAVE_ENTRY (_mfg_id, _part_id, _drv_data) \ { .mfg_id = (_mfg_id), .part_id = (_part_id), \ .driver_data = (unsigned long)(_drv_data) }
@@ -788,6 +821,11 @@ struct sdw_bus {int sdw_add_bus_master (struct sdw_bus *bus);void sdw_delete_bus_master (struct sdw_bus *bus); +struct sdw_master_device *sdw_md_add (struct sdw_md_driver *driver, +struct device *parent, +struct fwnode_handle *fwnode, +int link_id); +/** * sdw_port_config: Master or Slave Port configuration *
include/linux/soundwire/sdw_type.h +9 -0
@@ -6,15 +6,24 @@extern struct bus_type sdw_bus_type;extern struct device_type sdw_slave_type; +extern struct device_type sdw_md_type;static inline int is_sdw_slave (const struct device *dev) {return dev->type == &sdw_slave_type; } +static inline int is_sdw_master_device (const struct device *dev) +{ +return dev->type == &sdw_md_type; +} +#define to_sdw_slave_driver (_drv) \ container_of(_drv, struct sdw_driver, driver) +#define to_sdw_md_driver (_drv) \ + container_of(_drv, struct sdw_md_driver, driver) +#define sdw_register_slave_driver (drv) \ __sdw_register_slave_driver(drv, THIS_MODULE)
Signature · 1 line
2.20.1
Vinod Koul
maintainerRe: [PATCH v5 08/17] soundwire: add initial definitions for sdw_master_device
Quoted 8 lines · Pierre-Louis Bossart
Since we want an explicit support for the SoundWire Master device, add the definitions, following the Greybus example of a 'Host Device'.
A parent (such as the Intel audio controller) would use
sdw_md_add()to create the device, passing a driver as a parameter. Thesdw_md_release()would be called whenput_device()is invoked by the parent. We use the shortcut 'md' for 'master device' to avoid very long function names.
I agree we should not have long name :) but md does not sound great. Can we drop the device and use sdw_slave and sdw_master for devices and append _driver when we are talking about drivers...
we dont use sd for slave and imo this would gel well with existing names
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) · line 70
Quoted 9 lines
drivers/soundwire/bus_type.c +2
-1@@ -66,7 +66,10 @@ int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)* callback is set to use this function for a * different device type (e.g. Master or Monitor) */ -dev_err (dev,"uevent for unknown Soundwire type\n" ); +if (is_sdw_master_device (dev)) +dev_err (dev,"uevent for SoundWire Master type\n" );
see below [1]:
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) · line 71
Quoted 1 line
drivers/soundwire/bus_type.c +1
-0+static void sdw_md_release (struct device *dev)
sdw_master_release() won't be too long!
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
Quoted 7 lines
drivers/soundwire/bus_type.c +7
-0+{ +struct sdw_master_device *md =to_sdw_master_device (dev); + +kfree (md); +} + +struct device_type sdw_md_type = {
sdw_master_type and so on :)
drivers/soundwire/bus_type.c
Quoted 2 lines
drivers/soundwire/bus_type.c +2
-0+ .name = "soundwire_master", + .release = sdw_md_release,
[1]:
There is no uevent added here, so sdw_uevent() will never be called for this, can you check again if you see the print you added?
Quoted 2 lines
+struct
sdw_master_device{
we have sdw_slave, so would be better if we call this sdw_master
drivers/soundwire/bus_type.c
Quoted 4 lines
drivers/soundwire/bus_type.c +4
-0+struct device dev; +int link_id; +struct sdw_md_driver *driver; +void *pdata;
no sdw_bus pointer and I dont see bus adding this object.. Is there no link between bus and master device objects?
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 08/17] soundwire: add initial definitions for sdw_master_device
Quoted 10 lines · Vinod Koul
Quoted 8 lines · Pierre-Louis Bossart
Since we want an explicit support for the SoundWire Master device, add the definitions, following the Greybus example of a 'Host Device'.
A parent (such as the Intel audio controller) would use
sdw_md_add()to create the device, passing a driver as a parameter. Thesdw_md_release()would be called whenput_device()is invoked by the parent. We use the shortcut 'md' for 'master device' to avoid very long function names.
Quoted 5 lines
I agree we should not have long name :) but md does not sound great. Can we drop the device and use
sdw_slaveandsdw_masterfor devices and append_driverwhen we are talking about drivers...we dont use sd for slave and imo this would gel well with existing names
In SoundWire parlance, both 'Slave' and 'Master' are 'Devices', so yes we do in the standard talk about 'Slave Devices' and 'Master Devices'.
Then we have Linux 'Devices' which can be used for both.
If we use 'sdw_slave', would we be referring to the actual physical part or the Linux device?
FWIW the Greybus example used 'Host Device' and 'hd' as shortcut.
Quoted 13 lines
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) · line 70
Quoted 10 lines
drivers/soundwire/bus_type.c +2
-1@@ -66,7 +66,10 @@ int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)* callback is set to use this function for a * different device type (e.g. Master or Monitor) */ -dev_err (dev,"uevent for unknown Soundwire type\n" ); +if (is_sdw_master_device (dev)) +dev_err (dev,"uevent for SoundWire Master type\n" );see below [1]:
Quoted 3 lines
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) · line 71
Quoted 1 line
drivers/soundwire/bus_type.c +1
-0+static void sdw_md_release (struct device *dev)
sdw_master_release()won't be too long!
yes, but there is no such operation as 'Master Release' in SoundWire.
At least the 'md' shortcut conveys the implicit convention that this is a Linux device only.
I really would like to avoid overloading the standard definitions with the Linux ones...
Quoted 11 lines
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
Quoted 8 lines
drivers/soundwire/bus_type.c +7
-0+{ +struct sdw_master_device *md =to_sdw_master_device (dev); + +kfree (md); +} + +struct device_type sdw_md_type = {
sdw_master_typeand so on :)
Quoted 6 lines
drivers/soundwire/bus_type.c
Quoted 2 lines
drivers/soundwire/bus_type.c +2
-0+ .name = "soundwire_master", + .release = sdw_md_release,[1]:
There is no uevent added here, sosdw_uevent()will never be called for this, can you check again if you see the print you added?
as explained this is to avoid errors at a later point. I don't see any harm in providing error checks for a routine that can only be used for 1 of the 3 devices defined in the standard?
Quoted 5 lines
Quoted 2 lines
+struct
sdw_master_device{we have
sdw_slave, so would be better if we call thissdw_master
Quoted 7 lines
drivers/soundwire/bus_type.c
Quoted 4 lines
drivers/soundwire/bus_type.c +4
-0+struct device dev; +int link_id; +struct sdw_md_driver *driver; +void *pdata;no
sdw_buspointer and I dont see bus adding this object.. Is there no link between bus and master device objects?
There is currently no bus device object, see the structure definition it's a pointer to a device (which leads to all sorts of issues because we can't use container_of).
when the master device gets added, that's where the Linux device is created and the pointer saved in the bus structure, with IIRC sdw_add_bus_master().
ret = sdw_add_bus_master(&sdw->cdns.bus);
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 08/17] soundwire: add initial definitions for sdw_master_device
Quoted 22 lines · Pierre-Louis Bossart
Quoted 10 lines · Vinod Koul
Quoted 8 lines · Pierre-Louis Bossart
Since we want an explicit support for the SoundWire Master device, add the definitions, following the Greybus example of a 'Host Device'.
A parent (such as the Intel audio controller) would use
sdw_md_add()to create the device, passing a driver as a parameter. Thesdw_md_release()would be called whenput_device()is invoked by the parent. We use the shortcut 'md' for 'master device' to avoid very long function names.Quoted 5 lines
I agree we should not have long name :) but md does not sound great. Can we drop the device and use
sdw_slaveandsdw_masterfor devices and append_driverwhen we are talking about drivers...we dont use sd for slave and imo this would gel well with existing names
In SoundWire parlance, both 'Slave' and 'Master' are 'Devices', so yes we do in the standard talk about 'Slave Devices' and 'Master Devices'.
Quoted 6 lines
Then we have Linux 'Devices' which can be used for both.
If we use '
sdw_slave', would we be referring to the actual physical part or the Linux device?FWIW the Greybus example used 'Host Device' and 'hd' as shortcut.
But this messes up consistency in the naming of sdw objects. I am all for it, if we do sd for slave and name all structs and APIs accordingly. The key is consistency!
So it needs to be sd/md and so on or sdw_slave and sdw_master and so on... not a mix of both
Quoted 14 lines
Quoted 14 lines
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) · line 70
Quoted 9 lines
drivers/soundwire/bus_type.c +2
-1@@ -66,7 +66,10 @@ int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)* callback is set to use this function for a * different device type (e.g. Master or Monitor) */ -dev_err (dev,"uevent for unknown Soundwire type\n" ); +if (is_sdw_master_device (dev)) +dev_err (dev,"uevent for SoundWire Master type\n" );see below [1]:
Quoted 1 line
drivers/soundwire/bus_type.c +1
-0+static void sdw_md_release (struct device *dev)
Quoted 8 lines
Quoted 1 line
sdw_master_release()won't be too long!yes, but there is no such operation as 'Master Release' in SoundWire. At least the 'md' shortcut conveys the implicit convention that this is a Linux device only.
I really would like to avoid overloading the standard definitions with the Linux ones...
I agree with you on not overloading but from a linux pov, we need names which are consistent with each other...
Quoted 42 lines
Quoted 10 lines
drivers/soundwire/bus_type.c int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
Quoted 7 lines
drivers/soundwire/bus_type.c +7
-0+{ +struct sdw_master_device *md =to_sdw_master_device (dev); + +kfree (md); +} + +struct device_type sdw_md_type = {
sdw_master_typeand so on :)Quoted 6 lines
drivers/soundwire/bus_type.c
Quoted 2 lines
drivers/soundwire/bus_type.c +2
-0+ .name = "soundwire_master", + .release = sdw_md_release,[1]:
There is no uevent added here, sosdw_uevent()will never be called for this, can you check again if you see the print you added?as explained this is to avoid errors at a later point. I don't see any harm in providing error checks for a routine that can only be used for 1 of the 3 devices defined in the standard?
Quoted 11 lines
Quoted 1 line
+struct
sdw_master_device{we have
sdw_slave, so would be better if we call thissdw_masterdrivers/soundwire/bus_type.c
Quoted 4 lines
drivers/soundwire/bus_type.c +4
-0+struct device dev; +int link_id; +struct sdw_md_driver *driver; +void *pdata;no
sdw_buspointer and I dont see bus adding this object.. Is there no link between bus and master device objects?There is currently no bus device object, see the structure definition it's a pointer to a device (which leads to all sorts of issues because we can't use
container_of).when the master device gets added, that's where the Linux device is created and the pointer saved in the bus structure, with IIRC
sdw_add_bus_master().ret =
sdw_add_bus_master(&sdw->cdns.bus);
Signature · 5 lines
~Vinod _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v5 08/17] soundwire: add initial definitions for sdw_master_device
Quoted 21 lines
Quoted 21 lines
Quoted 7 lines
Quoted 6 lines
A parent (such as the Intel audio controller) would use
sdw_md_add()to create the device, passing a driver as a parameter. Thesdw_md_release()would be called whenput_device()is invoked by the parent. We use the shortcut 'md' for 'master device' to avoid very long function names.Quoted 5 lines
I agree we should not have long name :) but md does not sound great. Can we drop the device and use
sdw_slaveandsdw_masterfor devices and append_driverwhen we are talking about drivers...we dont use sd for slave and imo this would gel well with existing names
In SoundWire parlance, both 'Slave' and 'Master' are 'Devices', so yes we do in the standard talk about 'Slave Devices' and 'Master Devices'.
Then we have Linux 'Devices' which can be used for both.
If we use '
sdw_slave', would we be referring to the actual physical part or the Linux device?
Quoted 8 lines
Quoted 1 line
FWIW the Greybus example used 'Host Device' and 'hd' as shortcut.
But this messes up consistency in the naming of sdw objects. I am all for it, if we do sd for slave and name all structs and APIs accordingly. The key is consistency!
So it needs to be sd/md and so on or
sdw_slaveandsdw_masterand so on... not a mix of both
Well the problem is that the existing code took a shortcut and only modeled the slave part, e.g.
struct sdw_slave *slave = dev_to_sdw_dev(dev);
so now it's difficult to add 'sdw_slave_device' and 'sdw_master_device' without quite a few changes.
Would this work for you if we used the following names:
sdw_slave (legacy shortcut for sdw_slave_device, which could be removed in a a future cleanup if desired). sdw_slave_driversdw_master_devicesdw_master_driver
and all the 'md' replaced by the full 'master_device'.
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 08/17] soundwire: add initial definitions for sdw_master_device
Quoted 9 lines · Pierre-Louis Bossart
Would this work for you if we used the following names:
sdw_slave(legacy shortcut forsdw_slave_device, which could be removed in a a future cleanup if desired).sdw_slave_driversdw_master_devicesdw_master_driverand all the 'md' replaced by the full '
master_device'.
That does sound nicer, thanks
Signature · 1 line
~Vinod
PATCH v5 9/17 soundwire: intel: remove platform devices and use 'Master Devices' instead
In reply to Pierre-Louis BossartUse sdw_master_device and driver instead of platform devices
To quote GregKH:
"Don't mess with a platform device unless you really have no other possible choice. And even then, don't do it and try to do something else. Platform devices are really abused, don't perpetuate it "
In addition, rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to verify hardware support for SoundWire, allocate required resources as early as possible, and conversely help make the startup() callback lighter-weight with only hardware register setup.
--- drivers/soundwire/intel.c | 91 ++++++----- drivers/soundwire/intel.h | 8 +- drivers/soundwire/intel_init.c | 275 ++++++++++++++++++++++++--------- 3 files changed, 267 insertions(+), 107 deletions(-)
drivers/soundwire/intel.c +55 -36
@@ -92,8 +92,6 @@#define SDW_ALH_STRMZCFG_DMAT GENMASK(7, 0)#define SDW_ALH_STRMZCFG_CHN GENMASK(19, 16) -#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1) -enum intel_pdi_type {INTEL_PDI_IN =0 ,INTEL_PDI_OUT =1 ,
@@ -923,24 +921,23 @@ static int intel_init(struct sdw_intel *sdw)/* * probe and init */ -static int intel_probe (struct platform_device *pdev) +static int intel_master_probe (struct sdw_master_device *md,void *link_ctx) { -struct sdw_cdns_stream_config config;struct sdw_intel *sdw;int ret; - sdw =devm_kzalloc (&pdev->dev,sizeof (*sdw),GFP_KERNEL ); + sdw =devm_kzalloc (&md->dev,sizeof (*sdw),GFP_KERNEL );if (!sdw)return -ENOMEM ; - sdw->instance = pdev->id; - sdw->link_res =dev_get_platdata (&pdev->dev); - sdw->cdns.dev = &pdev->dev; + sdw->instance = md->link_id; + sdw->link_res = link_ctx; + sdw->cdns.dev = &md->dev; sdw->cdns.registers = sdw->link_res->registers; - sdw->cdns.instance = sdw->instance; + sdw->cdns.instance = md->link_id; sdw->cdns.msg_count =0 ; - sdw->cdns.bus.dev = &pdev->dev; - sdw->cdns.bus.link_id = pdev->id; + sdw->cdns.bus.dev = &md->dev; + sdw->cdns.bus.link_id = md->link_id;sdw_cdns_probe (&sdw->cdns);
@@ -948,16 +945,50 @@ static int intel_probe(struct platform_device *pdev) sdw_intel_ops.read_prop = intel_prop_read; sdw->cdns.bus.ops = &sdw_intel_ops; -platform_set_drvdata (pdev, sdw); + md->pdata = sdw; + +/* set driver data, accessed by snd_soc_dai_set_drvdata() */ +dev_set_drvdata (&md->dev, &sdw->cdns); ret =sdw_add_bus_master (&sdw->cdns.bus);if (ret) { -dev_err (&pdev->dev,"sdw_add_bus_master fail: %d\n" , ret); +dev_err (&md->dev,"sdw_add_bus_master fail: %d\n" , ret);return ret; }if (sdw->cdns.bus.prop.hw_disabled) { -dev_info (&pdev->dev,"SoundWire master %d is disabled, ignoring\n" , +dev_info (&md->dev,"SoundWire master %d is disabled, ignoring\n" , + sdw->cdns.bus.link_id); +return 0 ; + } + +/* Acquire IRQ */ + ret =request_threaded_irq (sdw->link_res->irq, + sdw_cdns_irq, sdw_cdns_thread, +IRQF_SHARED ,KBUILD_MODNAME , &sdw->cdns); +if (ret <0 ) { +dev_err (sdw->cdns.dev,"unable to grab IRQ %d, disabling device\n" , + sdw->link_res->irq); + goto err_init; + } + +return 0 ; + +err_init: +sdw_delete_bus_master (&sdw->cdns.bus); +return ret; +} + +static int intel_master_startup (struct sdw_master_device *md) +{ +struct sdw_cdns_stream_config config; +struct sdw_intel *sdw; +int ret; + + sdw = md->pdata; + +if (sdw->cdns.bus.prop.hw_disabled) { +dev_info (&md->dev,"SoundWire master %d is disabled, ignoring\n" , sdw->cdns.bus.link_id);return 0 ; }
@@ -975,16 +1006,6 @@ static int intel_probe(struct platform_device *pdev)intel_pdi_ch_update (sdw); -/* Acquire IRQ */ - ret =request_threaded_irq (sdw->link_res->irq, - sdw_cdns_irq, sdw_cdns_thread, -IRQF_SHARED ,KBUILD_MODNAME , &sdw->cdns); -if (ret <0 ) { -dev_err (sdw->cdns.dev,"unable to grab IRQ %d, disabling device\n" , - sdw->link_res->irq); - goto err_init; - } - ret =sdw_cdns_enable_interrupt (&sdw->cdns, true);if (ret <0 ) {dev_err (sdw->cdns.dev,"cannot enable interrupts\n" );
@@ -1011,17 +1032,17 @@ static int intel_probe(struct platform_device *pdev) err_interrupt:sdw_cdns_enable_interrupt (&sdw->cdns, false); -free_irq (sdw->link_res->irq, sdw); err_init: +free_irq (sdw->link_res->irq, sdw);sdw_delete_bus_master (&sdw->cdns.bus);return ret; } -static int intel_remove (struct platform_device *pdev) +static int intel_master_remove (struct sdw_master_device *md) {struct sdw_intel *sdw; - sdw =platform_get_drvdata (pdev); + sdw = md->pdata;if (!sdw->cdns.bus.prop.hw_disabled) {intel_debugfs_exit (sdw);
@@ -1031,19 +1052,17 @@ static int intel_remove(struct platform_device *pdev) }sdw_delete_bus_master (&sdw->cdns.bus); +device_unregister (&md->dev); +return 0 ; } -static struct platform_driver sdw_intel_drv = { - .probe = intel_probe, - .remove = intel_remove, - .driver = { - .name ="int-sdw" , - - }, +struct sdw_md_driver intel_sdw_driver = { + .probe = intel_master_probe, + .startup = intel_master_startup, + .remove = intel_master_remove, }; - -module_platform_driver (sdw_intel_drv); +EXPORT_SYMBOL (intel_sdw_driver);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_ALIAS ("platform:int-sdw" );
drivers/soundwire/intel.h +6 -2
@@ -7,7 +7,7 @@/** * struct sdw_intel_link_res - Soundwire Intel link resource structure, * typically populated by the controller driver. -* @pdev: platform_device +* @md: master device * @mmio_base: mmio base of SoundWire registers * @registers: Link IO registers base * @shim: Audio shim pointer
@@ -17,7 +17,7 @@* @dev: device implementing hw_params and free callbacks */ struct sdw_intel_link_res { -struct platform_device *pdev; +struct sdw_master_device *md;void __iomem *mmio_base;/* not strictly needed, useful for debug */ void __iomem *registers;void __iomem *shim;
@@ -27,4 +27,8 @@ struct sdw_intel_link_res { struct device *dev; }; +#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1) + +extern struct sdw_md_driver intel_sdw_driver; +#endif /* __SDW_INTEL_LOCAL_H */
drivers/soundwire/intel_init.c +206 -69
390 lines not on this page · raw message
Signature · 1 line
2.20.1
Vinod Koul
maintainerRe: [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 14 lines · Pierre-Louis Bossart
Use
sdw_master_deviceand driver instead of platform devicesTo quote GregKH:
"Don't mess with a platform device unless you really have no other possible choice. And even then, don't do it and try to do something else. Platform devices are really abused, don't perpetuate it "
In addition, rather than a plain-vanilla init/exit, this patch provides 3 steps in the initialization (ACPI scan, probe, startup) which makes it easier to verify hardware support for SoundWire, allocate required resources as early as possible, and conversely help make the
startup()callback lighter-weight with only hardware register setup.
...
Quoted 5 lines
drivers/soundwire/intel.c +4
-0+struct sdw_md_driver intel_sdw_driver = { + .probe = intel_master_probe, + .startup = intel_master_startup, + .remove = intel_master_remove, };
...
Quoted 1 line
+extern struct
sdw_md_driverintel_sdw_driver;
who uses this intel_sdw_driver? I would assumed someone would register this with the core...
Quoted 82 lines
drivers/soundwire/intel_init.c +43
-19+static struct sdw_intel_ctx +*sdw_intel_probe_controller (struct sdw_intel_res *res) +{ +struct sdw_intel_link_res *link; +struct sdw_intel_ctx *ctx; +struct acpi_device *adev; +struct sdw_master_device *md; +u32 link_mask; +int count; +int i; + +if (!res) +return NULL ; + +if (acpi_bus_get_device (res->handle, &adev)) +return NULL ; + +if (!res->count) +return NULL ; + + count = res->count;dev_dbg (&adev->dev,"Creating %d SDW Link devices\n" , count); ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return NULL ; - ctx->count = count; - ctx->links =kcalloc (ctx->count,sizeof (*ctx->links),GFP_KERNEL ); + ctx->links =kcalloc (count,sizeof (*ctx->links),GFP_KERNEL );if (!ctx->links) goto link_err; + ctx->count = count; + ctx->mmio_base = res->mmio_base; + ctx->link_mask = res->link_mask; + ctx->handle = res->handle; + link = ctx->links; + link_mask = ctx->link_mask;/* Create SDW Master devices */ -for (i =0 ; i < count; i++) { -if (link_mask && !(link_mask &BIT (i))) { -dev_dbg (&adev->dev, -"Link %d masked, will not be enabled\n" , i); - link++; +for (i =0 ; i < count; i++, link++) { +if (link_mask && !(link_mask &BIT (i)))continue ; - } + md =sdw_md_add (&intel_sdw_driver, + res->parent, +acpi_fwnode_handle (adev), + i); + +if (IS_ERR (md)) { +dev_err (&adev->dev,"Could not create link %d\n" , i); + goto err; + } + link->md = md; + link->mmio_base = res->mmio_base; link->registers = res->mmio_base +SDW_LINK_BASE - + (SDW_LINK_SIZE * i); + + (SDW_LINK_SIZE * i); link->shim = res->mmio_base +SDW_SHIM_BASE ; link->alh = res->mmio_base +SDW_ALH_BASE ; - + link->irq = res->irq; link->ops = res->ops; link->dev = res->dev; -memset (&pdevinfo,0 ,sizeof (pdevinfo)); - - pdevinfo.parent = res->parent; - pdevinfo.name ="int-sdw" ; - pdevinfo.id = i; - pdevinfo.fwnode =acpi_fwnode_handle (adev); - - pdev =platform_device_register_full (&pdevinfo); -if (IS_ERR (pdev)) {
drivers/soundwire/intel_init.c static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) · line 204
Quoted 10 lines
drivers/soundwire/intel_init.c +2
-8-dev_err (&adev->dev, -"platform device creation failed: %ld\n" , -PTR_ERR (pdev)); - goto pdev_err; - } - - link->pdev = pdev; - link++; +/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);
So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
That reminds me I am missing match code for master driver...
So we seem to be somewhere is middle wrt driver probing here! IIUC this is not a full master driver, thats okay, but then it is not completely transparent either...
I was somehow thinking that the driver will continue to be 'platform/acpi/of' driver and master device abstraction will be handled in the core (for example see how the busses like i2c handle this). The master device is created and used to represent but driver probing etc is not done
Thoughts..?
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 6 lines
Quoted 3 lines
+extern struct
sdw_md_driverintel_sdw_driver;who uses this
intel_sdw_driver? I would assumed someone would register this with the core...
this is a structure used by intel_init(), see the following code.
+ md = sdw_md_add(&intel_sdw_driver,
+ res->parent,
+ acpi_fwnode_handle(adev),
+ i);
that will in turn call intel_master_probe() as defined below:
+struct sdw_md_driver intel_sdw_driver = {
+ .probe = intel_master_probe,
+ .startup = intel_master_startup,
+
Quoted 9 lines
drivers/soundwire/intel_init.c static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) · line 204
Quoted 4 lines
drivers/soundwire/intel_init.c +2
-2- link->pdev = pdev; - link++; +/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
That reminds me I am missing match code for master driver...
There is no match for the master because it doesn't have an existence in ACPI. There are no _ADR or HID that can be used, the only thing that exists is the Controller which has 4 sublinks. Each master must be added
by hand.
Also the SoundWire master cannot be enumerated or matched against a SoundWire bus, since it controls the bus itself (that would be a chicken and egg problem). The SoundWire master would need to be matched on a parent bus (which does not exist for Intel) since the hardware is embedded in a larger audio cluster that's visible on PCI only.
Currently for Intel platforms, the SoundWire master device is created by the SOF driver (via the abstraction in intel_init.c).
Quoted 9 lines
So we seem to be somewhere is middle wrt driver probing here! IIUC this is not a full master driver, thats okay, but then it is not completely transparent either...
I was somehow thinking that the driver will continue to be 'platform/acpi/of' driver and master device abstraction will be handled in the core (for example see how the busses like i2c handle this). The master device is created and used to represent but driver probing etc is not done
I2C controllers are typically PCI devices or have some sort of ACPI description. This is not the case for SoundWire masters on Intel platforms, so even if I wanted to I would have no ability to implement any matching or parent bus registration.
Also the notion of 'probe' does not necessarily mean that the device is attached to a bus, we use DAI 'drivers' in ASoC and still have probe/remove callbacks.
And if you look at the definitions, we added additional callbacks since probe/remove are not enough to deal with hardware restrictions:
For Intel platforms, we have a startup() callback which is only invoked once the DSP is powered and the rails stable. Likewise we added an 'autonomous_clock_stop()' callback which will be needed when the Linux driver hands-over control of the hardware to the DSP firmware, e.g. to deal with in-band wakes in D0i3.
FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
[1] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 35 lines · Pierre-Louis Bossart
Quoted 6 lines
Quoted 3 lines
+extern struct
sdw_md_driverintel_sdw_driver;who uses this
intel_sdw_driver? I would assumed someone would register this with the core...this is a structure used by
intel_init(), see the following code.drivers/soundwire/intel_init.c +4
-0+ md =sdw_md_add (&intel_sdw_driver, + res->parent, +acpi_fwnode_handle (adev), + i);that will in turn call
intel_master_probe()as defined below:drivers/soundwire/intel.c +4
-0+struct sdw_md_driver intel_sdw_driver = { + .probe = intel_master_probe, + .startup = intel_master_startup, +Quoted 10 lines
drivers/soundwire/intel_init.c static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) · line 204
Quoted 5 lines
drivers/soundwire/intel_init.c +2
-2- link->pdev = pdev; - link++; +/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
That reminds me I am missing match code for master driver...
There is no match for the master because it doesn't have an existence in ACPI. There are no
_ADRor HID that can be used, the only thing that exists is the Controller which has 4 sublinks. Each master must be added by hand.
Quoted 8 lines
Also the SoundWire master cannot be enumerated or matched against a SoundWire bus, since it controls the bus itself (that would be a chicken and egg problem). The SoundWire master would need to be matched on a parent bus (which does not exist for Intel) since the hardware is embedded in a larger audio cluster that's visible on PCI only.
Currently for Intel platforms, the SoundWire master device is created by the SOF driver (via the abstraction in
intel_init.c).
That is okay for me, the thing that is bit confusing is having a probe etc and no match.. (more below)..
Quoted 4 lines
Quoted 4 lines
So we seem to be somewhere is middle wrt driver probing here! IIUC this is not a full master driver, thats okay, but then it is not completely transparent either...
Quoted 8 lines
Quoted 5 lines
I was somehow thinking that the driver will continue to be 'platform/acpi/of' driver and master device abstraction will be handled in the core (for example see how the busses like i2c handle this). The master device is created and used to represent but driver probing etc is not done
I2C controllers are typically PCI devices or have some sort of ACPI description. This is not the case for SoundWire masters on Intel platforms,
Well the world is not PCI/ACPI... We have controllers which are DT described and work in same manner as a PCI device.
Quoted 6 lines
so even if I wanted to I would have no ability to implement any matching or parent bus registration.
Also the notion of 'probe' does not necessarily mean that the device is attached to a bus, we use DAI 'drivers' in ASoC and still have probe/remove callbacks.
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
Quoted 9 lines
And if you look at the definitions, we added additional callbacks since probe/remove are not enough to deal with hardware restrictions:
For Intel platforms, we have a
startup()callback which is only invoked once the DSP is powered and the rails stable. Likewise we added an 'autonomous_clock_stop()' callback which will be needed when the Linux driver hands-over control of the hardware to the DSP firmware, e.g. to deal with in-band wakes in D0i3.
Quoted 7 lines
FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124
And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 35 lines
Quoted 13 lines
Quoted 8 lines
drivers/soundwire/intel_init.c static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) · line 204
Quoted 3 lines
drivers/soundwire/intel_init.c +2
-0+/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
That reminds me I am missing match code for master driver...
There is no match for the master because it doesn't have an existence in ACPI. There are no
_ADRor HID that can be used, the only thing that exists is the Controller which has 4 sublinks. Each master must be added by hand.Quoted 8 lines
Also the SoundWire master cannot be enumerated or matched against a SoundWire bus, since it controls the bus itself (that would be a chicken and egg problem). The SoundWire master would need to be matched on a parent bus (which does not exist for Intel) since the hardware is embedded in a larger audio cluster that's visible on PCI only.
Currently for Intel platforms, the SoundWire master device is created by the SOF driver (via the abstraction in
intel_init.c).That is okay for me, the thing that is bit confusing is having a probe etc and no match.. (more below)..
Quoted 10 lines
Quoted 9 lines
So we seem to be somewhere is middle wrt driver probing here! IIUC this is not a full master driver, thats okay, but then it is not completely transparent either...
I was somehow thinking that the driver will continue to be 'platform/acpi/of' driver and master device abstraction will be handled in the core (for example see how the busses like i2c handle this). The master device is created and used to represent but driver probing etc is not done
Quoted 5 lines
Quoted 2 lines
I2C controllers are typically PCI devices or have some sort of ACPI description. This is not the case for SoundWire masters on Intel platforms,
Well the world is not PCI/ACPI... We have controllers which are DT described and work in same manner as a PCI device.
Both DT and PCI would use a DIFFERENT matching on the parent bus, not a matching provided by the SoundWire subsystem itself.
Quoted 10 lines
Quoted 7 lines
so even if I wanted to I would have no ability to implement any matching or parent bus registration.
Also the notion of 'probe' does not necessarily mean that the device is attached to a bus, we use DAI 'drivers' in ASoC and still have probe/remove callbacks.
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
What I did is not different from what existed already with platform devices. They were manually created, weren't they?
Quoted 14 lines
Quoted 14 lines
And if you look at the definitions, we added additional callbacks since probe/remove are not enough to deal with hardware restrictions:
For Intel platforms, we have a
startup()callback which is only invoked once the DSP is powered and the rails stable. Likewise we added an 'autonomous_clock_stop()' callback which will be needed when the Linux driver hands-over control of the hardware to the DSP firmware, e.g. to deal with in-band wakes in D0i3.FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
Quoted 7 lines
Quoted 3 lines
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Please look at the code again, you have a USB probe that will manually call the GreyBus device creation.
static int ap_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
hd = gb_hd_create(&es2_driver, &udev->dev, static struct usb_driver es2_ap_driver = {
.name = "es2_ap_driver",
.probe = ap_probe, <<< code above
.disconnect = ap_disconnect,
.id_table = id_table,
.soft_unbind = 1,
};The master device probe suggested here is also called as part of the parent SOF PCI device probe, same as this USB example. I really don't see what your objection is, given that there is no way to deal with the SoundWire controller as a independent entity for Intel platforms.
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 51 lines · Pierre-Louis Bossart
Quoted 35 lines
Quoted 13 lines
Quoted 8 lines
drivers/soundwire/intel_init.c static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) · line 204
Quoted 3 lines
drivers/soundwire/intel_init.c +2
-0+/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
That reminds me I am missing match code for master driver...
There is no match for the master because it doesn't have an existence in ACPI. There are no
_ADRor HID that can be used, the only thing that exists is the Controller which has 4 sublinks. Each master must be added by hand.Quoted 8 lines
Also the SoundWire master cannot be enumerated or matched against a SoundWire bus, since it controls the bus itself (that would be a chicken and egg problem). The SoundWire master would need to be matched on a parent bus (which does not exist for Intel) since the hardware is embedded in a larger audio cluster that's visible on PCI only.
Currently for Intel platforms, the SoundWire master device is created by the SOF driver (via the abstraction in
intel_init.c).That is okay for me, the thing that is bit confusing is having a probe etc and no match.. (more below)..
Quoted 10 lines
Quoted 9 lines
So we seem to be somewhere is middle wrt driver probing here! IIUC this is not a full master driver, thats okay, but then it is not completely transparent either...
I was somehow thinking that the driver will continue to be 'platform/acpi/of' driver and master device abstraction will be handled in the core (for example see how the busses like i2c handle this). The master device is created and used to represent but driver probing etc is not done
Quoted 5 lines
Quoted 2 lines
I2C controllers are typically PCI devices or have some sort of ACPI description. This is not the case for SoundWire masters on Intel platforms,
Well the world is not PCI/ACPI... We have controllers which are DT described and work in same manner as a PCI device.
Both DT and PCI would use a DIFFERENT matching on the parent bus, not a matching provided by the SoundWire subsystem itself.
Quoted 8 lines
Quoted 7 lines
so even if I wanted to I would have no ability to implement any matching or parent bus registration.
Also the notion of 'probe' does not necessarily mean that the device is attached to a bus, we use DAI 'drivers' in ASoC and still have probe/remove callbacks.
Quoted 5 lines
Quoted 2 lines
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
What I did is not different from what existed already with platform devices. They were manually created, weren't they?
Manual creation of device based on a requirement is different, did I ask you why you are creating device :)
I am simple asking you not to call probe in the driver. If you need that, move it to core! We do not want these kind of things in the drivers...
Quoted 30 lines
Quoted 13 lines
Quoted 13 lines
And if you look at the definitions, we added additional callbacks since probe/remove are not enough to deal with hardware restrictions:
For Intel platforms, we have a
startup()callback which is only invoked once the DSP is powered and the rails stable. Likewise we added an 'autonomous_clock_stop()' callback which will be needed when the Linux driver hands-over control of the hardware to the DSP firmware, e.g. to deal with in-band wakes in D0i3.FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
Quoted 7 lines
Quoted 3 lines
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Please look at the code again, you have a USB probe that will manually call the GreyBus device creation.
static int ap_probe(struct
usb_interface*interface,
const structusb_device_id*id){ hd = gb_hd_create(&es2_driver, &udev->dev,
Quoted 7 lines
static struct usb_driver es2_ap_driver = {
.name = "es2_ap_driver",
.probe = ap_probe, <<< code above
.disconnect = ap_disconnect,
.id_table = id_table,
.soft_unbind = 1,
};Look closely the driver es2 calls into greybus core hd.c and gets the work done, subtle but a big differances in the approaches..
Quoted 4 lines
The master device probe suggested here is also called as part of the parent SOF PCI device probe, same as this USB example. I really don't see what your objection is, given that there is no way to deal with the SoundWire controller as a independent entity for Intel platforms.
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
What I did is not different from what existed already with platform devices. They were manually created, weren't they?
Quoted 6 lines
Manual creation of device based on a requirement is different, did I ask you why you are creating device :)
I am simple asking you not to call probe in the driver. If you need that, move it to core! We do not want these kind of things in the drivers...
What core are you talking about?
The SOF intel driver needs to create a device, which will then be bound with a SoundWire master driver.
What I am doing is no different from what your team did with platform_register_device, I am really lost on what you are asking.
Quoted 29 lines
Quoted 21 lines
Quoted 11 lines
Quoted 7 lines
FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Please look at the code again, you have a USB probe that will manually call the GreyBus device creation.
static int ap_probe(struct
usb_interface*interface,
const structusb_device_id*id){ hd = gb_hd_create(&es2_driver, &udev->dev,Quoted 7 lines
static struct usb_driver es2_ap_driver = { .name = "es2_ap_driver", .probe = ap_probe, <<< code above .disconnect = ap_disconnect, .id_table = id_table, .soft_unbind = 1, };
Quoted 2 lines
Look closely the driver es2 calls into greybus core
hd.cand gets the work done, subtle but a big differances in the approaches..
I am sorry, I have absolutely no idea what you are referring to.
The code I copy/pasted here makes no call to the greybus core, it's ap_probe -> gb_hd_create. No core involved. If I am mistaken, please show me what I got wrong.
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 7 lines · Pierre-Louis Bossart
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
What I did is not different from what existed already with platform devices. They were manually created, weren't they?
Quoted 8 lines
Quoted 6 lines
Manual creation of device based on a requirement is different, did I ask you why you are creating device :)
I am simple asking you not to call probe in the driver. If you need that, move it to core! We do not want these kind of things in the drivers...
What core are you talking about?
soundwire core ofcourse! IMO All that which goes into soundwire-bus-objs is considered as soundwire core part and rest are drivers intel, qc, so on!
Quoted 6 lines
The SOF intel driver needs to create a device, which will then be bound with a SoundWire master driver.
What I am doing is no different from what your team did with
platform_register_device, I am really lost on what you are asking.
Again repeating myself, you call an API to do that is absolutely fine, but we don't do that in drivers or open code these things
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 11 lines
Quoted 7 lines
FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Please look at the code again, you have a USB probe that will manually call the GreyBus device creation.
static int ap_probe(struct
usb_interface*interface,
const structusb_device_id*id){ hd = gb_hd_create(&es2_driver, &udev->dev,static struct usb_driver es2_ap_driver = { .name = "es2_ap_driver", .probe = ap_probe, <<< code above .disconnect = ap_disconnect, .id_table = id_table, .soft_unbind = 1, };
Quoted 8 lines
Quoted 2 lines
Look closely the driver es2 calls into greybus core
hd.cand gets the work done, subtle but a big differances in the approaches..I am sorry, I have absolutely no idea what you are referring to.
The code I copy/pasted here makes no call to the greybus core, it's
ap_probe->gb_hd_create. No core involved. If I am mistaken, please show me what I got wrong.
1. es2_ap_driver is host controller driver
2. gb_hd_create() is an API provided by greybus core!
es2 driver doesn't open code creation like you are doing in intel driver, it doesn't call probe on its own, greybus does that
This is very common pattern in linux kernel subsytems, drivers dont do these things, the respective subsystem core does that... see about es2 driver and implementation of gb_hd_create(). See callers of platform_register_device() and its implementation.
I don't know how else I can explain this to you, is something wrong in how I conveyed this info or you... or something else, I dont know!!!
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 11 lines · Vinod Koul
Quoted 10 lines · Pierre-Louis Bossart
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
What I did is not different from what existed already with platform devices. They were manually created, weren't they?
Manual creation of device based on a requirement is different, did I ask you why you are creating device :)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I am simple asking you not to call probe in the driver. If you need that, move it to core! We do not want these kind of things in the drivers...
What core are you talking about?
soundwire core ofcourse! IMO All that which goes into soundwire-bus-objs is considered as soundwire core part and rest are drivers intel, qc, so on!
This master code was added to the bus: v
v
soundwire-bus-objs := bus_type.o bus.o master.o slave.o mipi_disco.o stream.o obj-$(CONFIG_SOUNDWIRE) += soundwire-bus.o
and the API is also part of the sdw.h include file. That seems to meet exactly what you describe above, no?
git grep sdw_master_device_add (reformatted output)
drivers/soundwire/intel_init.c:
md = sdw_master_device_add(&intel_sdw_driver,
drivers/soundwire/master.c:
*sdw_master_device_add(struct sdw_master_driver *driver,
drivers/soundwire/master.c:EXPORT_SYMBOL_GPL(sdw_master_device_add);
include/linux/soundwire/sdw.h:
*sdw_master_device_add(struct sdw_master_driver *driver,
So, what exactly is the issue?
We are not 'calling the probe in the [Intel] driver' as you state it, we use a SoundWire core API which in turn will create a device. The device core takes care of calling the probe, see the master.c code which is NOT Intel-specific.
Quoted 9 lines
Quoted 6 lines
The SOF intel driver needs to create a device, which will then be bound with a SoundWire master driver.
What I am doing is no different from what your team did with
platform_register_device, I am really lost on what you are asking.Again repeating myself, you call an API to do that is absolutely fine, but we don't do that in drivers or open code these things
That is still quite unclear, what 'open-coding' are you referring to?
I am starting to wonder if you missed the addition of the master functionality in the previous patch:
[PATCH v5 08/17] soundwire: add initial definitions for sdw_master_device
What this patch 9 does is call the core-defined API and implement the intel-specific master driver.
Quoted 35 lines
Quoted 35 lines
Quoted 30 lines
Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
Quoted 7 lines
Quoted 3 lines
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Please look at the code again, you have a USB probe that will manually call the GreyBus device creation.
static int ap_probe(struct
usb_interface*interface,
const structusb_device_id*id){ hd = gb_hd_create(&es2_driver, &udev->dev,Quoted 7 lines
static struct usb_driver es2_ap_driver = { .name = "es2_ap_driver", .probe = ap_probe, <<< code above .disconnect = ap_disconnect, .id_table = id_table, .soft_unbind = 1, };Quoted 2 lines
Look closely the driver es2 calls into greybus core
hd.cand gets the work done, subtle but a big differances in the approaches..I am sorry, I have absolutely no idea what you are referring to.
Quoted 7 lines
Quoted 3 lines
The code I copy/pasted here makes no call to the greybus core, it's
ap_probe->gb_hd_create. No core involved. If I am mistaken, please show me what I got wrong.1.
es2_ap_driveris host controller driver2.
gb_hd_create()is an API provided by greybus core!
same in my code...
Quoted 11 lines
es2 driver doesn't open code creation like you are doing in intel driver, it doesn't call probe on its own, greybus does that
This is very common pattern in linux kernel subsytems, drivers dont do these things, the respective subsystem core does that... see about es2 driver and implementation of
gb_hd_create(). See callers ofplatform_register_device()and its implementation.I don't know how else I can explain this to you, is something wrong in how I conveyed this info or you... or something else, I dont know!!!
the new 'master' functionality is part of the bus code, so please clarify what you see as problematic for the partition.
Vinod Koul
maintainerRe: [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 63 lines · Pierre-Louis Bossart
Quoted 11 lines · Vinod Koul
Quoted 10 lines · Pierre-Louis Bossart
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
The "big" difference is that probe is called by core (asoc) and not by driver onto themselves.. IMO that needs to go away.
What I did is not different from what existed already with platform devices. They were manually created, weren't they?
Manual creation of device based on a requirement is different, did I ask you why you are creating device :)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I am simple asking you not to call probe in the driver. If you need that, move it to core! We do not want these kind of things in the drivers...
What core are you talking about?
soundwire core ofcourse! IMO All that which goes into soundwire-bus-objs is considered as soundwire core part and rest are drivers intel, qc, so on!
This master code was added to the bus: v
v
soundwire-bus-objs := bus_type.o bus.o master.o slave.o mipi_disco.o stream.o
obj-$(CONFIG_SOUNDWIRE) += soundwire-bus.oand the API is also part of the
sdw.hinclude file. That seems to meet exactly what you describe above, no?git grep
sdw_master_device_add(reformatted output)
drivers/soundwire/intel_init.c:
md = sdw_master_device_add(&intel_sdw_driver,
drivers/soundwire/master.c:
*sdw_master_device_add(structsdw_master_driver*driver,
drivers/soundwire/master.c:EXPORT_SYMBOL_GPL(sdw_master_device_add);
include/linux/soundwire/sdw.h:
*sdw_master_device_add(structsdw_master_driver*driver,So, what exactly is the issue?
We are not 'calling the probe in the [Intel] driver' as you state it, we use a SoundWire core API which in turn will create a device. The device core takes care of calling the probe, see the
master.ccode which is NOT Intel-specific.Quoted 9 lines
Quoted 6 lines
The SOF intel driver needs to create a device, which will then be bound with a SoundWire master driver.
What I am doing is no different from what your team did with
platform_register_device, I am really lost on what you are asking.Again repeating myself, you call an API to do that is absolutely fine, but we don't do that in drivers or open code these things
That is still quite unclear, what 'open-coding' are you referring to?
Quoted 7 lines
I am starting to wonder if you missed the addition of the master functionality in the previous patch:
[PATCH v5 08/17] soundwire: add initial definitions for
sdw_master_deviceWhat this patch 9 does is call the core-defined API and implement the intel-specific master driver.
Yes and no, it does call things introduced in patch 8, I questioned calling probe! See below!
Quoted 53 lines
Quoted 34 lines
Quoted 34 lines
Quoted 29 lines
Quoted 21 lines
Quoted 11 lines
Quoted 7 lines
FWIW, the implementation here follows what was suggested for Greybus 'Host Devices' [1] [2], so it's not like I am creating any sort of dangerous precedent.
[1]
https://elixir.bootlin.com/linux/latest/source/drivers/greybus/es2.c#L1275
[2] https://elixir.bootlin.com/linux/latest/source/drivers/greybus/hd.c#L124And if you look closely all this work is done by core not by drivers! Drivers _should_ never do all this, it is the job of core to do that for you.
Please look at the code again, you have a USB probe that will manually call the GreyBus device creation.
static int ap_probe(struct
usb_interface*interface,
const structusb_device_id*id){ hd = gb_hd_create(&es2_driver, &udev->dev,Quoted 7 lines
static struct usb_driver es2_ap_driver = { .name = "es2_ap_driver", .probe = ap_probe, <<< code above .disconnect = ap_disconnect, .id_table = id_table, .soft_unbind = 1, };Quoted 2 lines
Look closely the driver es2 calls into greybus core
hd.cand gets the work done, subtle but a big differances in the approaches..I am sorry, I have absolutely no idea what you are referring to.
Quoted 7 lines
Quoted 3 lines
The code I copy/pasted here makes no call to the greybus core, it's
ap_probe->gb_hd_create. No core involved. If I am mistaken, please show me what I got wrong.1.
es2_ap_driveris host controller driver2.
gb_hd_create()is an API provided by greybus core!same in my code...
Quoted 9 lines
es2 driver doesn't open code creation like you are doing in intel driver, it doesn't call probe on its own, greybus does that
This is very common pattern in linux kernel subsytems, drivers dont do these things, the respective subsystem core does that... see about es2 driver and implementation of
gb_hd_create(). See callers ofplatform_register_device()and its implementation.
Quoted 4 lines
Quoted 2 lines
I don't know how else I can explain this to you, is something wrong in how I conveyed this info or you... or something else, I dont know!!!
the new 'master' functionality is part of the bus code, so please clarify what you see as problematic for the partition.
I am quoting the code in patch, which i pointed in my first reply!
drivers/soundwire/intel_init.c
Quoted 3 lines · Pierre-Louis Bossart
drivers/soundwire/intel_init.c +0
-1--- a/drivers/soundwire/intel_init.c
This is intel specific file...
Quoted 1 line
+++
b/drivers/soundwire/intel_init.c
snip ...
drivers/soundwire/intel_init.c
Quoted 2 lines
drivers/soundwire/intel_init.c +2
-0+static struct sdw_intel_ctx +*sdw_intel_probe_controller (struct sdw_intel_res *res)
this is intel driver, intel function!
drivers/soundwire/intel_init.c
Quoted 5 lines
drivers/soundwire/intel_init.c +2
-3- - link->pdev = pdev; - link++; +/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);
^^^^^^
which does this... calls a probe()!
And my first reply was:
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* let the SoundWire master driver to its probe */ + md->driver->probe(md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
I rest my case!
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 30 lines
I am quoting the code in patch, which i pointed in my first reply!
drivers/soundwire/intel_init.c
Quoted 3 lines · Pierre-Louis Bossart
drivers/soundwire/intel_init.c +0
-1--- a/drivers/soundwire/intel_init.cThis is intel specific file...
Quoted 1 line
+++
b/drivers/soundwire/intel_init.csnip ...
drivers/soundwire/intel_init.c
Quoted 2 lines
drivers/soundwire/intel_init.c +2
-0+static struct sdw_intel_ctx +*sdw_intel_probe_controller (struct sdw_intel_res *res)this is intel driver, intel function!
drivers/soundwire/intel_init.c
Quoted 5 lines
drivers/soundwire/intel_init.c +2
-3- - link->pdev = pdev; - link++; +/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);^^^^^^which does this... calls a
probe()!And my first reply was:
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* let the SoundWire master driver to its probe */ + md->driver->probe(md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
I rest my case!
I think you are too focused on the probe case and not realizing the extensions suggested by this patchset. A "driver" is not limited to 'probe' and 'remove' cases.
As mentioned since mid-September, there is a need for an initialization of software/kernel structures (which I called probe but should have been called init really), and a second step where the hardware is actually configured - after all power rail dependencies are under control.
Can you please look at the .startup callback and let me know how a 'driver core' would handle this?
To the best of my knowledge, there is no .startup in any device model functionality, so the only thing I could do to avoid a direct call is add a wrapper to avoid a direct call, e.g.
static inline sdw_master_device_startup(struct sdw_master_device *md)
{
if (md && md->driver && md->driver->startup)
md->driver->startup(md);
}Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 38 lines · Pierre-Louis Bossart
Quoted 30 lines
I am quoting the code in patch, which i pointed in my first reply!
drivers/soundwire/intel_init.c
Quoted 3 lines · Pierre-Louis Bossart
drivers/soundwire/intel_init.c +0
-1--- a/drivers/soundwire/intel_init.cThis is intel specific file...
Quoted 1 line
+++
b/drivers/soundwire/intel_init.csnip ...
drivers/soundwire/intel_init.c
Quoted 2 lines
drivers/soundwire/intel_init.c +2
-0+static struct sdw_intel_ctx +*sdw_intel_probe_controller (struct sdw_intel_res *res)this is intel driver, intel function!
drivers/soundwire/intel_init.c
Quoted 5 lines
drivers/soundwire/intel_init.c +2
-3- - link->pdev = pdev; - link++; +/* let the SoundWire master driver to its probe */ + md->driver->probe (md, link);^^^^^^which does this... calls a
probe()!And my first reply was:
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* let the SoundWire master driver to its probe */ + md->driver->probe(md, link);So you are invoking driver probe here.. That is typically role of driver core to do that.. If we need that, make driver core do that for you!
I rest my case!
Quoted 7 lines
I think you are too focused on the probe case and not realizing the extensions suggested by this patchset. A "driver" is not limited to 'probe' and 'remove' cases.
As mentioned since mid-September, there is a need for an initialization of software/kernel structures (which I called probe but should have been called init really), and a second step where the hardware is actually configured -
I find it amusing that a person whom i admired for strict use of terms can get this differently!
A rename away from probe will certainly be very helpful as you would also agree that terms 'probe' and 'remove' have a very special meaning in kernel, so let us avoid these
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 4 lines
A rename away from probe will certainly be very helpful as you would also agree that terms 'probe' and 'remove' have a very special meaning in kernel, so let us avoid these
ok, so would the following be ok with you?
/**
* struct sdw_md_driver - SoundWire 'Master Device' driver
*
* @init: allocations and initializations (hardware may not be enabled yet)
* @startup: initialization handled after the hardware is enabled, all
* clock/power dependencies are available
* @shutdown: cleanups before hardware is disabled (optional)
* @exit: free all remaining resources
* @autonomous_clock_stop_enable: enable/disable driver control while
* in clock-stop mode, typically in always-on/D0ix modes. When the driver
* yields control, another entity in the system (typically firmware
* running on an always-on microprocessor) is responsible to tracking
* Slave-initiated wakes
*/
struct sdw_md_driver {
int (*init)(struct sdw_master_device *md, void *link_ctx);
int (*startup)(struct sdw_master_device *md);
int (*shutdown)(struct sdw_master_device *md);
int (*exit)(struct sdw_master_device *md);
int (*autonomous_clock_stop_enable)(struct sdw_master_device *md,
bool state);
};Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Hi Pierre,
I took some time to look into the overall code and how this is fitting into big picture and help recommend way forward.
Quoted 22 lines · Pierre-Louis Bossart
Quoted 5 lines
A rename away from probe will certainly be very helpful as you would also agree that terms 'probe' and 'remove' have a very special meaning in kernel, so let us avoid these
ok, so would the following be ok with you?
/**
* structsdw_md_driver- SoundWire 'Master Device' driver
*
* @init: allocations and initializations (hardware may not be enabled yet)
* @startup: initialization handled after the hardware is enabled, all
* clock/power dependencies are available
* @shutdown: cleanups before hardware is disabled (optional)
* @exit: free all remaining resources
* @autonomous_clock_stop_enable: enable/disable driver control while
* in clock-stop mode, typically in always-on/D0ix modes. When the driver
* yields control, another entity in the system (typically firmware
* running on an always-on microprocessor) is responsible to tracking
* Slave-initiated wakes
*/
Quoted 8 lines
struct sdw_md_driver {
int (*init)(struct sdw_master_device *md, void *link_ctx);
int (*startup)(struct sdw_master_device *md);
int (*shutdown)(struct sdw_master_device *md);
int (*exit)(struct sdw_master_device *md);
int (*autonomous_clock_stop_enable)(struct sdw_master_device *md,
bool state);
};So this is a soundwire core driver structure, but the modelling and explanation provided here suggests the reasoning to be based on hardware sequencing. I am not sure if we should follow this approach. Solving hardware sequencing is fine but that should IMO be restricted to intel code as that is intel issue which may or may not be present on other controllers.
If I look at the calling sequence of the code (looked up the sof code on github, topic/sof-dev-rebase), the sof code sound/soc/sof/intel/hda.c invokes the sdw_intel_startup() and sdw_intel_probe() based on hardware sequencing and further you call .init and .probe/startup of sdw_md_driver.
I really do not see why we need a sdw_md_driver object to do that. You can easily have a another function exported by sdw_intel driver and you call these and do same functionality without having a sdw_md_driver in between.
Now, I am going to step back one more step and ask you why should we have a sdw_md_driver? I am not seeing the driver object achieving anything here expect adding wrappers which we can avoid. But we still need to add the sdw_master_device() as a new device object and use that for both sysfs representation as well as representing the master device and do all the things we want, but it *can* come without having accompanying sdw_md_driver.
This way you can retain you calling sequence and add the master device.
Stretching this one more step I would ask that maybe it is even better idea that we should hide sdw_master_device_add() calling for soundwire drivers and move that internal to bus as part of bus registration as well, I don't see sdw_master_device calling back into the driver so it should not impact your sequences as well.
Do you see a reason for sdw_md_driver which is must have? I couldn't find that by looking at the code, let me know if I have missed anything here.
So to summarize, my recommendation would be to drop sdw_md_driver, keep sdw_master_device object and make sdw_master_device_add() hidden to driver and call it from sdw_add_bus_master() and keep intel specific startup/init routine which do same steps as they have now.
Thanks
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 4 lines · Vinod Koul
Hi Pierre,
I took some time to look into the overall code and how this is fitting into big picture and help recommend way forward.
Thanks Vinod, I appreciate the time you've taken to review this code. This is constructive feedback.
Quoted 32 lines · Pierre-Louis Bossart
Quoted 22 lines
Quoted 5 lines
A rename away from probe will certainly be very helpful as you would also agree that terms 'probe' and 'remove' have a very special meaning in kernel, so let us avoid these
ok, so would the following be ok with you?
/**
* structsdw_md_driver- SoundWire 'Master Device' driver
*
* @init: allocations and initializations (hardware may not be enabled yet)
* @startup: initialization handled after the hardware is enabled, all
* clock/power dependencies are available
* @shutdown: cleanups before hardware is disabled (optional)
* @exit: free all remaining resources
* @autonomous_clock_stop_enable: enable/disable driver control while
* in clock-stop mode, typically in always-on/D0ix modes. When the driver
* yields control, another entity in the system (typically firmware
* running on an always-on microprocessor) is responsible to tracking
* Slave-initiated wakes
*/Quoted 8 lines
struct sdw_md_driver { int (*init)(struct sdw_master_device *md, void *link_ctx); int (*startup)(struct sdw_master_device *md); int (*shutdown)(struct sdw_master_device *md); int (*exit)(struct sdw_master_device *md); int (*autonomous_clock_stop_enable)(struct sdw_master_device *md, bool state); };
Quoted 6 lines
So this is a soundwire core driver structure, but the modelling and explanation provided here suggests the reasoning to be based on hardware sequencing. I am not sure if we should follow this approach. Solving hardware sequencing is fine but that should IMO be restricted to intel code as that is intel issue which may or may not be present on other controllers.
I agree the directions are Intel-specific, there was no intention of requiring anyone to implement all these callbacks.
Quoted 9 lines
If I look at the calling sequence of the code (looked up the sof code on github, topic/sof-dev-rebase), the sof code
sound/soc/sof/intel/hda.cinvokes thesdw_intel_startup()andsdw_intel_probe()based on hardware sequencing and further you call .init and .probe/startup ofsdw_md_driver.I really do not see why we need a
sdw_md_driverobject to do that. You can easily have a another function exported bysdw_inteldriver and you call these and do same functionality without having asdw_md_driverin between.
I must admit I am beyond my comfort zone: I introduced this sdw_master_driver only based on Greg's recommendation to look at GreyBus.
All I care about are the three steps of
a. creating a device (needed because the ACPI description does not model the master hardware) b. doing the required initializations and allocations
c. exposing a startup callback, and provide room for expansion for future evolutions.
If there's a better way to do this I don't mind at all. The value-added of these patches is not in how the device/driver model is used but rather the hardware sequencing and power management.
That said, I have two key points that I should explain further.
When we started this work, we initially did not have a notion of 'master driver' coupled with the 'master_device'. But we faced a number of issues with ASoC registrations, which seemed to required a driver to be registered and associated with the device. We kept this part as a separate commit to make sure this requirement wasn't lost:
https://github.com/thesofproject/linux/commit/28b934ce9c165e095dac5cf71da5685768831337
Looking back at my notes, this came from this piece of code:
static char *fmt_single_name(struct device *dev, int *id)
{
char *found, name[NAME_SIZE];
int id1, id2;
if (dev_name(dev) == NULL)
return NULL;
strlcpy(name, dev_name(dev), NAME_SIZE);
/* are we a "%s.%d" name (platform and SPI components) */
found = strstr(name, dev->driver->name); <<< oopsso for ASoC, there is an expectation that each device does have a driver associated with it. Just for fun I reverted the commit above and that immediately trigger an kernel oops.
The other point that we came across is that PM support is only enabled thanks to a hook in the driver structure:
static const struct dev_pm_ops intel_pm = {
SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume) SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
};
struct sdw_master_driver intel_sdw_driver = {
.driver = {
.name = "intel-sdw",
.owner = THIS_MODULE,
.bus = &sdw_bus_type,
.pm = &intel_pm, <<<<
},
.probe = intel_master_probe,
.startup = intel_master_startup,
.process_wake_event = intel_master_process_wakeen_event,
.remove = intel_master_remove,
};I am not aware of any other way to do this.
In short, I have two technical reasons we came across that made us rely on this 'master driver' object. I agree that the solution I suggested may not be very elegant or can be seen as overkill, but it does provide support for two integration requirements.
Quoted 16 lines
Now, I am going to step back one more step and ask you why should we have a
sdw_md_driver? I am not seeing the driver object achieving anything here expect adding wrappers which we can avoid. But we still need to add thesdw_master_device()as a new device object and use that for both sysfs representation as well as representing the master device and do all the things we want, but it *can* come without having accompanyingsdw_md_driver.This way you can retain you calling sequence and add the master device.
Stretching this one more step I would ask that maybe it is even better idea that we should hide
sdw_master_device_add()calling for soundwire drivers and move that internal to bus as part of bus registration as well, I don't seesdw_master_devicecalling back into the driver so it should not impact your sequences as well.
Quoted 3 lines
Do you see a reason for
sdw_md_driverwhich is must have? I couldn't find that by looking at the code, let me know if I have missed anything here.
Yes, the two reasons explained above.
That said, one possible compromize would be to remove those callbacks and indirections, such md->driver->remove(md);
we could perfectly export something like
intel_device_remove(md)
which would directly call the relevant functions. that would essentially remove the notion of 'sdw_master_driver' but keep the bare minimal driver structure that's needed.
Note that the removal of platform devices is not something I wanted to enforce across the board. If Qualcomm are happy with the platform devices, that's fine with me. I only want to work around the two limitations I mentioned (ACPI does not support masters, only controllers, and power rail dependencies).
Quoted 4 lines
So to summarize, my recommendation would be to drop
sdw_md_driver, keepsdw_master_deviceobject and makesdw_master_device_add()hidden to driver and call it fromsdw_add_bus_master()and keep intel specific startup/init routine which do same steps as they have now.
I am afraid the sequence you suggest is not technically possible: sdw_add_bus_master() requires a device to be created already, see e.g. how it's used by Qualcomm:
sdw_add_bus_master() is called from the platform device probe. I cannot insert a device creation in this code.
It'd actually be counter productive to add device management at the bus level, since we'd soon have incompatibilities between Intel, Qualcomm and others. What is platform-specific should be handled outside of the bus layer.
I hope this email clarifies some of my points?
I'll try to nooddle with the notion of bare minimum driver, that looks like a possible alternative that solves my problems and would address your concerns.
Thanks
-Pierre
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Hi Pierre,
Quoted 24 lines · Pierre-Louis Bossart
Quoted 9 lines
Quoted 8 lines
struct sdw_md_driver { int (*init)(struct sdw_master_device *md, void *link_ctx); int (*startup)(struct sdw_master_device *md); int (*shutdown)(struct sdw_master_device *md); int (*exit)(struct sdw_master_device *md); int (*autonomous_clock_stop_enable)(struct sdw_master_device *md, bool state); };Quoted 6 lines
So this is a soundwire core driver structure, but the modelling and explanation provided here suggests the reasoning to be based on hardware sequencing. I am not sure if we should follow this approach. Solving hardware sequencing is fine but that should IMO be restricted to intel code as that is intel issue which may or may not be present on other controllers.
I agree the directions are Intel-specific, there was no intention of requiring anyone to implement all these callbacks.
Quoted 5 lines
If I look at the calling sequence of the code (looked up the sof code on github, topic/sof-dev-rebase), the sof code
sound/soc/sof/intel/hda.cinvokes thesdw_intel_startup()andsdw_intel_probe()based on hardware sequencing and further you call .init and .probe/startup ofsdw_md_driver.
Quoted 7 lines
Quoted 4 lines
I really do not see why we need a
sdw_md_driverobject to do that. You can easily have a another function exported bysdw_inteldriver and you call these and do same functionality without having asdw_md_driverin between.I must admit I am beyond my comfort zone: I introduced this
sdw_master_driveronly based on Greg's recommendation to look at GreyBus.
Well the recommendation was to add a device, so adding sdw_master_device was the right approach. But we don't need to add driver as well.
Quoted 11 lines
All I care about are the three steps of
a. creating a device (needed because the ACPI description does not model the master hardware)
b. doing the required initializations and allocations
c. exposing a startup callback, and provide room for expansion for future evolutions.If there's a better way to do this I don't mind at all. The value-added of these patches is not in how the device/driver model is used but rather the hardware sequencing and power management.
Quoted 7 lines
That said, I have two key points that I should explain further.
When we started this work, we initially did not have a notion of 'master driver' coupled with the '
master_device'. But we faced a number of issues with ASoC registrations, which seemed to required a driver to be registered and associated with the device. We kept this part as a separate commit to make sure this requirement wasn't lost:
Yes ASoC does require the DAI driver as it holds a reference to it. That was the reason we have a platform device and a platform driver for "int-sdw".
Would it make sense to keep this as is and then export the init and startup APIs which can be invoked by SOF part for hardware initialization. So driver loading is a separate step from hardware initialization and sequencing.
Also you continue with the benefit of parent-child relations for this device :) and pm should be simpler.
Btw this helps if ever in future you have a separate instance of sdw controller that can be just hooked to acpi/pci/whatever device part and driver works without big plumbing
Quoted 93 lines
https://github.com/thesofproject/linux/commit/28b934ce9c165e095dac5cf71da5685768831337
Looking back at my notes, this came from this piece of code:
static char *fmt_single_name(struct device *dev, int *id)
{ char *found, name[NAME_SIZE]; int id1, id2; if (dev_name(dev) == NULL) return NULL; strlcpy(name, dev_name(dev), NAME_SIZE); /* are we a "%s.%d" name (platform and SPI components) */ found = strstr(name, dev->driver->name); <<< oopsso for ASoC, there is an expectation that each device does have a driver associated with it. Just for fun I reverted the commit above and that immediately trigger an kernel oops.
The other point that we came across is that PM support is only enabled thanks to a hook in the driver structure:
static const struct
dev_pm_opsintel_pm= {
SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
};struct sdw_master_driver intel_sdw_driver = { .driver = { .name = "intel-sdw", .owner = THIS_MODULE, .bus = &sdw_bus_type, .pm = &intel_pm, <<<< }, .probe = intel_master_probe, .startup = intel_master_startup, .process_wake_event = intel_master_process_wakeen_event, .remove = intel_master_remove, };I am not aware of any other way to do this.
In short, I have two technical reasons we came across that made us rely on this 'master driver' object. I agree that the solution I suggested may not be very elegant or can be seen as overkill, but it does provide support for two integration requirements.
Quoted 16 lines
Now, I am going to step back one more step and ask you why should we have a
sdw_md_driver? I am not seeing the driver object achieving anything here expect adding wrappers which we can avoid. But we still need to add thesdw_master_device()as a new device object and use that for both sysfs representation as well as representing the master device and do all the things we want, but it *can* come without having accompanyingsdw_md_driver.This way you can retain you calling sequence and add the master device.
Stretching this one more step I would ask that maybe it is even better idea that we should hide
sdw_master_device_add()calling for soundwire drivers and move that internal to bus as part of bus registration as well, I don't seesdw_master_devicecalling back into the driver so it should not impact your sequences as well.Quoted 3 lines
Do you see a reason for
sdw_md_driverwhich is must have? I couldn't find that by looking at the code, let me know if I have missed anything here.Yes, the two reasons explained above.
That said, one possible compromize would be to remove those callbacks and indirections, such
md->driver->remove(md);we could perfectly export something like
intel_device_remove(md)which would directly call the relevant functions. that would essentially remove the notion of '
sdw_master_driver' but keep the bare minimal driver structure that's needed.Note that the removal of platform devices is not something I wanted to enforce across the board. If Qualcomm are happy with the platform devices, that's fine with me. I only want to work around the two limitations I mentioned (ACPI does not support masters, only controllers, and power rail dependencies).
Quoted 4 lines
So to summarize, my recommendation would be to drop
sdw_md_driver, keepsdw_master_deviceobject and makesdw_master_device_add()hidden to driver and call it fromsdw_add_bus_master()and keep intel specific startup/init routine which do same steps as they have now.
Quoted 8 lines
I am afraid the sequence you suggest is not technically possible:
sdw_add_bus_master()requires a device to be created already, see e.g. how it's used by Qualcomm:
sdw_add_bus_master()is called from the platform device probe. I cannot insert a device creation in this code.
So there are two things, lets discuss them independently. One is the device behind the controller object. I think I have given a recommendation above to keep the existing platform device for "int-sdw". This device can be PCI/ACPI/OF/Platform, we typically should not worry about it.
Second is we create the bus instance and that also create the sdw_master_device to represent the soundwire master device in sysfs, since this would be done by soundwire core (as I suggested), it would be independent of which type of driver is invoking this. In fact this needs to be completely independent of the driver calling this.
Intel code will call sdw_add_bus_master() and we would create a sdw_master_device for it and add the representation. So would the qcom code (btw with this, we wont need to do anything on qc code and it 'should just work (tm)'.
Quoted 4 lines
It'd actually be counter productive to add device management at the bus level, since we'd soon have incompatibilities between Intel, Qualcomm and others. What is platform-specific should be handled outside of the bus layer.
The vision I am thinking is that sdw_master_device is a representation of master for everyone independent of the platform it is being used.
Let me know if this helps
Thanks
Signature · 1 line
~Vinod
Re: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Hi Vinod,
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
If I look at the calling sequence of the code (looked up the sof code on github, topic/sof-dev-rebase), the sof code
sound/soc/sof/intel/hda.cinvokes thesdw_intel_startup()andsdw_intel_probe()based on hardware sequencing and further you call .init and .probe/startup ofsdw_md_driver.I really do not see why we need a
sdw_md_driverobject to do that. You can easily have a another function exported bysdw_inteldriver and you call these and do same functionality without having asdw_md_driverin between.
Quoted 5 lines
Quoted 2 lines
I must admit I am beyond my comfort zone: I introduced this
sdw_master_driveronly based on Greg's recommendation to look at GreyBus.Well the recommendation was to add a device, so adding
sdw_master_devicewas the right approach. But we don't need to add driver as well.
I provided two reasons below why we need one
[1] ASoC use of dev->driver
[2] PM hooks.
I would kindly ask that you re-check these points and reply on each, thank you. I did not remove them from my reply so that you don't have to go back to the previous emails.
Quoted 11 lines
Quoted 7 lines
That said, I have two key points that I should explain further.
When we started this work, we initially did not have a notion of 'master driver' coupled with the '
master_device'. But we faced a number of issues with ASoC registrations, which seemed to required a driver to be registered and associated with the device. We kept this part as a separate commit to make sure this requirement wasn't lost:Yes ASoC does require the DAI driver as it holds a reference to it. That was the reason we have a platform device and a platform driver for "int-sdw".
no, it's not related to references, it's using the name, see [1]. And it's not related to the 'dai driver' which is a separate entity unrelated to devices.
Quoted 7 lines
Would it make sense to keep this as is and then export the init and startup APIs which can be invoked by SOF part for hardware initialization. So driver loading is a separate step from hardware initialization and sequencing.
Also you continue with the benefit of parent-child relations for this device :) and pm should be simpler.
the parent-child relationship was used in all cases, I don't understand why things would be different, you still need to add hooks in the 'driver' for the pm of the 'master' child device, be it a platform device or not.
Quoted 6 lines
Btw this helps if ever in future you have a separate instance of sdw controller that can be just hooked to acpi/pci/whatever device part and driver works without big plumbing
[1]
Quoted 10 lines
Quoted 10 lines
Looking back at my notes, this came from this piece of code:
static char *fmt_single_name(struct device *dev, int *id)
{ char *found, name[NAME_SIZE]; int id1, id2; if (dev_name(dev) == NULL) return NULL;
Quoted 8 lines
Quoted 8 lines
strlcpy(name, dev_name(dev), NAME_SIZE); /* are we a "%s.%d" name (platform and SPI components) */ found = strstr(name, dev->driver->name); <<< oopsso for ASoC, there is an expectation that each device does have a driver associated with it. Just for fun I reverted the commit above and that immediately trigger an kernel oops.
[2]
Quoted 21 lines
Quoted 21 lines
The other point that we came across is that PM support is only enabled thanks to a hook in the driver structure:
static const struct
dev_pm_opsintel_pm= {
SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
};struct sdw_master_driver intel_sdw_driver = { .driver = { .name = "intel-sdw", .owner = THIS_MODULE, .bus = &sdw_bus_type, .pm = &intel_pm, <<<< }, .probe = intel_master_probe, .startup = intel_master_startup, .process_wake_event = intel_master_process_wakeen_event, .remove = intel_master_remove, };
Quoted 1 line
Quoted 1 line
I am not aware of any other way to do this.
I suggested a minimal way of using the 'device_driver' directly in https://github.com/thesofproject/linux/pull/1755
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
So to summarize, my recommendation would be to drop
sdw_md_driver, keepsdw_master_deviceobject and makesdw_master_device_add()hidden to driver and call it fromsdw_add_bus_master()and keep intel specific startup/init routine which do same steps as they have now.I am afraid the sequence you suggest is not technically possible:
sdw_add_bus_master()requires a device to be created already, see e.g. how it's used by Qualcomm:
Quoted 8 lines
Quoted 2 lines
sdw_add_bus_master()is called from the platform device probe. I cannot insert a device creation in this code.So there are two things, lets discuss them independently. One is the device behind the controller object. I think I have given a recommendation above to keep the existing platform device for "int-sdw". This device can be PCI/ACPI/OF/Platform, we typically should not worry about it.
I don't understand how a platform device can be PCI/ACPI/OF? what did you mean here?
Quoted 16 lines
Second is we create the bus instance and that also create the
sdw_master_deviceto represent the soundwire master device in sysfs, since this would be done by soundwire core (as I suggested), it would be independent of which type of driver is invoking this. In fact this needs to be completely independent of the driver calling this.Intel code will call
sdw_add_bus_master()and we would create asdw_master_devicefor it and add the representation. So would the qcom code (btw with this, we wont need to do anything on qc code and it 'should just work (tm)'.Quoted 4 lines
It'd actually be counter productive to add device management at the bus level, since we'd soon have incompatibilities between Intel, Qualcomm and others. What is platform-specific should be handled outside of the bus layer.
Quoted 4 lines
The vision I am thinking is that
sdw_master_deviceis a representation of master for everyone independent of the platform it is being used.Let me know if this helps
Sorry no, your reply just confused me completely.
The recommendation from Greg was "remove platform devices". Here's the quote from his May 9, 2019 reply:
"So soundwire is creating platform devices? Ick, no! Don't do that, create a "real" device that is the root of your bus and attach that to the platform/pci/whatever device that is the parent of that device's resources."
If your suggestion is to keep platform devices as currently done, then I will kindly ask that you speak with Greg and let me know what the agreement is.
The second part of your reply gets more confusing, you are suggesting that "Intel code will call sdw_add_bus_master() and we would create a sdw_master_device for it and add the representation". That is in direct contradiction with the notion of using platform devices. And it would by construction break the Qualcomm controller code just merged weeks ago. Are you suggesting I start changing Qualcomm code? Or that we add a new function that does device creation+bus addition in one shot?
And last you didn't acknowledge my two technical points as to why a driver is needed for this sdw_master_device.
So I am back to scratching my head on what the direction is? I just do not understand your line of thought.
Maybe we need to stop the long sentences and use this decision flow:
a) is the master device a platform device (Yes/No)?
b) if No for a) then
b.1) is the master device created within sdw_add_bus_master() b.2) is the master device created before calling sdw_add_bus_master()
Can you please clarify what your desired choices are on this last paragraph?
Thanks
-Pierre
Vinod Koul
maintainerRe: [alsa-devel] [PATCH v5 09/17] soundwire: intel: remove platform devices and use 'Master Devices' instead
Quoted 54 lines · Pierre-Louis Bossart
Hi Vinod,
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
If I look at the calling sequence of the code (looked up the sof code on github, topic/sof-dev-rebase), the sof code
sound/soc/sof/intel/hda.cinvokes thesdw_intel_startup()andsdw_intel_probe()based on hardware sequencing and further you call .init and .probe/startup ofsdw_md_driver.I really do not see why we need a
sdw_md_driverobject to do that. You can easily have a another function exported bysdw_inteldriver and you call these and do same functionality without having asdw_md_driverin between.Quoted 5 lines
Quoted 2 lines
I must admit I am beyond my comfort zone: I introduced this
sdw_master_driveronly based on Greg's recommendation to look at GreyBus.Well the recommendation was to add a device, so adding
sdw_master_devicewas the right approach. But we don't need to add driver as well.I provided two reasons below why we need one
[1] ASoC use ofdev->driver
[2] PM hooks.I would kindly ask that you re-check these points and reply on each, thank you. I did not remove them from my reply so that you don't have to go back to the previous emails.
Quoted 11 lines
Quoted 7 lines
That said, I have two key points that I should explain further.
When we started this work, we initially did not have a notion of 'master driver' coupled with the '
master_device'. But we faced a number of issues with ASoC registrations, which seemed to required a driver to be registered and associated with the device. We kept this part as a separate commit to make sure this requirement wasn't lost:Yes ASoC does require the DAI driver as it holds a reference to it. That was the reason we have a platform device and a platform driver for "int-sdw".
no, it's not related to references, it's using the name, see [1]. And it's not related to the 'dai driver' which is a separate entity unrelated to devices.
Quoted 7 lines
Would it make sense to keep this as is and then export the init and startup APIs which can be invoked by SOF part for hardware initialization. So driver loading is a separate step from hardware initialization and sequencing.
Also you continue with the benefit of parent-child relations for this device :) and pm should be simpler.
the parent-child relationship was used in all cases, I don't understand why things would be different, you still need to add hooks in the 'driver' for the pm of the 'master' child device, be it a platform device or not.
Quoted 27 lines
Quoted 6 lines
Btw this helps if ever in future you have a separate instance of sdw controller that can be just hooked to acpi/pci/whatever device part and driver works without big plumbing
[1]
Quoted 18 lines
Quoted 18 lines
Looking back at my notes, this came from this piece of code:
static char *fmt_single_name(struct device *dev, int *id)
{ char *found, name[NAME_SIZE]; int id1, id2; if (dev_name(dev) == NULL) return NULL; strlcpy(name, dev_name(dev), NAME_SIZE); /* are we a "%s.%d" name (platform and SPI components) */ found = strstr(name, dev->driver->name); <<< oopsso for ASoC, there is an expectation that each device does have a driver associated with it. Just for fun I reverted the commit above and that immediately trigger an kernel oops.
in the existing driver (the one on upstream atm), you have:
static struct platform_driver sdw_intel_drv = {
.probe = intel_probe,
.remove = intel_remove,
.driver = {
.name = "int-sdw",
},
};This is the DAI driver which registers the DAIs and and you pass on this device, so for platform driver and above it should just work. That is why my recommendation is to continue with this.
Quoted 25 lines
[2]
Quoted 22 lines
Quoted 22 lines
The other point that we came across is that PM support is only enabled thanks to a hook in the driver structure:
static const struct
dev_pm_opsintel_pm= {
SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
};struct sdw_master_driver intel_sdw_driver = { .driver = { .name = "intel-sdw", .owner = THIS_MODULE, .bus = &sdw_bus_type, .pm = &intel_pm, <<<< }, .probe = intel_master_probe, .startup = intel_master_startup, .process_wake_event = intel_master_process_wakeen_event, .remove = intel_master_remove, };I am not aware of any other way to do this.
Again, you can add this to platform_driver sdw_intel_drv.
Quoted 18 lines
I suggested a minimal way of using the '
device_driver' directly in
https://github.com/thesofproject/linux/pull/1755Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
So to summarize, my recommendation would be to drop
sdw_md_driver, keepsdw_master_deviceobject and makesdw_master_device_add()hidden to driver and call it fromsdw_add_bus_master()and keep intel specific startup/init routine which do same steps as they have now.I am afraid the sequence you suggest is not technically possible:
sdw_add_bus_master()requires a device to be created already, see e.g. how it's used by Qualcomm:
sdw_add_bus_master()is called from the platform device probe. I cannot insert a device creation in this code.
Quoted 8 lines
Quoted 5 lines
So there are two things, lets discuss them independently. One is the device behind the controller object. I think I have given a recommendation above to keep the existing platform device for "int-sdw". This device can be PCI/ACPI/OF/Platform, we typically should not worry about it.
I don't understand how a platform device can be PCI/ACPI/OF? what did you mean here?
What I meant is that keep the existing platform device for "int-sdw".
And
a master device for everyone across x86/arm/etc spectrum would be PCI/ACPI/OF/Platform and we should be agnostic and let these drivers add a bus and register that
Quoted 23 lines
Quoted 16 lines
Second is we create the bus instance and that also create the
sdw_master_deviceto represent the soundwire master device in sysfs, since this would be done by soundwire core (as I suggested), it would be independent of which type of driver is invoking this. In fact this needs to be completely independent of the driver calling this.Intel code will call
sdw_add_bus_master()and we would create asdw_master_devicefor it and add the representation. So would the qcom code (btw with this, we wont need to do anything on qc code and it 'should just work (tm)'.Quoted 4 lines
It'd actually be counter productive to add device management at the bus level, since we'd soon have incompatibilities between Intel, Qualcomm and others. What is platform-specific should be handled outside of the bus layer.
Quoted 4 lines
The vision I am thinking is that
sdw_master_deviceis a representation of master for everyone independent of the platform it is being used.Let me know if this helps
Sorry no, your reply just confused me completely.
Quoted 7 lines
The recommendation from Greg was "remove platform devices". Here's the quote from his May 9, 2019 reply:
"So soundwire is creating platform devices? Ick, no! Don't do that, create a "real" device that is the root of your bus and attach that to the platform/pci/whatever device that is the parent of that device's resources."
Is soundwire subsystem creating platform devices, answer is no.
The problem is we were using the master device (platform/of/pci/etc) for our own sysfs attributes, which was a mistake and I want to rectify that.
The device behind the soundwire controller can be anything. If hardware creates a device for soundwire we should continue using that
Quoted 12 lines
If your suggestion is to keep platform devices as currently done, then I will kindly ask that you speak with Greg and let me know what the agreement is.
The second part of your reply gets more confusing, you are suggesting that "Intel code will call
sdw_add_bus_master()and we would create asdw_master_devicefor it and add the representation". That is in direct contradiction with the notion of using platform devices. And it would by construction break the Qualcomm controller code just merged weeks ago. Are you suggesting I start changing Qualcomm code? Or that we add a new function that does device creation+bus addition in one shot?
Quoted 5 lines
And last you didn't acknowledge my two technical points as to why a driver is needed for this
sdw_master_device.So I am back to scratching my head on what the direction is? I just do not understand your line of thought.
Sorry to confuse you, I guess somewhere I missed to communicate that
1. keep existing platform device for master (that solves your pm and asoc issue)
2. add a sdw_master device, but we dont need driver, use that device for sdw sysfs attributes
3. If possible, have one api, rather than 2 for bus and master device creation.
Quoted 3 lines
Maybe we need to stop the long sentences and use this decision flow:
a) is the master device a platform device (Yes/No)?
For your case, yes. For QC case it will be of device
Quoted 2 lines
b) if No for a) then
b.1) is the master device created withinsdw_add_bus_master()
If possible that would be great. All I am trying here is to avoid having two APIs for registration and use a single APIs for drivers to call.
Quoted 1 line
b.2) is the master device created before calling
sdw_add_bus_master()
IIUC, it should be called after, right?
Quoted 2 lines
Can you please clarify what your desired choices are on this last paragraph?
Let me know if this helped.
Signature · 1 line
~Vinod
PATCH v5 10/17 soundwire: register master device driver
In reply to Pierre-Louis BossartFrom: Bard Liao <[email protected]>
While we don't have a matching function, setting an device driver is still necessary for ASoC to register DAI components as well as power management.
--- drivers/soundwire/intel.c | 6 ++++++ drivers/soundwire/intel_init.c | 10 ++++++++++ drivers/soundwire/master.c | 1 + include/linux/soundwire/sdw.h | 1 + 4 files changed, 18 insertions(+)
drivers/soundwire/intel.c +6 -0
@@ -17,6 +17,7 @@#include <linux/soundwire/sdw_registers.h> #include <linux/soundwire/sdw.h> #include <linux/soundwire/sdw_intel.h> +#include <linux/soundwire/sdw_type.h> #include "cadence_master.h" #include "bus.h" #include "intel.h"
@@ -1058,6 +1059,11 @@ static int intel_master_remove(struct sdw_master_device *md) }struct sdw_md_driver intel_sdw_driver = { + .driver = { + .name ="intel-sdw" , + .owner =THIS_MODULE , + .bus = &sdw_bus_type, + }, .probe = intel_master_probe, .startup = intel_master_startup, .remove = intel_master_remove,
drivers/soundwire/intel_init.c +10 -0
@@ -146,6 +146,7 @@ static struct sdw_intel_ctxstruct sdw_master_device *md;u32 link_mask;int count; +int err;int i;if (!res)
@@ -176,6 +177,12 @@ static struct sdw_intel_ctx link = ctx->links; link_mask = ctx->link_mask; + err =driver_register (&intel_sdw_driver.driver); +if (err) { +dev_err (&adev->dev,"failed to register sdw master driver\n" ); + goto register_err; + } +/* Create SDW Master devices */ for (i =0 ; i < count; i++, link++) {if (link_mask && !(link_mask &BIT (i)))
@@ -209,6 +216,8 @@ static struct sdw_intel_ctx err:sdw_intel_cleanup (ctx); link_err: +driver_unregister (&intel_sdw_driver.driver); +register_err:kfree (ctx);return NULL ; }
@@ -350,6 +359,7 @@ EXPORT_SYMBOL(sdw_intel_startup);void sdw_intel_exit (struct sdw_intel_ctx *ctx) {sdw_intel_cleanup (ctx); +driver_unregister (&intel_sdw_driver.driver);kfree (ctx); }EXPORT_SYMBOL (sdw_intel_exit);
drivers/soundwire/master.c +1 -0
@@ -46,6 +46,7 @@ struct sdw_master_device *sdw_md_add(struct sdw_md_driver *driver, md->dev.type = &sdw_md_type; md->dev.dma_mask = md->dev.parent->dma_mask;dev_set_name (&md->dev,"sdw-master-%d" , md->link_id); + md->dev.driver = &driver->driver; ret =device_register (&md->dev);if (ret) {
include/linux/soundwire/sdw.h +1 -0
@@ -630,6 +630,7 @@ struct sdw_md_driver {int (*remove)(struct sdw_master_device *md);int (*autonomous_clock_stop_enable)(struct sdw_master_device *md,bool state); +struct device_driver driver; };#define SDW_SLAVE_ENTRY (_mfg_id, _part_id, _drv_data) \
Signature · 1 line
2.20.1
PATCH v5 11/17 soundwire: intel: add prepare support in sdw dai driver
In reply to Pierre-Louis BossartFrom: Rander Wang <[email protected]>
The existing code does not expose a prepare operation, which is very much needed to deal with underflow and resume operations.
--- drivers/soundwire/intel.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/soundwire/intel.c +17 -0
@@ -698,6 +698,21 @@ static int intel_hw_params(struct snd_pcm_substream *substream,return ret; } +static int intel_prepare (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct sdw_cdns_dma_data *dma; + + dma =snd_soc_dai_get_dma_data (dai, substream); +if (!dma) { +dev_err (dai->dev,"failed to get dma data in %s" , + __func__); +return -EIO ; + } + +return sdw_prepare_stream (dma->stream); +} +static int intel_hw_free (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {
@@ -744,6 +759,7 @@ static int intel_pdm_set_sdw_stream(struct snd_soc_dai *dai,static const struct snd_soc_dai_ops intel_pcm_dai_ops = { .hw_params = intel_hw_params, + .prepare = intel_prepare, .hw_free = intel_hw_free, .shutdown = intel_shutdown, .set_sdw_stream = intel_pcm_set_sdw_stream,
@@ -751,6 +767,7 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {static const struct snd_soc_dai_ops intel_pdm_dai_ops = { .hw_params = intel_hw_params, + .prepare = intel_prepare, .hw_free = intel_hw_free, .shutdown = intel_shutdown, .set_sdw_stream = intel_pdm_set_sdw_stream,
Signature · 1 line
2.20.1
PATCH v5 12/17 soundwire: intel: add trigger support in sdw dai driver
In reply to Pierre-Louis BossartFrom: Rander Wang <[email protected]>
The existing code does not expose a trigger callback, which is very much required for streaming.
The SoundWire stream is enabled and disabled in trigger function.
--- drivers/soundwire/intel.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/soundwire/intel.c +39 -0
@@ -713,6 +713,43 @@ static int intel_prepare(struct snd_pcm_substream *substream,return sdw_prepare_stream (dma->stream); } +static int intel_trigger (struct snd_pcm_substream *substream,int cmd, +struct snd_soc_dai *dai) +{ +struct sdw_cdns_dma_data *dma; +int ret; + + dma =snd_soc_dai_get_dma_data (dai, substream); +if (!dma) { +dev_err (dai->dev,"failed to get dma data in %s" , __func__); +return -EIO ; + } + +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +case SNDRV_PCM_TRIGGER_RESUME : + ret =sdw_enable_stream (dma->stream); +break ; + +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_STOP : + ret =sdw_disable_stream (dma->stream); +break ; + +default : + ret = -EINVAL ; +break ; + } + +if (ret) +dev_err (dai->dev, +"%s trigger %d failed: %d" , + __func__, cmd, ret); +return ret; +} +static int intel_hw_free (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {
@@ -760,6 +797,7 @@ static int intel_pdm_set_sdw_stream(struct snd_soc_dai *dai,static const struct snd_soc_dai_ops intel_pcm_dai_ops = { .hw_params = intel_hw_params, .prepare = intel_prepare, + .trigger = intel_trigger, .hw_free = intel_hw_free, .shutdown = intel_shutdown, .set_sdw_stream = intel_pcm_set_sdw_stream,
@@ -768,6 +806,7 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {static const struct snd_soc_dai_ops intel_pdm_dai_ops = { .hw_params = intel_hw_params, .prepare = intel_prepare, + .trigger = intel_trigger, .hw_free = intel_hw_free, .shutdown = intel_shutdown, .set_sdw_stream = intel_pdm_set_sdw_stream,
Signature · 1 line
2.20.1
PATCH v5 13/17 soundwire: intel: add sdw_stream_setup helper for .startup callback
In reply to Pierre-Louis BossartFrom: Rander Wang <[email protected]>
The sdw stream is allocated and stored in dai to share the sdw runtime information.
--- drivers/soundwire/intel.c | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/soundwire/intel.c +65 -0
@@ -616,6 +616,69 @@ static int intel_post_bank_switch(struct sdw_bus *bus)* DAI routines */ +static int sdw_stream_setup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct sdw_stream_runtime *sdw_stream =NULL ; +char *name; +int i, ret; + + name =kzalloc (32 ,GFP_KERNEL ); +if (!name) +return -ENOMEM ; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +snprintf (name,32 ,"%s-Playback" , dai->name); +else +snprintf (name,32 ,"%s-Capture" , dai->name); + + sdw_stream =sdw_alloc_stream (name); +if (!sdw_stream) { +dev_err (dai->dev,"alloc stream failed for DAI %s" , dai->name); + ret = -ENOMEM ; + goto error; + } + +/* Set stream pointer on CPU DAI */ + ret =snd_soc_dai_set_sdw_stream (dai, sdw_stream, substream->stream); +if (ret <0 ) { +dev_err (dai->dev,"failed to set stream pointer on cpu dai %s" , + dai->name); + goto release_stream; + } + +/* Set stream pointer on all CODEC DAIs */ +for (i =0 ; i < rtd->num_codecs; i++) { + ret =snd_soc_dai_set_sdw_stream (rtd->codec_dais[i], sdw_stream, + substream->stream); +if (ret <0 ) { +dev_err (dai->dev,"failed to set stream pointer on codec dai %s" , + rtd->codec_dais[i]->name); + goto release_stream; + } + } + +return 0 ; + +release_stream: +sdw_release_stream (sdw_stream); +error: +kfree (name); +return ret; +} + +static int intel_startup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +/* +* TODO: add pm_runtime support here, the startup callback +* will make sure the IP is 'active' +*/ + +return sdw_stream_setup (substream, dai); +} +static int intel_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai)
@@ -795,6 +858,7 @@ static int intel_pdm_set_sdw_stream(struct snd_soc_dai *dai, }static const struct snd_soc_dai_ops intel_pcm_dai_ops = { + .startup = intel_startup, .hw_params = intel_hw_params, .prepare = intel_prepare, .trigger = intel_trigger,
@@ -804,6 +868,7 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = { };static const struct snd_soc_dai_ops intel_pdm_dai_ops = { + .startup = intel_startup, .hw_params = intel_hw_params, .prepare = intel_prepare, .trigger = intel_trigger,
Signature · 1 line
2.20.1
PATCH v5 14/17 soundwire: intel: free all resources on hw_free()
In reply to Pierre-Louis BossartMake sure all calls to the SoundWire stream API are done and involve callback
--- drivers/soundwire/intel.c | 40 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
drivers/soundwire/intel.c +38 -2
@@ -549,6 +549,25 @@ static int intel_params_stream(struct sdw_intel *sdw,return -EIO ; } +static int intel_free_stream (struct sdw_intel *sdw, +struct snd_pcm_substream *substream, +struct snd_soc_dai *dai, +int link_id) +{ +struct sdw_intel_link_res *res = sdw->link_res; +struct sdw_intel_stream_free_data free_data; + + free_data.substream = substream; + free_data.dai = dai; + free_data.link_id = link_id; + +if (res->ops && res->ops->free_stream && res->dev) +return res->ops->free_stream (res->dev, + &free_data); + +return 0 ; +} +/* * bank switch routines */
@@ -817,6 +836,7 @@ static int intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); +struct sdw_intel *sdw =cdns_to_intel (cdns);struct sdw_cdns_dma_data *dma;int ret;
@@ -824,12 +844,28 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)if (!dma)return -EIO ; + ret =sdw_deprepare_stream (dma->stream); +if (ret) { +dev_err (dai->dev,"sdw_deprepare_stream: failed %d" , ret); +return ret; + } + ret =sdw_stream_remove_master (&cdns->bus, dma->stream); -if (ret <0 ) +if (ret <0 ) {dev_err (dai->dev,"remove master from stream %s failed: %d\n" , dma->stream->name, ret); +return ret; + } -return ret; + ret =intel_free_stream (sdw, substream, dai, sdw->instance); +if (ret <0 ) { +dev_err (dai->dev,"intel_free_stream: failed %d" , ret); +return ret; + } + +sdw_release_stream (dma->stream); + +return 0 ; } static void intel_shutdown(struct snd_pcm_substream *substream,
Signature · 1 line
2.20.1
PATCH v5 15/17 soundwire: intel_init: add implementation of sdw_intel_enable_irq()
In reply to Pierre-Louis BossartThis function is required to enable all interrupts across all links.
--- drivers/soundwire/intel_init.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/soundwire/intel_init.c +24 -0
@@ -137,6 +137,30 @@ sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)return 0 ; } +#define HDA_DSP_REG_ADSPIC2 (0x10) +#define HDA_DSP_REG_ADSPIS2 (0x14) +#define HDA_DSP_REG_ADSPIC2_SNDW BIT(5) + +/** +* sdw_intel_enable_irq() - enable/disable Intel SoundWire IRQ +* @mmio_base: The mmio base of the control register +* @enable: true if enable +*/ +void sdw_intel_enable_irq (void __iomem *mmio_base,bool enable) +{ +u32 val; + + val =readl (mmio_base +HDA_DSP_REG_ADSPIC2 ); + +if (enable) + val |=HDA_DSP_REG_ADSPIC2_SNDW ; +else + val &= ~HDA_DSP_REG_ADSPIC2_SNDW ; + +writel (val, mmio_base +HDA_DSP_REG_ADSPIC2 ); +} +EXPORT_SYMBOL (sdw_intel_enable_irq); +static struct sdw_intel_ctx *sdw_intel_probe_controller (struct sdw_intel_res *res) {
Signature · 1 line
2.20.1
PATCH v5 16/17 soundwire: intel_init: use EXPORT_SYMBOL_NS
In reply to Pierre-Louis BossartMake sure all symbols in this soundwire-intel-init module are exported with a namespace.
The MODULE_IMPORT_NS will be used in Intel/SOF HDaudio modules to be posted in a separate series.
Namespaces are only introduced for the Intel parts of the SoundWire code at this time, in future patches we should also add namespaces for Cadence parts and the SoundWire core.
--- drivers/soundwire/intel_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/soundwire/intel_init.c +5 -5
@@ -159,7 +159,7 @@ void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable)writel (val, mmio_base +HDA_DSP_REG_ADSPIC2 ); } -EXPORT_SYMBOL (sdw_intel_enable_irq); +EXPORT_SYMBOL_NS (sdw_intel_enable_irq,SOUNDWIRE_INTEL_INIT );static struct sdw_intel_ctx *sdw_intel_probe_controller (struct sdw_intel_res *res)
@@ -346,7 +346,7 @@ int sdw_intel_acpi_scan(acpi_handle *parent_handle,return sdw_intel_scan_controller (info); } -EXPORT_SYMBOL (sdw_intel_acpi_scan); +EXPORT_SYMBOL_NS (sdw_intel_acpi_scan,SOUNDWIRE_INTEL_INIT );/** * sdw_intel_probe() - SoundWire Intel probe routine
@@ -362,7 +362,7 @@ struct sdw_intel_ctx {return sdw_intel_probe_controller (res); } -EXPORT_SYMBOL (sdw_intel_probe); +EXPORT_SYMBOL_NS (sdw_intel_probe,SOUNDWIRE_INTEL_INIT );/** * sdw_intel_startup() - SoundWire Intel startup
@@ -373,7 +373,7 @@ int sdw_intel_startup(struct sdw_intel_ctx *ctx) {return sdw_intel_startup_controller (ctx); } -EXPORT_SYMBOL (sdw_intel_startup); +EXPORT_SYMBOL_NS (sdw_intel_startup,SOUNDWIRE_INTEL_INIT );/** * sdw_intel_exit() - SoundWire Intel exit * @ctx: SoundWire context allocated in the probe
@@ -386,7 +386,7 @@ void sdw_intel_exit(struct sdw_intel_ctx *ctx)driver_unregister (&intel_sdw_driver.driver);kfree (ctx); } -EXPORT_SYMBOL (sdw_intel_exit); +EXPORT_SYMBOL_NS (sdw_intel_exit,SOUNDWIRE_INTEL_INIT );MODULE_LICENSE ("Dual BSD/GPL" );MODULE_DESCRIPTION ("Intel Soundwire Init Library" );
Signature · 1 line
2.20.1
PATCH v5 17/17 soundwire: intel: use EXPORT_SYMBOL_NS
In reply to Pierre-Louis BossartThe soundwire-intel module exports an 'intel_sdw_driver' structure, which is declared with a namespace explicitly imported by the soundwire-intel-init module.
The use of namespaces might be deemed overkill here, but it did help enforce a proper code partitioning for follow-up patches on clock-stop support.
--- drivers/soundwire/intel.c | 2 +- drivers/soundwire/intel_init.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/soundwire/intel.c +1 -1
@@ -1225,7 +1225,7 @@ struct sdw_md_driver intel_sdw_driver = { .startup = intel_master_startup, .remove = intel_master_remove, }; -EXPORT_SYMBOL (intel_sdw_driver); +EXPORT_SYMBOL_NS (intel_sdw_driver,SOUNDWIRE_INTEL );MODULE_LICENSE ("Dual BSD/GPL" );MODULE_ALIAS ("platform:int-sdw" );
drivers/soundwire/intel_init.c +1 -0
@@ -390,3 +390,4 @@ EXPORT_SYMBOL_NS(sdw_intel_exit, SOUNDWIRE_INTEL_INIT);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_DESCRIPTION ("Intel Soundwire Init Library" ); +MODULE_IMPORT_NS (SOUNDWIRE_INTEL );
Signature · 1 line
2.20.1