diff mbox

[RFC] bus: mvebu-mbus: do not set WIN_CTRL_SYNCBARRIER on non io-coherent platforms.

Message ID 1429886671-14415-1-git-send-email-nschichan@freebox.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Nicolas Schichan April 24, 2015, 2:44 p.m. UTC
On those platforms (orion5x, kirkwood and dove AFAICS) the
WIN_CTRL_SYNCBARRIER bit in the window control register is either
reserved (all windows except 6 and 7) or enables read-only protection
(windows 6 and 7).

Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
---

Hello Thomas,

Please find here my attempt at fixing this. I have been relying on the
hw_io_coherency field of the struct mvebu_mbus_state which is always
false for the platforms without the WIN_CTRL_SYNCBARRIER bit available
(orion5x, kirkwood, and dove).

I was going to add a field to mvebu_soc_data documenting the
availability of the WIN_CTRL_SYNCBARRIER bit for each platform but for
that purpose, the mvebu_mbus_state struct hw_io_coherency field looks
to be enough.

This has been tested on mv88f6282 (kirkwood).

Regards,

 drivers/bus/mvebu-mbus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Thomas Petazzoni April 24, 2015, 2:54 p.m. UTC | #1
Dear Nicolas Schichan,

On Fri, 24 Apr 2015 16:44:31 +0200, Nicolas Schichan wrote:
> On those platforms (orion5x, kirkwood and dove AFAICS) the
> WIN_CTRL_SYNCBARRIER bit in the window control register is either
> reserved (all windows except 6 and 7) or enables read-only protection
> (windows 6 and 7).
> 
> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
> ---
> 
> Hello Thomas,
> 
> Please find here my attempt at fixing this. I have been relying on the
> hw_io_coherency field of the struct mvebu_mbus_state which is always
> false for the platforms without the WIN_CTRL_SYNCBARRIER bit available
> (orion5x, kirkwood, and dove).
> 
> I was going to add a field to mvebu_soc_data documenting the
> availability of the WIN_CTRL_SYNCBARRIER bit for each platform but for
> that purpose, the mvebu_mbus_state struct hw_io_coherency field looks
> to be enough.
> 
> This has been tested on mv88f6282 (kirkwood).

Thanks, it looks good to me. Can you resend with:

Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: <stable@vger.kernel.org> # v4.0+
Fixes: a0b5cd4ac2d6 ("bus: mvebu-mbus: use automatic I/O synchronization barriers")

An addition to the commit log like:

Commit a0b5cd4ac2d6 ("bus: mvebu-mbus: use automatic I/O
synchronization barriers") enabled the usage of automatic I/O
synchronization barriers by enabling bit WIN_CTRL_SYNCBARRIER in the
control registers of MBus windows, but....

And in the code, maybe add a comment above the WIN_CTRL_SYNCBARRIER
definition like:

/* Only on HW I/O coherency capable platforms */
#define WIN_CTRL_SYNCBARRIER ...

Thanks a lot!

Thomas
diff mbox

Patch

diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index fb9ec62..019a033 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -323,8 +323,9 @@  static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus,
 	ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) |
 		(attr << WIN_CTRL_ATTR_SHIFT)    |
 		(target << WIN_CTRL_TGT_SHIFT)   |
-		WIN_CTRL_SYNCBARRIER             |
 		WIN_CTRL_ENABLE;
+	if (mbus->hw_io_coherency)
+		ctrl |= WIN_CTRL_SYNCBARRIER;
 
 	writel(base & WIN_BASE_LOW, addr + WIN_BASE_OFF);
 	writel(ctrl, addr + WIN_CTRL_OFF);