public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Shanker Donthineni <sdonthineni@nvidia.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-efi@vger.kernel.org
Subject: Re: [PATCH 1/1] efi: rtc: Enable SET/GET WAKEUP services as optional
Date: Mon, 2 Jan 2023 23:21:45 +0100	[thread overview]
Message-ID: <Y7NY+ba2USk7hEAx@mail.local> (raw)
In-Reply-To: <CAMj1kXG79-MxGJEwvnekqbVyeEMVHBfhNjwZkz91mMwv4-vT3Q@mail.gmail.com>

On 02/01/2023 11:47:11+0100, Ard Biesheuvel wrote:
> On Tue, 27 Dec 2022 at 05:09, Shanker Donthineni <sdonthineni@nvidia.com> wrote:
> >
> > The current implementation of rtc-efi is expecting all the 4
> > time services GET{SET}_TIME{WAKEUP} must be supported by UEFI
> > firmware. As per the EFI_RT_PROPERTIES_TABLE, the platform
> > specific implementations can choose to enable selective time
> > services based on the RTC device capabilities.
> >
> > This patch does the following changes to provide GET/SET RTC
> > services on platforms that do not support the WAKEUP feature.
> >
> > 1) Relax time services cap check when creating a platform device.
> > 2) Clear RTC_FEATURE_ALARM bit in the absence of WAKEUP services.
> > 3) Conditional alarm entries in '/proc/driver/rtc'.
> >
> > Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
> 
> Queued as a fix in efi/urgent, thanks.

This rather seems like an rtc heavy patch and the subject line is
misleading. This should be rtc: efi:
Also, I'm pretty sure this doesn't qualify as an urgent fix.

> 
> 
> > ---
> >  drivers/rtc/rtc-efi.c | 48 ++++++++++++++++++++++++-------------------
> >  include/linux/efi.h   |  3 ++-
> >  2 files changed, 29 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
> > index e991cccdb6e9c..1e8bc6cc1e12d 100644
> > --- a/drivers/rtc/rtc-efi.c
> > +++ b/drivers/rtc/rtc-efi.c
> > @@ -188,9 +188,10 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm)
> >
> >  static int efi_procfs(struct device *dev, struct seq_file *seq)
> >  {
> > -       efi_time_t      eft, alm;
> > -       efi_time_cap_t  cap;
> > -       efi_bool_t      enabled, pending;
> > +       efi_time_t        eft, alm;
> > +       efi_time_cap_t    cap;
> > +       efi_bool_t        enabled, pending;
> > +       struct rtc_device *rtc = dev_get_drvdata(dev);
> >
> >         memset(&eft, 0, sizeof(eft));
> >         memset(&alm, 0, sizeof(alm));
> > @@ -213,23 +214,25 @@ static int efi_procfs(struct device *dev, struct seq_file *seq)
> >                 /* XXX fixme: convert to string? */
> >                 seq_printf(seq, "Timezone\t: %u\n", eft.timezone);
> >
> > -       seq_printf(seq,
> > -                  "Alarm Time\t: %u:%u:%u.%09u\n"
> > -                  "Alarm Date\t: %u-%u-%u\n"
> > -                  "Alarm Daylight\t: %u\n"
> > -                  "Enabled\t\t: %s\n"
> > -                  "Pending\t\t: %s\n",
> > -                  alm.hour, alm.minute, alm.second, alm.nanosecond,
> > -                  alm.year, alm.month, alm.day,
> > -                  alm.daylight,
> > -                  enabled == 1 ? "yes" : "no",
> > -                  pending == 1 ? "yes" : "no");
> > -
> > -       if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
> > -               seq_puts(seq, "Timezone\t: unspecified\n");
> > -       else
> > -               /* XXX fixme: convert to string? */
> > -               seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
> > +       if (test_bit(RTC_FEATURE_ALARM, rtc->features)) {
> > +               seq_printf(seq,
> > +                          "Alarm Time\t: %u:%u:%u.%09u\n"
> > +                          "Alarm Date\t: %u-%u-%u\n"
> > +                          "Alarm Daylight\t: %u\n"
> > +                          "Enabled\t\t: %s\n"
> > +                          "Pending\t\t: %s\n",
> > +                          alm.hour, alm.minute, alm.second, alm.nanosecond,
> > +                          alm.year, alm.month, alm.day,
> > +                          alm.daylight,
> > +                          enabled == 1 ? "yes" : "no",
> > +                          pending == 1 ? "yes" : "no");
> > +
> > +               if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
> > +                       seq_puts(seq, "Timezone\t: unspecified\n");
> > +               else
> > +                       /* XXX fixme: convert to string? */
> > +                       seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
> > +       }
> >
> >         /*
> >          * now prints the capabilities
> > @@ -269,7 +272,10 @@ static int __init efi_rtc_probe(struct platform_device *dev)
> >
> >         rtc->ops = &efi_rtc_ops;
> >         clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features);
> > -       set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features);
> > +       if (efi_rt_services_supported(EFI_RT_SUPPORTED_WAKEUP_SERVICES))
> > +               set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features);
> > +       else
> > +               clear_bit(RTC_FEATURE_ALARM, rtc->features);
> >
> >         device_init_wakeup(&dev->dev, true);
> >
> > diff --git a/include/linux/efi.h b/include/linux/efi.h
> > index 4b27519143f56..98598bd1d2fa5 100644
> > --- a/include/linux/efi.h
> > +++ b/include/linux/efi.h
> > @@ -668,7 +668,8 @@ extern struct efi {
> >
> >  #define EFI_RT_SUPPORTED_ALL                                   0x3fff
> >
> > -#define EFI_RT_SUPPORTED_TIME_SERVICES                         0x000f
> > +#define EFI_RT_SUPPORTED_TIME_SERVICES                         0x0003
> > +#define EFI_RT_SUPPORTED_WAKEUP_SERVICES                       0x000c
> >  #define EFI_RT_SUPPORTED_VARIABLE_SERVICES                     0x0070
> >
> >  extern struct mm_struct efi_mm;
> > --
> > 2.25.1
> >

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2023-01-02 22:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27  4:09 [PATCH 1/1] efi: rtc: Enable SET/GET WAKEUP services as optional Shanker Donthineni
2023-01-02 10:47 ` Ard Biesheuvel
2023-01-02 22:21   ` Alexandre Belloni [this message]
2023-01-02 22:57     ` Shanker Donthineni
2023-01-03  9:18     ` Ard Biesheuvel
2023-01-03 16:36       ` Shanker Donthineni
2023-01-03 16:37         ` Ard Biesheuvel

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=Y7NY+ba2USk7hEAx@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=a.zummo@towertech.it \
    --cc=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sdonthineni@nvidia.com \
    /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