devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: f.fainelli@gmail.com, linux@roeck-us.net, jdelvare@suse.com,
	wahrenst@gmx.net, Eric Anholt <eric@anholt.net>,
	bcm-kernel-feedback-list@broadcom.com,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-pwm@vger.kernel.org,
	Thierry Reding <thierry.reding@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	linux-hwmon@vger.kernel.org, robh+dt@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] pwm: Add Raspberry Pi Firmware based PWM bus
Date: Tue, 13 Oct 2020 14:17:58 +0200	[thread overview]
Message-ID: <20201013121758.gl6ni4b47ei2bhdf@pengutronix.de> (raw)
In-Reply-To: <7899e490543723c97ffad6f42942907f8db6b9b4.camel@suse.de>

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

Hello Nicolas,

On Tue, Oct 13, 2020 at 01:20:00PM +0200, Nicolas Saenz Julienne wrote:
> On Mon, 2020-10-12 at 09:06 +0200, Uwe Kleine-König wrote:
> > > +	depends on RASPBERRYPI_FIRMWARE || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
> > 
> > This is more complicated than necessary.
> > 
> > 	depends on RASPBERRYPI_FIRMWARE || COMPILE_TEST
> > 
> > is logically equivalent.
> 
> It's not exactly the same, see patch 7ed915059c300 ("gpio: raspberrypi-ext: fix
> firmware dependency ") which explains why this pattern is needed.

Hmm, this is strange, but if Arnd doesn't know a better solution, then
be it so. Is this idiom usual enough to not justify a comment?

> > What happens if duty_cycle happens to be bigger than RPI_PWM_MAX_DUTY?
> > 
> > I think the right thing to do here is:
> > 
> > 	if (state->period < RPI_PWM_PERIOD_NS ||
> 
> Why not using state->period != RPI_PWM_PERIOD_NS here?

From the consumer's point of view having to hit the only correct period
is hard. So the usual convention is to provide the biggest period not
bigger than the requested one. (The idea for the future is to provide a
pwm_round_state() function which allows to find out the effect of
pwm_apply_state() with the same arguments. This then allows to
efficiently find the best setting for the consumer.)

> > Huh, why do you have to do this twice, just with different error
> > messages? I assume you want to set RPI_PWM_DEF_DUTY_REG? What is the
> > effect of writing this property?
> 
> Obviously, I failed to change the register name.
> 
> This is supposed to set the default duty cycle after resetting the board. I
> added it so as to keep compatibility with the downstream version of this.
> 
> I'll add a comment to explain this.

fine.

> > > +	int ret;
> > > +
> > > +	firmware_node = of_get_parent(dev->of_node);
> > > +	if (!firmware_node) {
> > > +		dev_err(dev, "Missing firmware node\n");
> > > +		return -ENOENT;
> > > +	}
> > > +
> > > +	firmware = rpi_firmware_get(firmware_node);
> > > +	of_node_put(firmware_node);
> > > +	if (!firmware)
> > > +		return -EPROBE_DEFER;
> > 
> > I don't see a mechanism that prevents the driver providing the firmware
> > going away while the PWM is still in use.
> 
> There isn't an explicit one. But since you depend on a symbol from the firmware
> driver you won't be able to remove the kernel module before removing the PMW
> one.

this prevents the that the module is unloaded, but not that the driver
is unbound.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

  reply	other threads:[~2020-10-13 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 15:30 [PATCH 0/3] Raspberry Pi 4 PoE HAT fan support Nicolas Saenz Julienne
2020-10-09 15:30 ` [PATCH 1/3] dt-bindings: pwm: Add binding for RPi firmware PWM bus Nicolas Saenz Julienne
2020-10-12  7:01   ` Uwe Kleine-König
2020-10-13 10:35     ` Nicolas Saenz Julienne
2020-10-13 12:08       ` Uwe Kleine-König
2020-10-13 12:33         ` Nicolas Saenz Julienne
2020-10-13 15:18           ` Uwe Kleine-König
2020-10-09 15:30 ` [PATCH 2/3] DO NOT MERGE: ARM: dts: Add RPi's official PoE hat support Nicolas Saenz Julienne
2020-10-09 15:30 ` [PATCH 3/3] pwm: Add Raspberry Pi Firmware based PWM bus Nicolas Saenz Julienne
2020-10-12  7:06   ` Uwe Kleine-König
2020-10-13 11:20     ` Nicolas Saenz Julienne
2020-10-13 12:17       ` Uwe Kleine-König [this message]
2020-10-13 16:50         ` Nicolas Saenz Julienne
2020-10-14  7:02           ` 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=20201013121758.gl6ni4b47ei2bhdf@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux@roeck-us.net \
    --cc=nsaenzjulienne@suse.de \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=wahrenst@gmx.net \
    /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;
as well as URLs for NNTP newsgroup(s).