testsuite/gpiobench: Provide choice to switch clock for getting timestamp
PATCH 1/1 testsuite/gpiobench: Provide choice to switch clock for getting timestamp
Provide choices to switch clock between MONO and REALTIME for getting different timestamp since gpio driver already provide choosable service.
testsuite/gpiobench/gpiobench.c +18 -5
@@ -85,6 +85,7 @@ struct test_info {unsigned long total_cycles;unsigned long max_histogram;int mode; +int clockid;int prio;int quiet;int tracelimit;
@@ -121,7 +122,10 @@ static void display_help(void)" must be specified\n" "-m --testmode 0 is loopback mode\n" " 1 is react mode which works with a latency box,\n" -" default=0\n\n" +" default=0\n" +"-k --clockid 0 is CLOCK_REALTIME\n" +" 1 is CLOCK_MONOTONIC,\n" +" default=1\n\n" "e.g. gpiobench -o 20 -i 21 -c pinctrl-bcm2835\n" );
@@ -130,7 +134,7 @@ static void display_help(void)static void process_options (int argc,char *argv[]) {int c =0 ; -static const char optstring[] ="h:p:m:l:c:b:i:o:q" ; +static const char optstring[] ="h:p:m:l:c:b:i:o:k:q" ;struct option long_options[] = { {"bracetrace" , required_argument,0 ,'b' },
@@ -142,6 +146,7 @@ static void process_options(int argc, char *argv[]) { "intr", required_argument, 0, 'i'}, { "pinctrl", required_argument, 0, 'c'}, { "testmode", required_argument, 0, 'm'}, + { "clockid", required_argument, 0, 'k'}, { 0, 0, 0, 0}, };
@@ -185,6 +190,11 @@ static void process_options(int argc, char *argv[])MODE_REACT ?MODE_REACT :MODE_LOOPBACK ;break ; +case 'k' : + ti.clockid =atoi (optarg) >=CLOCK_MONOTONIC ? +CLOCK_MONOTONIC :CLOCK_REALTIME ; +break ; +default :display_help ();exit (2 );
@@ -291,7 +301,7 @@ static int rw_gpio(int value, int index)struct rtdm_gpio_readout rdo;long long gpio_write, gpio_read, inner_diff, outer_diff; -clock_gettime (CLOCK_MONOTONIC , ×tamp); +clock_gettime (ti.clockid, ×tamp); gpio_write =calc_us (timestamp); ret =write (ti.fd_dev_out, &value,sizeof (value));
@@ -306,7 +316,7 @@ static int rw_gpio(int value, int index)return ret; } -clock_gettime (CLOCK_MONOTONIC , ×tamp); +clock_gettime (ti.clockid, ×tamp); gpio_read =calc_us (timestamp); inner_diff = (rdo.timestamp - gpio_write) /1000 ;
@@ -472,6 +482,7 @@ static void init_ti(void) ti.gpio_out =-1 ; ti.gpio_intr =-1 ; ti.mode =MODE_LOOPBACK ; + ti.clockid =CLOCK_MONOTONIC ; ti.ts.inner_min = ti.ts.outer_min =DEFAULT_LIMIT ; ti.ts.inner_max = ti.ts.outer_max =0 ;
@@ -632,7 +643,9 @@ int main(int argc, char **argv) goto out; } - ret =ioctl (ti.fd_dev_intr,GPIO_RTIOC_TS_MONO , &value); + ret =ioctl (ti.fd_dev_intr, + ti.clockid ==CLOCK_MONOTONIC ? +GPIO_RTIOC_TS_MONO :GPIO_RTIOC_TS_REAL , &value);if (ret) {printf ("ioctl gpio port ts, failed\n" ); goto out;
Signature · 1 line
2.17.1
Jan Kiszka
AppliedQuoted 86 lines · Hongzhan Chen via Xenomai
Provide choices to switch clock between MONO and REALTIME for getting different timestamp since gpio driver already provide choosable service.
Signed-off-by Hongzhan Chen <[email protected]>testsuite/gpiobench/gpiobench.c +15
-4@@ -85,6 +85,7 @@ struct test_info {unsigned long total_cycles;unsigned long max_histogram;int mode; +int clockid;int prio;int quiet;int tracelimit;@@ -121,7 +122,10 @@ static void display_help(void)" must be specified\n" "-m --testmode 0 is loopback mode\n" " 1 is react mode which works with a latency box,\n" -" default=0\n\n" +" default=0\n" +"-k --clockid 0 is CLOCK_REALTIME\n" +" 1 is CLOCK_MONOTONIC,\n" +" default=1\n\n" "e.g. gpiobench -o 20 -i 21 -c pinctrl-bcm2835\n" );@@ -130,7 +134,7 @@ static void display_help(void)static void process_options (int argc,char *argv[]) {int c =0 ; -static const char optstring[] ="h:p:m:l:c:b:i:o:q" ; +static const char optstring[] ="h:p:m:l:c:b:i:o:k:q" ;struct option long_options[] = { {"bracetrace" , required_argument,0 ,'b' },@@ -142,6 +146,7 @@ static void process_options(int argc, char *argv[]) { "intr", required_argument, 0, 'i'}, { "pinctrl", required_argument, 0, 'c'}, { "testmode", required_argument, 0, 'm'}, + { "clockid", required_argument, 0, 'k'}, { 0, 0, 0, 0}, };@@ -185,6 +190,11 @@ static void process_options(int argc, char *argv[])MODE_REACT ?MODE_REACT :MODE_LOOPBACK ;break ; +case 'k' : + ti.clockid =atoi (optarg) >=CLOCK_MONOTONIC ? +CLOCK_MONOTONIC :CLOCK_REALTIME ; +break ; +default :display_help ();exit (2 );@@ -291,7 +301,7 @@ static int rw_gpio(int value, int index)struct rtdm_gpio_readout rdo;long long gpio_write, gpio_read, inner_diff, outer_diff; -clock_gettime (CLOCK_MONOTONIC , ×tamp); +clock_gettime (ti.clockid, ×tamp); gpio_write =calc_us (timestamp); ret =write (ti.fd_dev_out, &value,sizeof (value));@@ -306,7 +316,7 @@ static int rw_gpio(int value, int index)return ret; } -clock_gettime (CLOCK_MONOTONIC , ×tamp); +clock_gettime (ti.clockid, ×tamp); gpio_read =calc_us (timestamp); inner_diff = (rdo.timestamp - gpio_write) /1000 ;@@ -472,6 +482,7 @@ static void init_ti(void) ti.gpio_out =-1 ; ti.gpio_intr =-1 ; ti.mode =MODE_LOOPBACK ; + ti.clockid =CLOCK_MONOTONIC ; ti.ts.inner_min = ti.ts.outer_min =DEFAULT_LIMIT ; ti.ts.inner_max = ti.ts.outer_max =0 ;
testsuite/gpiobench/gpiobench.c int main(int argc, char **argv) · line 651
Quoted 10 lines
testsuite/gpiobench/gpiobench.c +3
-1@@ -632,7 +643,9 @@ int main(int argc, char **argv) goto out; } - ret =ioctl (ti.fd_dev_intr,GPIO_RTIOC_TS_MONO , &value); + ret =ioctl (ti.fd_dev_intr, + ti.clockid ==CLOCK_MONOTONIC ? +GPIO_RTIOC_TS_MONO :GPIO_RTIOC_TS_REAL , &value);if (ret) {printf ("ioctl gpio port ts, failed\n" ); goto out;
Merged to next, thanks.
May I assume that both modes work fine now?
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 108 lines
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Friday, September 3, 2021 3:09 PM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [PATCH] testsuite/gpiobench: Provide choice to switch clock for getting timestampQuoted 86 lines · Hongzhan Chen via Xenomai
Provide choices to switch clock between MONO and REALTIME for getting different timestamp since gpio driver already provide choosable service.
Signed-off-by Hongzhan Chen <[email protected]>testsuite/gpiobench/gpiobench.c +15
-4@@ -85,6 +85,7 @@ struct test_info {unsigned long total_cycles;unsigned long max_histogram;int mode; +int clockid;int prio;int quiet;int tracelimit;@@ -121,7 +122,10 @@ static void display_help(void)" must be specified\n" "-m --testmode 0 is loopback mode\n" " 1 is react mode which works with a latency box,\n" -" default=0\n\n" +" default=0\n" +"-k --clockid 0 is CLOCK_REALTIME\n" +" 1 is CLOCK_MONOTONIC,\n" +" default=1\n\n" "e.g. gpiobench -o 20 -i 21 -c pinctrl-bcm2835\n" );@@ -130,7 +134,7 @@ static void display_help(void)static void process_options (int argc,char *argv[]) {int c =0 ; -static const char optstring[] ="h:p:m:l:c:b:i:o:q" ; +static const char optstring[] ="h:p:m:l:c:b:i:o:k:q" ;struct option long_options[] = { {"bracetrace" , required_argument,0 ,'b' },@@ -142,6 +146,7 @@ static void process_options(int argc, char *argv[]) { "intr", required_argument, 0, 'i'}, { "pinctrl", required_argument, 0, 'c'}, { "testmode", required_argument, 0, 'm'}, + { "clockid", required_argument, 0, 'k'}, { 0, 0, 0, 0}, };@@ -185,6 +190,11 @@ static void process_options(int argc, char *argv[])MODE_REACT ?MODE_REACT :MODE_LOOPBACK ;break ; +case 'k' : + ti.clockid =atoi (optarg) >=CLOCK_MONOTONIC ? +CLOCK_MONOTONIC :CLOCK_REALTIME ; +break ; +default :display_help ();exit (2 );@@ -291,7 +301,7 @@ static int rw_gpio(int value, int index)struct rtdm_gpio_readout rdo;long long gpio_write, gpio_read, inner_diff, outer_diff; -clock_gettime (CLOCK_MONOTONIC , ×tamp); +clock_gettime (ti.clockid, ×tamp); gpio_write =calc_us (timestamp); ret =write (ti.fd_dev_out, &value,sizeof (value));@@ -306,7 +316,7 @@ static int rw_gpio(int value, int index)return ret; } -clock_gettime (CLOCK_MONOTONIC , ×tamp); +clock_gettime (ti.clockid, ×tamp); gpio_read =calc_us (timestamp); inner_diff = (rdo.timestamp - gpio_write) /1000 ;@@ -472,6 +482,7 @@ static void init_ti(void) ti.gpio_out =-1 ; ti.gpio_intr =-1 ; ti.mode =MODE_LOOPBACK ; + ti.clockid =CLOCK_MONOTONIC ; ti.ts.inner_min = ti.ts.outer_min =DEFAULT_LIMIT ; ti.ts.inner_max = ti.ts.outer_max =0 ;testsuite/gpiobench/gpiobench.c int main(int argc, char **argv) · line 651
Quoted 10 lines
testsuite/gpiobench/gpiobench.c +3
-1@@ -632,7 +643,9 @@ int main(int argc, char **argv) goto out; } - ret =ioctl (ti.fd_dev_intr,GPIO_RTIOC_TS_MONO , &value); + ret =ioctl (ti.fd_dev_intr, + ti.clockid ==CLOCK_MONOTONIC ? +GPIO_RTIOC_TS_MONO :GPIO_RTIOC_TS_REAL , &value);if (ret) {printf ("ioctl gpio port ts, failed\n" ); goto out;Merged to next, thanks.
Quoted 1 line
May I assume that both modes work fine now?
According to my test on rockipx board, both work fine.
Regards
Hongzhan Chen
Quoted 4 lines
Jan
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux