All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Samuel Holland <samuel@sholland.org>
Cc: Chen-Yu Tsai <wens@csie.org>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	Andre Przywara <andre.przywara@arm.com>
Subject: Re: [PATCH 3/3] mailbox: sunxi-msgbox: Add a new mailbox driver
Date: Thu, 1 Mar 2018 11:32:59 +0100	[thread overview]
Message-ID: <20180301103259.nomjbwkw4xbvhbfv@flea> (raw)
In-Reply-To: <fdf86770-6f45-3b3c-50ea-7a8363894639@sholland.org>

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

On Wed, Feb 28, 2018 at 11:19:11AM -0600, Samuel Holland wrote:
> Hi,
> 
> On 02/28/18 02:32, Maxime Ripard wrote:
> > On Tue, Feb 27, 2018 at 08:27:14PM -0600, Samuel Holland wrote:
> >> +	/*
> >> +	 * The failure path should not disable the clock or assert the reset,
> >> +	 * because the PSCI implementation in firmware relies on this device
> >> +	 * being functional. Claiming the clock in this driver is required to
> >> +	 * prevent Linux from turning it off.
> >> +	 */
> >> +	ret = clk_prepare_enable(clk);
> >> +	if (ret) {
> >> +		dev_err(dev, "Failed to enable bus clock: %d\n", ret);
> >> +		return ret;
> >> +	}
> > 
> > You don't need it to be always on though. You only need it to be
> > enabled when you access the registers (on both sides I guess?). So you
> > could very well enable the clock in your registers accessors in Linux,
> > and do the same in the ARISC firmware. That should work.
> 
> It does need to always be on because the *PSCI* implementation (ATF) also uses
> SCPI concurrently with Linux (on a separate channel). Turning off the clock
> anywhere in Linux could turn it off in the middle of a PSCI SCPI call on a
> different CPU, causing ATF to hang in EL3 (which would be very bad).

Then the above code doesn't fix anything. You should mark the clock
critical, otherwise that clock will be turned off if the driver is
compiled as a module and not loaded (or loaded later), or if the
driver is not even compiled in.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

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

WARNING: multiple messages have this Message-ID (diff)
From: maxime.ripard@bootlin.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] mailbox: sunxi-msgbox: Add a new mailbox driver
Date: Thu, 1 Mar 2018 11:32:59 +0100	[thread overview]
Message-ID: <20180301103259.nomjbwkw4xbvhbfv@flea> (raw)
In-Reply-To: <fdf86770-6f45-3b3c-50ea-7a8363894639@sholland.org>

On Wed, Feb 28, 2018 at 11:19:11AM -0600, Samuel Holland wrote:
> Hi,
> 
> On 02/28/18 02:32, Maxime Ripard wrote:
> > On Tue, Feb 27, 2018 at 08:27:14PM -0600, Samuel Holland wrote:
> >> +	/*
> >> +	 * The failure path should not disable the clock or assert the reset,
> >> +	 * because the PSCI implementation in firmware relies on this device
> >> +	 * being functional. Claiming the clock in this driver is required to
> >> +	 * prevent Linux from turning it off.
> >> +	 */
> >> +	ret = clk_prepare_enable(clk);
> >> +	if (ret) {
> >> +		dev_err(dev, "Failed to enable bus clock: %d\n", ret);
> >> +		return ret;
> >> +	}
> > 
> > You don't need it to be always on though. You only need it to be
> > enabled when you access the registers (on both sides I guess?). So you
> > could very well enable the clock in your registers accessors in Linux,
> > and do the same in the ARISC firmware. That should work.
> 
> It does need to always be on because the *PSCI* implementation (ATF) also uses
> SCPI concurrently with Linux (on a separate channel). Turning off the clock
> anywhere in Linux could turn it off in the middle of a PSCI SCPI call on a
> different CPU, causing ATF to hang in EL3 (which would be very bad).

Then the above code doesn't fix anything. You should mark the clock
critical, otherwise that clock will be turned off if the driver is
compiled as a module and not loaded (or loaded later), or if the
driver is not even compiled in.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180301/a6441894/attachment.sig>

  reply	other threads:[~2018-03-01 10:33 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28  2:27 [PATCH 0/3] Allwinner sunxi message box support Samuel Holland
2018-02-28  2:27 ` Samuel Holland
2018-02-28  2:27 ` [PATCH 1/3] dt-bindings: Add a binding for the sunxi message box Samuel Holland
2018-02-28  2:27   ` Samuel Holland
2018-02-28  8:28   ` Maxime Ripard
2018-02-28  8:28     ` Maxime Ripard
2018-02-28 17:17     ` Andre Przywara
2018-02-28 17:17       ` Andre Przywara
2018-03-01 10:03       ` Maxime Ripard
2018-03-01 10:03         ` Maxime Ripard
2018-02-28 17:52     ` Samuel Holland
2018-02-28 17:52       ` Samuel Holland
2018-02-28  2:27 ` [PATCH 2/3] mailbox: Avoid NULL dereference in mbox_chan_received_data Samuel Holland
2018-02-28  2:27   ` Samuel Holland
2018-02-28 17:17   ` Andre Przywara
2018-02-28 17:17     ` Andre Przywara
2018-03-01 13:32   ` Jassi Brar
2018-03-01 13:32     ` Jassi Brar
2018-02-28  2:27 ` [PATCH 3/3] mailbox: sunxi-msgbox: Add a new mailbox driver Samuel Holland
2018-02-28  2:27   ` Samuel Holland
2018-02-28  8:32   ` Maxime Ripard
2018-02-28  8:32     ` Maxime Ripard
2018-02-28 17:19     ` Samuel Holland
2018-02-28 17:19       ` Samuel Holland
2018-03-01 10:32       ` Maxime Ripard [this message]
2018-03-01 10:32         ` Maxime Ripard
2018-03-01 11:32         ` Andre Przywara
2018-03-01 11:32           ` Andre Przywara
2018-03-01 11:51           ` Maxime Ripard
2018-03-01 11:51             ` Maxime Ripard
2018-02-28  9:16   ` Jassi Brar
2018-02-28  9:16     ` Jassi Brar
2018-02-28 17:51     ` Samuel Holland
2018-02-28 17:51       ` Samuel Holland
2018-02-28 18:14       ` Jassi Brar
2018-02-28 18:14         ` Jassi Brar
2018-02-28 18:14         ` Jassi Brar
2018-02-28 18:56         ` Samuel Holland
2018-02-28 18:56           ` Samuel Holland
2018-02-28 18:56           ` Samuel Holland
2018-03-01  5:22           ` Jassi Brar
2018-03-01  5:22             ` Jassi Brar
2018-03-01  5:22             ` Jassi Brar
2018-02-28  8:24 ` [PATCH 0/3] Allwinner sunxi message box support Maxime Ripard
2018-02-28  8:24   ` Maxime Ripard
2018-02-28 17:18   ` Samuel Holland
2018-02-28 17:18     ` Samuel Holland
2018-03-01 10:28     ` Maxime Ripard
2018-03-01 10:28       ` Maxime Ripard

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=20180301103259.nomjbwkw4xbvhbfv@flea \
    --to=maxime.ripard@bootlin.com \
    --cc=andre.przywara@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=wens@csie.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.