All of lore.kernel.org
 help / color / mirror / Atom feed
From: thierry.reding@gmail.com (Thierry Reding)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH v3 1/4] pwm: Add support for Meson PWM Controller
Date: Tue, 6 Sep 2016 12:04:38 +0200	[thread overview]
Message-ID: <20160906100438.GE15644@ulmo.ba.sec> (raw)
In-Reply-To: <a43f6e6e-05f6-cefe-451d-528588b85a8c@baylibre.com>

On Tue, Sep 06, 2016 at 11:14:45AM +0200, Neil Armstrong wrote:
> On 09/06/2016 11:07 AM, Thierry Reding wrote:
> > On Tue, Sep 06, 2016 at 10:36:49AM +0200, Neil Armstrong wrote:
> >> Hi Thierry,
> >>
> [...]
> > 
> >>
> >> The second bug is in probe(), I understand the point to allocate
> >> dynamically the channels and attach them to each pwm chip, but when
> >> calling meson_pwm_init_channels() we get an OOPS because
> >> meson->chip.pwms[i] are allocated in pwmchip_add(). Moving
> >> meson_pwm_init_channels() would fix this, but in case of a clk
> >> PROBE_DEFER, we would need to remove back the pwmchip, which is a
> >> quite a bad design decision....
> > 
> > Ah yes... that one again. I remember running into that a while ago with
> > some other driver. To be honest, I think that's a short-coming of the
> > PWM subsystem and the fix would be for PWM chip registration to be split
> > into two parts: pwm_chip_init() and pwm_chip_add(). That way, a chip
> > would be initialized using pwm_chip_init() where the pwms array would be
> > allocated, and pwm_chip_add() would register the chip with the system.
> > 
> > Currently a few drivers might be vulnerable to a race condition between
> > registration and implementation (i.e. PWM channels aren't fully set up
> > when they are exposed to users and sysfs).
> > 
> >> The smartest fix I found was to allocate channels in probe, init them
> >> them attach them after pwmchip_add():
> >>
> [...]
> 
> > 
> > That's the race I was talking about above. I suppose it's not too big an
> > issue since other drivers seem to manage, so I'm going to merge your
> > fixed driver.
> 
> ok thanks !

I've made a few tiny changes (reg -> offset, temporary variable to track
&channels[i], ...) and pushed it all out. Hopefully that now fixes any
of the remaining issues.

> > Unless you feel like taking a stab at the pwm_chip_init()/pwm_chip_add()
> > split, in which case your driver would be the first to be race-free. =)
> 
> Having he driver upstream is a priority, but having it completely
> race-free would be great! I'll be happy to collaborate to a race-free
> pwmchip probe somehow !

Fair enough. I'll do some prototyping and keep you in the loop if I come
up with something that I think will do.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20160906/089d2a89/attachment.sig>

WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: Neil Armstrong <narmstrong@baylibre.com>
Cc: carlo@caione.org, khilman@baylibre.com,
	linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/4] pwm: Add support for Meson PWM Controller
Date: Tue, 6 Sep 2016 12:04:38 +0200	[thread overview]
Message-ID: <20160906100438.GE15644@ulmo.ba.sec> (raw)
In-Reply-To: <a43f6e6e-05f6-cefe-451d-528588b85a8c@baylibre.com>

[-- Attachment #1: Type: text/plain, Size: 2324 bytes --]

On Tue, Sep 06, 2016 at 11:14:45AM +0200, Neil Armstrong wrote:
> On 09/06/2016 11:07 AM, Thierry Reding wrote:
> > On Tue, Sep 06, 2016 at 10:36:49AM +0200, Neil Armstrong wrote:
> >> Hi Thierry,
> >>
> [...]
> > 
> >>
> >> The second bug is in probe(), I understand the point to allocate
> >> dynamically the channels and attach them to each pwm chip, but when
> >> calling meson_pwm_init_channels() we get an OOPS because
> >> meson->chip.pwms[i] are allocated in pwmchip_add(). Moving
> >> meson_pwm_init_channels() would fix this, but in case of a clk
> >> PROBE_DEFER, we would need to remove back the pwmchip, which is a
> >> quite a bad design decision....
> > 
> > Ah yes... that one again. I remember running into that a while ago with
> > some other driver. To be honest, I think that's a short-coming of the
> > PWM subsystem and the fix would be for PWM chip registration to be split
> > into two parts: pwm_chip_init() and pwm_chip_add(). That way, a chip
> > would be initialized using pwm_chip_init() where the pwms array would be
> > allocated, and pwm_chip_add() would register the chip with the system.
> > 
> > Currently a few drivers might be vulnerable to a race condition between
> > registration and implementation (i.e. PWM channels aren't fully set up
> > when they are exposed to users and sysfs).
> > 
> >> The smartest fix I found was to allocate channels in probe, init them
> >> them attach them after pwmchip_add():
> >>
> [...]
> 
> > 
> > That's the race I was talking about above. I suppose it's not too big an
> > issue since other drivers seem to manage, so I'm going to merge your
> > fixed driver.
> 
> ok thanks !

I've made a few tiny changes (reg -> offset, temporary variable to track
&channels[i], ...) and pushed it all out. Hopefully that now fixes any
of the remaining issues.

> > Unless you feel like taking a stab at the pwm_chip_init()/pwm_chip_add()
> > split, in which case your driver would be the first to be race-free. =)
> 
> Having he driver upstream is a priority, but having it completely
> race-free would be great! I'll be happy to collaborate to a race-free
> pwmchip probe somehow !

Fair enough. I'll do some prototyping and keep you in the loop if I come
up with something that I think will do.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/4] pwm: Add support for Meson PWM Controller
Date: Tue, 6 Sep 2016 12:04:38 +0200	[thread overview]
Message-ID: <20160906100438.GE15644@ulmo.ba.sec> (raw)
In-Reply-To: <a43f6e6e-05f6-cefe-451d-528588b85a8c@baylibre.com>

On Tue, Sep 06, 2016 at 11:14:45AM +0200, Neil Armstrong wrote:
> On 09/06/2016 11:07 AM, Thierry Reding wrote:
> > On Tue, Sep 06, 2016 at 10:36:49AM +0200, Neil Armstrong wrote:
> >> Hi Thierry,
> >>
> [...]
> > 
> >>
> >> The second bug is in probe(), I understand the point to allocate
> >> dynamically the channels and attach them to each pwm chip, but when
> >> calling meson_pwm_init_channels() we get an OOPS because
> >> meson->chip.pwms[i] are allocated in pwmchip_add(). Moving
> >> meson_pwm_init_channels() would fix this, but in case of a clk
> >> PROBE_DEFER, we would need to remove back the pwmchip, which is a
> >> quite a bad design decision....
> > 
> > Ah yes... that one again. I remember running into that a while ago with
> > some other driver. To be honest, I think that's a short-coming of the
> > PWM subsystem and the fix would be for PWM chip registration to be split
> > into two parts: pwm_chip_init() and pwm_chip_add(). That way, a chip
> > would be initialized using pwm_chip_init() where the pwms array would be
> > allocated, and pwm_chip_add() would register the chip with the system.
> > 
> > Currently a few drivers might be vulnerable to a race condition between
> > registration and implementation (i.e. PWM channels aren't fully set up
> > when they are exposed to users and sysfs).
> > 
> >> The smartest fix I found was to allocate channels in probe, init them
> >> them attach them after pwmchip_add():
> >>
> [...]
> 
> > 
> > That's the race I was talking about above. I suppose it's not too big an
> > issue since other drivers seem to manage, so I'm going to merge your
> > fixed driver.
> 
> ok thanks !

I've made a few tiny changes (reg -> offset, temporary variable to track
&channels[i], ...) and pushed it all out. Hopefully that now fixes any
of the remaining issues.

> > Unless you feel like taking a stab at the pwm_chip_init()/pwm_chip_add()
> > split, in which case your driver would be the first to be race-free. =)
> 
> Having he driver upstream is a priority, but having it completely
> race-free would be great! I'll be happy to collaborate to a race-free
> pwmchip probe somehow !

Fair enough. I'll do some prototyping and keep you in the loop if I come
up with something that I think will do.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160906/089d2a89/attachment.sig>

  reply	other threads:[~2016-09-06 10:04 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22 15:36 [PATCH v3 0/4] pwm: Add Amlogic Meson SoC PWM Controller Neil Armstrong
2016-08-22 15:36 ` Neil Armstrong
2016-08-22 15:36 ` Neil Armstrong
2016-08-22 15:36 ` [PATCH v3 1/4] pwm: Add support for Meson " Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-28 16:33   ` Martin Blumenstingl
2016-08-28 16:33     ` Martin Blumenstingl
2016-08-28 16:33     ` Martin Blumenstingl
2016-09-05  9:53     ` Thierry Reding
2016-09-05  9:53       ` Thierry Reding
2016-09-05  9:53       ` Thierry Reding
2016-09-06 21:24       ` Martin Blumenstingl
2016-09-06 21:24         ` Martin Blumenstingl
2016-09-06 21:24         ` Martin Blumenstingl
2016-09-05  9:00   ` Thierry Reding
2016-09-05  9:00     ` Thierry Reding
2016-09-05  9:00     ` Thierry Reding
2016-09-05  9:20     ` Neil Armstrong
2016-09-05  9:20       ` Neil Armstrong
2016-09-05  9:20       ` Neil Armstrong
2016-09-06  8:36     ` Neil Armstrong
2016-09-06  8:36       ` Neil Armstrong
2016-09-06  8:36       ` Neil Armstrong
2016-09-06  9:07       ` Thierry Reding
2016-09-06  9:07         ` Thierry Reding
2016-09-06  9:07         ` Thierry Reding
2016-09-06  9:14         ` Neil Armstrong
2016-09-06  9:14           ` Neil Armstrong
2016-09-06  9:14           ` Neil Armstrong
2016-09-06  9:14           ` Neil Armstrong
2016-09-06 10:04           ` Thierry Reding [this message]
2016-09-06 10:04             ` Thierry Reding
2016-09-06 10:04             ` Thierry Reding
2016-09-06 12:11             ` jbrunet
2016-09-06 12:11               ` jbrunet
2016-09-06 12:11               ` jbrunet
2016-08-22 15:36 ` [PATCH v3 2/4] dt-bindings: pwm: Add bindings " Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36 ` [PATCH v3 3/4] ARM64: dts: meson-gxbb: Add Meson GXBB PWM Controller nodes Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-28 16:29   ` Martin Blumenstingl
2016-08-28 16:29     ` Martin Blumenstingl
2016-08-28 16:29     ` Martin Blumenstingl
2016-08-28 16:29     ` Martin Blumenstingl
2016-08-22 15:36 ` [PATCH v3 4/4] ARM: dts: meson8b: Add Meson8b " Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-08-22 15:36   ` Neil Armstrong
2016-09-07 20:19 ` [PATCH v3 0/4] pwm: Add Amlogic Meson SoC PWM Controller Kevin Hilman
2016-09-07 20:19   ` Kevin Hilman
2016-09-07 20:19   ` Kevin Hilman

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=20160906100438.GE15644@ulmo.ba.sec \
    --to=thierry.reding@gmail.com \
    --cc=linus-amlogic@lists.infradead.org \
    /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.