Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probes ipc4 get config #5249

Open
wants to merge 5 commits into
base: topic/sof-dev
Choose a base branch
from

Conversation

jsarha
Copy link

@jsarha jsarha commented Nov 20, 2024

  • Some trivial fixes
  • proper sof_probes_ipc_ops points_info() implementation for ipc4
  • more informative debufs read output for ipc4
  • all availabe probe points option to points_info() and a separate debugfs file for it

The functionality of the new features depend on thesofproject/sof#9669

@jsarha jsarha marked this pull request as ready for review November 20, 2024 20:43
@jsarha jsarha force-pushed the probes_ipc4_get_config branch 5 times, most recently from 39862fe to 32b8154 Compare November 21, 2024 15:46
lgirdwood
lgirdwood previously approved these changes Nov 21, 2024
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

LGTM, nice addition to make this way easier to use.

@jsarha
Copy link
Author

jsarha commented Nov 21, 2024

The small updates are for fixing sparse warnings from exotic builds. The check fails at first failed file and commit, so there is many iterations. Missing documentation, wrong format string for 32-bit build, etc. etc.

@jsarha jsarha force-pushed the probes_ipc4_get_config branch 2 times, most recently from c5ea419 to c0b2ba6 Compare November 21, 2024 21:25
Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@jsarha, you are flexing again the boundaries of what sof-clients can do ;)
There are couple of places that we need to align with the definition of sof-client, I know it makes things a bit harder, but I want to keep the rules applicable.

sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.c Show resolved Hide resolved
sound/soc/sof/sof-client-probes.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.c Outdated Show resolved Hide resolved
Copy link
Author

@jsarha jsarha left a comment

Choose a reason for hiding this comment

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

Thanks @ujfalusi for feedback! I'll drop the first commit, implement the find widgets wrapper, and add the new sof_probes_ipc_ops callback.

sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.c Outdated Show resolved Hide resolved
@jsarha jsarha force-pushed the probes_ipc4_get_config branch 2 times, most recently from e0c8597 to ccc2da5 Compare November 25, 2024 08:16
lgirdwood
lgirdwood previously approved these changes Nov 28, 2024
Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@jsarha, this version looks much cleaner but there are few things that should be checked.

sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.h Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.c Show resolved Hide resolved
Copy link
Author

@jsarha jsarha left a comment

Choose a reason for hiding this comment

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

Thanks again. Hope its now good. At least its converging.

sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.h Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes.c Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc4.c Outdated Show resolved Hide resolved
sound/soc/sof/sof-client-probes-ipc3.c Show resolved Hide resolved
@ujfalusi
Copy link
Collaborator

ujfalusi commented Dec 2, 2024

@jsarha, can you check the W=1 build errors?

@jsarha jsarha force-pushed the probes_ipc4_get_config branch from 42620ca to f5bbc39 Compare December 9, 2024 09:42
@jsarha
Copy link
Author

jsarha commented Dec 9, 2024

@jsarha, can you check the W=1 build errors?

Oops, there were other short comings in the previous version too. I'll ping you once the compile CI tests are ready, if they are now OK.

@jsarha
Copy link
Author

jsarha commented Dec 9, 2024

@ujfalusi , I think this is finally good to go.

ujfalusi
ujfalusi previously approved these changes Dec 13, 2024
Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@jsarha, looks good to my eyes, but I will re-check it on Monday with somewhat fresher mind.
Thank you for the updates!

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Just one pointer check.

return ret;
}
info = msg.data_ptr;
*num_desc = info->num_elems;
Copy link
Member

Choose a reason for hiding this comment

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

do we check if this is NULL ?

Copy link
Author

@jsarha jsarha Dec 27, 2024

Choose a reason for hiding this comment

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

Which one? num_descs comes from these calls: https://github.com/jsarha/linux-sof/blob/f5bbc39177bbfcd1753a7fef69043f69e3b5a540/sound/soc/sof/sof-client-probes.c#L78 and https://github.com/jsarha/linux-sof/blob/f5bbc39177bbfcd1753a7fef69043f69e3b5a540/sound/soc/sof/sof-client-probes.c#L227 , and info is assigned from msg.data_ptr which is allocated and checked couple of lines earlier (on line 199). There should be no need to add any more checks for either one being NULL, should there?

return ret;
}
info = msg.data_ptr;
*num_desc = info->num_elems;
Copy link
Author

@jsarha jsarha Dec 27, 2024

Choose a reason for hiding this comment

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

Which one? num_descs comes from these calls: https://github.com/jsarha/linux-sof/blob/f5bbc39177bbfcd1753a7fef69043f69e3b5a540/sound/soc/sof/sof-client-probes.c#L78 and https://github.com/jsarha/linux-sof/blob/f5bbc39177bbfcd1753a7fef69043f69e3b5a540/sound/soc/sof/sof-client-probes.c#L227 , and info is assigned from msg.data_ptr which is allocated and checked couple of lines earlier (on line 199). There should be no need to add any more checks for either one being NULL, should there?

info = msg.data_ptr;
*num_desc = info->num_elems;
dev_dbg(dev, "%s: got %zu probe points", __func__, *num_desc);
info = msg.data_ptr;
Copy link
Author

Choose a reason for hiding this comment

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

Hmm, this superfluous assignment should go.

Jyri Sarha added 3 commits December 30, 2024 18:59
Upgrade the struct sof_probes_ipc_ops points_info() method from dummy
implementation to a working implementation. The actual functionality
requires that the DSP FW supports the IPC request. The support was
just recently added. If its not there an IPC failure is reported in
the logs.

Signed-off-by: Jyri Sarha <[email protected]>
Add SOF_IPC4_MOD_INSTANCE_GET() and SOF_IPC4_MOD_ID_GET() for getting
the ids from ipc4 header presentation.

Signed-off-by: Jyri Sarha <[email protected]>
Add sof_client_ipc4_find_swidget_by_id() for finding widgets from SOF
client devices. The motivation is to decode probes debugfs output to
be more readable.

Signed-off-by: Jyri Sarha <[email protected]>
@jsarha jsarha force-pushed the probes_ipc4_get_config branch from c3528ea to 4276e4f Compare December 30, 2024 17:44
@jsarha
Copy link
Author

jsarha commented Dec 30, 2024

Rebased on top of 6.13 based sof-dev.

@jsarha
Copy link
Author

jsarha commented Jan 7, 2025

@lgirdwood & @ujfalusi, a gentle ping!

@lgirdwood
Copy link
Member

@ujfalusi @ranj063 pls review.

@@ -34,13 +34,18 @@ struct sof_probe_point_desc {
unsigned int stream_tag;
} __packed;

enum sof_probe_info_type {
PROBES_INFO_ACTIVE_PROBES = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

i dont think you need the = 0

Copy link
Author

Choose a reason for hiding this comment

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

I usually like to explicitely show how an enum value will behave when interpreted as a boolean or what enum symbol a zeroed memory will have, but here there really is no need to care about what the numerical value is (I think I was expecting to use the value as a boolean).

Copy link
Collaborator

@ranj063 ranj063 left a comment

Choose a reason for hiding this comment

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

just one nit-pick, looks good otherwise

ranj063
ranj063 previously approved these changes Jan 8, 2025
Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

@jsarha, sorry for the delay, I have only one minor comment.

dev_err(dev, "%s: Failed to find widget for module %lu.%lu\n",
__func__, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
ret = snprintf(buf, size, "%u,%u,%u\nUNKNOWN buffer_id 0x%08x\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we keep this in one line ?

"%u,%u,%u\tUNKNOWN buffer_id 0x%08x\n"

and you are printing the desc->buffer_id twice?

Copy link
Author

Choose a reason for hiding this comment

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

Sure will "\n" to "\t". I am using different macros in different times I am printing desc->buffer_id. The module id and instance id is printed separately.

lgirdwood
lgirdwood previously approved these changes Jan 14, 2025
@jsarha jsarha dismissed stale reviews from lgirdwood and ranj063 via cd94f96 January 15, 2025 11:04
@jsarha jsarha force-pushed the probes_ipc4_get_config branch from 4276e4f to cd94f96 Compare January 15, 2025 11:04
Copy link
Author

@jsarha jsarha left a comment

Choose a reason for hiding this comment

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

Fixes recommended in last review round applied.

@@ -34,13 +34,18 @@ struct sof_probe_point_desc {
unsigned int stream_tag;
} __packed;

enum sof_probe_info_type {
PROBES_INFO_ACTIVE_PROBES = 0,
Copy link
Author

Choose a reason for hiding this comment

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

I usually like to explicitely show how an enum value will behave when interpreted as a boolean or what enum symbol a zeroed memory will have, but here there really is no need to care about what the numerical value is (I think I was expecting to use the value as a boolean).

dev_err(dev, "%s: Failed to find widget for module %lu.%lu\n",
__func__, SOF_IPC4_MOD_ID_GET(desc->buffer_id),
SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
ret = snprintf(buf, size, "%u,%u,%u\nUNKNOWN buffer_id 0x%08x\n",
Copy link
Author

Choose a reason for hiding this comment

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

Sure will "\n" to "\t". I am using different macros in different times I am printing desc->buffer_id. The module id and instance id is printed separately.

SOF_IPC4_MOD_INSTANCE_GET(desc->buffer_id));
ret = snprintf(buf, size, "%u,%u,%u\tUNKNOWN buffer_id 0x%08x\n",
desc->buffer_id, desc->purpose, desc->stream_tag,
desc->buffer_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I saw it before, but why are we printing the desc->buffer_id twice if swidget is not found?
Why not:

	ret = snprintf(buf, size, "%u,%u,%u\t<unknown> %s buf idx %lu %s\n",
		       desc->buffer_id, desc->purpose, desc->stream_tag,
		       sof_probe_ipc4_type_string(SOF_IPC4_PROBE_TYPE_GET(desc->buffer_id)),
		       SOF_IPC4_PROBE_IDX_GET(desc->buffer_id),
		       desc->stream_tag ? "(connected)" : "");

or combine the two prints into one:

	ret = snprintf(buf, size, "%u,%u,%u\t%s %s buf idx %lu %s\n",
		       desc->buffer_id, desc->purpose, desc->stream_tag,
		       swidget ? swidget->widget->name : "<unknown>",
		       sof_probe_ipc4_type_string(SOF_IPC4_PROBE_TYPE_GET(desc->buffer_id)),
		       SOF_IPC4_PROBE_IDX_GET(desc->buffer_id),
		       desc->stream_tag ? "(connected)" : "");

Jyri Sarha added 2 commits January 15, 2025 19:09
The current output of three integers is not very human readable. Use
ipc4 functions to describe in more detail what the struct
sof_probe_point_desc buffer_id is actually referring to in an ipc4 SOF
system.

Before this commit the "probe_points" debugfs file could read as:

Id: 0x01000004  Purpose: 0  Node id: 0x100
Id: 0x00000006  Purpose: 0  Node id: 0x100

And after in the same situation in an ipc4 system it reads:

16777220,0,256	host-copier.0.playback output buf idx 0 (probed)
6,0,256	gain.1.1 input buf idx 0 (probed)

The triplet in the beginning of the line can be used to reinserted the
probe point again by writing it into "probe_points" debugfs file, if
its first removed by writing the fist number in "probe_points_remove".
The last number is ignored when creating a probe point.

Signed-off-by: Jyri Sarha <[email protected]>
Add another debugfs file, "probe_points_available", that shows all the
available probe points in the SOF FW at the time of query. The probe
points are there only when an active SOF stream exists in the
system. However, the stream identifiers are persistent in the sense
that the same probe point identifiers always appear with the same
playback or capture command in the same system configuration.

The output, when reading "probe_points_available", may look like this:

16777220,0,256 host-copier.0.playback output 1 buf idx 0 (probed)
6,0,256	gain.1.1 input buf idx 0 (probed)
16777222,0,0	gain.1.1 output buf idx 0
2,0,0	mixin.1.1 input buf idx 0
16777218,0,0	mixin.1.1 output buf idx 0
3,0,0	mixout.2.1 input buf idx 0
16777219,0,0	mixout.2.1 output buf idx 0
65542,0,0	gain.2.1 input 0 buf idx 0
16842758,0,0	gain.2.1 output buf idx 0
15,0,0	smart_amp.2.1 input buf idx 0
16777231,0,0	smart_amp.2.1 output buf idx 0
65540,0,0	dai-copier.SSP.NoCodec-0.playback input buf idx 0

The triplet at the beginning of a line can be copy-pasted as such to
"probe_points" debugfs file for adding a probe point. The rest of the
line tries to give human readable explanation of what this probe point
is.

Signed-off-by: Jyri Sarha <[email protected]>
@jsarha jsarha force-pushed the probes_ipc4_get_config branch from cd94f96 to e6cd124 Compare January 15, 2025 17:18
@jsarha
Copy link
Author

jsarha commented Jan 15, 2025

@ujfalusi & @ranj063 , hope this is now good.

@ranj063 ranj063 requested a review from ujfalusi January 15, 2025 19:37
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Almost good to go for me, lets use HEX for our IDs though.

@@ -8,6 +8,7 @@
#include <sound/soc.h>
#include <sound/sof/ipc4/header.h>
#include <uapi/sound/sof/header.h>
#include "sof-audio.h"
Copy link
Member

Choose a reason for hiding this comment

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

@jsarha btw the 1st triplet above 16777220,0,256 is better in HEX as 0x1000004, 0x0, 0x100

Copy link
Author

Choose a reason for hiding this comment

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

@lgirdwood , the reason for the decimal format is the the fackt that its decimal numbers that are expected when defining the probe points. So if we want to be able to copy-paste the triplets to probe_points debgfs file, then we want to print decimal numbers. We can of course change the write interface too so that it expect hex-numbers or is sensitive to "0x" prefix. It would take a day or two to implement and properly test that, should I go that way?

Copy link
Member

Choose a reason for hiding this comment

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

Pls make hex, the hex value also make sense when introspection is performed by anyone debugging as they map to bit masks within the IDs, i.e. its not a coincidence we have 0x1000004 and 0x100 as values.

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