diff options
Diffstat (limited to 'drivers/bus')
-rw-r--r-- | drivers/bus/mvebu-mbus.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 293e2e0a0a87..afee0f731111 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/of.h> | 56 | #include <linux/of.h> |
57 | #include <linux/of_address.h> | 57 | #include <linux/of_address.h> |
58 | #include <linux/debugfs.h> | 58 | #include <linux/debugfs.h> |
59 | #include <linux/log2.h> | ||
59 | 60 | ||
60 | /* | 61 | /* |
61 | * DDR target is the same on all platforms. | 62 | * DDR target is the same on all platforms. |
@@ -266,6 +267,17 @@ static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus, | |||
266 | mbus->soc->win_cfg_offset(win); | 267 | mbus->soc->win_cfg_offset(win); |
267 | u32 ctrl, remap_addr; | 268 | u32 ctrl, remap_addr; |
268 | 269 | ||
270 | if (!is_power_of_2(size)) { | ||
271 | WARN(true, "Invalid MBus window size: 0x%zx\n", size); | ||
272 | return -EINVAL; | ||
273 | } | ||
274 | |||
275 | if ((base & (phys_addr_t)(size - 1)) != 0) { | ||
276 | WARN(true, "Invalid MBus base/size: %pa len 0x%zx\n", &base, | ||
277 | size); | ||
278 | return -EINVAL; | ||
279 | } | ||
280 | |||
269 | ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) | | 281 | ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) | |
270 | (attr << WIN_CTRL_ATTR_SHIFT) | | 282 | (attr << WIN_CTRL_ATTR_SHIFT) | |
271 | (target << WIN_CTRL_TGT_SHIFT) | | 283 | (target << WIN_CTRL_TGT_SHIFT) | |
@@ -413,6 +425,10 @@ static int mvebu_devs_debug_show(struct seq_file *seq, void *v) | |||
413 | win, (unsigned long long)wbase, | 425 | win, (unsigned long long)wbase, |
414 | (unsigned long long)(wbase + wsize), wtarget, wattr); | 426 | (unsigned long long)(wbase + wsize), wtarget, wattr); |
415 | 427 | ||
428 | if (!is_power_of_2(wsize) || | ||
429 | ((wbase & (u64)(wsize - 1)) != 0)) | ||
430 | seq_puts(seq, " (Invalid base/size!!)"); | ||
431 | |||
416 | if (win < mbus->soc->num_remappable_wins) { | 432 | if (win < mbus->soc->num_remappable_wins) { |
417 | seq_printf(seq, " (remap %016llx)\n", | 433 | seq_printf(seq, " (remap %016llx)\n", |
418 | (unsigned long long)wremap); | 434 | (unsigned long long)wremap); |