Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Andy Shevchenko <andy@kernel.org>,
	linux-pwm@vger.kernel.org, Bartosz Golaszewski <brgl@bgdev.pl>,
	kernel@pengutronix.de, Sean Young <sean@mess.org>
Subject: Re: [PATCH v1 000/101] pwm: Fix lifetime issues for pwm_chips
Date: Fri, 6 Oct 2023 12:15:55 +0200	[thread overview]
Message-ID: <ZR_eW-YsYrLUxPfF@orome.fritz.box> (raw)
In-Reply-To: <20231001111024.a3ce3het2y3n7kvx@pengutronix.de>

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

On Sun, Oct 01, 2023 at 01:10:24PM +0200, Uwe Kleine-König wrote:
> Hello again,
> 
> On Tue, Sep 26, 2023 at 12:06:25PM +0200, Uwe Kleine-König wrote:
> > On Tue, Aug 08, 2023 at 07:17:50PM +0200, Uwe Kleine-König wrote:
> > > this series addresses the issues I reported already earlier to this
> > > list[1]. It is based on pwm/for-next and several patches I already sent
> > > out, too. Maybe some of these have to be reworked (e.g. Thierry already
> > > signalled not to like the patches dropping runtime error messages) but
> > > in the expectation that I will have to create a v2 for this series, too
> > > and it actually fixes a race condition, I sent the patches out for
> > > review anyhow. For the same reason I didn't Cc: all the individual
> > > maintainers.
> > > 
> > > If you want to actually test I suggest you fetch my complete history
> > > from
> > > 
> > > 	https://git.pengutronix.de/git/ukl/linux pwm-lifetime-tracking
> > > 
> > > . 
> > > 
> > > In the end drivers have to allocate their pwm_chip using
> > > pwmchip_alloc(). This is important for the memory backing the pwm_chip
> > > being able to have a longer life than the driver.
> > > 
> > > The motivation for this series is to prepare the pwm framework to add a
> > > character device for each pwm_chip for easier and faster access to PWMs
> > > from userspace compared to the sysfs API. For such an extension proper
> > > lifetime tracking is important, too, as such a device can still be open
> > > if a PWM disappears.
> > 
> > I wonder how this topic will continue. This series fixes a lifetime
> > issue that can result in a userspace triggered oops and it builds the
> > base for my efforts to create a /dev/pwmchipX for faster control of PWMs
> > from userspace (compared to sysfs). (Currently in the prototype stage.)
> > 
> > I'd like to get this in during the next merge window, please tell me
> > what needs to be done to make this happen.
> 
> One problem I noticed yesterday is that this series depends on patch
> "drm/ssd130x: Print the PWM's label instead of its number" that
> currently waits in drm-misc-next for getting in the main line. The
> series could for sure be reworked to not rely on this patch, but I'd
> prefer to wait until after the next merge window instead of reworking
> it.
> 
> Still, getting some feedback here in the mean time would be nice. The
> questions I wonder about myself are:
> 
>  - In patch #1, devm_pwmchip_alloc() could get another parameter for the
>    .ops member. This would save a line per driver like
> 
>    	chip->ops = &pwm_clk_ops;
> 
>    in return for an additional parameter that yields longer lines in the
>    drivers.
> 
>  - In patch #101 instead of using &pwm_lock a per-pwmchip lock could be
>    used for pwm_apply_state(). This would allow to parallelize pwm calls
>    for different chips; I don't know how much this matters. Maybe the
>    sensible option here is to keep it simple for now (i.e. how I
>    implemented it now) until someone complains? (But see also the next
>    item.)
> 
>  - A further complication is the requirement of pwm-ir-tx for faster
>    pwm_apply_state() calls, see
> 
> 	https://lore.kernel.org/linux-pwm/ZRb5OWvx3GxYWf9g@gofer.mess.org
>    	https://lore.kernel.org/linux-pwm/1bd5241d584ceb4d6b731c4dc3203fb9686ee1d1.1696156485.git.sean@mess.org
> 
>    . This complicates the locking scheme, I didn't try to address that
>    yet.

Frankly, I think per-chip locking is the only way to support slow
busses. If we use the subsystem-wide lock, effectively all chips become
slow and unusable for things like pwm-ir-tx.

Perhaps we can draw some inspiration from how the IRQ infrastructure
deals with this? IRQ chips have irq_bus_lock() and irq_bus_sync_unlock()
callbacks to deal with this. We could have something similar for PWM
chips. Perhaps that's even something that could be handled in the core
by checking a "might_sleep" flag for the chip.

Thierry

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

  reply	other threads:[~2023-10-06 10:16 UTC|newest]

Thread overview: 129+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 17:17 [PATCH v1 000/101] pwm: Fix lifetime issues for pwm_chips Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 001/101] pwm: Provide devm_pwmchip_alloc() function Uwe Kleine-König
2023-10-06  9:23   ` Thierry Reding
2023-10-06 10:56     ` Uwe Kleine-König
2023-10-06 11:08       ` Thierry Reding
2023-10-06 12:36         ` Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 002/101] pwm: ab8500: Make use of " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 003/101] pwm: apple: " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 004/101] pwm: atmel-hlcdc: " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 005/101] pwm: atmel: " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 006/101] pwm: atmel-tcb: " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 007/101] pwm: bcm2835: " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 008/101] pwm: bcm-iproc: " Uwe Kleine-König
2023-08-08 17:17 ` [PATCH v1 009/101] pwm: bcm-kona: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 010/101] pwm: berlin: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 011/101] pwm: brcmstb: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 012/101] pwm: clk: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 013/101] pwm: clps711x: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 014/101] pwm: crc: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 015/101] pwm: cros-ec: Change prototype of helper to prepare further changes Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 016/101] pwm: cros-ec: Make use of devm_pwmchip_alloc() function Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 017/101] pwm: dwc: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 018/101] pwm: ep93xx: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 019/101] pwm: fsl-ftm: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 020/101] pwm: hibvt: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 021/101] pwm: img: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 022/101] pwm: imx1: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 023/101] pwm: imx27: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 024/101] pwm: imx-tpm: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 025/101] pwm: intel-lgm: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 026/101] pwm: iqs620a: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 027/101] pwm: jz4740: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 028/101] pwm: keembay: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 029/101] pwm: lp3943: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 030/101] pwm: lpc18xx-sct: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 031/101] pwm: lpc32xx: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 032/101] pwm: lpss-*: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 033/101] pwm: mediatek: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 034/101] pwm: meson: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 035/101] pwm: microchip-core: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 036/101] pwm: mtk-disp: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 037/101] pwm: mxs: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 038/101] pwm: ntxec: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 039/101] pwm: omap-dmtimer: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 040/101] pwm: pca9685: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 041/101] pwm: pxa: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 042/101] pwm: raspberrypi-poe: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 043/101] pwm: rcar: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 044/101] pwm: renesas-tpu: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 045/101] pwm: rockchip: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 046/101] pwm: rz-mtu3: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 047/101] pwm: samsung: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 048/101] pwm: sifive: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 049/101] pwm: sl28cpld: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 050/101] pwm: spear: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 051/101] pwm: sprd: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 052/101] pwm: sti: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 053/101] pwm: stm32-lp: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 054/101] pwm: stm32: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 055/101] pwm: stmpe: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 056/101] pwm: sun4i: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 057/101] pwm: sunplus: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 058/101] pwm: tegra: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 059/101] pwm: tiecap: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 060/101] pwm: tiehrpwm: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 061/101] pwm: twl-led: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 062/101] pwm: twl: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 063/101] pwm: visconti: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 064/101] pwm: vt8500: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 065/101] pwm: xilinx: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 066/101] gpio: mvebu: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 067/101] drm/bridge: ti-sn65dsi86: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 068/101] leds: qcom-lpg: " Uwe Kleine-König
2023-08-08 17:18 ` [PATCH v1 069/101] staging: greybus: pwm: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 070/101] pwm: Ensure a struct pwm have the same lifetime as its pwm_chip Uwe Kleine-König
2023-10-06  9:38   ` Thierry Reding
2023-10-06 11:04     ` Uwe Kleine-König
2023-10-06 11:16       ` Thierry Reding
2023-10-06 17:04         ` Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 071/101] pwm: ab8500: Store parent device in driver data Uwe Kleine-König
2023-10-06  9:41   ` Thierry Reding
2023-10-06 11:09     ` Uwe Kleine-König
2023-10-06 11:20       ` Thierry Reding
2023-10-06 21:16         ` Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 072/101] pwm: atmel: Stop using struct pwm_chip::dev Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 073/101] pwm: dwc: Store parent device in driver data Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 074/101] pwm: ep93xx: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 075/101] pwm: fsl-ftm: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 076/101] pwm: img: Make use of parent device pointer " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 077/101] pwm: imx27: Store parent device " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 078/101] pwm: jz4740: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 079/101] pwm: lpc18xx-sct: Make use of parent device pointer " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 080/101] pwm: lpss: Store parent device " Uwe Kleine-König
2023-08-08 17:49   ` Andy Shevchenko
2023-08-09  6:10     ` Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 081/101] pwm: mediatek: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 082/101] pwm: meson: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 083/101] pwm: mtk-disp: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 084/101] pwm: omap: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 085/101] pwm: pca9685: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 086/101] pwm: raspberrypi-poe: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 087/101] pwm: rcar: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 088/101] pwm: rz-mtu3: Make use of parent device pointer " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 089/101] pwm: samsung: Store parent device " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 090/101] pwm: sifive: Make use of parent device pointer " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 091/101] pwm: stm32: Store parent device " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 092/101] pwm: stmpe: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 093/101] pwm: sun4i: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 094/101] pwm: tiecap: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 095/101] pwm: tiehrpwm: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 096/101] pwm: twl: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 097/101] pwm: twl-led: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 098/101] pwm: vt8500: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 099/101] staging: greybus: pwm: " Uwe Kleine-König
2023-08-08 17:19 ` [PATCH v1 100/101] pwm: Ensure the memory backing a PWM chip isn't freed while used Uwe Kleine-König
2023-10-06 12:37   ` Thierry Reding
2023-10-06 13:16     ` Uwe Kleine-König
2023-10-06 13:35     ` Andy Shevchenko
2023-08-08 17:19 ` [PATCH v1 101/101] pwm: Add more locking Uwe Kleine-König
2023-10-06 10:09   ` Thierry Reding
2023-10-06 11:14     ` Uwe Kleine-König
2023-09-26 10:06 ` [PATCH v1 000/101] pwm: Fix lifetime issues for pwm_chips Uwe Kleine-König
2023-10-01 11:10   ` Uwe Kleine-König
2023-10-06 10:15     ` Thierry Reding [this message]
2023-10-06 17:05       ` Uwe Kleine-König
2023-10-06  9:20 ` Thierry Reding
2023-10-06 10:41   ` Uwe Kleine-König
2023-10-06 11:50     ` Thierry Reding
2023-10-06 17:35       ` 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=ZR_eW-YsYrLUxPfF@orome.fritz.box \
    --to=thierry.reding@gmail.com \
    --cc=andy@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=kernel@pengutronix.de \
    --cc=linux-pwm@vger.kernel.org \
    --cc=sean@mess.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox