mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] ARM: stm32mp: ddrctl: add STM32MP131 RAM size querying support
Date: Tue, 1 Mar 2022 09:49:39 +0100	[thread overview]
Message-ID: <20220301084939.GR19585@pengutronix.de> (raw)
In-Reply-To: <20220223113846.3022227-1-a.fatoum@pengutronix.de>

On Wed, Feb 23, 2022 at 12:38:47PM +0100, Ahmad Fatoum wrote:
> buswidth is read from HW. With nb_bytes == 2, there is a possibility
> that we get a zero size out here, if driver and device are
> mismatched, e.g. because barebox is booted in FIP with mismatched
> external device tree.
> 
> As this runs very early before relocation, round up instead of crashing
> to be a bit more on the safe side.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  arch/arm/mach-stm32mp/ddrctrl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
> index 7f0944d7e77c..ed211cf58ebc 100644
> --- a/arch/arm/mach-stm32mp/ddrctrl.c
> +++ b/arch/arm/mach-stm32mp/ddrctrl.c
> @@ -101,7 +101,8 @@ static unsigned long ddrctrl_addrmap_ramsize(struct stm32mp1_ddrctl __iomem *d,
>  	if (LINE_UNUSED(reg, ADDRMAP6_ROW_B13)) rows--;
>  	if (LINE_UNUSED(reg, ADDRMAP6_ROW_B12)) rows--;
>  
> -	return memory_sdram_size(cols, rows, BIT(banks), nb_bytes / BIT(buswidth));
> +	return memory_sdram_size(cols, rows, BIT(banks),
> +				 DIV_ROUND_UP(nb_bytes, BIT(buswidth)));
>  }
>  
>  static inline unsigned ddrctrl_ramsize(void __iomem *base, unsigned nb_bytes)
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2022-03-01  8:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 11:38 Ahmad Fatoum
2022-03-01  8:49 ` Sascha Hauer [this message]

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=20220301084939.GR19585@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox