Skip to contentSkip to conversation

socfpga: stratix10: fix sdram_calculate_size

PATCH Superseded Dalon Westergreen 3 participants 6 messages Sep 10, 2018 – Sep 11, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 socfpga: stratix10: fix sdram_calculate_size

Incorrect type of size variable results in 0 being returned for sdram sizes greater than or equal to 4GB.

---
 drivers/ddr/altera/sdram_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/altera/sdram_s10.c +1 -1
index 48f4f47b14..dad0147b64 100644
@@ -375,7 +375,7 @@ unsigned long sdram_calculate_size(void)
 {
 	u32 dramaddrw = hmc_readl(DRAMADDRW);
 
-	u32 size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+	unsigned long  size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 socfpga: stratix10: fix sdram_calculate_size

Quoted 15 lines · Dalon Westergreen

Incorrect type of size variable results in 0 being returned for sdram sizes greater than or equal to 4GB.

---
 drivers/ddr/altera/sdram_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/altera/sdram_s10.c +0 -0
index 48f4f47b14..dad0147b64 100644

drivers/ddr/altera/sdram_s10.c unsigned long sdram_calculate_size(void) · line 381

Quoted 8 lines
drivers/ddr/altera/sdram_s10.c +1 -1
@@ -375,7 +375,7 @@ unsigned long sdram_calculate_size(void)
 {
 	u32 dramaddrw = hmc_readl(DRAMADDRW);
 
-	u32 size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+	unsigned long  size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +

Change the function to report size in MiB, prescale it here and you won't have problems for a while . How does that sound ?

Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 socfpga: stratix10: fix sdram_calculate_size

Quoted 17 lines · Marek Vasut

On 09/10/2018 10:41 PM, Dalon Westergreen wrote:
Incorrect type of size variable results in 0 beingreturned for sdram sizes greater than or equal to4GB.

drivers/ddr/altera/sdram_s10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

(quoted diff) +0 -0

b/drivers/ddr/altera/sdram_s10.cindex 48f4f47b14..dad0147b64 100644--- a/drivers/ddr/altera/sdram_s10.c+++ b/drivers/ddr/altera/sdram_s10.c@@ -375,7
+375,7 @@ unsigned long sdram_calculate_size(void) { u32 dramaddrw =
hmc_readl(DRAMADDRW); - u32 size = 1 <<
(DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) ++ unsigned long size = 1 <<
(DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) + DRAMADDRW_CFG_B
ANK_GRP_ADDR_WIDTH(dramaddrw) + DRAMADDRW_CFG_BANK_ADDR
_WIDTH(dramaddrw) + DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw)
+

Quoted 2 lines

Change the function to report size in MiB, prescale it here and youwon't have problems for a while . How does that sound ?

Prefer not to as this will be used for comparisons later which would mean we would need to scale #defines from linux/sizes.h.
--dalon

#3 lore raw

PATCH 1/1 socfpga: stratix10: fix sdram_calculate_size

Quoted 26 lines · Dalon L Westergreen
Quoted 25 lines · Marek Vasut

On 09/10/2018 10:41 PM, Dalon Westergreen wrote:
Incorrect type of size variable results in 0 being returned for sdram sizes greater than or equal to 4GB.

Signed-off-by Dalon Westergreen <dwesterg at gmail.com <mailto:[email protected]>>
---
 drivers/ddr/altera/sdram_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/altera/sdram_s10.c +1 -1
index 48f4f47b14..dad0147b64 100644
@@ -375,7 +375,7 @@ unsigned long sdram_calculate_size(void)
 {
 	u32 dramaddrw = hmc_readl(DRAMADDRW);
 
-	u32 size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+	unsigned long  size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
Quoted 5 lines
Quoted 2 lines

Change the function to report size in MiB, prescale it here and you won't have problems for a while . How does that sound ?

Prefer not to as this will be used for comparisons later which would mean we would need to scale #defines from linux/sizes.h.

What comparisons ? I only see it assigned to gd->sdram_size , in which case it might rather make sense to adjust the type of the function to unsigned long long (so it returns u64).

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 socfpga: stratix10: fix sdram_calculate_size

Quoted 19 lines · Marek Vasut

On 09/11/2018 03:28 PM, Dalon L Westergreen wrote:
On Tue, 2018-09-11 at 11:31 +0200, Marek Vasut wrote:
On 09/10/2018 10:41 PM, Dalon Westergreen wrote:Incorrect type of size variable results in 0 beingreturned for sdram sizes greater than or equal to4GB.

dwesterg at gmail.com>>--- drivers/ddr/altera/sdram_s10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

(quoted diff) +0 -0

b/drivers/ddr/altera/sdram_s10.cindex 48f4f47b14..dad0147b64 100644--- a/drivers/ddr/altera/sdram_s10.c+++ b/drivers/ddr/altera/sdram_s10.c@@ -375,7
+375,7 @@ unsigned long sdram_calculate_size(void) { u32 dramaddrw =
hmc_readl(DRAMADDRW); - u32 size = 1 <<
(DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) ++ unsigned long size = 1 <<
(DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) + DRAMADDRW_CFG_B
ANK_GRP_ADDR_WIDTH(dramaddrw) + DRAMADDRW_CFG_BANK_ADDR
_WIDTH(dramaddrw) + DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw)
+

Quoted 7 lines

Change the function to report size in MiB, prescale it here and youwon't have problems for a while . How does that sound ?
Prefer not to as this will be used for comparisons later which wouldmean we would need to scale #defines from linux/sizes.h.
What comparisons ? I only see it assigned to gd->sdram_size , in whichcase it might rather make sense to adjust the type of the function tounsigned long long (so it returns u64).

Yes, i think the function should be phys_size_t type, i will adjust it. There are no comparisons as ofyet, but there likely will be a need to do so to deal with some corner cases.
--dalon

#5 lore raw

PATCH 1/1 socfpga: stratix10: fix sdram_calculate_size

Quoted 34 lines · Dalon L Westergreen
Quoted 33 lines · Marek Vasut

On 09/11/2018 03:28 PM, Dalon L Westergreen wrote:
On Tue, 2018-09-11 at 11:31 +0200, Marek Vasut wrote:
On 09/10/2018 10:41 PM, Dalon Westergreen wrote:
Incorrect type of size variable results in 0 being returned for sdram sizes greater than or equal to 4GB.

Signed-off-by Dalon Westergreen <dwesterg at gmail.com <mailto:[email protected]> <mailto:dwesterg at gmail.com <mailto:[email protected]>>>
---
 drivers/ddr/altera/sdram_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/altera/sdram_s10.c +1 -1
index 48f4f47b14..dad0147b64 100644
@@ -375,7 +375,7 @@ unsigned long sdram_calculate_size(void)
 {
 	u32 dramaddrw = hmc_readl(DRAMADDRW);
 
-	u32 size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+	unsigned long  size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
 			 DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +

Change the function to report size in MiB, prescale it here and you won't have problems for a while . How does that sound ?

Prefer not to as this will be used for comparisons later which would mean we would need to scale #defines from linux/sizes.h.

Quoted 8 lines
Quoted 3 lines

What comparisons ? I only see it assigned to gd->sdram_size , in which case it might rather make sense to adjust the type of the function to unsigned long long (so it returns u64).

Yes, i think the function should be phys_size_t type, i will adjust it. There are no comparisons as of
yet, but there likely will be a need to do so to deal with some corner cases.

OK, sounds good , thanks !

Signature · 2 lines
Best regards,
Marek Vasut