Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755147Ab1BBWYs (ORCPT ); Wed, 2 Feb 2011 17:24:48 -0500 Received: from e32.co.us.ibm.com ([32.97.110.150]:41077 "EHLO e32.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754475Ab1BBWYr (ORCPT ); Wed, 2 Feb 2011 17:24:47 -0500 Subject: Re: [PATCH] RTC: Fix for issues in the kernel RTC API. From: John Stultz To: Marcelo Roberto Jimenez Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org In-Reply-To: References: <1296577820-27456-1-git-send-email-mroberto@cpti.cetuc.puc-rio.br> <1296615605.3336.239.camel@work-vm> Content-Type: text/plain; charset="UTF-8" Date: Wed, 02 Feb 2011 14:24:39 -0800 Message-ID: <1296685479.3336.298.camel@work-vm> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4788 Lines: 108 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/