Skip to content

Commit 88e43ac

Browse files
committed
patches: Apply fix for -Wframe-larger-than in vdec_vp9_req_lat_if.c
As there has been no movement on the upstream report [1], apply Arnd's workaround, which I have requested to be applied [2]. Link: llvm/llvm-project#111903 [1] Link: https://lore.kernel.org/20241118200641.GA768549@thelio-3990X/ [2] Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 4f1b5e8 commit 88e43ac

12 files changed

+306
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] media: mediatek: vcodec: mark
3+
vdec_vp9_slice_map_counts_eob_coef noinline
4+
From: Arnd Bergmann <[email protected]>
5+
Date: Fri, 18 Oct 2024 15:14:42 +0000
6+
Message-Id: <[email protected]>
7+
MIME-Version: 1.0
8+
Content-Type: text/plain; charset="utf-8"
9+
Content-Transfer-Encoding: 7bit
10+
11+
With KASAN enabled, clang fails to optimize the inline version of
12+
vdec_vp9_slice_map_counts_eob_coef() properly, leading to kilobytes
13+
of temporary values spilled to the stack:
14+
15+
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c:1526:12: error: stack frame size (2160) exceeds limit (2048) in 'vdec_vp9_slice_update_prob' [-Werror,-Wframe-larger-than]
16+
17+
This seems to affect all versions of clang including the latest (clang-20),
18+
but the degree of stack overhead is different per release.
19+
20+
Marking the function as noinline_for_stack is harmless here and avoids
21+
the problem completely.
22+
23+
Signed-off-by: Arnd Bergmann <[email protected]>
24+
Reviewed-by: Nathan Chancellor <[email protected]>
25+
Link: https://lore.kernel.org/r/[email protected]
26+
---
27+
I have not come to a conclusion on how exactly clang fails to do this
28+
right, but can provide the .config and/or preprocessed source files
29+
and command line if we think this should be fixed in clang.
30+
---
31+
.../mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 3 ++-
32+
1 file changed, 2 insertions(+), 1 deletion(-)
33+
34+
diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
35+
index eea709d93820..47c302745c1d 100644
36+
--- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
37+
+++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
38+
@@ -1188,7 +1188,8 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
39+
return ret;
40+
}
41+
42+
-static
43+
+/* clang stack usage explodes if this is inlined */
44+
+static noinline_for_stack
45+
void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,
46+
struct vdec_vp9_slice_frame_counts *counts,
47+
struct v4l2_vp9_frame_symbol_counts *counts_helper)
48+
--
49+
2.39.5
50+

patches/6.1/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20241018_arnd_media_mediatek_vcodec_mark_vdec_vp9_slice_map_counts_eob_coef_noinline.patch
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] media: mediatek: vcodec: mark
3+
vdec_vp9_slice_map_counts_eob_coef noinline
4+
From: Arnd Bergmann <[email protected]>
5+
Date: Fri, 18 Oct 2024 15:14:42 +0000
6+
Message-Id: <[email protected]>
7+
MIME-Version: 1.0
8+
Content-Type: text/plain; charset="utf-8"
9+
Content-Transfer-Encoding: 7bit
10+
11+
With KASAN enabled, clang fails to optimize the inline version of
12+
vdec_vp9_slice_map_counts_eob_coef() properly, leading to kilobytes
13+
of temporary values spilled to the stack:
14+
15+
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c:1526:12: error: stack frame size (2160) exceeds limit (2048) in 'vdec_vp9_slice_update_prob' [-Werror,-Wframe-larger-than]
16+
17+
This seems to affect all versions of clang including the latest (clang-20),
18+
but the degree of stack overhead is different per release.
19+
20+
Marking the function as noinline_for_stack is harmless here and avoids
21+
the problem completely.
22+
23+
Signed-off-by: Arnd Bergmann <[email protected]>
24+
Reviewed-by: Nathan Chancellor <[email protected]>
25+
Link: https://lore.kernel.org/r/[email protected]
26+
---
27+
I have not come to a conclusion on how exactly clang fails to do this
28+
right, but can provide the .config and/or preprocessed source files
29+
and command line if we think this should be fixed in clang.
30+
---
31+
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 3 ++-
32+
1 file changed, 2 insertions(+), 1 deletion(-)
33+
34+
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
35+
index eea709d93820..47c302745c1d 100644
36+
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
37+
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
38+
@@ -1188,7 +1188,8 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
39+
return ret;
40+
}
41+
42+
-static
43+
+/* clang stack usage explodes if this is inlined */
44+
+static noinline_for_stack
45+
void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,
46+
struct vdec_vp9_slice_frame_counts *counts,
47+
struct v4l2_vp9_frame_symbol_counts *counts_helper)
48+
--
49+
2.39.5
50+

patches/6.6/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20241018_arnd_media_mediatek_vcodec_mark_vdec_vp9_slice_map_counts_eob_coef_noinline.patch
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] media: mediatek: vcodec: mark
3+
vdec_vp9_slice_map_counts_eob_coef noinline
4+
From: Arnd Bergmann <[email protected]>
5+
Date: Fri, 18 Oct 2024 15:14:42 +0000
6+
Message-Id: <[email protected]>
7+
MIME-Version: 1.0
8+
Content-Type: text/plain; charset="utf-8"
9+
Content-Transfer-Encoding: 7bit
10+
11+
With KASAN enabled, clang fails to optimize the inline version of
12+
vdec_vp9_slice_map_counts_eob_coef() properly, leading to kilobytes
13+
of temporary values spilled to the stack:
14+
15+
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c:1526:12: error: stack frame size (2160) exceeds limit (2048) in 'vdec_vp9_slice_update_prob' [-Werror,-Wframe-larger-than]
16+
17+
This seems to affect all versions of clang including the latest (clang-20),
18+
but the degree of stack overhead is different per release.
19+
20+
Marking the function as noinline_for_stack is harmless here and avoids
21+
the problem completely.
22+
23+
Signed-off-by: Arnd Bergmann <[email protected]>
24+
Reviewed-by: Nathan Chancellor <[email protected]>
25+
Link: https://lore.kernel.org/r/[email protected]
26+
---
27+
I have not come to a conclusion on how exactly clang fails to do this
28+
right, but can provide the .config and/or preprocessed source files
29+
and command line if we think this should be fixed in clang.
30+
---
31+
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 3 ++-
32+
1 file changed, 2 insertions(+), 1 deletion(-)
33+
34+
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
35+
index eea709d93820..47c302745c1d 100644
36+
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
37+
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
38+
@@ -1188,7 +1188,8 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
39+
return ret;
40+
}
41+
42+
-static
43+
+/* clang stack usage explodes if this is inlined */
44+
+static noinline_for_stack
45+
void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,
46+
struct vdec_vp9_slice_frame_counts *counts,
47+
struct v4l2_vp9_frame_symbol_counts *counts_helper)
48+
--
49+
2.39.5
50+

patches/arm64-fixes/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
506a1ac4c4464a61e4336e135841067dbc040aaa.patch
2+
20241018_arnd_media_mediatek_vcodec_mark_vdec_vp9_slice_map_counts_eob_coef_noinline.patch
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] media: mediatek: vcodec: mark
3+
vdec_vp9_slice_map_counts_eob_coef noinline
4+
From: Arnd Bergmann <[email protected]>
5+
Date: Fri, 18 Oct 2024 15:14:42 +0000
6+
Message-Id: <[email protected]>
7+
MIME-Version: 1.0
8+
Content-Type: text/plain; charset="utf-8"
9+
Content-Transfer-Encoding: 7bit
10+
11+
With KASAN enabled, clang fails to optimize the inline version of
12+
vdec_vp9_slice_map_counts_eob_coef() properly, leading to kilobytes
13+
of temporary values spilled to the stack:
14+
15+
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c:1526:12: error: stack frame size (2160) exceeds limit (2048) in 'vdec_vp9_slice_update_prob' [-Werror,-Wframe-larger-than]
16+
17+
This seems to affect all versions of clang including the latest (clang-20),
18+
but the degree of stack overhead is different per release.
19+
20+
Marking the function as noinline_for_stack is harmless here and avoids
21+
the problem completely.
22+
23+
Signed-off-by: Arnd Bergmann <[email protected]>
24+
Reviewed-by: Nathan Chancellor <[email protected]>
25+
Link: https://lore.kernel.org/r/[email protected]
26+
---
27+
I have not come to a conclusion on how exactly clang fails to do this
28+
right, but can provide the .config and/or preprocessed source files
29+
and command line if we think this should be fixed in clang.
30+
---
31+
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 3 ++-
32+
1 file changed, 2 insertions(+), 1 deletion(-)
33+
34+
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
35+
index eea709d93820..47c302745c1d 100644
36+
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
37+
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
38+
@@ -1188,7 +1188,8 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
39+
return ret;
40+
}
41+
42+
-static
43+
+/* clang stack usage explodes if this is inlined */
44+
+static noinline_for_stack
45+
void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,
46+
struct vdec_vp9_slice_frame_counts *counts,
47+
struct v4l2_vp9_frame_symbol_counts *counts_helper)
48+
--
49+
2.39.5
50+

patches/arm64/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
506a1ac4c4464a61e4336e135841067dbc040aaa.patch
2+
20241018_arnd_media_mediatek_vcodec_mark_vdec_vp9_slice_map_counts_eob_coef_noinline.patch
23
afa9b48f327c9ef36bfba4c643a29385a633252b.patch
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] media: mediatek: vcodec: mark
3+
vdec_vp9_slice_map_counts_eob_coef noinline
4+
From: Arnd Bergmann <[email protected]>
5+
Date: Fri, 18 Oct 2024 15:14:42 +0000
6+
Message-Id: <[email protected]>
7+
MIME-Version: 1.0
8+
Content-Type: text/plain; charset="utf-8"
9+
Content-Transfer-Encoding: 7bit
10+
11+
With KASAN enabled, clang fails to optimize the inline version of
12+
vdec_vp9_slice_map_counts_eob_coef() properly, leading to kilobytes
13+
of temporary values spilled to the stack:
14+
15+
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c:1526:12: error: stack frame size (2160) exceeds limit (2048) in 'vdec_vp9_slice_update_prob' [-Werror,-Wframe-larger-than]
16+
17+
This seems to affect all versions of clang including the latest (clang-20),
18+
but the degree of stack overhead is different per release.
19+
20+
Marking the function as noinline_for_stack is harmless here and avoids
21+
the problem completely.
22+
23+
Signed-off-by: Arnd Bergmann <[email protected]>
24+
Reviewed-by: Nathan Chancellor <[email protected]>
25+
Link: https://lore.kernel.org/r/[email protected]
26+
---
27+
I have not come to a conclusion on how exactly clang fails to do this
28+
right, but can provide the .config and/or preprocessed source files
29+
and command line if we think this should be fixed in clang.
30+
---
31+
.../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 3 ++-
32+
1 file changed, 2 insertions(+), 1 deletion(-)
33+
34+
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
35+
index eea709d93820..47c302745c1d 100644
36+
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
37+
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
38+
@@ -1188,7 +1188,8 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
39+
return ret;
40+
}
41+
42+
-static
43+
+/* clang stack usage explodes if this is inlined */
44+
+static noinline_for_stack
45+
void vdec_vp9_slice_map_counts_eob_coef(unsigned int i, unsigned int j, unsigned int k,
46+
struct vdec_vp9_slice_frame_counts *counts,
47+
struct v4l2_vp9_frame_symbol_counts *counts_helper)
48+
--
49+
2.39.5
50+

patches/mainline/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
20240819_nathan_hexagon_disable_constant_extender_optimization_for_llvm_prior_to_19_1_0.patch
2+
20241018_arnd_media_mediatek_vcodec_mark_vdec_vp9_slice_map_counts_eob_coef_noinline.patch

0 commit comments

Comments
 (0)