ASoC: Intel: Handle device properties with software node API
Subsystems (5)
Heikki Krogerus
reviewerPATCH 1/1 ASoC: Intel: Handle device properties with software node API
The function device_add_properties() is going to be removed. Replacing it with software node API equivalents.
---
Hi,
This patch depends on a fix from mainline, available in v5.12-rc4:
2a92c90f2ecc ("software node: Fix device_add_software_node()")Cheers,
--- sound/soc/intel/boards/bytcht_es8316.c | 2 +- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/sof_sdw_rt711.c | 20 +++++++++++++++----- sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 20 +++++++++++++++----- 5 files changed, 33 insertions(+), 13 deletions(-)
sound/soc/intel/boards/bytcht_es8316.c +1 -1
@@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) props[cnt++] =PROPERTY_ENTRY_BOOL ("everest,jack-detect-inverted" );if (cnt) { - ret =device_add_properties (codec_dev, props); + ret =device_create_managed_software_node (codec_dev, props,NULL );if (ret) {put_device (codec_dev);return ret;
sound/soc/intel/boards/bytcr_rt5640.c +1 -1
@@ -918,7 +918,7 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)if (byt_rt5640_quirk &BYT_RT5640_JD_NOT_INV ) props[cnt++] =PROPERTY_ENTRY_BOOL ("realtek,jack-detect-not-inverted" ); - ret =device_add_properties (i2c_dev, props); + ret =device_create_managed_software_node (i2c_dev, props,NULL );put_device (i2c_dev);return ret;
sound/soc/intel/boards/bytcr_rt5651.c +1 -1
@@ -547,7 +547,7 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev)if (byt_rt5651_quirk &BYT_RT5651_JD_NOT_INV ) props[cnt++] =PROPERTY_ENTRY_BOOL ("realtek,jack-detect-not-inverted" ); -return device_add_properties (i2c_dev, props); +return device_create_managed_software_node (i2c_dev, props,NULL ); }static int byt_rt5651_init (struct snd_soc_pcm_runtime *runtime)
sound/soc/intel/boards/sof_sdw_rt711.c +15 -5
@@ -24,19 +24,29 @@static int rt711_add_codec_device_props (const char *sdw_dev_name) {struct property_entry props[MAX_NO_PROPS ] = {}; +struct fwnode_handle *fwnode;struct device *sdw_dev;int ret; +if (!SOF_RT711_JDSRC (sof_sdw_quirk)) +return 0 ; + sdw_dev =bus_find_device_by_name (&sdw_bus_type,NULL , sdw_dev_name);if (!sdw_dev)return -EPROBE_DEFER ; -if (SOF_RT711_JDSRC (sof_sdw_quirk)) { - props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , -SOF_RT711_JDSRC (sof_sdw_quirk)); + props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , +SOF_RT711_JDSRC (sof_sdw_quirk)); + + fwnode =fwnode_create_software_node (props,NULL ); +if (IS_ERR (fwnode)) { +put_device (sdw_dev); +return PTR_ERR (fwnode); } - ret =device_add_properties (sdw_dev, props); + ret =device_add_software_node (sdw_dev,to_software_node (fwnode)); + +fwnode_handle_put (fwnode);put_device (sdw_dev);return ret;
@@ -144,7 +154,7 @@ int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link)if (!sdw_dev)return -EINVAL ; -device_remove_properties (sdw_dev); +device_remove_software_node (sdw_dev);put_device (sdw_dev);return 0 ;
sound/soc/intel/boards/sof_sdw_rt711_sdca.c +15 -5
@@ -24,19 +24,29 @@static int rt711_sdca_add_codec_device_props (const char *sdw_dev_name) {struct property_entry props[MAX_NO_PROPS ] = {}; +struct fwnode_handle *fwnode;struct device *sdw_dev;int ret; +if (!SOF_RT711_JDSRC (sof_sdw_quirk)) +return 0 ; + sdw_dev =bus_find_device_by_name (&sdw_bus_type,NULL , sdw_dev_name);if (!sdw_dev)return -EPROBE_DEFER ; -if (SOF_RT711_JDSRC (sof_sdw_quirk)) { - props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , -SOF_RT711_JDSRC (sof_sdw_quirk)); + props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , +SOF_RT711_JDSRC (sof_sdw_quirk)); + + fwnode =fwnode_create_software_node (props,NULL ); +if (IS_ERR (fwnode)) { +put_device (sdw_dev); +return PTR_ERR (fwnode); } - ret =device_add_properties (sdw_dev, props); + ret =device_add_software_node (sdw_dev,to_software_node (fwnode)); + +fwnode_handle_put (fwnode);put_device (sdw_dev);return ret;
@@ -144,7 +154,7 @@ int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_linif (!sdw_dev)return -EINVAL ; -device_remove_properties (sdw_dev); +device_remove_software_node (sdw_dev);put_device (sdw_dev);return 0 ;
Signature · 1 line
2.30.2
Quoted 25 lines · Heikki Krogerus
The function
device_add_properties()is going to be removed. Replacing it with software node API equivalents.Signed-off-by Heikki Krogerus <[email protected]>---
Hi,This patch depends on a fix from mainline, available in v5.12-rc4:
2a92c90f2ecc ("software node: Fix device_add_software_node()")Cheers,
--- sound/soc/intel/boards/bytcht_es8316.c | 2 +- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/sof_sdw_rt711.c | 20 +++++++++++++++----- sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 20 +++++++++++++++----- 5 files changed, 33 insertions(+), 13 deletions(-)sound/soc/intel/boards/bytcht_es8316.c +0
-0
sound/soc/intel/boards/bytcht_es8316.c static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) · line 547
Quoted 5 lines
sound/soc/intel/boards/bytcht_es8316.c +1
-1@@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) props[cnt++] =PROPERTY_ENTRY_BOOL ("everest,jack-detect-inverted" );if (cnt) { - ret =device_add_properties (codec_dev, props); + ret =device_create_managed_software_node (codec_dev, props,NULL );
I don't think this is correct. This is using the codec_dev device, but this property is created in the machine driver - different device. I think the proper fix is to remove the property in the machine driver .remove() callback, as done below for the SoundWire case, and not to rely on devm_ with the wrong device.
there was a thread between July and October on this in https://github.com/thesofproject/linux/pull/2306/
It seems that we need to restart this work.
Heikki, do you mind if I take your patches (keeping you as the author) and rework+test them with the SOF tree + CI ?
Quoted 124 lines
sound/soc/intel/boards/bytcht_es8316.c +0
-0if (ret) {put_device (codec_dev);return ret;sound/soc/intel/boards/bytcr_rt5640.c +1
-1@@ -918,7 +918,7 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)if (byt_rt5640_quirk &BYT_RT5640_JD_NOT_INV ) props[cnt++] =PROPERTY_ENTRY_BOOL ("realtek,jack-detect-not-inverted" ); - ret =device_add_properties (i2c_dev, props); + ret =device_create_managed_software_node (i2c_dev, props,NULL );put_device (i2c_dev);return ret;sound/soc/intel/boards/bytcr_rt5651.c +1
-1@@ -547,7 +547,7 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev)if (byt_rt5651_quirk &BYT_RT5651_JD_NOT_INV ) props[cnt++] =PROPERTY_ENTRY_BOOL ("realtek,jack-detect-not-inverted" ); -return device_add_properties (i2c_dev, props); +return device_create_managed_software_node (i2c_dev, props,NULL ); }static int byt_rt5651_init (struct snd_soc_pcm_runtime *runtime)sound/soc/intel/boards/sof_sdw_rt711.c +15
-5@@ -24,19 +24,29 @@static int rt711_add_codec_device_props (const char *sdw_dev_name) {struct property_entry props[MAX_NO_PROPS ] = {}; +struct fwnode_handle *fwnode;struct device *sdw_dev;int ret; +if (!SOF_RT711_JDSRC (sof_sdw_quirk)) +return 0 ; + sdw_dev =bus_find_device_by_name (&sdw_bus_type,NULL , sdw_dev_name);if (!sdw_dev)return -EPROBE_DEFER ; -if (SOF_RT711_JDSRC (sof_sdw_quirk)) { - props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , -SOF_RT711_JDSRC (sof_sdw_quirk)); + props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , +SOF_RT711_JDSRC (sof_sdw_quirk)); + + fwnode =fwnode_create_software_node (props,NULL ); +if (IS_ERR (fwnode)) { +put_device (sdw_dev); +return PTR_ERR (fwnode); } - ret =device_add_properties (sdw_dev, props); + ret =device_add_software_node (sdw_dev,to_software_node (fwnode)); + +fwnode_handle_put (fwnode);put_device (sdw_dev);return ret;@@ -144,7 +154,7 @@ int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link)if (!sdw_dev)return -EINVAL ; -device_remove_properties (sdw_dev); +device_remove_software_node (sdw_dev);put_device (sdw_dev);return 0 ;sound/soc/intel/boards/sof_sdw_rt711_sdca.c +15
-5@@ -24,19 +24,29 @@static int rt711_sdca_add_codec_device_props (const char *sdw_dev_name) {struct property_entry props[MAX_NO_PROPS ] = {}; +struct fwnode_handle *fwnode;struct device *sdw_dev;int ret; +if (!SOF_RT711_JDSRC (sof_sdw_quirk)) +return 0 ; + sdw_dev =bus_find_device_by_name (&sdw_bus_type,NULL , sdw_dev_name);if (!sdw_dev)return -EPROBE_DEFER ; -if (SOF_RT711_JDSRC (sof_sdw_quirk)) { - props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , -SOF_RT711_JDSRC (sof_sdw_quirk)); + props[0 ] =PROPERTY_ENTRY_U32 ("realtek,jd-src" , +SOF_RT711_JDSRC (sof_sdw_quirk)); + + fwnode =fwnode_create_software_node (props,NULL ); +if (IS_ERR (fwnode)) { +put_device (sdw_dev); +return PTR_ERR (fwnode); } - ret =device_add_properties (sdw_dev, props); + ret =device_add_software_node (sdw_dev,to_software_node (fwnode)); + +fwnode_handle_put (fwnode);put_device (sdw_dev);return ret;@@ -144,7 +154,7 @@ int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_linif (!sdw_dev)return -EINVAL ; -device_remove_properties (sdw_dev); +device_remove_software_node (sdw_dev);put_device (sdw_dev);return 0 ;
Heikki Krogerus
reviewerQuoted 39 lines · Pierre-Louis Bossart
Quoted 25 lines · Heikki Krogerus
The function
device_add_properties()is going to be removed. Replacing it with software node API equivalents.Signed-off-by Heikki Krogerus <[email protected]>---
Hi,This patch depends on a fix from mainline, available in v5.12-rc4:
2a92c90f2ecc ("software node: Fix device_add_software_node()")Cheers,
--- sound/soc/intel/boards/bytcht_es8316.c | 2 +- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/sof_sdw_rt711.c | 20 +++++++++++++++----- sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 20 +++++++++++++++----- 5 files changed, 33 insertions(+), 13 deletions(-)sound/soc/intel/boards/bytcht_es8316.c +0
-0sound/soc/intel/boards/bytcht_es8316.c static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) · line 546
Quoted 4 lines
sound/soc/intel/boards/bytcht_es8316.c +1
-1@@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) props[cnt++] =PROPERTY_ENTRY_BOOL ("everest,jack-detect-inverted" );if (cnt) { - ret =device_add_properties (codec_dev, props); + ret =device_create_managed_software_node (codec_dev, props,NULL );I don't think this is correct. This is using the
codec_devdevice, but this property is created in the machine driver - different device. I think the proper fix is to remove the property in the machine driver .remove() callback, as done below for the SoundWire case, and not to rely ondevm_with the wrong device.
Quoted 7 lines
there was a thread between July and October on this in
https://github.com/thesofproject/linux/pull/2306/It seems that we need to restart this work.
Heikki, do you mind if I take your patches (keeping you as the author) and rework+test them with the SOF tree + CI ?
OK by me (though, I'm not sure about the author part after that).
thanks,
Signature · 1 line
heikki
Hi Heikki,
Quoted 19 lines
Quoted 19 lines
sound/soc/intel/boards/bytcht_es8316.c static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) · line 546
Quoted 9 lines
sound/soc/intel/boards/bytcht_es8316.c +1
-1@@ -544,7 +544,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) props[cnt++] =PROPERTY_ENTRY_BOOL ("everest,jack-detect-inverted" );if (cnt) { - ret =device_add_properties (codec_dev, props); + ret =device_create_managed_software_node (codec_dev, props,NULL );I don't think this is correct. This is using the
codec_devdevice, but this property is created in the machine driver - different device. I think the proper fix is to remove the property in the machine driver .remove() callback, as done below for the SoundWire case, and not to rely ondevm_with the wrong device.there was a thread between July and October on this in
https://github.com/thesofproject/linux/pull/2306/
Quoted 6 lines
Quoted 4 lines
It seems that we need to restart this work.
Heikki, do you mind if I take your patches (keeping you as the author) and rework+test them with the SOF tree + CI ?
OK by me (though, I'm not sure about the author part after that).
I took the code and split it in two for BYT/CHT (modified to remove devm_) and SoundWire parts (added as is).
https://github.com/thesofproject/linux/pull/2810
Both cases result in a refcount error on device_remove_sof when removing the platform device. I don't understand the code well enough to figure out what happens, but it's likely a case of the software node being removed twice?
kernel: [ 872.695132] refcount_t: underflow; use-after-free.
kernel: [ 872.695153] WARNING: CPU: 7 PID: 16086 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
<snip>
kernel: [ 872.695222] CPU: 7 PID: 16086 Comm: rmmod Not tainted 5.12.0-rc4-pr2810-5522-default #439c50f6
kernel: [ 872.695225] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP, BIOS TGLSFWI1.R00.3264.A00.2006251828 06/25/2020
kernel: [ 872.695226] RIP: 0010:refcount_warn_saturate+0xa6/0xf0
< snip>
kernel: [ 872.695244] Call Trace:
kernel: [ 872.695248] sof_sdw_rt711_exit+0x2d/0x40 [snd_soc_sof_sdw]
kernel: [ 872.695253] mc_remove+0xa8/0xe0 [snd_soc_sof_sdw]
kernel: [ 872.695256] ? rt711_rtd_init+0x170/0x170 [snd_soc_sof_sdw]
kernel: [ 872.695259] platform_remove+0x1a/0x40
kernel: [ 872.695264] device_release_driver_internal+0xf1/0x1d0
kernel: [ 872.695267] bus_remove_device+0xed/0x160
kernel: [ 872.695269] device_del+0x187/0x3e0
kernel: [ 872.695272] platform_device_del.part.0+0xe/0x60
kernel: [ 872.695274] platform_device_unregister+0x17/0x30
kernel: [ 872.695277] snd_sof_device_remove+0x53/0xf0 [snd_sof]
kernel: [ 872.695283] sof_pci_remove+0x15/0x40 [snd_sof_pci]
kernel: [ 872.695286] pci_device_remove+0x36/0xa0
kernel: [ 872.695290] device_release_driver_internal+0xf1/0x1d0
kernel: [ 872.695292] driver_detach+0x42/0x90
kernel: [ 872.695294] bus_remove_driver+0x56/0xd0
kernel: [ 872.695296] pci_unregister_driver+0x36/0x80
kernel: [ 872.695299] __x64_sys_delete_module+0x18f/0x250
Heikki Krogerus
reviewerQuoted 8 lines · Pierre-Louis Bossart
I took the code and split it in two for BYT/CHT (modified to remove
devm_) and SoundWire parts (added as is).https://github.com/thesofproject/linux/pull/2810
Both cases result in a refcount error on
device_remove_sofwhen removing the platform device. I don't understand the code well enough to figure out what happens, but it's likely a case of the software node being removed twice?
Right. Because you are injecting the node to an already existing device, the node does not get linked with the device in sysfs. That would increment the reference count in a normal case. It all happens in the function software_node_notify(). Driver core calls it when a device is added and also when it's removed. In this case it is only called when it's removed.
I think the best way to handle this now is to simply not decrementing the ref count when you add the properties, so don't call fwnode_handle_put() there (but add a comment explaining why you are not calling it).
For a better solution you would call device_reprobe() after you have injected the software node, but before that you need to modify device_reprobe() so it calls device_platform_notify() (which it really should call in any case). But this should probable be done later, separately.
thanks,
P.S.
Have you guys considered the possibility of describing the connections between all these components by using one of the methods that we now have for that in kernel, for example device graph? It can now be used also with software nodes (OF graph and ACPI device graph are of course already fully supported).
Signature · 1 line
heikki
Heikki Krogerus
reviewerQuoted 17 lines · Heikki Krogerus
Quoted 8 lines · Pierre-Louis Bossart
I took the code and split it in two for BYT/CHT (modified to remove
devm_) and SoundWire parts (added as is).https://github.com/thesofproject/linux/pull/2810
Both cases result in a refcount error on
device_remove_sofwhen removing the platform device. I don't understand the code well enough to figure out what happens, but it's likely a case of the software node being removed twice?Right. Because you are injecting the node to an already existing device, the node does not get linked with the device in sysfs. That would increment the reference count in a normal case. It all happens in the function
software_node_notify(). Driver core calls it when a device is added and also when it's removed. In this case it is only called when it's removed.
Quoted 4 lines
I think the best way to handle this now is to simply not decrementing the ref count when you add the properties, so don't call
fwnode_handle_put()there (but add a comment explaining why you are not calling it).
No, sorry... That's just too hacky. Let's not do that after all.
We can also fix this in the software node code. I'm attaching a patch that should make it possible to inject the software nodes also afterwards safely. This is definitely also not without its problems, but we can go with that if it works. Let me know.
Quoted 8 lines
For a better solution you would call
device_reprobe()after you have injected the software node, but before that you need to modifydevice_reprobe()so it callsdevice_platform_notify()(which it really should call in any case). But this should probable be done later, separately.thanks,
Quoted 7 lines
P.S.Have you guys considered the possibility of describing the connections between all these components by using one of the methods that we now have for that in kernel, for example device graph? It can now be used also with software nodes (OF graph and ACPI device graph are of course already fully supported).
Br,
Signature · 1 line
heikki
From 3d3dca1f80941f8975390bc8f488176d00acef22 Mon Sep 17 00:00:00 2001
From: Heikki Krogerus <[email protected]>
Date: Tue, 13 Apr 2021 16:28:34 +0300
Subject: [PATCH] software node: Allow node addition to already existing device
If the node is added to an already exiting device, the node needs to be also linked to the device separately.
This will make sure the reference count is kept in balance also when the node is injected to a device afterwards.
--- drivers/base/swnode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/base/swnode.c +3 -2
@@ -1032,6 +1032,7 @@ int device_add_software_node(struct device *dev, const struct software_node *nod }set_secondary_fwnode (dev, &swnode->fwnode); +software_node_notify (dev,KOBJ_ADD );return 0 ; }
@@ -1105,8 +1106,8 @@ int software_node_notify(struct device *dev, unsigned long action)switch (action) {case KOBJ_ADD : - ret =sysfs_create_link (&dev->kobj, &swnode->kobj, -"software_node" ); + ret =sysfs_create_link_nowarn (&dev->kobj, &swnode->kobj, +"software_node" );if (ret)break ;
Signature · 1 line
2.30.2
Quoted 23 lines · Heikki Krogerus
Quoted 17 lines · Heikki Krogerus
Quoted 8 lines · Pierre-Louis Bossart
I took the code and split it in two for BYT/CHT (modified to remove
devm_) and SoundWire parts (added as is).https://github.com/thesofproject/linux/pull/2810
Both cases result in a refcount error on
device_remove_sofwhen removing the platform device. I don't understand the code well enough to figure out what happens, but it's likely a case of the software node being removed twice?Right. Because you are injecting the node to an already existing device, the node does not get linked with the device in sysfs. That would increment the reference count in a normal case. It all happens in the function
software_node_notify(). Driver core calls it when a device is added and also when it's removed. In this case it is only called when it's removed.Quoted 4 lines
I think the best way to handle this now is to simply not decrementing the ref count when you add the properties, so don't call
fwnode_handle_put()there (but add a comment explaining why you are not calling it).
Quoted 6 lines
No, sorry... That's just too hacky. Let's not do that after all.
We can also fix this in the software node code. I'm attaching a patch that should make it possible to inject the software nodes also afterwards safely. This is definitely also not without its problems, but we can go with that if it works. Let me know.
I tested manually on bytcr w/ RT5640 and used the SOF CI farm to test the SoundWire cases, I don't see any issues with your patch. The refcount issue is gone and the module load/unload cycles don't report any problems.
Would you queue it for 5.13-rc1, or is this too late already?
Quoted 8 lines
Quoted 8 lines
For a better solution you would call
device_reprobe()after you have injected the software node, but before that you need to modifydevice_reprobe()so it callsdevice_platform_notify()(which it really should call in any case). But this should probable be done later, separately.thanks,
Quoted 7 lines
Quoted 7 lines
P.S.Have you guys considered the possibility of describing the connections between all these components by using one of the methods that we now have for that in kernel, for example device graph? It can now be used also with software nodes (OF graph and ACPI device graph are of course already fully supported).
I must admit I've never heard of a 'device graph'. Any pointers or APIs you can think of? It's a good comment since we are planning to rework the SOF clients and machine driver handling.
Heikki Krogerus
reviewerQuoted 33 lines · Pierre-Louis Bossart
Quoted 23 lines · Heikki Krogerus
Quoted 17 lines · Heikki Krogerus
Quoted 8 lines · Pierre-Louis Bossart
I took the code and split it in two for BYT/CHT (modified to remove
devm_) and SoundWire parts (added as is).https://github.com/thesofproject/linux/pull/2810
Both cases result in a refcount error on
device_remove_sofwhen removing the platform device. I don't understand the code well enough to figure out what happens, but it's likely a case of the software node being removed twice?Right. Because you are injecting the node to an already existing device, the node does not get linked with the device in sysfs. That would increment the reference count in a normal case. It all happens in the function
software_node_notify(). Driver core calls it when a device is added and also when it's removed. In this case it is only called when it's removed.Quoted 4 lines
I think the best way to handle this now is to simply not decrementing the ref count when you add the properties, so don't call
fwnode_handle_put()there (but add a comment explaining why you are not calling it).Quoted 6 lines
No, sorry... That's just too hacky. Let's not do that after all.
We can also fix this in the software node code. I'm attaching a patch that should make it possible to inject the software nodes also afterwards safely. This is definitely also not without its problems, but we can go with that if it works. Let me know.
Quoted 5 lines
I tested manually on bytcr w/ RT5640 and used the SOF CI farm to test the SoundWire cases, I don't see any issues with your patch. The refcount issue is gone and the module load/unload cycles don't report any problems.
Would you queue it for 5.13-rc1, or is this too late already?
I'll send it out now. Let's see what happens.
thanks,
Quoted 20 lines
Quoted 8 lines
Quoted 8 lines
For a better solution you would call
device_reprobe()after you have injected the software node, but before that you need to modifydevice_reprobe()so it callsdevice_platform_notify()(which it really should call in any case). But this should probable be done later, separately.thanks,
Quoted 7 lines
Quoted 7 lines
P.S.Have you guys considered the possibility of describing the connections between all these components by using one of the methods that we now have for that in kernel, for example device graph? It can now be used also with software nodes (OF graph and ACPI device graph are of course already fully supported).
I must admit I've never heard of a 'device graph'. Any pointers or APIs you can think of?
It's a good comment since we are planning to rework the SOF clients and machine driver handling.
Signature · 1 line
heikki
Hi Heikki,
Going back to this initial patch, I have a doubt based on Andy Shevchenko's comment on an update [1]
Quoted 2 lines
The function
device_add_properties()is going to be removed. Replacing it with software node API equivalents.
The replacement pattern takes this one line:
Review
Quoted 1 line
(quoted diff) +0
-1- ret = device_add_properties(sdw_dev, props);
which gets replaced by
sound/soc/intel/boards/sof_sdw_rt711.c line 49
Quoted 8 lines
sound/soc/intel/boards/sof_sdw_rt711.c +6
-0+ fwnode =fwnode_create_software_node (props,NULL ); +if (IS_ERR (fwnode)) { +return PTR_ERR (fwnode); } + ret =device_add_software_node (sdw_dev,to_software_node (fwnode)); + +fwnode_handle_put (fwnode);
is the fwnode_handle_put() actually required here? This seems to work fine in our tests but I wasn't able to find in the code a matching _get().
Thanks for any pointers/comments!
-Pierre
[1] https://github.com/thesofproject/linux/pull/3041#discussion_r671450168