Skip to contentSkip to conversation

EDAC, sb_edac: Remove VLA usage

PATCH In review Gustavo A. R. Silva 2 participants 5 messages Mar 10, 2018 – Mar 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 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

---

Notice that due to this change, the field max_interleave is no longer used after it has been initialized. Maybe it should be removed?

Thanks
--
Gustavo

---
 drivers/edac/sb_edac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/edac/sb_edac.c +2 -1
index 8721002..11cb2c9 100644
@@ -110,6 +110,7 @@ static const u32 knl_interleave_list[] = {
 	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
 	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
 };
+#define MAX_INTERLEAVE	ARRAY_SIZE(knl_interleave_list)
 
 struct interleave_pkg {
 	unsigned char start;
@@ -1899,7 +1900,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;
maintainer
#1 lore raw
Quoted 11 lines · Gustavo A. R. Silva

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

---

Notice that due to this change, the field max_interleave is no longer used after it has been initialized. Maybe it should be removed?

Yes.

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

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

define that as the max of all interleave lists array sizes so that people can update it properly when new interleave lists get added.

#2 lore raw

Hi Borislav,

Quoted 7 lines · Borislav Petkov
Quoted 6 lines · Gustavo A. R. Silva

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

Quoted 8 lines
Quoted 5 lines

---

Notice that due to this change, the field max_interleave is no longer used after it has been initialized. Maybe it should be removed?

Yes.

I'll remove it then.

Quoted 9 lines

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

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

define that as the max of all interleave lists array sizes so that people can update it properly when new interleave lists get added.

Do you mean just adding a code comment?

Thanks for the feedback.
---
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

maintainer
#3 lore raw
Quoted 1 line · Gustavo A. R. Silva

Do you mean just adding a code comment?

No, I mean

#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(knl_interleave_list), ...

which computes the max of all three array sizes.

Thx.

#4 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 1 line · Gustavo A. R. Silva

Do you mean just adding a code comment?

No, I mean

#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(knl_interleave_list), ...

which computes the max of all three array sizes.

Thx.

I got it.

Exactly this:

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

ARRAY_SIZE(sbridge_interleave_list))))

I'll send v2 shortly.

Thanks!
---
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