public inbox for barebox@lists.infradead.org
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: Re: [PATCH 04/10] arm: socfpga: iossm: store size in bytes
Date: Wed, 8 Apr 2026 09:12:32 +0200	[thread overview]
Message-ID: <adX_4NMJOObMDzq1@pengutronix.de> (raw)
In-Reply-To: <11c7cdd4-9bf4-4325-a408-87421d5d0db2@pengutronix.de>

On Tue, 07 Apr 2026 19:43:19 +0200, Ahmad Fatoum wrote:
> On 4/7/26 7:09 PM, Michael Tretter wrote:
> > The mem_width_info is the memory size in gigabits. Convert it to bytes
> > before storing it for each bank to have a more convenient format and
> > simplify the conversion when reading the value.
> > 
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> > ---
> >  arch/arm/mach-socfpga/agilex5-sdram.c |  7 +++----
> >  arch/arm/mach-socfpga/iossm_mailbox.c | 13 +++++++++----
> >  arch/arm/mach-socfpga/iossm_mailbox.h |  5 +++--
> >  3 files changed, 15 insertions(+), 10 deletions(-)
> > 
> > diff --git a/arch/arm/mach-socfpga/agilex5-sdram.c b/arch/arm/mach-socfpga/agilex5-sdram.c
> > index 96b2b425315f..5fb59d413e8f 100644
> > --- a/arch/arm/mach-socfpga/agilex5-sdram.c
> > +++ b/arch/arm/mach-socfpga/agilex5-sdram.c
> > @@ -299,10 +299,6 @@ int agilex5_ddr_init_full(void)
> >  		return ret;
> >  	}
> >  
> > -	hw_size = (phys_size_t)io96b_ctrl.overall_size * SZ_1G / SZ_8;
> > -
> > -	pr_debug("%s: %lld MiB\n", io96b_ctrl.ddr_type, hw_size >> 20);
> > -
> >  	ret = io96b_ecc_enable_status(&io96b_ctrl);
> >  	if (ret) {
> >  		pr_debug("DDR: Failed to get DDR ECC status\n");
> > @@ -326,6 +322,9 @@ int agilex5_ddr_init_full(void)
> >  		pr_debug("SDRAM-ECC: Initialized success\n");
> >  	}
> >  
> > +	hw_size = io96b_ctrl.overall_size;
> > +	pr_debug("%s: %lld MiB\n", io96b_ctrl.ddr_type, hw_size / SZ_1M);
> > +
> >  	sdram_set_firewall(hw_size);
> >  
> >  	/* Firewall setting for MPFE CSR */
> > diff --git a/arch/arm/mach-socfpga/iossm_mailbox.c b/arch/arm/mach-socfpga/iossm_mailbox.c
> > index 9299fee71e0b..042ea4a99e5c 100644
> > --- a/arch/arm/mach-socfpga/iossm_mailbox.c
> > +++ b/arch/arm/mach-socfpga/iossm_mailbox.c
> > @@ -9,6 +9,7 @@
> >  #include <common.h>
> >  #include <io.h>
> >  #include <linux/bitfield.h>
> > +#include <linux/sizes.h>
> >  #include "iossm_mailbox.h"
> >  #include <mach/socfpga/generic.h>
> >  #include <mach/socfpga/soc64-regs.h>
> > @@ -404,21 +405,25 @@ int io96b_get_mem_width_info(struct io96b_info *io96b_ctrl)
> >  	struct io96b_mb_resp usr_resp;
> >  	struct io96b_mb_ctrl *mb_ctrl;
> >  	int i, j;
> > -	u16 memory_size;
> > -	u16 total_memory_size = 0;
> > +	phys_size_t memory_size;
> > +	u32 mem_width_info;
> > +	phys_size_t total_memory_size = 0;
> >  
> >  	/* Get all memory interface(s) total memory size on all instance(s) */
> >  	for (i = 0; i < io96b_ctrl->num_instance; i++) {
> >  		mb_ctrl = &io96b_ctrl->io96b[i].mb_ctrl;
> >  		memory_size = 0;
> > +
> >  		for (j = 0; j < mb_ctrl->num_mem_interface; j++) {
> >  			io96b_mb_req_no_param(io96b_ctrl->io96b[i].io96b_csr_addr,
> >  					      mb_ctrl->ip_type[j],
> >  					      mb_ctrl->ip_instance_id[j],
> >  					      CMD_GET_MEM_INFO, GET_MEM_WIDTH_INFO, &usr_resp);
> > +			mem_width_info = usr_resp.cmd_resp_data[1] & GENMASK(7, 0);
> >  
> > -			memory_size = memory_size +
> > -				(usr_resp.cmd_resp_data[1] & GENMASK(7, 0));
> > +			mb_ctrl->memory_size[j] = mem_width_info * (SZ_1G / SZ_8);
> > +
> > +			memory_size += mb_ctrl->memory_size[j];
> >  		}
> >  
> >  		if (!memory_size) {
> > diff --git a/arch/arm/mach-socfpga/iossm_mailbox.h b/arch/arm/mach-socfpga/iossm_mailbox.h
> > index bd66621d5f70..1b1bb1c7a19a 100644
> > --- a/arch/arm/mach-socfpga/iossm_mailbox.h
> > +++ b/arch/arm/mach-socfpga/iossm_mailbox.h
> > @@ -79,6 +79,7 @@ struct io96b_mb_ctrl {
> >  	u32 num_mem_interface;
> >  	u32 ip_type[2];
> >  	u32 ip_instance_id[2];
> > +	u32 memory_size[2];
> 
> This overflows for >= SZ_8G memory. That looks odd.

That should have been phys_size_t like the other uses, too. Thanks! I'll
send a v2.

Michael

> 
> Thanks,
> Ahmad
> 
> >  };
> >  
> >  /*
> > @@ -101,7 +102,7 @@ struct io96b_mb_resp {
> >   * @mb_ctrl:		IOSSM mailbox required information
> >   */
> >  struct io96b_instance {
> > -	u16 size;
> > +	phys_size_t size;
> >  	phys_addr_t io96b_csr_addr;
> >  	bool cal_status;
> >  	struct io96b_mb_ctrl mb_ctrl;
> > @@ -126,7 +127,7 @@ struct io96b_info {
> >  	bool			 overall_cal_status;
> >  	const char		*ddr_type;
> >  	bool			 ecc_status;
> > -	u16			 overall_size;
> > +	phys_size_t		 overall_size;
> >  	struct io96b_instance	 io96b[MAX_IO96B_SUPPORTED];
> >  	bool			 ckgen_lock;
> >  	u8			 num_port;
> > 



  reply	other threads:[~2026-04-08  7:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 17:09 [PATCH 00/10] arm: socfpga: iossm: add support for mailbox v1 Michael Tretter
2026-04-07 17:09 ` [PATCH 01/10] arm: socfpga: iossm: remove uninitialized variable Michael Tretter
2026-04-07 17:09 ` [PATCH 02/10] arm: socfpga: iossm: add version check Michael Tretter
2026-04-07 17:09 ` [PATCH 03/10] arm: socfpga: iossm: use local mb_ctrl variable Michael Tretter
2026-04-07 17:09 ` [PATCH 04/10] arm: socfpga: iossm: store size in bytes Michael Tretter
2026-04-07 17:43   ` Ahmad Fatoum
2026-04-08  7:12     ` Michael Tretter [this message]
2026-04-07 17:09 ` [PATCH 05/10] arm: socfpga: iossm: refactor io96b_mb_init Michael Tretter
2026-04-07 17:10 ` [PATCH 06/10] arm: socfpga: iossm: refactor return value handling Michael Tretter
2026-04-07 17:10 ` [PATCH 07/10] arm: socfgpa: iossm: extract poll_bist_mem_init_status Michael Tretter
2026-04-07 17:10 ` [PATCH 08/10] arm: socfgpa: iossm: extract initialization of one interface Michael Tretter
2026-04-07 17:10 ` [PATCH 09/10] arm: socfpga: iossm: add memory initialization with inline ecc Michael Tretter
2026-04-07 17:10 ` [PATCH 10/10] arm: socfpga: iossm: add support for mailbox v1 Michael Tretter

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=adX_4NMJOObMDzq1@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.trumtrar@pengutronix.de \
    /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