public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>
Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RTC: Fix for issues in the kernel RTC API.
Date: Wed, 02 Feb 2011 14:24:39 -0800	[thread overview]
Message-ID: <1296685479.3336.298.camel@work-vm> (raw)
In-Reply-To: <AANLkTincYETuV-P5DG9cpgUL-hSoqAG=oQvS2kRUmAkb@mail.gmail.com>

On Wed, 2011-02-02 at 15:58 -0200, Marcelo Roberto Jimenez wrote:
> The reason I added it before was that the user space behavior of the
> rtc-test kernel RTC driver had changed, but maybe its previous
> behavior is is no longer acceptable. Alarm interrupts were hand
> generated by the user by echoing to the sys interface, but it does not
> make sense to even have a timer in that case. That way,
> alarm_irq_enable() would bypass the kernel implementation.
> 
> Also, the way it is today, the programmer implementing the driver
> _must_ define alarm_irq_enable(), even if this function does nothing,
> otherwise you get EINVAL.
> 
> Maybe I got alarm_irq_enable() completely wrong and it should just be removed.

No, I think you are just bringing up some subtleties of the interface,
and clearly if the rtc-test driver is broken, that's my fault.

I've started playing with the rtc-test driver, and I am seeing some
issues there, so I'll try to see if I can't fix those quickly here.


> >> 2 - In the current configuration, an update interrupt, for example,
> >> would be a trigger for an alarm interrupt as well, even though the mode
> >> variable stated it was an update interrupt. To avoid that, mode is
> >> beeing checked inside rtc_handle_legacy_irq(). That used to be the
> >> previous user space behaviour.
> >
> > Right, we internally use recurring alarm interrupts to emulate the
> > update interrupt mode. Although I believe I provided the right behavior
> > to userland, so I'm not sure I see the issue or how your changes correct
> > things.
> 
> Again, what the rtc-test kernel RTC and the strongarm RTC user space
> behavior have changed. Alarm interrupts and update interrupts were
> generated by a different interrupts in the strongarm driver, and the
> rtc-test driver also behaved similarly, i.e., an update interrupt did
> not trigger an alarm interrupt. Currently, rtc_handle_legacy_irq()
> centralizes the irq processing, and by not checking the generated
> interrupt, it allows the new behavior, which seemed broken to me.

So 


> >> 3 - The irq_set_freq() and rtc_irq_set_state() functions are entry
> >> points to the RTC API, and were not calling the irq_set_state() and
> >> irq_set_freq() callbacks. These are also necessary overrides to provide
> >> a proper independent RTC implementation.
> >
> > Again, the freq is handled via a hrtimer now, so we shouldn't be calling
> > out to the hardware specific rtc driver anymore.
> 
> My reasoning here goes along the same lines as in the
> alarm_irq_enable() case, so I believe those callbacks should also be
> removed, right?
> 
> For rtc_irq_set_freq(), I believe that the current code allows a user
> space program to call the RTC_IRQP_SET ioclt() with freq == 0 and have
> a division by zero in the kernel code. I'll send a separate patch for
> that.

Yes. Very good catch here. Thanks for sending that in! I'll be sending
it upstream through Thomas shortly here.


> >> 4 - The rtc-test kernel RTC driver has been updated to work properly
> >> with the new kernel RTC timer infrastructure. This driver has been used
> >> together with the rtctest.c source code present in the file
> >> Documentation/rtc.txt to test the user space behaviour of all the
> >> modifications in this patch.
> >
> > So forgive me, as I might just be missing what you're describing. It
> > might be easier if you break fixes up into multiple patches?
> 
> The original purpose of the patch was to bring back the previous
> rtc-test driver behaviour, I think that anything less would be to
> commit broken work in progress code.

Very much agreed. 

So thanks for your more detailed explanation. Taking a look at the
rtc-test driver, I can see there's some issues in my emulation code
surrounding the split between the rtc driver ioctl and the emulated
processing (basically if the driver registers an ioctl handler, it
short-circuits the emulation code causing problems).

There's some ugliness here, as basically either the RTC driver can try
to handle all or most of the functionality through the ioctl or
implement operations and let the generic code handle the rest. 

So for instance, the driver can handle RTC_AIE_ON directly in the ioctl
operation, and then not implement the alarm_irq_enable operation.

So there's a number of ways you could implement the same functionality
in the driver.  I missed this inconsistency here. So I'll have to clean
that up somewhat. :(

Thanks again for pointing this issue out! I'll be sending you patches
for testing soon.

thanks
-john



  reply	other threads:[~2011-02-02 22:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01 16:30 [PATCH] RTC: Fix for issues in the kernel RTC API Marcelo Roberto Jimenez
2011-02-02  3:00 ` John Stultz
2011-02-02 17:58   ` Marcelo Roberto Jimenez
2011-02-02 22:24     ` John Stultz [this message]
2011-02-02 22:28       ` john stultz
2011-02-03 18:41         ` Marcelo Roberto Jimenez

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=1296685479.3336.298.camel@work-vm \
    --to=john.stultz@linaro.org \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mroberto@cpti.cetuc.puc-rio.br \
    --cc=rtc-linux@googlegroups.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