Re: [PATCH linux dev-5.3] soc: aspeed: Fail probe of lpc-ctrl if reserved memory is not aligned
Andrew Jeffery
andrew at aj.id.au
Thu Oct 17 10:36:45 AEDT 2019
On Thu, 17 Oct 2019, at 09:53, Milton Miller II wrote:
> On 10/16/2019 about 06:06PM in some timezone, Andrew Jeffery wrote:
>
> >Alignment is a hardware constraint of the LPC2AHB bridge, and>misaligned
> >reserved memory will present as corrupted data.
> >
> >Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
> >---
> > drivers/soc/aspeed/aspeed-lpc-ctrl.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> >diff --git a/drivers/soc/aspeed/aspeed-lpc-ctrl.c
> >b/drivers/soc/aspeed/aspeed-lpc-ctrl.c
> >index 12e4421dee37..5bad6a33ca43 100644
> >--- a/drivers/soc/aspeed/aspeed-lpc-ctrl.c
> >+++ b/drivers/soc/aspeed/aspeed-lpc-ctrl.c
> >@@ -241,6 +241,18 @@ static int aspeed_lpc_ctrl_probe(struct
> >platform_device *pdev)
> >
> > lpc_ctrl->mem_size = resource_size(&resm);
> > lpc_ctrl->mem_base = resm.start;
> >+
> >+ if (hweight32(lpc_ctrl->mem_size) != 1) {
>
> is_power_of_2 from include/linux/log2.h
Ack.
>
> >+ dev_err(dev, "Reserved memory size must be a power of 2, got>%zu\n",
> >+ lpc_ctrl->mem_size);
> >+ return -EINVAL;
> >+ }
> >+
> >+ if (lpc_ctrl->mem_base & (lpc_ctrl->mem_size - 1)) {
>
> This could be IS_ALIGNED() from kernel.h
Ack.
Thanks,
Andrew
More information about the openbmc
mailing list