From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Lars Poeschel <poeschel@lemonage.de>,
Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
"open list:PWM SUBSYSTEM" <linux-pwm@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pwm: sysfs: Set class on pwm devices
Date: Wed, 30 Sep 2020 18:30:07 +0200 [thread overview]
Message-ID: <20200930163007.GA1673764@kroah.com> (raw)
In-Reply-To: <20200930150302.n3kcw3lzepug53za@pengutronix.de>
On Wed, Sep 30, 2020 at 05:03:02PM +0200, Uwe Kleine-König wrote:
> On Wed, Sep 30, 2020 at 04:13:52PM +0200, Lars Poeschel wrote:
> > On Wed, Sep 30, 2020 at 01:51:06PM +0200, Greg Kroah-Hartman wrote:
> > > On Wed, Sep 30, 2020 at 01:27:20PM +0200, Lars Poeschel wrote:
> > > > On Wed, Sep 30, 2020 at 12:52:38PM +0200, Greg Kroah-Hartman wrote:
> > > > > On Wed, Sep 30, 2020 at 12:01:26PM +0200, Uwe Kleine-König wrote:
> > > > > > On Wed, Sep 30, 2020 at 11:52:04AM +0200, Greg Kroah-Hartman wrote:
> > > > > > > On Wed, Sep 30, 2020 at 11:41:46AM +0200, Uwe Kleine-König wrote:
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > I added Greg Kroah-Hartman who I discussed this with via irc a bit to
> > > > > > > > Cc:.
> > > > > > > >
> > > > > > > > On Wed, Sep 30, 2020 at 11:20:56AM +0200, Lars Poeschel wrote:
> > > > > > > > > thank you for your review!
> > > > > > > > >
> > > > > > > > > On Wed, Sep 30, 2020 at 08:57:26AM +0200, Uwe Kleine-König wrote:
> > > > > > > > > > On Tue, Sep 29, 2020 at 02:19:53PM +0200, poeschel@lemonage.de wrote:
> > > > > > > > > > > From: Lars Poeschel <poeschel@lemonage.de>
> > > > > > > > > > >
> > > > > > > > > > > This adds a class to exported pwm devices.
> > > > > > > > > > > Exporting a pwm through sysfs did not yield udev events. The
> > > > > > > > > >
> > > > > > > > > > I wonder what is your use-case here. This for sure also has a place to
> > > > > > > > > > be mentioned in the commit log. I suspect there is a better way to
> > > > > > > > > > accomplish you way.
> > > > > > > > >
> > > > > > > > > Use-case is to be able to use a pwm from a non-root userspace process.
> > > > > > > > > I use udev rules to adjust permissions.
> > > > > > > >
> > > > > > > > Hmm, how do you trigger the export? Without being aware of all the
> > > > > > > > details in the sysfs code I would expect that the exported stuff is
> > > > > > > > available instantly once the write used to export the PWM is completed.
> > > > > > > > So changing the permissions can be done directly after triggering the
> > > > > > > > export in the same process.
> > > > > > >
> > > > > > > It looks like userspace wants to see when a pwmX device shows up, right?
> > > > > > >
> > > > > > > And it's not because those devices do not belong to any class or bus, so
> > > > > > > they are just "floating" out there (they might show up under
> > > > > > > /sys/bus/virtual, if you set things up right, which I don't think is
> > > > > > > happening here...)
> > > > > > >
> > > > > > > So yes, you need to create a class, or assign this to a bus, which is
> > > > > > > fine, but it looks like no one is doing that. Don't create new classes
> > > > > > > dynamically, but rather, just assign this to the existing pwm class.
> > > > > > > What's wrong with that? I saw an older patch that did that, what did
> > > > > > > that break?
> > > > > >
> > > > > > Are you refering to 7e5d1fd75c3dde9fc10c4472b9368089d1b81d00? Did you
> > > > > > read the reverting commit's log message? (i.e.
> > > > > > c289d6625237aa785b484b4e94c23b3b91ea7e60)
> > > > > >
> > > > > > I guess the breakage is that the resulting name then is:
> > > > > >
> > > > > > "pwm%d", pwm->id
> > > > > >
> > > > > > where pwm->id is a number unique to the pwmchip. So doing
> > > > > >
> > > > > > echo 0 > pwmchip1/export
> > > > > > echo 0 > pwmchip2/export
> > > > > >
> > > > > > breaks because both want to create pwm0 in the class directory.
> > > > >
> > > > > Ah, that makes more sense why that didn't work.
> > > > >
> > > > > Ok, can the "name" of the new export chip be changed? Is that
> > > > > hard-coded somewhere in userspace tools already? Depending on that, the
> > > > > solution for this will change...
> > > >
> > > > I know that back then, when sysfs for pwm was created, Thierry didn't
> > > > want to have one global namespace like gpio sysfs has. What you ask for
> > > > is something like:
> > > > pwm-{chipnumber}-{pwmnumber}
> > > > Right ? Can that be considered non-global ?
> > >
> > > Yes, and that's just "global" for the pwm class namespace.
> > >
> > > > Thierry's mail from back then is here:
> > > > https://lore.kernel.org/lkml/20130408081745.GA21392@avionic-0098.mockup.avionic-design.de/
> > > >
> > > > A short search on github I found this:
> > > > https://github.com/vsergeev/c-periphery/blob/d34077d7ee45fa7d1947cc0174919452fac31597/src/pwm.c#L74
> > > >
> > > > Seems to match your hardcoded criteria ?
> > >
> > > Yes, ugh :(
> > >
> > > Ok, now I see why the "lots of pwm classes!" patch was proposed.
> > >
> > > And maybe that's really the only way forward here, as the chip namespace
> > > is the only unique thing.
> > >
> > > But wow, it feels wrong...
> >
> > Would the following feel better:
> > * use the new naming scheme you proposed for pwm's :
> > pwm-{chipnumber}-{pwmnumber}
> > * assign the normal pwm class to the exported pwm devices. That lets
> > them appear in the global /sys/class/pwm directory as e.g. pwm-0-0
> > * maintain backward compatibility through symlinks e.g.:
> > pwmchip0/pwm0 -> ../pwm-0-0
>
> My preferred way forward is: Create a proper device (i.e. something like
> /dev/pwmchipX) and make that usable with atomic operations. Then we
> don't need to go through sysfs and can modify more than one property at
> a time.
Kind of like what gpio did with the move to a char device node instead
of sysfs files? That's fine with me if you all want to do that.
> But other than that your suggestion sounds better than one class per
> chip.
I agree, that seems sane. Well, semi-sane, symlinks are "fun" :)
thanks,
greg k-h
next prev parent reply other threads:[~2020-09-30 16:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 12:19 [PATCH] pwm: sysfs: Set class on pwm devices poeschel
2020-09-30 6:57 ` Uwe Kleine-König
2020-09-30 9:20 ` Lars Poeschel
2020-09-30 9:41 ` Uwe Kleine-König
2020-09-30 9:52 ` Greg Kroah-Hartman
2020-09-30 10:01 ` Uwe Kleine-König
2020-09-30 10:52 ` Greg Kroah-Hartman
2020-09-30 11:27 ` Lars Poeschel
2020-09-30 11:51 ` Greg Kroah-Hartman
2020-09-30 14:13 ` Lars Poeschel
2020-09-30 15:03 ` Uwe Kleine-König
2020-09-30 16:30 ` Greg Kroah-Hartman [this message]
2020-10-01 9:05 ` Lars Poeschel
2020-10-01 11:24 ` Greg Kroah-Hartman
2020-10-01 13:50 ` Lars Poeschel
2020-10-02 7:58 ` Greg Kroah-Hartman
2020-10-05 9:30 ` Thierry Reding
2020-10-05 9:45 ` Greg Kroah-Hartman
2020-10-05 10:17 ` Thierry Reding
2020-10-05 10:40 ` Greg Kroah-Hartman
2020-10-05 11:08 ` Thierry Reding
2020-10-05 11:17 ` Greg Kroah-Hartman
2020-10-05 11:58 ` Thierry Reding
2020-10-05 12:12 ` Greg Kroah-Hartman
2020-10-05 10:49 ` Lars Poeschel
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=20200930163007.GA1673764@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=poeschel@lemonage.de \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.