Linux PWM subsystem development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: linux-pwm@vger.kernel.org
Subject: Re: [PATCH 3/6] pwm: Add support for pwmchip devices for faster and easier userspace access
Date: Fri, 12 Jul 2024 19:20:44 +0200	[thread overview]
Message-ID: <d3c3f69e1e2561d88285738e28ba733f77297288.camel@gmail.com> (raw)
In-Reply-To: <lsl34pvo3vbnqwnzrv36fguasxxb3brrgq44e2w3flgrdjzlx6@5vx53mvpi5fi>

On Fri, 2024-07-12 at 18:28 +0200, Uwe Kleine-König wrote:
> On Fri, Jul 12, 2024 at 01:01:04PM +0200, Nuno Sá wrote:
> > On Fri, 2024-07-12 at 11:48 +0200, Uwe Kleine-König wrote:
> > > On Tue, Jul 09, 2024 at 11:37:13AM +0200, Nuno Sá wrote:
> > > > On Mon, 2024-07-08 at 12:52 +0200, Uwe Kleine-König wrote:
> > > > > With this change each pwmchip can be accessed from userspace via a
> > > > > character device. Compared to the sysfs-API this is faster (on a
> > > > > stm32mp157 applying a new configuration takes approx 25% only) and
> > > > > allows to pass the whole configuration in a single ioctl allowing atomic
> > > > > application.
> > > > > 
> > > > > Thanks to Randy Dunlap for pointing out a missing kernel-doc
> > > > > description.
> > > > > 
> > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> > > > > ---
> > > > 
> > > > I didn't looked very carefully at the patch but one thing did caught my
> > > > attention
> > > > 
> > > > ...
> > > > 
> > > > > +
> > > > > +struct pwmchip_waveform {
> > > > > +	unsigned int hwpwm;
> > > > > +	__u64 period_length;
> > > > > +	__u64 duty_length;
> > > > > +	__u64 duty_offset;
> > > > > +};
> > > > > +
> > > > 
> > > > I do not think we should have holes in the struct given this is an userspace
> > > > interface.
> > > 
> > > Ack, will add explicit padding (and a check that it is zeroed).
> > > 
> > 
> > Why not having the __u64 coming first :)? It also save you 4 bytes (yeah, should
> > not make a difference)
> 
> Well no. First conceptually hwpwm should come first and second there is
> https://www.kernel.org/doc/html/latest/process/botching-up-ioctls.html
> which recommends:
> 
> 	Align everything to the natural size and use explicit padding.
> 	32-bit platforms don’t necessarily align 64-bit values to 64-bit
> 	boundaries, but 64-bit platforms do. So we always need padding
> 	to the natural size to get this right.
> 

Right, my bad! The third point about struct sizes is also valid and would fail with
my suggestion.

Thanks!
- Nuno Sá

> > > 

  reply	other threads:[~2024-07-12 17:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-08 10:52 [PATCH 0/6] pwm: New abstraction and userspace API Uwe Kleine-König
2024-07-08 10:52 ` [PATCH 1/6] pwm: Add more locking Uwe Kleine-König
2024-07-08 10:52 ` [PATCH 2/6] pwm: New abstraction for PWM waveforms Uwe Kleine-König
2024-07-08 18:12   ` Trevor Gamblin
2024-07-08 10:52 ` [PATCH 3/6] pwm: Add support for pwmchip devices for faster and easier userspace access Uwe Kleine-König
2024-07-08 18:13   ` Trevor Gamblin
2024-07-09  9:37   ` Nuno Sá
2024-07-12  9:48     ` Uwe Kleine-König
2024-07-12 11:01       ` Nuno Sá
2024-07-12 16:28         ` Uwe Kleine-König
2024-07-12 17:20           ` Nuno Sá [this message]
2024-07-08 10:52 ` [PATCH 4/6] pwm: Add tracing for waveform callbacks Uwe Kleine-König
2024-07-08 18:14   ` Trevor Gamblin
2024-07-09  6:54     ` Uwe Kleine-König
2024-07-08 10:52 ` [PATCH 5/6] pwm: axi-pwmgen: Implementation of the " Uwe Kleine-König
2024-07-08 18:08   ` Trevor Gamblin
2024-07-08 10:52 ` [PATCH 6/6] pwm: stm32: " Uwe Kleine-König

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=d3c3f69e1e2561d88285738e28ba733f77297288.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.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