public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Richard Cochran <richardcochran@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org,
	devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org,
	Krzysztof Halasa <khc@pm.waw.pl>,
	Rodolfo Giometti <giometti@linux.it>
Subject: Re: [PATCH 1/5] ptp: Added a brand new class driver for ptp clocks.
Date: Mon, 16 Aug 2010 16:26:23 +0200	[thread overview]
Message-ID: <201008161626.24083.arnd@arndb.de> (raw)
In-Reply-To: <363bd749a38d0b785d8431e591bf54c38db4c2d7.1281956490.git.richard.cochran@omicron.at>

On Monday 16 August 2010, Richard Cochran wrote:
> This patch adds an infrastructure for hardware clocks that implement
> IEEE 1588, the Precision Time Protocol (PTP). A class driver offers a
> registration method to particular hardware clock drivers. Each clock is
> exposed to user space as a character device with ioctls that allow tuning
> of the PTP clock.

Have you considered integrating the subsystem into the Posix clock/timer
framework?

I can't really tell from reading the source if this is possible or
not, but my feeling is that if it can be done, that would be a much
nicer interface. We already have clock_gettime/clock_settime/
timer_settime/... system calls, and while you'd need to add another
clockid and some syscalls, my feeling is that it will be more
usable in the end.

> +static const struct file_operations ptp_fops = {
> +       .owner          = THIS_MODULE,
> +       .ioctl          = ptp_ioctl,
> +       .open           = ptp_open,
> +       .poll           = ptp_poll,
> +       .read           = ptp_read,
> +       .release        = ptp_release,
> +};

.ioctl is gone, you have to use .unlocked_ioctl and make sure that
your ptp_ioctl function can handle being called concurrently.

You should also add a .compat_ioctl function, ideally one that
points to ptp_ioctl so you don't have to list every command as
being compatible. Right now, some commands are incompatible,
which means you need more changes to the interface.

> +struct ptp_clock_timer {
> +       int alarm_index;       /* Which alarm to query or configure. */
> +       int signum;            /* Requested signal. */
> +       int flags;             /* Zero or TIMER_ABSTIME, see TIMER_SETTIME(2) */
> +       struct itimerspec tsp; /* See TIMER_SETTIME(2) */
> +};

This data structure is incompatible between 32 and 64 bit user space,
so you would need a compat_ioctl() function to convert between the
two formats. Better define the structure in a compatible way, avoiding
variable-length fields and implicit padding.

> +struct ptp_clock_request {
> +       int type;  /* One of the ptp_request_types enumeration values. */
> +       int index; /* Which channel to configure. */
> +       struct timespec ts; /* For period signals, the desired period. */
> +       int flags; /* Bit field for PTP_ENABLE_FEATURE or other flags. */
> +};

Same problem here, timespec is either 64 or 128 bits long and has different
alignment.

> +struct ptp_extts_event {
> +       int index;
> +       struct timespec ts;
> +};

here too.

> +#define PTP_CLOCK_VERSION 0x00000001
> +
> +#define PTP_CLK_MAGIC '='
> +
> +#define PTP_CLOCK_APIVERS _IOR (PTP_CLK_MAGIC, 1, __u32)

Try avoiding versioned ABIs. It's better to just add new ioctls
or syscalls when you need some extra functionality and leave the
old ones around.

> +#define PTP_CLOCK_ADJTIME _IOW (PTP_CLK_MAGIC, 3, struct timespec)
> +#define PTP_CLOCK_GETTIME _IOR (PTP_CLK_MAGIC, 4, struct timespec)
> +#define PTP_CLOCK_SETTIME _IOW (PTP_CLK_MAGIC, 5, struct timespec)

These are also incompatible.

	Arnd

  reply	other threads:[~2010-08-16 14:26 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-16 11:17 [PATCH v5 0/5] ptp: IEEE 1588 clock support Richard Cochran
2010-08-16 11:17 ` [PATCH 1/5] ptp: Added a brand new class driver for ptp clocks Richard Cochran
2010-08-16 14:26   ` Arnd Bergmann [this message]
2010-08-16 19:00     ` Richard Cochran
2010-08-16 19:59       ` Arnd Bergmann
2010-08-17  8:32         ` Richard Cochran
2010-08-17  9:25           ` Arnd Bergmann
2010-08-17 10:52             ` Richard Cochran
2010-08-17 11:36               ` Arnd Bergmann
2010-08-18  0:40                 ` john stultz
2010-08-18 14:04                 ` Richard Cochran
2010-08-18 15:02                   ` Arnd Bergmann
2010-08-19  9:22                     ` Richard Cochran
2010-08-19 12:29                       ` Arnd Bergmann
2010-08-19 15:23                         ` Ira W. Snyder
2010-08-19 15:48                           ` Arnd Bergmann
2010-08-16 19:24   ` john stultz
2010-08-16 19:38     ` john stultz
2010-08-17  8:53     ` Richard Cochran
2010-08-18  0:22       ` john stultz
2010-08-18  7:19         ` Richard Cochran
2010-08-19  0:12           ` john stultz
2010-08-19  5:55             ` Richard Cochran
2010-08-19 12:28               ` Arnd Bergmann
2010-08-19 15:38                 ` Richard Cochran
2010-08-23 20:21                   ` john stultz
2010-08-27 11:08                     ` Richard Cochran
2010-08-27 12:03                       ` Arnd Bergmann
2010-08-27 20:56                         ` John Stultz
2010-08-27 12:45                       ` Alan Cox
2010-08-27 20:14                       ` John Stultz
2010-08-23 20:08               ` john stultz
2010-08-24 18:30                 ` Stephan Gatzka
2010-08-25  9:40                 ` Christian Riesch
2010-08-27  1:57                   ` john stultz
2010-08-27  7:57                     ` Richard Cochran
2010-08-27 12:41                       ` Alan Cox
2010-08-27 14:02                         ` Richard Cochran
2010-08-27 14:50                           ` Alan Cox
2010-08-27 15:35                           ` M. Warner Losh
2010-08-29 13:32                         ` Christian Riesch
2010-08-27 12:38                 ` Richard Cochran
2010-08-27 13:38                   ` Alan Cox
2010-08-27 14:34                     ` Richard Cochran
2010-08-27 15:06                       ` Alan Cox
2010-08-27 15:21                         ` Patrick Loschmidt
2010-08-27 22:30                   ` John Stultz
2010-09-06  6:33                     ` Richard Cochran
2010-09-21 16:54                       ` Stephan Gatzka
2010-09-21 20:47                     ` Kyle Moffett
2010-09-22 10:14                       ` Richard Cochran
2010-08-16 11:18 ` [PATCH 2/5] ptp: Added a clock that uses the Linux system time Richard Cochran
2010-08-16 11:18 ` [PATCH 3/5] ptp: Added a clock that uses the eTSEC found on the MPC85xx Richard Cochran
2010-08-16 11:18 ` [PATCH 4/5] ptp: Added a clock driver for the IXP46x Richard Cochran
2010-08-16 11:19 ` [PATCH 5/5] ptp: Added a clock driver for the National Semiconductor PHYTER Richard Cochran

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=201008161626.24083.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=giometti@linux.it \
    --cc=khc@pm.waw.pl \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.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