@@ -234,120 +234,10 @@ static int snd_sof_debugfs_probe_item(struct snd_sof_dev *sdev,
234234}
235235#endif
236236
237- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
238- #define MAX_IPC_FLOOD_DURATION_MS 1000
239- #define MAX_IPC_FLOOD_COUNT 10000
240- #define IPC_FLOOD_TEST_RESULT_LEN 512
241-
242- static int sof_debug_ipc_flood_test (struct snd_sof_dev * sdev ,
243- struct snd_sof_dfsentry * dfse ,
244- bool flood_duration_test ,
245- unsigned long ipc_duration_ms ,
246- unsigned long ipc_count )
247- {
248- struct sof_ipc_cmd_hdr hdr ;
249- struct sof_ipc_reply reply ;
250- u64 min_response_time = U64_MAX ;
251- ktime_t start , end , test_end ;
252- u64 avg_response_time = 0 ;
253- u64 max_response_time = 0 ;
254- u64 ipc_response_time ;
255- int i = 0 ;
256- int ret ;
257-
258- /* configure test IPC */
259- hdr .cmd = SOF_IPC_GLB_TEST_MSG | SOF_IPC_TEST_IPC_FLOOD ;
260- hdr .size = sizeof (hdr );
261-
262- /* set test end time for duration flood test */
263- if (flood_duration_test )
264- test_end = ktime_get_ns () + ipc_duration_ms * NSEC_PER_MSEC ;
265-
266- /* send test IPC's */
267- while (1 ) {
268- start = ktime_get ();
269- ret = sof_ipc_tx_message (sdev -> ipc , hdr .cmd , & hdr , hdr .size ,
270- & reply , sizeof (reply ));
271- end = ktime_get ();
272-
273- if (ret < 0 )
274- break ;
275-
276- /* compute min and max response times */
277- ipc_response_time = ktime_to_ns (ktime_sub (end , start ));
278- min_response_time = min (min_response_time , ipc_response_time );
279- max_response_time = max (max_response_time , ipc_response_time );
280-
281- /* sum up response times */
282- avg_response_time += ipc_response_time ;
283- i ++ ;
284-
285- /* test complete? */
286- if (flood_duration_test ) {
287- if (ktime_to_ns (end ) >= test_end )
288- break ;
289- } else {
290- if (i == ipc_count )
291- break ;
292- }
293- }
294-
295- if (ret < 0 )
296- dev_err (sdev -> dev ,
297- "error: ipc flood test failed at %d iterations\n" , i );
298-
299- /* return if the first IPC fails */
300- if (!i )
301- return ret ;
302-
303- /* compute average response time */
304- do_div (avg_response_time , i );
305-
306- /* clear previous test output */
307- memset (dfse -> cache_buf , 0 , IPC_FLOOD_TEST_RESULT_LEN );
308-
309- if (flood_duration_test ) {
310- dev_dbg (sdev -> dev , "IPC Flood test duration: %lums\n" ,
311- ipc_duration_ms );
312- snprintf (dfse -> cache_buf , IPC_FLOOD_TEST_RESULT_LEN ,
313- "IPC Flood test duration: %lums\n" , ipc_duration_ms );
314- }
315-
316- dev_dbg (sdev -> dev ,
317- "IPC Flood count: %d, Avg response time: %lluns\n" ,
318- i , avg_response_time );
319- dev_dbg (sdev -> dev , "Max response time: %lluns\n" ,
320- max_response_time );
321- dev_dbg (sdev -> dev , "Min response time: %lluns\n" ,
322- min_response_time );
323-
324- /* format output string */
325- snprintf (dfse -> cache_buf + strlen (dfse -> cache_buf ),
326- IPC_FLOOD_TEST_RESULT_LEN - strlen (dfse -> cache_buf ),
327- "IPC Flood count: %d\nAvg response time: %lluns\n" ,
328- i , avg_response_time );
329-
330- snprintf (dfse -> cache_buf + strlen (dfse -> cache_buf ),
331- IPC_FLOOD_TEST_RESULT_LEN - strlen (dfse -> cache_buf ),
332- "Max response time: %lluns\nMin response time: %lluns\n" ,
333- max_response_time , min_response_time );
334-
335- return ret ;
336- }
337- #endif
338237
339238static ssize_t sof_dfsentry_write (struct file * file , const char __user * buffer ,
340239 size_t count , loff_t * ppos )
341240{
342- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
343- struct snd_sof_dfsentry * dfse = file -> private_data ;
344- struct snd_sof_dev * sdev = dfse -> sdev ;
345- unsigned long ipc_duration_ms = 0 ;
346- bool flood_duration_test = false;
347- unsigned long ipc_count = 0 ;
348- struct dentry * dentry ;
349- int err ;
350- #endif
351241 size_t size ;
352242 char * string ;
353243 int ret ;
@@ -359,78 +249,6 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
359249 size = simple_write_to_buffer (string , count , ppos , buffer , count );
360250 ret = size ;
361251
362- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
363- /*
364- * write op is only supported for ipc_flood_count or
365- * ipc_flood_duration_ms debugfs entries atm.
366- * ipc_flood_count floods the DSP with the number of IPC's specified.
367- * ipc_duration_ms test floods the DSP for the time specified
368- * in the debugfs entry.
369- */
370- dentry = file -> f_path .dentry ;
371- if (strcmp (dentry -> d_name .name , "ipc_flood_count" ) &&
372- strcmp (dentry -> d_name .name , "ipc_flood_duration_ms" )) {
373- ret = - EINVAL ;
374- goto out ;
375- }
376-
377- if (!strcmp (dentry -> d_name .name , "ipc_flood_duration_ms" ))
378- flood_duration_test = true;
379-
380- /* test completion criterion */
381- if (flood_duration_test )
382- ret = kstrtoul (string , 0 , & ipc_duration_ms );
383- else
384- ret = kstrtoul (string , 0 , & ipc_count );
385- if (ret < 0 )
386- goto out ;
387-
388- /* limit max duration/ipc count for flood test */
389- if (flood_duration_test ) {
390- if (!ipc_duration_ms ) {
391- ret = size ;
392- goto out ;
393- }
394-
395- /* find the minimum. min() is not used to avoid warnings */
396- if (ipc_duration_ms > MAX_IPC_FLOOD_DURATION_MS )
397- ipc_duration_ms = MAX_IPC_FLOOD_DURATION_MS ;
398- } else {
399- if (!ipc_count ) {
400- ret = size ;
401- goto out ;
402- }
403-
404- /* find the minimum. min() is not used to avoid warnings */
405- if (ipc_count > MAX_IPC_FLOOD_COUNT )
406- ipc_count = MAX_IPC_FLOOD_COUNT ;
407- }
408-
409- ret = pm_runtime_get_sync (sdev -> dev );
410- if (ret < 0 && ret != - EACCES ) {
411- dev_err_ratelimited (sdev -> dev ,
412- "error: debugfs write failed to resume %d\n" ,
413- ret );
414- pm_runtime_put_noidle (sdev -> dev );
415- goto out ;
416- }
417-
418- /* flood test */
419- ret = sof_debug_ipc_flood_test (sdev , dfse , flood_duration_test ,
420- ipc_duration_ms , ipc_count );
421-
422- pm_runtime_mark_last_busy (sdev -> dev );
423- err = pm_runtime_put_autosuspend (sdev -> dev );
424- if (err < 0 )
425- dev_err_ratelimited (sdev -> dev ,
426- "error: debugfs write failed to idle %d\n" ,
427- err );
428-
429- /* return size if test is successful */
430- if (ret >= 0 )
431- ret = size ;
432- out :
433- #endif
434252 kfree (string );
435253 return ret ;
436254}
@@ -446,24 +264,6 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
446264 int size ;
447265 u8 * buf ;
448266
449- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
450- struct dentry * dentry ;
451-
452- dentry = file -> f_path .dentry ;
453- if ((!strcmp (dentry -> d_name .name , "ipc_flood_count" ) ||
454- !strcmp (dentry -> d_name .name , "ipc_flood_duration_ms" ))) {
455- if (* ppos )
456- return 0 ;
457-
458- count = strlen (dfse -> cache_buf );
459- size_ret = copy_to_user (buffer , dfse -> cache_buf , count );
460- if (size_ret )
461- return - EFAULT ;
462-
463- * ppos += count ;
464- return count ;
465- }
466- #endif
467267 size = dfse -> size ;
468268
469269 /* validate position & count */
@@ -621,19 +421,6 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
621421 dfse -> size = size ;
622422 dfse -> sdev = sdev ;
623423
624- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
625- if (!strncmp (name , "ipc_flood" , strlen ("ipc_flood" ))) {
626- /*
627- * cache_buf is unused for SOF_DFSENTRY_TYPE_BUF debugfs entries.
628- * So, use it to save the results of the last IPC flood test.
629- */
630- dfse -> cache_buf = devm_kzalloc (sdev -> dev , IPC_FLOOD_TEST_RESULT_LEN ,
631- GFP_KERNEL );
632- if (!dfse -> cache_buf )
633- return - ENOMEM ;
634- }
635- #endif
636-
637424 debugfs_create_file (name , mode , sdev -> debugfs_root , dfse ,
638425 & sof_dfs_fops );
639426 /* add to dfsentry list */
@@ -794,24 +581,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)
794581 return err ;
795582#endif
796583
797- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
798- /* create read-write ipc_flood_count debugfs entry */
799- err = snd_sof_debugfs_buf_item (sdev , NULL , 0 ,
800- "ipc_flood_count" , 0666 );
801-
802- /* errors are only due to memory allocation, not debugfs */
803- if (err < 0 )
804- return err ;
805-
806- /* create read-write ipc_flood_duration_ms debugfs entry */
807- err = snd_sof_debugfs_buf_item (sdev , NULL , 0 ,
808- "ipc_flood_duration_ms" , 0666 );
809-
810- /* errors are only due to memory allocation, not debugfs */
811- if (err < 0 )
812- return err ;
813- #endif
814-
815584 return 0 ;
816585}
817586EXPORT_SYMBOL_GPL (snd_sof_dbg_init );
0 commit comments