@@ -234,107 +234,6 @@ 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
339238#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR )
340239static ssize_t msg_inject_read (struct file * file , char __user * buffer ,
@@ -437,15 +336,6 @@ static int snd_sof_debugfs_msg_inject_item(struct snd_sof_dev *sdev,
437336static ssize_t sof_dfsentry_write (struct file * file , const char __user * buffer ,
438337 size_t count , loff_t * ppos )
439338{
440- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
441- struct snd_sof_dfsentry * dfse = file -> private_data ;
442- struct snd_sof_dev * sdev = dfse -> sdev ;
443- unsigned long ipc_duration_ms = 0 ;
444- bool flood_duration_test = false;
445- unsigned long ipc_count = 0 ;
446- struct dentry * dentry ;
447- int err ;
448- #endif
449339 size_t size ;
450340 char * string ;
451341 int ret ;
@@ -457,78 +347,6 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
457347 size = simple_write_to_buffer (string , count , ppos , buffer , count );
458348 ret = size ;
459349
460- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
461- /*
462- * write op is only supported for ipc_flood_count or
463- * ipc_flood_duration_ms debugfs entries atm.
464- * ipc_flood_count floods the DSP with the number of IPC's specified.
465- * ipc_duration_ms test floods the DSP for the time specified
466- * in the debugfs entry.
467- */
468- dentry = file -> f_path .dentry ;
469- if (strcmp (dentry -> d_name .name , "ipc_flood_count" ) &&
470- strcmp (dentry -> d_name .name , "ipc_flood_duration_ms" )) {
471- ret = - EINVAL ;
472- goto out ;
473- }
474-
475- if (!strcmp (dentry -> d_name .name , "ipc_flood_duration_ms" ))
476- flood_duration_test = true;
477-
478- /* test completion criterion */
479- if (flood_duration_test )
480- ret = kstrtoul (string , 0 , & ipc_duration_ms );
481- else
482- ret = kstrtoul (string , 0 , & ipc_count );
483- if (ret < 0 )
484- goto out ;
485-
486- /* limit max duration/ipc count for flood test */
487- if (flood_duration_test ) {
488- if (!ipc_duration_ms ) {
489- ret = size ;
490- goto out ;
491- }
492-
493- /* find the minimum. min() is not used to avoid warnings */
494- if (ipc_duration_ms > MAX_IPC_FLOOD_DURATION_MS )
495- ipc_duration_ms = MAX_IPC_FLOOD_DURATION_MS ;
496- } else {
497- if (!ipc_count ) {
498- ret = size ;
499- goto out ;
500- }
501-
502- /* find the minimum. min() is not used to avoid warnings */
503- if (ipc_count > MAX_IPC_FLOOD_COUNT )
504- ipc_count = MAX_IPC_FLOOD_COUNT ;
505- }
506-
507- ret = pm_runtime_get_sync (sdev -> dev );
508- if (ret < 0 && ret != - EACCES ) {
509- dev_err_ratelimited (sdev -> dev ,
510- "error: debugfs write failed to resume %d\n" ,
511- ret );
512- pm_runtime_put_noidle (sdev -> dev );
513- goto out ;
514- }
515-
516- /* flood test */
517- ret = sof_debug_ipc_flood_test (sdev , dfse , flood_duration_test ,
518- ipc_duration_ms , ipc_count );
519-
520- pm_runtime_mark_last_busy (sdev -> dev );
521- err = pm_runtime_put_autosuspend (sdev -> dev );
522- if (err < 0 )
523- dev_err_ratelimited (sdev -> dev ,
524- "error: debugfs write failed to idle %d\n" ,
525- err );
526-
527- /* return size if test is successful */
528- if (ret >= 0 )
529- ret = size ;
530- out :
531- #endif
532350 kfree (string );
533351 return ret ;
534352}
@@ -544,24 +362,6 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
544362 int size ;
545363 u8 * buf ;
546364
547- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
548- struct dentry * dentry ;
549-
550- dentry = file -> f_path .dentry ;
551- if ((!strcmp (dentry -> d_name .name , "ipc_flood_count" ) ||
552- !strcmp (dentry -> d_name .name , "ipc_flood_duration_ms" ))) {
553- if (* ppos )
554- return 0 ;
555-
556- count = strlen (dfse -> cache_buf );
557- size_ret = copy_to_user (buffer , dfse -> cache_buf , count );
558- if (size_ret )
559- return - EFAULT ;
560-
561- * ppos += count ;
562- return count ;
563- }
564- #endif
565365 size = dfse -> size ;
566366
567367 /* validate position & count */
@@ -719,19 +519,6 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
719519 dfse -> size = size ;
720520 dfse -> sdev = sdev ;
721521
722- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
723- if (!strncmp (name , "ipc_flood" , strlen ("ipc_flood" ))) {
724- /*
725- * cache_buf is unused for SOF_DFSENTRY_TYPE_BUF debugfs entries.
726- * So, use it to save the results of the last IPC flood test.
727- */
728- dfse -> cache_buf = devm_kzalloc (sdev -> dev , IPC_FLOOD_TEST_RESULT_LEN ,
729- GFP_KERNEL );
730- if (!dfse -> cache_buf )
731- return - ENOMEM ;
732- }
733- #endif
734-
735522 debugfs_create_file (name , mode , sdev -> debugfs_root , dfse ,
736523 & sof_dfs_fops );
737524 /* add to dfsentry list */
@@ -892,24 +679,6 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)
892679 return err ;
893680#endif
894681
895- #if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST )
896- /* create read-write ipc_flood_count debugfs entry */
897- err = snd_sof_debugfs_buf_item (sdev , NULL , 0 ,
898- "ipc_flood_count" , 0666 );
899-
900- /* errors are only due to memory allocation, not debugfs */
901- if (err < 0 )
902- return err ;
903-
904- /* create read-write ipc_flood_duration_ms debugfs entry */
905- err = snd_sof_debugfs_buf_item (sdev , NULL , 0 ,
906- "ipc_flood_duration_ms" , 0666 );
907-
908- /* errors are only due to memory allocation, not debugfs */
909- if (err < 0 )
910- return err ;
911- #endif
912-
913682#if IS_ENABLED (CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR )
914683 err = snd_sof_debugfs_msg_inject_item (sdev , "ipc_msg_inject" , 0644 ,
915684 & msg_inject_fops );
0 commit comments