[PATCH] build: Disable -Wformat-truncation

2021-08-06 Thread Jan Kiszka via Xenomai
From: Jan Kiszka 

This is default-on in Debian 11 and triggers in heapobj_pkg_init_shared
or heapobj_bind_session without adding value - we truncate for good
reasons.

Signed-off-by: Jan Kiszka 
---
 configure.ac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index bd5fd5ba9a..b6742c4b92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -692,7 +692,8 @@ fi
 dnl Internal CFLAGS and LDFLAGS, may be enhanced per-arch below
 XENO_USER_CFLAGS="$XENO_USER_APP_CFLAGS -pipe -fstrict-aliasing \
 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long \
--Wno-unused-parameter -Werror -Wformat-security -D__XENO__ -D__IN_XENO__"
+-Wno-unused-parameter -Wno-format-truncation -Werror -Wformat-security \
+-D__XENO__ -D__IN_XENO__"
 if test x$want_fortify = xyes -a x$debug_mode != xfull; then
XENO_USER_CFLAGS="$XENO_USER_CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
 fi
-- 
2.31.1



Re: Arm userland not building with gcc-9 and later

2021-08-06 Thread Jan Kiszka via Xenomai
On 06.08.21 18:16, Jan Kiszka wrote:
> On 06.08.21 15:34, Philippe Gerum wrote:
>>
>> Jan Kiszka  writes:
>>
>>> On 06.08.21 15:09, Philippe Gerum wrote:

 Jan Kiszka  writes:

> Hi all,
>
> just wanted to debug the RTnet issues we now see in CI on arm and arm64.
> I picked arm as first target, but that apparently starts to break with
> gcc-9 or newer (tried 9.2 and 10.2):
>
> make[5]: Entering directory '/xenomai/lib/cobalt/arch/arm'
>   CC   libarch_la-features.lo
> features.c: In function 'cobalt_arch_check_features':
> features.c:82:1: error: r7 cannot be used in 'asm' here
>82 | }
>   | ^
>
> That seems to be related to passing the syscall number via r7 on ARM. Is
> our ABI soon no longer compilable, or can we fix this?
>
> Jan

 r7 may be used as a scratch register by gcc in some
 cases. -fomit-frame-pointer for debug builds may help (i.e. when the
 optimizer is switched off).

>>>
>>> Good hint. I had --enable-debug=full set, and it builds without it (and
>>> now reports other issues that Debian's gcc-10 sees).
>>>
>>> But how to resolve this properly?
>>>
>>> Jan
>>
>> XENOMAI_SYSCALL2(sc_cobalt_archcall) in features.c is likely the issue.
>>
>> Either move those bits into some new syscall wrapper which would live in
>> lib/cobalt/internal.c, where there is no register allocation conflict so
>> far. Or discourage gcc from using r7 as a scratch register in
>> arm/features.c entirely? e.g.:
>>
>> diff --git a/lib/cobalt/arch/arm/Makefile.am 
>> b/lib/cobalt/arch/arm/Makefile.am
>> index a5095be3d..d5e542ebe 100644
>> --- a/lib/cobalt/arch/arm/Makefile.am
>> +++ b/lib/cobalt/arch/arm/Makefile.am
>> @@ -6,6 +6,7 @@ libarch_la_SOURCES = features.c
>>  
>>  libarch_la_CPPFLAGS =   \
>>  @XENO_COBALT_CFLAGS@\
>> +-fomit-frame-pointer\
>>  -I$(srcdir)/../..   \
>>  -I$(top_srcdir)/include/cobalt  \
>>  -I$(top_srcdir)/include
>>
> 
> -fomit-frame-pointer does not help with -O0. It even keeps the problem
> alive with -O2.
> 
> Looks like arm needs a non-unlined helper function for syscalls, to be safe.
> 

What might be cheaper, a call-out to a helper or some push/pop around
the syscall like below? But I suspect the helper will do push/pop as well...

#define __SYS_CALLOP "push {r7}; mov %%r7,%[__r7]; swi\t0; pop {r7}"

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



Re: Arm userland not building with gcc-9 and later

2021-08-06 Thread Jan Kiszka via Xenomai
On 06.08.21 15:34, Philippe Gerum wrote:
> 
> Jan Kiszka  writes:
> 
>> On 06.08.21 15:09, Philippe Gerum wrote:
>>>
>>> Jan Kiszka  writes:
>>>
 Hi all,

 just wanted to debug the RTnet issues we now see in CI on arm and arm64.
 I picked arm as first target, but that apparently starts to break with
 gcc-9 or newer (tried 9.2 and 10.2):

 make[5]: Entering directory '/xenomai/lib/cobalt/arch/arm'
   CC   libarch_la-features.lo
 features.c: In function 'cobalt_arch_check_features':
 features.c:82:1: error: r7 cannot be used in 'asm' here
82 | }
   | ^

 That seems to be related to passing the syscall number via r7 on ARM. Is
 our ABI soon no longer compilable, or can we fix this?

 Jan
>>>
>>> r7 may be used as a scratch register by gcc in some
>>> cases. -fomit-frame-pointer for debug builds may help (i.e. when the
>>> optimizer is switched off).
>>>
>>
>> Good hint. I had --enable-debug=full set, and it builds without it (and
>> now reports other issues that Debian's gcc-10 sees).
>>
>> But how to resolve this properly?
>>
>> Jan
> 
> XENOMAI_SYSCALL2(sc_cobalt_archcall) in features.c is likely the issue.
> 
> Either move those bits into some new syscall wrapper which would live in
> lib/cobalt/internal.c, where there is no register allocation conflict so
> far. Or discourage gcc from using r7 as a scratch register in
> arm/features.c entirely? e.g.:
> 
> diff --git a/lib/cobalt/arch/arm/Makefile.am b/lib/cobalt/arch/arm/Makefile.am
> index a5095be3d..d5e542ebe 100644
> --- a/lib/cobalt/arch/arm/Makefile.am
> +++ b/lib/cobalt/arch/arm/Makefile.am
> @@ -6,6 +6,7 @@ libarch_la_SOURCES = features.c
>  
>  libarch_la_CPPFLAGS =\
>   @XENO_COBALT_CFLAGS@\
> + -fomit-frame-pointer\
>   -I$(srcdir)/../..   \
>   -I$(top_srcdir)/include/cobalt  \
>   -I$(top_srcdir)/include
> 

-fomit-frame-pointer does not help with -O0. It even keeps the problem
alive with -O2.

Looks like arm needs a non-unlined helper function for syscalls, to be safe.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



Re: Arm userland not building with gcc-9 and later

2021-08-06 Thread Philippe Gerum via Xenomai


Jan Kiszka  writes:

> On 06.08.21 15:09, Philippe Gerum wrote:
>> 
>> Jan Kiszka  writes:
>> 
>>> Hi all,
>>>
>>> just wanted to debug the RTnet issues we now see in CI on arm and arm64.
>>> I picked arm as first target, but that apparently starts to break with
>>> gcc-9 or newer (tried 9.2 and 10.2):
>>>
>>> make[5]: Entering directory '/xenomai/lib/cobalt/arch/arm'
>>>   CC   libarch_la-features.lo
>>> features.c: In function 'cobalt_arch_check_features':
>>> features.c:82:1: error: r7 cannot be used in 'asm' here
>>>82 | }
>>>   | ^
>>>
>>> That seems to be related to passing the syscall number via r7 on ARM. Is
>>> our ABI soon no longer compilable, or can we fix this?
>>>
>>> Jan
>> 
>> r7 may be used as a scratch register by gcc in some
>> cases. -fomit-frame-pointer for debug builds may help (i.e. when the
>> optimizer is switched off).
>> 
>
> Good hint. I had --enable-debug=full set, and it builds without it (and
> now reports other issues that Debian's gcc-10 sees).
>
> But how to resolve this properly?
>
> Jan

XENOMAI_SYSCALL2(sc_cobalt_archcall) in features.c is likely the issue.

Either move those bits into some new syscall wrapper which would live in
lib/cobalt/internal.c, where there is no register allocation conflict so
far. Or discourage gcc from using r7 as a scratch register in
arm/features.c entirely? e.g.:

diff --git a/lib/cobalt/arch/arm/Makefile.am b/lib/cobalt/arch/arm/Makefile.am
index a5095be3d..d5e542ebe 100644
--- a/lib/cobalt/arch/arm/Makefile.am
+++ b/lib/cobalt/arch/arm/Makefile.am
@@ -6,6 +6,7 @@ libarch_la_SOURCES = features.c
 
 libarch_la_CPPFLAGS =  \
@XENO_COBALT_CFLAGS@\
+   -fomit-frame-pointer\
-I$(srcdir)/../..   \
-I$(top_srcdir)/include/cobalt  \
-I$(top_srcdir)/include

-- 
Philippe.



Re: Arm userland not building with gcc-9 and later

2021-08-06 Thread Jan Kiszka via Xenomai
On 06.08.21 15:09, Philippe Gerum wrote:
> 
> Jan Kiszka  writes:
> 
>> Hi all,
>>
>> just wanted to debug the RTnet issues we now see in CI on arm and arm64.
>> I picked arm as first target, but that apparently starts to break with
>> gcc-9 or newer (tried 9.2 and 10.2):
>>
>> make[5]: Entering directory '/xenomai/lib/cobalt/arch/arm'
>>   CC   libarch_la-features.lo
>> features.c: In function 'cobalt_arch_check_features':
>> features.c:82:1: error: r7 cannot be used in 'asm' here
>>82 | }
>>   | ^
>>
>> That seems to be related to passing the syscall number via r7 on ARM. Is
>> our ABI soon no longer compilable, or can we fix this?
>>
>> Jan
> 
> r7 may be used as a scratch register by gcc in some
> cases. -fomit-frame-pointer for debug builds may help (i.e. when the
> optimizer is switched off).
> 

Good hint. I had --enable-debug=full set, and it builds without it (and
now reports other issues that Debian's gcc-10 sees).

But how to resolve this properly?

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



Re: Arm userland not building with gcc-9 and later

2021-08-06 Thread Philippe Gerum via Xenomai


Jan Kiszka  writes:

> Hi all,
>
> just wanted to debug the RTnet issues we now see in CI on arm and arm64.
> I picked arm as first target, but that apparently starts to break with
> gcc-9 or newer (tried 9.2 and 10.2):
>
> make[5]: Entering directory '/xenomai/lib/cobalt/arch/arm'
>   CC   libarch_la-features.lo
> features.c: In function 'cobalt_arch_check_features':
> features.c:82:1: error: r7 cannot be used in 'asm' here
>82 | }
>   | ^
>
> That seems to be related to passing the syscall number via r7 on ARM. Is
> our ABI soon no longer compilable, or can we fix this?
>
> Jan

r7 may be used as a scratch register by gcc in some
cases. -fomit-frame-pointer for debug builds may help (i.e. when the
optimizer is switched off).

-- 
Philippe.



Arm userland not building with gcc-9 and later

2021-08-06 Thread Jan Kiszka via Xenomai
Hi all,

just wanted to debug the RTnet issues we now see in CI on arm and arm64.
I picked arm as first target, but that apparently starts to break with
gcc-9 or newer (tried 9.2 and 10.2):

make[5]: Entering directory '/xenomai/lib/cobalt/arch/arm'
  CC   libarch_la-features.lo
features.c: In function 'cobalt_arch_check_features':
features.c:82:1: error: r7 cannot be used in 'asm' here
   82 | }
  | ^

That seems to be related to passing the syscall number via r7 on ARM. Is
our ABI soon no longer compilable, or can we fix this?

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



Re: [xenomai-images][PATCH v2] linux-xenomai_4.4: Add machine specific config for beagle bone black

2021-08-06 Thread Jan Kiszka via Xenomai
On 05.08.21 16:41, Jan Kiszka via Xenomai wrote:
> On 05.08.21 14:29, Q. Gylstorff wrote:
>> From: Quirin Gylstorff 
>>
>> The beagle bone black does most[1] of the time not boot ipipe 4.4 + xenomai 
>> 3.0.x if
>> the following kernel configuration elements are active:
>>  - CONFIG_RAW_PRINTK
>>  - CONFIG_DEBUG_LL
>>  - CONFIG_IPIPE_DEBUG
>>  - CONFIG_XENO_OPT_DEBUG
>>
>> Last message in U-boot is:
>> ```
>> Starting kernel ...
>> ```
>>
>> 4.19 and newer are not impacted.
>>
>> [1]: The CI build boots around 1 out 4. See 
>> https://source.denx.de/Xenomai/xenomai-images/-/jobs/303430
>>
>> Signed-off-by: Quirin Gylstorff 
>> ---
>> Changes V2:
>>  - replace defconfig with partial config
>>  - adapt commit message for sporatic CI boots
>>
>>  recipes-kernel/linux/files/bbb_4.4.cfg| 4 
>>  recipes-kernel/linux/linux-xenomai_4.4.bb | 1 +
>>  2 files changed, 5 insertions(+)
>>  create mode 100644 recipes-kernel/linux/files/bbb_4.4.cfg
>>
>> diff --git a/recipes-kernel/linux/files/bbb_4.4.cfg 
>> b/recipes-kernel/linux/files/bbb_4.4.cfg
>> new file mode 100644
>> index 000..4628f44
>> --- /dev/null
>> +++ b/recipes-kernel/linux/files/bbb_4.4.cfg
>> @@ -0,0 +1,4 @@
>> +# CONFIG_RAW_PRINTK is not set
>> +# CONFIG_DEBUG_LL is not set
>> +# CONFIG_IPIPE_DEBUG is not set
>> +# CONFIG_XENO_OPT_DEBUG is not set
>> diff --git a/recipes-kernel/linux/linux-xenomai_4.4.bb 
>> b/recipes-kernel/linux/linux-xenomai_4.4.bb
>> index 2a1137c..42c6d83 100644
>> --- a/recipes-kernel/linux/linux-xenomai_4.4.bb
>> +++ b/recipes-kernel/linux/linux-xenomai_4.4.bb
>> @@ -16,6 +16,7 @@ SRCREV_amd64 ?= "ipipe-core-4.4.268-cip57-x86-28"
>>  PV_amd64 = "4.4.268+"
>>  
>>  SRC_URI_append_armhf = " 
>> git://github.com/xenomai-ci/ipipe.git;protocol=https;nobranch=1"
>> +SRC_URI_append_armhf = " ${@ 'file://bbb_4.4.cfg' if d.getVar('MACHINE') == 
>> 'beagle-bone-black' else '' }"
>>  SRCREV_armhf ?= "ipipe-core-4.4.268-cip57-arm-13"
>>  PV_armhf = "4.4.268+"
>>  
>>
> 
> Thanks, applied.
> 

Bad news: https://source.denx.de/Xenomai/xenomai-images/-/jobs/304747

Possibly, non-debug only lowers the probability of a regression on armhf
or bbb.

Where you able to grab any early boot messages in the failing cases?

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



Re: [xenomai-images][RFC][PATCH] ci: Switch to Google nameserver

2021-08-06 Thread Jan Kiszka via Xenomai
On 02.08.21 17:43, Jan Kiszka via Xenomai wrote:
> From: Jan Kiszka 
> 
> This is a temporary hack: Our AWS runners see a lot of DNS errors for
> deb.debian.org. Let's see if they are less with this server.
> 
> Signed-off-by: Jan Kiszka 
> ---
> 
> Seems to work, though only one run passed so far. Go this way for now?
> 
>  ci/gitlab-ci-base.yml | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ci/gitlab-ci-base.yml b/ci/gitlab-ci-base.yml
> index 2638dec..ce9c800 100644
> --- a/ci/gitlab-ci-base.yml
> +++ b/ci/gitlab-ci-base.yml
> @@ -39,6 +39,7 @@ default:
>extends: .add-proxy-config
>stage: build
>script:
> +- sudo sh -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
>  - echo "Building 
> kas.yml:board-${TARGET}.yml${XENOMAI_BUILD_OPTION}${LINUX_BUILD_OPTION}${BUILD_OPTIONS}:opt-debug.yml"
>  - kas build 
> kas.yml:board-${TARGET}.yml${XENOMAI_BUILD_OPTION}${LINUX_BUILD_OPTION}${BUILD_OPTIONS}:opt-debug.yml
>  - if [ -n "${USE_S3_BUCKET}" ]; then scripts/deploy_to_aws.sh ${TARGET}; 
> fi
> 

Seems you found the reason in our AWS setup. I'm dropping this from next
again to confirm that we are safe.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



Re: [PATCH] testsuite/smokey: net: Load rtnet module if missing

2021-08-06 Thread Jan Kiszka via Xenomai
On 06.08.21 10:23, Chen, Hongzhan wrote:
> 
> 
>  -Original Message-
>> From: Jan Kiszka  
>> Sent: Friday, August 6, 2021 4:12 PM
>> To: Chen, Hongzhan ; Xenomai 
>> Subject: Re: [PATCH] testsuite/smokey: net: Load rtnet module if missing
>>
>> On 06.08.21 09:48, Chen, Hongzhan wrote:
>>>
>>>
 -Original Message-
 From: Jan Kiszka  
 Sent: Friday, August 6, 2021 3:38 PM
 To: Xenomai 
 Cc: Chen, Hongzhan 
 Subject: [PATCH] testsuite/smokey: net: Load rtnet module if missing

 From: Jan Kiszka 

 This allows to run RTnet tests if the core is built as module but not
 yet loaded at the start of the test.

 For that, silence error reports of 'modprobe rtnet'.

 Signed-off-by: Jan Kiszka 
 ---

 This should do the trick as well, just a bit simpler.

 testsuite/smokey/net_common/setup.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

 diff --git a/testsuite/smokey/net_common/setup.c 
 b/testsuite/smokey/net_common/setup.c
 index 1badabdfb4..44a0cb24b9 100644
 --- a/testsuite/smokey/net_common/setup.c
 +++ b/testsuite/smokey/net_common/setup.c
 @@ -138,7 +138,7 @@ static int do_down(const char *intf)
return 0;
 }

 -static int smokey_net_modprobe(int modid)
 +static int smokey_net_modprobe(int modid, bool silent)
 {
struct module *m = modules + modid;
char buffer[128];
 @@ -168,7 +168,8 @@ static int smokey_net_modprobe(int modid)
smokey_trace("%s module not there: modprobing", m->name);

err = smokey_check_errno(
 -  snprintf(buffer, sizeof(buffer), "modprobe %s", m->name));
 +  snprintf(buffer, sizeof(buffer), "modprobe %s %s", m->name,
 +   silent ? "2>/dev/null" : ""));
if (err < 0)
return err;

 @@ -177,7 +178,8 @@ static int smokey_net_modprobe(int modid)
return err;

if (!WIFEXITED(err) || WEXITSTATUS(err) != 0) {
 -  smokey_warning("%s: abnormal exit", buffer);
 +  if (!silent)
 +  smokey_warning("%s: abnormal exit", buffer);
return -EINVAL;
}

 @@ -224,7 +226,7 @@ static int smokey_net_setup_rtcfg_client(const char 
 *intf, int net_config)
if ((net_config & _CC_COBALT_NET_CFG) == 0)
return -ENOSYS;

 -  err = smokey_net_modprobe(MODID_CFG);
 +  err = smokey_net_modprobe(MODID_CFG, false);
if (err < 0)
return err;

 @@ -408,6 +410,12 @@ int smokey_net_setup(const char *driver, const char 
 *intf, int tested_config,
struct sockaddr_in *in_peer = vpeer;
struct sockaddr *peer = vpeer;

 +  /*
 +   * Main module needs to be loaded in order to use
 +   * _CC_COBALT_GET_NET_CONFIG.
 +   */
 +  smokey_net_modprobe(MODID_RTNET, true);
>>>
>>>  no need to check return value?
>>>
>>
>> Theoretically, we could miss the case that RTnet was configured but the
> 
> What about RTnet is not configured? New modinfo checking patch as we 
> discussed to protect this?

If RTnet is not configured, the test will fail silently ("no kernel
support"). If we don't want that case for our CI/CT setup, we need to
check the output for such messages and fail the test run at lava level.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



RE: [PATCH] testsuite/smokey: net: Load rtnet module if missing

2021-08-06 Thread Chen, Hongzhan via Xenomai


 -Original Message-
>From: Jan Kiszka  
>Sent: Friday, August 6, 2021 4:12 PM
>To: Chen, Hongzhan ; Xenomai 
>Subject: Re: [PATCH] testsuite/smokey: net: Load rtnet module if missing
>
>On 06.08.21 09:48, Chen, Hongzhan wrote:
>> 
>> 
>>> -Original Message-
>>> From: Jan Kiszka  
>>> Sent: Friday, August 6, 2021 3:38 PM
>>> To: Xenomai 
>>> Cc: Chen, Hongzhan 
>>> Subject: [PATCH] testsuite/smokey: net: Load rtnet module if missing
>>>
>>> From: Jan Kiszka 
>>>
>>> This allows to run RTnet tests if the core is built as module but not
>>> yet loaded at the start of the test.
>>>
>>> For that, silence error reports of 'modprobe rtnet'.
>>>
>>> Signed-off-by: Jan Kiszka 
>>> ---
>>>
>>> This should do the trick as well, just a bit simpler.
>>>
>>> testsuite/smokey/net_common/setup.c | 22 +++---
>>> 1 file changed, 15 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/testsuite/smokey/net_common/setup.c 
>>> b/testsuite/smokey/net_common/setup.c
>>> index 1badabdfb4..44a0cb24b9 100644
>>> --- a/testsuite/smokey/net_common/setup.c
>>> +++ b/testsuite/smokey/net_common/setup.c
>>> @@ -138,7 +138,7 @@ static int do_down(const char *intf)
>>> return 0;
>>> }
>>>
>>> -static int smokey_net_modprobe(int modid)
>>> +static int smokey_net_modprobe(int modid, bool silent)
>>> {
>>> struct module *m = modules + modid;
>>> char buffer[128];
>>> @@ -168,7 +168,8 @@ static int smokey_net_modprobe(int modid)
>>> smokey_trace("%s module not there: modprobing", m->name);
>>>
>>> err = smokey_check_errno(
>>> -   snprintf(buffer, sizeof(buffer), "modprobe %s", m->name));
>>> +   snprintf(buffer, sizeof(buffer), "modprobe %s %s", m->name,
>>> +silent ? "2>/dev/null" : ""));
>>> if (err < 0)
>>> return err;
>>>
>>> @@ -177,7 +178,8 @@ static int smokey_net_modprobe(int modid)
>>> return err;
>>>
>>> if (!WIFEXITED(err) || WEXITSTATUS(err) != 0) {
>>> -   smokey_warning("%s: abnormal exit", buffer);
>>> +   if (!silent)
>>> +   smokey_warning("%s: abnormal exit", buffer);
>>> return -EINVAL;
>>> }
>>>
>>> @@ -224,7 +226,7 @@ static int smokey_net_setup_rtcfg_client(const char 
>>> *intf, int net_config)
>>> if ((net_config & _CC_COBALT_NET_CFG) == 0)
>>> return -ENOSYS;
>>>
>>> -   err = smokey_net_modprobe(MODID_CFG);
>>> +   err = smokey_net_modprobe(MODID_CFG, false);
>>> if (err < 0)
>>> return err;
>>>
>>> @@ -408,6 +410,12 @@ int smokey_net_setup(const char *driver, const char 
>>> *intf, int tested_config,
>>> struct sockaddr_in *in_peer = vpeer;
>>> struct sockaddr *peer = vpeer;
>>>
>>> +   /*
>>> +* Main module needs to be loaded in order to use
>>> +* _CC_COBALT_GET_NET_CONFIG.
>>> +*/
>>> +   smokey_net_modprobe(MODID_RTNET, true);
>> 
>>  no need to check return value?
>> 
>
>Theoretically, we could miss the case that RTnet was configured but the

What about RTnet is not configured? New modinfo checking patch as we discussed 
to protect this?

Regards

Hongzhan Chen

>module cannot be loaded. But I think this is negligible, and the
>alternative is rather complex.
>
>We could rather add a "no kernel support" test to our lava jobs when all
>features are enabled. Will also ensure that we do not degrade on that again.
>
>Jan
>
>> Regards
>> Hongzhan Chen
>>> +
>>> err = cobalt_corectl(_CC_COBALT_GET_NET_CONFIG,
>>> _config, sizeof(net_config));
>>> if (err == -EINVAL)
>>> @@ -423,15 +431,15 @@ int smokey_net_setup(const char *driver, const char 
>>> *intf, int tested_config,
>>> return -ENOSYS;
>>>
>>> modules[MODID_DRIVER].name = driver;
>>> -   err = smokey_net_modprobe(MODID_DRIVER);
>>> +   err = smokey_net_modprobe(MODID_DRIVER, false);
>>> if (err < 0)
>>> return err;
>>>
>>> -   err = smokey_net_modprobe(MODID_IPV4);
>>> +   err = smokey_net_modprobe(MODID_IPV4, false);
>>> if (err < 0)
>>> return err;
>>
>> -err = smokey_net_modprobe(option_to_modid(tested_config));
>> +err = smokey_net_modprobe(option_to_modid(tested_config), false);
>>  if (err < 0)
>>  return err;
>>
>> -- 
>> 2.31.1
> 
 
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux


[Patch] drivers/gpio: Allow selection of timestamp source for GPIO timestamps

2021-08-06 Thread François Legal via Xenomai
This patch allows to select which time source (monotonic/realtime) is used to 
timestamp GPIO events.
The time source used to be monotonic which is the opposite of what other 
drivers do. Now default changed to realtime, plus new API added to go back to 
monotonic.


Signed-off-by: François LEGAL 
---
diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
index 2839f7d51..f8a93b7f7 100644
--- a/include/rtdm/uapi/gpio.h
+++ b/include/rtdm/uapi/gpio.h
@@ -30,6 +30,8 @@ struct rtdm_gpio_readout {
 #define GPIO_RTIOC_REQS_IO(RTDM_CLASS_GPIO, 4)
 #define GPIO_RTIOC_RELS_IO(RTDM_CLASS_GPIO, 5)
 #define GPIO_RTIOC_TS  _IOR(RTDM_CLASS_GPIO, 7, int)
+#define GPIO_RTIOC_TS_REAL  _IOR(RTDM_CLASS_GPIO, 8, int)
+#define GPIO_RTIOC_TS_MONO  _IOR(RTDM_CLASS_GPIO, 9, int)

 #define GPIO_TRIGGER_NONE  0x0 /* unspecified */
 #define GPIO_TRIGGER_EDGE_RISING   0x1
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index bc283064b..3eaf425c6 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -36,13 +36,15 @@ static LIST_HEAD(rtdm_gpio_chips);

 static DEFINE_MUTEX(chip_lock);

+static nanosecs_abs_t (*timestamp_get_func_ptr)(void) = rtdm_clock_read;
+
 static int gpio_pin_interrupt(rtdm_irq_t *irqh)
 {
struct rtdm_gpio_pin *pin;

pin = rtdm_irq_get_arg(irqh, struct rtdm_gpio_pin);

-   pin->timestamp = rtdm_clock_read_monotonic();
+   pin->timestamp = timestamp_get_func_ptr();
rtdm_event_signal(>event);

return RTDM_IRQ_HANDLED;
@@ -192,9 +194,18 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
chan->requested = false;
break;
case GPIO_RTIOC_TS:
+   case GPIO_RTIOC_TS_REAL:
+   ret = rtdm_safe_copy_from_user(fd, , arg, sizeof(val));
+   if (ret)
+   return ret;
+   timestamp_get_func_ptr = rtdm_clock_read;
+   chan->want_timestamp = !!val;
+   break;
+   case GPIO_RTIOC_TS_MONO:
ret = rtdm_safe_copy_from_user(fd, , arg, sizeof(val));
if (ret)
return ret;
+   timestamp_get_func_ptr = rtdm_clock_read_monotonic;
chan->want_timestamp = !!val;
break;
default:




Re: [PATCH] testsuite/smokey: net: Load rtnet module if missing

2021-08-06 Thread Jan Kiszka via Xenomai
On 06.08.21 09:48, Chen, Hongzhan wrote:
> 
> 
>> -Original Message-
>> From: Jan Kiszka  
>> Sent: Friday, August 6, 2021 3:38 PM
>> To: Xenomai 
>> Cc: Chen, Hongzhan 
>> Subject: [PATCH] testsuite/smokey: net: Load rtnet module if missing
>>
>> From: Jan Kiszka 
>>
>> This allows to run RTnet tests if the core is built as module but not
>> yet loaded at the start of the test.
>>
>> For that, silence error reports of 'modprobe rtnet'.
>>
>> Signed-off-by: Jan Kiszka 
>> ---
>>
>> This should do the trick as well, just a bit simpler.
>>
>> testsuite/smokey/net_common/setup.c | 22 +++---
>> 1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/testsuite/smokey/net_common/setup.c 
>> b/testsuite/smokey/net_common/setup.c
>> index 1badabdfb4..44a0cb24b9 100644
>> --- a/testsuite/smokey/net_common/setup.c
>> +++ b/testsuite/smokey/net_common/setup.c
>> @@ -138,7 +138,7 @@ static int do_down(const char *intf)
>>  return 0;
>> }
>>
>> -static int smokey_net_modprobe(int modid)
>> +static int smokey_net_modprobe(int modid, bool silent)
>> {
>>  struct module *m = modules + modid;
>>  char buffer[128];
>> @@ -168,7 +168,8 @@ static int smokey_net_modprobe(int modid)
>>  smokey_trace("%s module not there: modprobing", m->name);
>>
>>  err = smokey_check_errno(
>> -snprintf(buffer, sizeof(buffer), "modprobe %s", m->name));
>> +snprintf(buffer, sizeof(buffer), "modprobe %s %s", m->name,
>> + silent ? "2>/dev/null" : ""));
>>  if (err < 0)
>>  return err;
>>
>> @@ -177,7 +178,8 @@ static int smokey_net_modprobe(int modid)
>>  return err;
>>
>>  if (!WIFEXITED(err) || WEXITSTATUS(err) != 0) {
>> -smokey_warning("%s: abnormal exit", buffer);
>> +if (!silent)
>> +smokey_warning("%s: abnormal exit", buffer);
>>  return -EINVAL;
>>  }
>>
>> @@ -224,7 +226,7 @@ static int smokey_net_setup_rtcfg_client(const char 
>> *intf, int net_config)
>>  if ((net_config & _CC_COBALT_NET_CFG) == 0)
>>  return -ENOSYS;
>>
>> -err = smokey_net_modprobe(MODID_CFG);
>> +err = smokey_net_modprobe(MODID_CFG, false);
>>  if (err < 0)
>>  return err;
>>
>> @@ -408,6 +410,12 @@ int smokey_net_setup(const char *driver, const char 
>> *intf, int tested_config,
>>  struct sockaddr_in *in_peer = vpeer;
>>  struct sockaddr *peer = vpeer;
>>
>> +/*
>> + * Main module needs to be loaded in order to use
>> + * _CC_COBALT_GET_NET_CONFIG.
>> + */
>> +smokey_net_modprobe(MODID_RTNET, true);
> 
>  no need to check return value?
> 

Theoretically, we could miss the case that RTnet was configured but the
module cannot be loaded. But I think this is negligible, and the
alternative is rather complex.

We could rather add a "no kernel support" test to our lava jobs when all
features are enabled. Will also ensure that we do not degrade on that again.

Jan

> Regards
> Hongzhan Chen
>> +
>>  err = cobalt_corectl(_CC_COBALT_GET_NET_CONFIG,
>>  _config, sizeof(net_config));
>>  if (err == -EINVAL)
>> @@ -423,15 +431,15 @@ int smokey_net_setup(const char *driver, const char 
>> *intf, int tested_config,
>>  return -ENOSYS;
>>
>>  modules[MODID_DRIVER].name = driver;
>> -err = smokey_net_modprobe(MODID_DRIVER);
>> +err = smokey_net_modprobe(MODID_DRIVER, false);
>>  if (err < 0)
>>  return err;
>>
>> -err = smokey_net_modprobe(MODID_IPV4);
>> +err = smokey_net_modprobe(MODID_IPV4, false);
>>  if (err < 0)
>>  return err;
>>
>> -err = smokey_net_modprobe(option_to_modid(tested_config));
>> +err = smokey_net_modprobe(option_to_modid(tested_config), false);
>>  if (err < 0)
>>  return err;
>>
>> -- 
>> 2.31.1
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



RE: [PATCH] testsuite/smokey: net: Load rtnet module if missing

2021-08-06 Thread Chen, Hongzhan via Xenomai


>-Original Message-
>From: Jan Kiszka  
>Sent: Friday, August 6, 2021 3:38 PM
>To: Xenomai 
>Cc: Chen, Hongzhan 
>Subject: [PATCH] testsuite/smokey: net: Load rtnet module if missing
>
>From: Jan Kiszka 
>
>This allows to run RTnet tests if the core is built as module but not
>yet loaded at the start of the test.
>
>For that, silence error reports of 'modprobe rtnet'.
>
>Signed-off-by: Jan Kiszka 
>---
>
>This should do the trick as well, just a bit simpler.
>
> testsuite/smokey/net_common/setup.c | 22 +++---
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
>diff --git a/testsuite/smokey/net_common/setup.c 
>b/testsuite/smokey/net_common/setup.c
>index 1badabdfb4..44a0cb24b9 100644
>--- a/testsuite/smokey/net_common/setup.c
>+++ b/testsuite/smokey/net_common/setup.c
>@@ -138,7 +138,7 @@ static int do_down(const char *intf)
>   return 0;
> }
> 
>-static int smokey_net_modprobe(int modid)
>+static int smokey_net_modprobe(int modid, bool silent)
> {
>   struct module *m = modules + modid;
>   char buffer[128];
>@@ -168,7 +168,8 @@ static int smokey_net_modprobe(int modid)
>   smokey_trace("%s module not there: modprobing", m->name);
> 
>   err = smokey_check_errno(
>-  snprintf(buffer, sizeof(buffer), "modprobe %s", m->name));
>+  snprintf(buffer, sizeof(buffer), "modprobe %s %s", m->name,
>+   silent ? "2>/dev/null" : ""));
>   if (err < 0)
>   return err;
> 
>@@ -177,7 +178,8 @@ static int smokey_net_modprobe(int modid)
>   return err;
> 
>   if (!WIFEXITED(err) || WEXITSTATUS(err) != 0) {
>-  smokey_warning("%s: abnormal exit", buffer);
>+  if (!silent)
>+  smokey_warning("%s: abnormal exit", buffer);
>   return -EINVAL;
>   }
> 
>@@ -224,7 +226,7 @@ static int smokey_net_setup_rtcfg_client(const char *intf, 
>int net_config)
>   if ((net_config & _CC_COBALT_NET_CFG) == 0)
>   return -ENOSYS;
> 
>-  err = smokey_net_modprobe(MODID_CFG);
>+  err = smokey_net_modprobe(MODID_CFG, false);
>   if (err < 0)
>   return err;
> 
>@@ -408,6 +410,12 @@ int smokey_net_setup(const char *driver, const char 
>*intf, int tested_config,
>   struct sockaddr_in *in_peer = vpeer;
>   struct sockaddr *peer = vpeer;
> 
>+  /*
>+   * Main module needs to be loaded in order to use
>+   * _CC_COBALT_GET_NET_CONFIG.
>+   */
>+  smokey_net_modprobe(MODID_RTNET, true);

 no need to check return value?

Regards
Hongzhan Chen
>+
>   err = cobalt_corectl(_CC_COBALT_GET_NET_CONFIG,
>   _config, sizeof(net_config));
>   if (err == -EINVAL)
>@@ -423,15 +431,15 @@ int smokey_net_setup(const char *driver, const char 
>*intf, int tested_config,
>   return -ENOSYS;
> 
>   modules[MODID_DRIVER].name = driver;
>-  err = smokey_net_modprobe(MODID_DRIVER);
>+  err = smokey_net_modprobe(MODID_DRIVER, false);
>   if (err < 0)
>   return err;
> 
>-  err = smokey_net_modprobe(MODID_IPV4);
>+  err = smokey_net_modprobe(MODID_IPV4, false);
>   if (err < 0)
>   return err;
> 
>-  err = smokey_net_modprobe(option_to_modid(tested_config));
>+  err = smokey_net_modprobe(option_to_modid(tested_config), false);
>   if (err < 0)
>   return err;
> 
>-- 
>2.31.1



Re: [PATCH 2/2] testsuite/smokey: net_client: skip late packet error in vm mode

2021-08-06 Thread Jan Kiszka via Xenomai
On 05.08.21 07:01, Jan Kiszka via Xenomai wrote:
> On 05.08.21 02:39, Chen, Hongzhan wrote:
>>
>>
>>> -Original Message-
>>> From: Jan Kiszka  
>>> Sent: Wednesday, August 4, 2021 6:20 PM
>>> To: Chen, Hongzhan ; xenomai@xenomai.org
>>> Subject: Re: [PATCH 2/2] testsuite/smokey: net_client: skip late packet 
>>> error in vm mode
>>>
>>> On 04.08.21 04:47, Hongzhan Chen via Xenomai wrote:
 In vm mode, skip late packet error in functional test to avoid
 test failure.

 Signed-off-by: Hongzhan Chen 

 diff --git a/testsuite/smokey/net_common/client.c 
 b/testsuite/smokey/net_common/client.c
 index d13d72918..752ea55ed 100644
 --- a/testsuite/smokey/net_common/client.c
 +++ b/testsuite/smokey/net_common/client.c
 @@ -204,7 +204,7 @@ static int smokey_net_client_loop(struct 
 smokey_net_client *client)
} while (err != -ETIMEDOUT);
}
  
 -  if (glost || glate)
 +  if (glost || (!smokey_on_vm && glate))
fprintf(stderr, "RTnet %s test failed", client->name);
if (glost) {
if (glost == limit)
 @@ -214,11 +214,11 @@ static int smokey_net_client_loop(struct 
 smokey_net_client *client)
fprintf(stderr, ", %Lu packets lost (%g %%)",
glost, 100.0 * glost / limit);
}
 -  if (glate)
 +  if (!smokey_on_vm && glate)
fprintf(stderr, ", %Lu overruns", glate);
>>>
>>> I think we can keep this report, just not mark the test failed in case
>>> of smokey_on_vm.
>>
>> But this string printed out here looks like ugly  in case of smokey_on_vm., 
>> do we need to change something ?
>> How about :
>>
>> if (!smokey_on_vm && glate)
>>   fprintf(stderr, "there is %Lu overruns", glate);
>> else if (glate)
>>  fprintf(stderr, ", %Lu overruns", glate);
>>
> 
> Hmm, what is the difference?
> 

OK, sorry, now I see the relevance. Applied this one.

Thanks,
Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux



[PATCH] testsuite/smokey: net: Load rtnet module if missing

2021-08-06 Thread Jan Kiszka via Xenomai
From: Jan Kiszka 

This allows to run RTnet tests if the core is built as module but not
yet loaded at the start of the test.

For that, silence error reports of 'modprobe rtnet'.

Signed-off-by: Jan Kiszka 
---

This should do the trick as well, just a bit simpler.

 testsuite/smokey/net_common/setup.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/testsuite/smokey/net_common/setup.c 
b/testsuite/smokey/net_common/setup.c
index 1badabdfb4..44a0cb24b9 100644
--- a/testsuite/smokey/net_common/setup.c
+++ b/testsuite/smokey/net_common/setup.c
@@ -138,7 +138,7 @@ static int do_down(const char *intf)
return 0;
 }
 
-static int smokey_net_modprobe(int modid)
+static int smokey_net_modprobe(int modid, bool silent)
 {
struct module *m = modules + modid;
char buffer[128];
@@ -168,7 +168,8 @@ static int smokey_net_modprobe(int modid)
smokey_trace("%s module not there: modprobing", m->name);
 
err = smokey_check_errno(
-   snprintf(buffer, sizeof(buffer), "modprobe %s", m->name));
+   snprintf(buffer, sizeof(buffer), "modprobe %s %s", m->name,
+silent ? "2>/dev/null" : ""));
if (err < 0)
return err;
 
@@ -177,7 +178,8 @@ static int smokey_net_modprobe(int modid)
return err;
 
if (!WIFEXITED(err) || WEXITSTATUS(err) != 0) {
-   smokey_warning("%s: abnormal exit", buffer);
+   if (!silent)
+   smokey_warning("%s: abnormal exit", buffer);
return -EINVAL;
}
 
@@ -224,7 +226,7 @@ static int smokey_net_setup_rtcfg_client(const char *intf, 
int net_config)
if ((net_config & _CC_COBALT_NET_CFG) == 0)
return -ENOSYS;
 
-   err = smokey_net_modprobe(MODID_CFG);
+   err = smokey_net_modprobe(MODID_CFG, false);
if (err < 0)
return err;
 
@@ -408,6 +410,12 @@ int smokey_net_setup(const char *driver, const char *intf, 
int tested_config,
struct sockaddr_in *in_peer = vpeer;
struct sockaddr *peer = vpeer;
 
+   /*
+* Main module needs to be loaded in order to use
+* _CC_COBALT_GET_NET_CONFIG.
+*/
+   smokey_net_modprobe(MODID_RTNET, true);
+
err = cobalt_corectl(_CC_COBALT_GET_NET_CONFIG,
_config, sizeof(net_config));
if (err == -EINVAL)
@@ -423,15 +431,15 @@ int smokey_net_setup(const char *driver, const char 
*intf, int tested_config,
return -ENOSYS;
 
modules[MODID_DRIVER].name = driver;
-   err = smokey_net_modprobe(MODID_DRIVER);
+   err = smokey_net_modprobe(MODID_DRIVER, false);
if (err < 0)
return err;
 
-   err = smokey_net_modprobe(MODID_IPV4);
+   err = smokey_net_modprobe(MODID_IPV4, false);
if (err < 0)
return err;
 
-   err = smokey_net_modprobe(option_to_modid(tested_config));
+   err = smokey_net_modprobe(option_to_modid(tested_config), false);
if (err < 0)
return err;
 
-- 
2.31.1



[PATCH] testsuite/smokey: net: load rtnet module if it has not been loaded

2021-08-06 Thread Hongzhan Chen via Xenomai
Before checking net config, rtnet should be ready.

Signed-off-by: Hongzhan Chen 

diff --git a/testsuite/smokey/net_common/setup.c 
b/testsuite/smokey/net_common/setup.c
index 1badabdfb..bdae10bfb 100644
--- a/testsuite/smokey/net_common/setup.c
+++ b/testsuite/smokey/net_common/setup.c
@@ -138,6 +138,56 @@ static int do_down(const char *intf)
return 0;
 }
 
+static int smokey_net_modinfo(int modid)
+{
+   struct module *m = modules + modid;
+   char buffer[128];
+   int err;
+
+   if (modid < 0)
+   return -EINVAL;
+
+   smokey_trace("%s module: modinfoing", m->name);
+   err = smokey_check_errno(
+   snprintf(buffer, sizeof(buffer), "modinfo %s", m->name));
+   if (err < 0)
+   return err;
+
+   err = smokey_check_errno(system(buffer));
+   if (err < 0)
+   return err;
+
+   if (!WIFEXITED(err)) {
+   smokey_warning("%s: abnormal exit", buffer);
+   return -EINVAL;
+   }
+
+   if (WEXITSTATUS(err) != 0) {
+   /* double check if there is 'module not found' error,
+* translate it into -ENOSYS
+*/
+   err = smokey_check_errno(
+   snprintf(buffer, sizeof(buffer),
+   "modinfo %s 2>&1 | grep '%s not found'",
+   m->name, m->name));
+   if (err < 0)
+   return err;
+
+   err = smokey_check_errno(system(buffer));
+   if (err < 0)
+   return err;
+
+   if (!WIFEXITED(err) || WEXITSTATUS(err) != 0) {
+   smokey_warning("%s: abnormal exit", buffer);
+   return -EINVAL;
+   }
+
+   return -ENOSYS;
+   }
+
+   return err;
+}
+
 static int smokey_net_modprobe(int modid)
 {
struct module *m = modules + modid;
@@ -408,6 +458,14 @@ int smokey_net_setup(const char *driver, const char *intf, 
int tested_config,
struct sockaddr_in *in_peer = vpeer;
struct sockaddr *peer = vpeer;
 
+   err = smokey_net_modinfo(MODID_RTNET);
+   if (err < 0)
+   return err;
+
+   err = smokey_net_modprobe(MODID_RTNET);
+   if (err < 0)
+   return err;
+
err = cobalt_corectl(_CC_COBALT_GET_NET_CONFIG,
_config, sizeof(net_config));
if (err == -EINVAL)
-- 
2.17.1