Skip to content

updates for keyword detect - #771

Merged
plbossart merged 5 commits into
thesofproject:topic/sof-devfrom
keyonjie:topic/kwd
Apr 3, 2019
Merged

plbossart merged 5 commits into
thesofproject:topic/sof-devfrom
keyonjie:topic/kwd

Conversation

@keyonjie

@keyonjie keyonjie commented Apr 2, 2019

Copy link
Copy Markdown

Mostly are topology updates, needed for keyword detect feature.

ranj063 added 5 commits April 2, 2019 14:52
Align all processing components to use the same IPC component constructor
and bump up the ABI.

Also, de-duplicate FIR and IIR handling code into one function that
can deal with multiple processing component types.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add process comp type for keyword detect, KPB and channel
selector components and support for loading
such comps during topology load.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add support for binding widgets to external dapm events.
Define and implement the DAPM event handler for
keyword detect component. The keyword detect component
is responsible for setting the pipeline params and
triggering all the components in the pipeline upon receiving a
PRE_PMU or a POST_PMD DAPM event indicating that the
audio pipeline it is connected to has been activated.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
output/out_drv type widgets may be added in topology
for compatibility. In the case of hostless pipelines,
these might be used to propagate DAPM events to the
pipeline. Do not send such routes to the FW as they
need not be handled by the DSP.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
In the keyword detect pipeline, there is a need for
the detect component to receive the runtime PCM
params from the capture pipeline. So in order to
facilitate retreiving the PCM params from the
capture pipeline, the detect component has to
have its stream_name set to the PCM name.

The function snd_sof_find_spcm_name() is currently used to
acquire the PCM for a widget by matching the widget's
stream name with the PCM name. If the stream_name field for
the widget is not set in topology the input argument "name"
will be empty.

Also, not all PCM's have both playback and capture capabilities set
in topology ie the caps name could be empty. If the "name"
argument happens to be empty because
the stream name for the widget was not in topology,
snd_sof_find_spcm_name() will return the first spcm that has
an empty name for either its playback or capture caps.

So, add the check to make sure that the
caps name is set before matching with the input argument.

Also, modify signature for snd_sof_find_spcm_name to take
const char * as input.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@plbossart
plbossart requested review from juimonen and ranj063 April 2, 2019 16:31

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @keyonjie. Patches 3,4,5 could be merged directly. For the first two, I'd like to have more information on backwards compatibility since they seem to be a minor ABI change.

/* SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 3
#define SOF_ABI_MINOR 4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there really an ABI change and is this aligned with firmware?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also have you tested backwards compatibility (new kernel, old firmware)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie @plbossart the ABI change is probably the most confusing bit of all for me. The same change was merged in the FW a few weeks ago and the ABI minor version was bumped up to 2. But since then, there have been other changes merged into the FW and the kernel which have updated the ABI too.

So I'd say we probably dont need an ABI change for this. But then we do update the ipc structure so maybe we should?

@plbossart plbossart Apr 2, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgirdwood need your help on this one. it seems all of this was merged in the firmware some time back?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just went though uapi headers of FW, we are actually somewhat mismatched already with the latest codes of both side(maybe it can still work for EQ components), I think that is a reason of why @lgirdwood is planning for a marjor version bump?

back to question from @plbossart, I think we are good as here the new struct sof_ipc_comp_process is compatible with the old struct sof_ipc_comp_eq_fir and struct sof_ipc_comp_eq_iir, that means, though the driver sending with new struct, FW can still parse them in format of old ones, and get the correct settings. Furthermore, there is no de facto EQ topology used by any releases yet so we are good with this update? @singalsu can you help confirm?

some minor mismatched for abi of processing components e.g.
FW:

/** \brief Types of processing components */
enum sof_ipc_process_type {
	SOF_PROCESS_NONE = 0,		/**< None */
	SOF_PROCESS_EQFIR,		/**< Intel FIR */
	SOF_PROCESS_EQIIR,		/**< Intel IIR */
};

/* generic "effect", "codec" or proprietary processing component */
struct sof_ipc_comp_process {
	struct sof_ipc_comp comp;
	struct sof_ipc_comp_config config;
	uint32_t size;	/**< size of bespoke data section in bytes */
	uint32_t type;	/**< sof_ipc_effect_type */

	/* reserved for future use */
	uint32_t reserved[7];

	unsigned char data[0];
} __attribute__((packed));

driver:

/** \brief Types of EFFECT */
enum sof_ipc_effect_type {
	SOF_EFFECT_NONE = 0,		/**< None */
	SOF_EFFECT_INTEL_EQFIR,		/**< Intel FIR */
	SOF_EFFECT_INTEL_EQIIR,		/**< Intel IIR */
};

/* general purpose EFFECT configuration */
struct sof_ipc_comp_effect {
	struct sof_ipc_hdr hdr;
	uint32_t type;			/** sof_ipc_effect_type */
} __packed;

/* FIR equalizer component */
struct sof_ipc_comp_eq_fir {
	struct sof_ipc_comp comp;
	struct sof_ipc_comp_config config;
	uint32_t size;

	/* reserved for future use */
	uint32_t reserved[8];

	unsigned char data[0];
} __packed;

/* IIR equalizer component */
struct sof_ipc_comp_eq_iir {
	struct sof_ipc_comp comp;
	struct sof_ipc_comp_config config;
	uint32_t size;

	/* reserved for future use */
	uint32_t reserved[8];

	unsigned char data[0];
} __packed;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do backwards compatibility test if @singalsu or @ranj063 can help point out which EQ topology file I should run on what platform which is verified work with latest code base.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I am going to merge this to realign with firmware. @singalsu please make sure we deal with backwards compatibility issues and that the old firmware-new kernel case is covered. Thanks!

@plbossart
plbossart merged commit bf3d5cf into thesofproject:topic/sof-dev Apr 3, 2019
@singalsu

singalsu commented Apr 3, 2019

Copy link
Copy Markdown
Collaborator

@plbossart OK, I'll test with this. I have related two other EQ control issues to fix as well.

plbossart pushed a commit that referenced this pull request Aug 25, 2023
…n driver remove

When the tagging protocol in current use is "ocelot-8021q" and we unbind
the driver, we see this splat:

$ echo '0000:00:00.2' > /sys/bus/pci/drivers/fsl_enetc/unbind
mscc_felix 0000:00:00.5 swp0: left promiscuous mode
sja1105 spi2.0: Link is Down
DSA: tree 1 torn down
mscc_felix 0000:00:00.5 swp2: left promiscuous mode
sja1105 spi2.2: Link is Down
DSA: tree 3 torn down
fsl_enetc 0000:00:00.2 eno2: left promiscuous mode
mscc_felix 0000:00:00.5: Link is Down
------------[ cut here ]------------
RTNL: assertion failed at net/dsa/tag_8021q.c (409)
WARNING: CPU: 1 PID: 329 at net/dsa/tag_8021q.c:409 dsa_tag_8021q_unregister+0x12c/0x1a0
Modules linked in:
CPU: 1 PID: 329 Comm: bash Not tainted 6.5.0-rc3+ #771
pc : dsa_tag_8021q_unregister+0x12c/0x1a0
lr : dsa_tag_8021q_unregister+0x12c/0x1a0
Call trace:
 dsa_tag_8021q_unregister+0x12c/0x1a0
 felix_tag_8021q_teardown+0x130/0x150
 felix_teardown+0x3c/0xd8
 dsa_tree_teardown_switches+0xbc/0xe0
 dsa_unregister_switch+0x168/0x260
 felix_pci_remove+0x30/0x60
 pci_device_remove+0x4c/0x100
 device_release_driver_internal+0x188/0x288
 device_links_unbind_consumers+0xfc/0x138
 device_release_driver_internal+0xe0/0x288
 device_driver_detach+0x24/0x38
 unbind_store+0xd8/0x108
 drv_attr_store+0x30/0x50
---[ end trace 0000000000000000 ]---
------------[ cut here ]------------
RTNL: assertion failed at net/8021q/vlan_core.c (376)
WARNING: CPU: 1 PID: 329 at net/8021q/vlan_core.c:376 vlan_vid_del+0x1b8/0x1f0
CPU: 1 PID: 329 Comm: bash Tainted: G        W          6.5.0-rc3+ #771
pc : vlan_vid_del+0x1b8/0x1f0
lr : vlan_vid_del+0x1b8/0x1f0
 dsa_tag_8021q_unregister+0x8c/0x1a0
 felix_tag_8021q_teardown+0x130/0x150
 felix_teardown+0x3c/0xd8
 dsa_tree_teardown_switches+0xbc/0xe0
 dsa_unregister_switch+0x168/0x260
 felix_pci_remove+0x30/0x60
 pci_device_remove+0x4c/0x100
 device_release_driver_internal+0x188/0x288
 device_links_unbind_consumers+0xfc/0x138
 device_release_driver_internal+0xe0/0x288
 device_driver_detach+0x24/0x38
 unbind_store+0xd8/0x108
 drv_attr_store+0x30/0x50
DSA: tree 0 torn down

This was somewhat not so easy to spot, because "ocelot-8021q" is not the
default tagging protocol, and thus, not everyone who tests the unbinding
path may have switched to it beforehand. The default
felix_tag_npi_teardown() does not require rtnl_lock() to be held.

Fixes: 7c83a7c ("net: dsa: add a second tagger for Ocelot switches based on tag_8021q")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20230803134253.2711124-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
oder-chiou pushed a commit to oder-chiou/linux-soundwire that referenced this pull request May 5, 2026
The following trace can be seen if a device is being unregistered while
its number of channels are being modified.

  DEBUG_LOCKS_WARN_ON(lock->magic != lock)
  WARNING: CPU: 3 PID: 3754 at kernel/locking/mutex.c:564 __mutex_lock+0xc8a/0x1120
  CPU: 3 UID: 0 PID: 3754 Comm: ethtool Not tainted 6.13.0-rc6+ thesofproject#771
  RIP: 0010:__mutex_lock+0xc8a/0x1120
  Call Trace:
   <TASK>
   ethtool_check_max_channel+0x1ea/0x880
   ethnl_set_channels+0x3c3/0xb10
   ethnl_default_set_doit+0x306/0x650
   genl_family_rcv_msg_doit+0x1e3/0x2c0
   genl_rcv_msg+0x432/0x6f0
   netlink_rcv_skb+0x13d/0x3b0
   genl_rcv+0x28/0x40
   netlink_unicast+0x42e/0x720
   netlink_sendmsg+0x765/0xc20
   __sys_sendto+0x3ac/0x420
   __x64_sys_sendto+0xe0/0x1c0
   do_syscall_64+0x95/0x180
   entry_SYSCALL_64_after_hwframe+0x76/0x7e

This is because unregister_netdevice_many_notify might run before the
rtnl lock section of ethnl operations, eg. set_channels in the above
example. In this example the rss lock would be destroyed by the device
unregistration path before being used again, but in general running
ethnl operations while dismantle has started is not a good idea.

Fix this by denying any operation on devices being unregistered. A check
was already there in ethnl_ops_begin, but not wide enough.

Note that the same issue cannot be seen on the ioctl version
(__dev_ethtool) because the device reference is retrieved from within
the rtnl lock section there. Once dismantle started, the net device is
unlisted and no reference will be found.

Fixes: dde91cc ("ethtool: do not perform operations on net devices being unregistered")
Signed-off-by: Antoine Tenart <atenart@kernel.org>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Link: https://patch.msgid.link/20250116092159.50890-1-atenart@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants