From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Joseph Jang <jjang@nvidia.com>
Cc: "shuah@kernel.org" <shuah@kernel.org>,
"avagin@google.com" <avagin@google.com>,
"amir73il@gmail.com" <amir73il@gmail.com>,
"brauner@kernel.org" <brauner@kernel.org>,
Matt Ochs <mochs@nvidia.com>, Koba Ko <kobak@nvidia.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH 1/2] selftest: rtc: Add to check rtc alarm status for alarm related test
Date: Fri, 18 Oct 2024 10:27:06 +0200 [thread overview]
Message-ID: <20241018082706d7b167ab@mail.local> (raw)
In-Reply-To: <c900db54-d764-4389-ad9a-bc2be61eedd2@nvidia.com>
On 18/10/2024 12:26:44+0800, Joseph Jang wrote:
>
>
> On 2024/6/24 9:43 AM, Joseph Jang wrote:
> >
> >
> > On 2024/6/21 3:36 AM, Alexandre Belloni wrote:
> > > On 23/05/2024 18:38:06-0700, Joseph Jang wrote:
> > > > In alarm_wkalm_set and alarm_wkalm_set_minute test, they use different
> > > > ioctl (RTC_ALM_SET/RTC_WKALM_SET) for alarm feature detection. They will
> > > > skip testing if RTC_ALM_SET/RTC_WKALM_SET ioctl returns an EINVAL error
> > > > code. This design may miss detecting real problems when the
> > > > efi.set_wakeup_time() return errors and then RTC_ALM_SET/RTC_WKALM_SET
> > > > ioctl returns an EINVAL error code with RTC_FEATURE_ALARM enabled.
> > > >
> > > > In order to make rtctest more explicit and robust, we propose to use
> > > > RTC_PARAM_GET ioctl interface to check rtc alarm feature state before
> > > > running alarm related tests. If the kernel does not support RTC_PARAM_GET
> > > > ioctl interface, we will fallback to check the error number of
> > > > (RTC_ALM_SET/RTC_WKALM_SET) ioctl call for alarm feature detection.
> > > >
> > > > Requires commit 101ca8d05913b ("rtc: efi: Enable SET/GET WAKEUP services
> > > > as optional")
> > > >
> > > > Reviewed-by: Koba Ko <kobak@nvidia.com>
> > > > Reviewed-by: Matthew R. Ochs <mochs@nvidia.com>
> > > > Signed-off-by: Joseph Jang <jjang@nvidia.com>
> > > > ---
> > > > tools/testing/selftests/rtc/Makefile | 2 +-
> > > > tools/testing/selftests/rtc/rtctest.c | 64 +++++++++++++++++++++++++++
> > > > 2 files changed, 65 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/tools/testing/selftests/rtc/Makefile b/tools/testing/selftests/rtc/Makefile
> > > > index 55198ecc04db..6e3a98fb24ba 100644
> > > > --- a/tools/testing/selftests/rtc/Makefile
> > > > +++ b/tools/testing/selftests/rtc/Makefile
> > > > @@ -1,5 +1,5 @@
> > > > # SPDX-License-Identifier: GPL-2.0
> > > > -CFLAGS += -O3 -Wl,-no-as-needed -Wall
> > > > +CFLAGS += -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include/
> > >
> > > Is this change actually needed?
> >
> > If we didn't include "-I../../../../usr/include/" in rtctest Makefile,
> > we may encounter build errors like the following because rtctest default
> > look at the header file from /usr/include/linux/rtc.h which miss the
> > definition of struct rtc_param, RTC_PARAM_FEATURES and RTC_PARAM_GET.
> >
> > rtctest.c: In function ‘get_rtc_alarm_state’:
> > rtctest.c:94:15: error: variable ‘param’ has initializer but incomplete
> > type
> > 94 | struct rtc_param param = { 0 };
> > | ^~~~~~~~~
> > rtctest.c:94:35: warning: excess elements in struct initializer
> > 94 | struct rtc_param param = { 0 };
> > | ^
> > rtctest.c:94:35: note: (near initialization for ‘param’)
> > rtctest.c:94:25: error: storage size of ‘param’ isn’t known
> > 94 | struct rtc_param param = { 0 };
> > | ^~~~~
> > rtctest.c:98:22: error: ‘RTC_PARAM_FEATURES’ undeclared (first use in
> > this function)
> > 98 | param.param = RTC_PARAM_FEATURES;
> > | ^~~~~~~~~~~~~~~~~~
> > rtctest.c:98:22: note: each undeclared identifier is reported only once
> > for each function it appears in
> > rtctest.c:100:23: error: ‘RTC_PARAM_GET’ undeclared (first use in this
> > function); did you mean ‘RTC_ALM_SET’?
> > 100 | rc = ioctl(fd, RTC_PARAM_GET, ¶m);
> > | ^~~~~~~~~~~~~
> > | RTC_ALM_SET
> >
> > After adding "-I../../../../usr/include/", the rtctest will look at
> > linux kernel source header files from
> > <Linux root directory>/usr/include/linux/rtc.h to find the definition of
> > struct rtc_param, RTC_PARAM_FEATURES and RTC_PARAM_GET and fix the
> > rtctest build errors.
> >
> >
> > Thank you,
> > Joseph.
> >
> > >
> Hi Alexandre,
>
> Thank you for reviewing the kernel patch [PATCH 1/2].
> We are still not sure if we could include linux headers files from kernel
> source directory by the following change ?
>
> -CFLAGS += -O3 -Wl,-no-as-needed -Wall
> +CFLAGS += -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include/
I guess this is ok, I expected Shuah to take this path too.
>
> Thank you,
> Joseph.
>
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2024-10-18 8:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-24 1:38 [PATCH 0/2] selftest: rtc: Add rtc feature detection and rtc file check Joseph Jang
2024-05-24 1:38 ` [PATCH 1/2] selftest: rtc: Add to check rtc alarm status for alarm related test Joseph Jang
2024-06-20 19:36 ` Alexandre Belloni
2024-06-24 1:35 ` Joseph Jang
2024-06-24 1:43 ` Joseph Jang
2024-10-18 4:26 ` Joseph Jang
2024-10-18 8:27 ` Alexandre Belloni [this message]
2024-10-18 15:42 ` Shuah Khan
2024-05-24 1:38 ` [PATCH 2/2] selftest: rtc: Check if could access /dev/rtc0 before testing Joseph Jang
2024-06-20 19:37 ` Alexandre Belloni
2024-09-24 5:37 ` Joseph Jang
2024-09-24 16:05 ` Shuah Khan
2024-09-24 19:31 ` Alexandre Belloni
2024-09-24 19:57 ` Shuah Khan
2024-10-18 4:18 ` Joseph Jang
2024-10-18 15:39 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241018082706d7b167ab@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=amir73il@gmail.com \
--cc=avagin@google.com \
--cc=brauner@kernel.org \
--cc=jjang@nvidia.com \
--cc=kobak@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mochs@nvidia.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).