Skip to contentSkip to conversation

EDAC, sb_edac: Remove VLA usage

PATCH Superseded Gustavo A. R. Silva 2 participants 3 messages Mar 13, 2018

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 EDAC, sb_edac: Remove VLA usage

In preparation to enabling -Wvla, remove VLA and replace it with a fixed-length array instead.

Fixed as part of the directive to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621

---
Changes in v2:
- Use macro max_t to compute the max of all three array sizes. This change is based on Borislav's feedback.

 drivers/edac/sb_edac.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/edac/sb_edac.c +5 -1
index 8721002..196b012 100644
@@ -110,6 +110,10 @@ static const u32 knl_interleave_list[] = {
 	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
 	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
 };
+#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),\
+			max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list),\
+					    ARRAY_SIZE(knl_interleave_list))))
+
 
 struct interleave_pkg {
 	unsigned char start;
@@ -1899,7 +1903,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
 	int			n_rir, n_sads, n_tads, sad_way, sck_xch;
 	int			sad_interl, idx, base_ch;
 	int			interleave_mode, shiftup = 0;
-	unsigned		sad_interleave[pvt->info.max_interleave];
+	unsigned int		sad_interleave[MAX_INTERLEAVE];
 	u32			reg, dram_rule;
 	u8			ch_way, sck_way, pkg, sad_ha = 0;
 	u32			tad_offset;
Reviewed-by on v2 1/1
#1 lore raw

Em Tue, 13 Mar 2018 06:20:34 -0500
"Gustavo A. R. Silva" <[email protected]> escreveu:

Quoted 20 lines

In preparation to enabling -Wvla, remove VLA and replace it with a fixed-length array instead.

Fixed as part of the directive to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621

---
Changes in v2:
- Use macro max_t to compute the max of all three array sizes. This change is based on Borislav's feedback.

 drivers/edac/sb_edac.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/edac/sb_edac.c +0 -0
index 8721002..196b012 100644

drivers/edac/sb_edac.c static const u32 knl_interleave_list[] = { · line 116

Quoted 7 lines
drivers/edac/sb_edac.c +4 -0
@@ -110,6 +110,10 @@ static const u32 knl_interleave_list[] = {
 	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
 	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
 };
+#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),\
+			max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list),\
+					    ARRAY_SIZE(knl_interleave_list))))
+

In order to avoid too long lines, it would be better to do it as:

#define MAX_INTERLEAVE						        \
	(max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),       \
	       max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list), \
		     ARRAY_SIZE(knl_interleave_list))))

With that:

drivers/edac/sb_edac.c static int get_memory_error_data(struct mem_ctl_info *mci, · line 1909

Quoted 12 lines
drivers/edac/sb_edac.c +1 -1
 struct interleave_pkg {
 	unsigned char start;
@@ -1899,7 +1903,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
 	int			n_rir, n_sads, n_tads, sad_way, sck_xch;
 	int			sad_interl, idx, base_ch;
 	int			interleave_mode, shiftup = 0;
-	unsigned		sad_interleave[pvt->info.max_interleave];
+	unsigned int		sad_interleave[MAX_INTERLEAVE];
 	u32			reg, dram_rule;
 	u8			ch_way, sck_way, pkg, sad_ha = 0;
 	u32			tad_offset;

Thanks,
Mauro
---
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 33 lines · Mauro Carvalho Chehab

Em Tue, 13 Mar 2018 06:20:34 -0500
"Gustavo A. R. Silva" <[email protected]> escreveu:

Quoted 20 lines

In preparation to enabling -Wvla, remove VLA and replace it with a fixed-length array instead.

Fixed as part of the directive to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621

---
Changes in v2:
- Use macro max_t to compute the max of all three array sizes. This change is based on Borislav's feedback.

  drivers/edac/sb_edac.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/edac/sb_edac.c +0 -0
index 8721002..196b012 100644

drivers/edac/sb_edac.c static const u32 knl_interleave_list[] = { · line 116

Quoted 7 lines
drivers/edac/sb_edac.c +4 -0
@@ -110,6 +110,10 @@ static const u32 knl_interleave_list[] = {
  	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
  	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
  };
+#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),\
+			max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list),\
+					    ARRAY_SIZE(knl_interleave_list))))
+

In order to avoid too long lines, it would be better to do it as:

Quoted 5 lines
#define MAX_INTERLEAVE						        \
	(max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),       \
	       max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list), \
		     ARRAY_SIZE(knl_interleave_list))))

Yep. I agree.

Quoted 5 lines

With that:

I'll send v3 and add your Reviewed-by.

Thanks, Mauro.
---
Gustavo
--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html