From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EB28C33C9E for ; Fri, 17 Jan 2020 21:54:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BFA12192A for ; Fri, 17 Jan 2020 21:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729497AbgAQVys (ORCPT ); Fri, 17 Jan 2020 16:54:48 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:43055 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbgAQVyr (ORCPT ); Fri, 17 Jan 2020 16:54:47 -0500 X-Originating-IP: 90.65.92.102 Received: from localhost (lfbn-lyo-1-1913-102.w90-65.abo.wanadoo.fr [90.65.92.102]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id B79F11BF207; Fri, 17 Jan 2020 21:54:44 +0000 (UTC) Date: Fri, 17 Jan 2020 22:54:44 +0100 From: Alexandre Belloni To: Aleksandar Markovic Cc: Arnd Bergmann , Laurent Vivier , Filip Bozuta , Peter Maydell , Daniel =?iso-8859-1?Q?P=2E_Berrang=E9?= , Richard Henderson , "qemu-devel@nongnu.org" , Max Filippov , "amarkovic@wavecomp.com" , "philmd@redhat.com" , linux-rtc@vger.kernel.org Subject: Re: [PATCH 08/12] linux-user: Add support for setting alsa timer enhanced read using ioctl Message-ID: <20200117215444.GD3036@piout.net> References: <1579103618-20217-9-git-send-email-Filip.Bozuta@rt-rk.com> <518d717d-9f1e-e00e-f2a9-df8861241d1c@rt-rk.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org Hi, Quick answers to your very good questions below: On 17/01/2020 21:50:34+0100, Aleksandar Markovic wrote: > Alexandre (and Arnd too, or any other person knowledgeable in the area), > > I just need to clarify a couple of details with you, please. > > Firstly, here is what man page rtc(4) says: > > "The /dev/rtc (or /dev/rtc0, /dev/rtc1, etc.) device can be opened > only once (until it is closed) and it is read-only. On read(2) and > select(2) the calling process is blocked until the next interrupt from > that RTC is received. Following the interrupt, the process can read a > long integer, of which the least significant byte contains a bit mask > encoding the types of interrupt that occurred, while the remaining 3 > bytes contain the number of interrupts since the last read(2)." > > So, it looks read() will always return only 4 bytes of useful info > (regardless of host being 32-bit/64-bit). > > My questions are: > > - Is the description in man page genuinely accurate? > It is accurate. It is a mask of: #define RTC_IRQF 0x80 /* Any of the following is active */ #define RTC_PF 0x40 /* Periodic interrupt */ #define RTC_AF 0x20 /* Alarm interrupt */ #define RTC_UF 0x10 /* Update interrupt for 1Hz RTC */ Which will most likely be RTC_IRQF | RTC_AF. > - To me (but I am really an outsider to using RTC in applications), > this feature (blocking read()/select()) even looks very nice and > convenient, in all fairness. But I would like to ask you: Is this > feature used rarely or frequently by other libraries/tools/etc.? In > other words, is the feature "obscure" or "crucial" part of RTC kernel > support? Or, something in between? > Nobody is actually using the return value. > - Does MC146818 support this feature? > This feature is implemented in the RTC core so it is supported by all RTCs that have alarms. Internally, the value is an unsigned long and it is casted properly by put_user in rtc_dev_read: https://elixir.bootlin.com/linux/v5.4/source/drivers/rtc/dev.c#L178 -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com