Skip to content

Commit b178c94

Browse files
jluebbegregkh
authored andcommitted
bus: mbus: fix window size calculation for 4GB windows
commit 2bbbd96357ce76cc45ec722c00f654aa7b189112 upstream. At least the Armada XP SoC supports 4GB on a single DRAM window. Because the size register values contain the actual size - 1, the MSB is set in that case. For example, the SDRAM window's control register's value is 0xffffffe1 for 4GB (bits 31 to 24 contain the size). The MBUS driver reads back each window's size from registers and calculates the actual size as (control_reg | ~DDR_SIZE_MASK) + 1, which overflows for 32 bit values, resulting in other miscalculations further on (a bad RAM window for the CESA crypto engine calculated by mvebu_mbus_setup_cpu_target_nooverlap() in my case). This patch changes the type in 'struct mbus_dram_window' from u32 to u64, which allows us to keep using the same register calculation code in most MBUS-using drivers (which calculate ->size - 1 again). Fixes: fddddb5 ("bus: introduce an Marvell EBU MBus driver") Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 260b673 commit b178c94

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/bus/mvebu-mbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus)
720720
if (mbus->hw_io_coherency)
721721
w->mbus_attr |= ATTR_HW_COHERENCY;
722722
w->base = base & DDR_BASE_CS_LOW_MASK;
723-
w->size = (size | ~DDR_SIZE_MASK) + 1;
723+
w->size = (u64)(size | ~DDR_SIZE_MASK) + 1;
724724
}
725725
}
726726
mvebu_mbus_dram_info.num_cs = cs;

include/linux/mbus.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ struct mbus_dram_target_info
2929
struct mbus_dram_window {
3030
u8 cs_index;
3131
u8 mbus_attr;
32-
u32 base;
33-
u32 size;
32+
u64 base;
33+
u64 size;
3434
} cs[4];
3535
};
3636

0 commit comments

Comments
 (0)