Skip to content

Commit 39862fe

Browse files
author
Jyri Sarha
committed
ASoC: SOF: sof-client-probes: Add available points_info(), IPC4 only
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]>
1 parent b822f74 commit 39862fe

File tree

4 files changed

+78
-14
lines changed

4 files changed

+78
-14
lines changed

sound/soc/sof/sof-client-probes-ipc3.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ static int ipc3_probes_deinit(struct sof_client_dev *cdev)
100100
}
101101

102102
static int ipc3_probes_info(struct sof_client_dev *cdev, unsigned int cmd,
103-
void **params, size_t *num_params)
103+
void **params, size_t *num_params,
104+
enum sof_probe_info_type type)
104105
{
105106
size_t max_msg_size = sof_client_get_ipc_max_payload_size(cdev);
107+
struct device *dev = &cdev->auxdev.dev;
106108
struct sof_ipc_probe_info_params msg = {{{0}}};
107109
struct sof_ipc_probe_info_params *reply;
108110
size_t bytes;
@@ -111,6 +113,11 @@ static int ipc3_probes_info(struct sof_client_dev *cdev, unsigned int cmd,
111113
*params = NULL;
112114
*num_params = 0;
113115

116+
if (type != PROBES_INFO_ACTIVE_PROBES) {
117+
dev_err(dev, "%s: info type %u not supported", __func__, type);
118+
return -EOPNOTSUPP;
119+
}
120+
114121
reply = kzalloc(max_msg_size, GFP_KERNEL);
115122
if (!reply)
116123
return -ENOMEM;
@@ -153,10 +160,12 @@ static int ipc3_probes_info(struct sof_client_dev *cdev, unsigned int cmd,
153160
*/
154161
static int ipc3_probes_points_info(struct sof_client_dev *cdev,
155162
struct sof_probe_point_desc **desc,
156-
size_t *num_desc)
163+
size_t *num_desc,
164+
enum sof_probe_info_type)
157165
{
158166
return ipc3_probes_info(cdev, SOF_IPC_PROBE_POINT_INFO,
159-
(void **)desc, num_desc);
167+
(void **)desc, num_desc,
168+
PROBES_INFO_ACTIVE_PROBES);
160169
}
161170

162171
/**

sound/soc/sof/sof-client-probes-ipc4.c

+24-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum sof_ipc4_probe_runtime_param {
2828
SOF_IPC4_PROBE_INJECTION_DMA_DETACH,
2929
SOF_IPC4_PROBE_POINTS,
3030
SOF_IPC4_PROBE_POINTS_DISCONNECT,
31+
SOF_IPC4_PROBE_POINTS_AVAILABLE,
3132
};
3233

3334
struct sof_ipc4_probe_gtw_cfg {
@@ -170,30 +171,49 @@ static int ipc4_probes_deinit(struct sof_client_dev *cdev)
170171
}
171172

172173
/**
173-
* ipc4_probes_points_info - retrieve list of active probe points
174+
* ipc4_probes_points_info - retrieve list of probe points
174175
* @cdev: SOF client device
175176
* @desc: Returned list of active probes
176177
* @num_desc: Returned count of active probes
178+
* @type: Either PROBES_INFO_ACTIVE_PROBES or PROBES_INFO_AVAILABE_PROBES
177179
* @return: 0 on success, negative error code on error
180+
*
181+
* Returns list if active probe poins if type is
182+
* PROBES_INFO_ACTIVE_PROBES, or list of all available probe points if
183+
* type is PROBES_INFO_AVAILABE_PROBES.
178184
*/
179185
static int ipc4_probes_points_info(struct sof_client_dev *cdev,
180186
struct sof_probe_point_desc **desc,
181-
size_t *num_desc)
187+
size_t *num_desc,
188+
enum sof_probe_info_type type)
182189
{
183190
struct sof_man4_module *mentry = sof_ipc4_probe_get_module_info(cdev);
184191
struct device *dev = &cdev->auxdev.dev;
185192
struct sof_ipc4_probe_info *info;
186193
struct sof_ipc4_msg msg;
194+
u32 param_id;
187195
int i, ret;
188196

189197
if (!mentry)
190198
return -ENODEV;
191199

200+
switch (type) {
201+
case PROBES_INFO_ACTIVE_PROBES:
202+
param_id = SOF_IPC4_PROBE_POINTS;
203+
break;
204+
case PROBES_INFO_AVAILABE_PROBES:
205+
param_id = SOF_IPC4_PROBE_POINTS_AVAILABLE;
206+
break;
207+
default:
208+
dev_err(dev, "%s: info type %u not supported", __func__, type);
209+
return -EOPNOTSUPP;
210+
};
211+
192212
msg.primary = mentry->id;
193213
msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST);
194214
msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG);
195215

196-
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(SOF_IPC4_PROBE_POINTS);
216+
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(param_id);
197217

198218
msg.data_size = cdev->sdev->ipc->max_payload_size;
199219
msg.data_ptr = kzalloc(msg.data_size, GFP_KERNEL);
@@ -247,7 +267,7 @@ static int ipc4_probes_points_add(struct sof_client_dev *cdev,
247267
int i, ret;
248268

249269
if (!mentry)
250-
return -ENODEV;
270+
return -EOPNOTSUPP;
251271

252272
/* The sof_probe_point_desc and sof_ipc4_probe_point structs
253273
* are of same size and even the integers are the same in the

sound/soc/sof/sof-client-probes.c

+36-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static int sof_probes_compr_shutdown(struct snd_compr_stream *cstream,
7575
int i, ret;
7676

7777
/* disconnect all probe points */
78-
ret = ipc->points_info(cdev, &desc, &num_desc);
78+
ret = ipc->points_info(cdev, &desc, &num_desc,
79+
PROBES_INFO_ACTIVE_PROBES);
7980
if (ret < 0) {
8081
dev_err(dai->dev, "Failed to get probe points: %d\n", ret);
8182
goto exit;
@@ -245,7 +246,8 @@ static int sof_probes_ipc4_prints(struct sof_client_dev *cdev, char *buf, size_t
245246
#endif
246247

247248
static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
248-
size_t count, loff_t *ppos)
249+
size_t count, loff_t *ppos,
250+
enum sof_probe_info_type type)
249251
{
250252
struct sof_client_dev *cdev = file->private_data;
251253
struct sof_probes_priv *priv = cdev->data;
@@ -272,7 +274,7 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
272274
goto exit;
273275
}
274276

275-
ret = ipc->points_info(cdev, &desc, &num_desc);
277+
ret = ipc->points_info(cdev, &desc, &num_desc, type);
276278
if (ret < 0)
277279
goto pm_error;
278280

@@ -308,6 +310,22 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
308310
return ret;
309311
}
310312

313+
static ssize_t sof_probes_dfs_active_points_read(struct file *file,
314+
char __user *to,
315+
size_t count, loff_t *ppos)
316+
{
317+
return sof_probes_dfs_points_read(file, to, count, ppos,
318+
PROBES_INFO_ACTIVE_PROBES);
319+
}
320+
321+
static ssize_t sof_probes_dfs_available_points_read(struct file *file,
322+
char __user *to,
323+
size_t count, loff_t *ppos)
324+
{
325+
return sof_probes_dfs_points_read(file, to, count, ppos,
326+
PROBES_INFO_AVAILABE_PROBES);
327+
}
328+
311329
static ssize_t
312330
sof_probes_dfs_points_write(struct file *file, const char __user *from,
313331
size_t count, loff_t *ppos)
@@ -358,15 +376,23 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
358376
return ret;
359377
}
360378

361-
static const struct file_operations sof_probes_points_fops = {
379+
static const struct file_operations sof_probes_active_points_fops = {
362380
.open = simple_open,
363-
.read = sof_probes_dfs_points_read,
381+
.read = sof_probes_dfs_active_points_read,
364382
.write = sof_probes_dfs_points_write,
365383
.llseek = default_llseek,
366384

367385
.owner = THIS_MODULE,
368386
};
369387

388+
static const struct file_operations sof_probes_available_points_fops = {
389+
.open = simple_open,
390+
.read = sof_probes_dfs_available_points_read,
391+
.llseek = default_llseek,
392+
393+
.owner = THIS_MODULE,
394+
};
395+
370396
static ssize_t
371397
sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
372398
size_t count, loff_t *ppos)
@@ -512,13 +538,17 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
512538

513539
/* create read-write probes_points debugfs entry */
514540
priv->dfs_points = debugfs_create_file("probe_points", 0644, dfsroot,
515-
cdev, &sof_probes_points_fops);
541+
cdev, &sof_probes_active_points_fops);
516542

517543
/* create read-write probe_points_remove debugfs entry */
518544
priv->dfs_points_remove = debugfs_create_file("probe_points_remove", 0644,
519545
dfsroot, cdev,
520546
&sof_probes_points_remove_fops);
521547

548+
/* create read-write probes_points debugfs entry */
549+
priv->dfs_points = debugfs_create_file("probe_points_available", 0644, dfsroot,
550+
cdev, &sof_probes_available_points_fops);
551+
522552
links = devm_kcalloc(dev, SOF_PROBES_NUM_DAI_LINKS, sizeof(*links), GFP_KERNEL);
523553
cpus = devm_kcalloc(dev, SOF_PROBES_NUM_DAI_LINKS, sizeof(*cpus), GFP_KERNEL);
524554
if (!links || !cpus) {

sound/soc/sof/sof-client-probes.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ struct sof_probe_point_desc {
4848
#define SOF_IPC4_PROBE_IDX_GET(x) (((x) & SOF_IPC4_PROBE_IDX_MASK) \
4949
>> SOF_IPC4_PROBE_IDX_SHIFT)
5050

51+
enum sof_probe_info_type {
52+
PROBES_INFO_ACTIVE_PROBES = 0,
53+
PROBES_INFO_AVAILABE_PROBES,
54+
};
55+
5156
struct sof_probes_ipc_ops {
5257
int (*init)(struct sof_client_dev *cdev, u32 stream_tag,
5358
size_t buffer_size);
5459
int (*deinit)(struct sof_client_dev *cdev);
5560
int (*points_info)(struct sof_client_dev *cdev,
5661
struct sof_probe_point_desc **desc,
57-
size_t *num_desc);
62+
size_t *num_desc, enum sof_probe_info_type type);
5863
int (*points_add)(struct sof_client_dev *cdev,
5964
struct sof_probe_point_desc *desc,
6065
size_t num_desc);

0 commit comments

Comments
 (0)