Skip to contentSkip to conversation

platform/chrome: cros_ec_proto: remove big stub objects from stack

PATCH Applied Tzung-Bi Shih 3 participants 4 messages Jan 17, 2023 – Jan 18, 2023

Subsystems (2)
lore
Share & tools
lore

Tzung-Bi Shih

author maintainer
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_proto: remove big stub objects from stack

sizeof(struct device) = 680
sizeof(struct cros_ec_dev) = 720

They tend to exceed the stack frame size limit in some specific environment which results in the following compilation error:

Quoted 1 line
Quoted 1 line

drivers/platform/chrome/cros_ec_proto_test.c:2530:13: error: stack

frame size (2128) exceeds limit (2048) in
'cros_ec_proto_test_get_sensor_count_legacy'

Remove the big stub objects from stack.

This is:

$ sed -i 's/struct cros_ec_dev /static struct cros_ec_dev /' \
    drivers/platform/chrome/cros_ec_proto_test.c
---
 drivers/platform/chrome/cros_ec_proto_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/chrome/cros_ec_proto_test.c +5 -5
index 08c58d031593..5b9748e0463b 100644
@@ -2371,7 +2371,7 @@ static void cros_ec_proto_test_get_host_event_normal(struct kunit *test)
 static void cros_ec_proto_test_check_features_cached(struct kunit *test)
 {
 	int ret, i;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec.features.flags[0] = EC_FEATURE_MASK_0(EC_FEATURE_FINGERPRINT);
 	ec.features.flags[1] = EC_FEATURE_MASK_0(EC_FEATURE_SCP);
@@ -2396,7 +2396,7 @@ static void cros_ec_proto_test_check_features_not_cached(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret, i;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec_dev->max_request = 0xff;
 	ec_dev->max_response = 0xee;
@@ -2449,7 +2449,7 @@ static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec_dev->max_request = 0xff;
 	ec_dev->max_response = 0xee;
@@ -2494,7 +2494,7 @@ static void cros_ec_proto_test_get_sensor_count_xfer_error(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec_dev->max_request = 0xff;
 	ec_dev->max_response = 0xee;
@@ -2534,7 +2534,7 @@ static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret, i;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 	struct {
 		u8 readmem_data;
 		int expected_result;
Signature · 1 line
2.39.0.246.g2a6d74b583-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Tzung-Bi Shih

sizeof(struct device) = 680
sizeof(struct cros_ec_dev) = 720

They tend to exceed the stack frame size limit in some specific environment which results in the following compilation error:

Quoted 1 line
Quoted 1 line

drivers/platform/chrome/cros_ec_proto_test.c:2530:13: error: stack

frame size (2128) exceeds limit (2048) in
'cros_ec_proto_test_get_sensor_count_legacy'

Quoted 8 lines

Remove the big stub objects from stack.

This is:

$ sed -i 's/struct cros_ec_dev /static struct cros_ec_dev /' \
    drivers/platform/chrome/cros_ec_proto_test.c
Quoted 53 lines
---
 drivers/platform/chrome/cros_ec_proto_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/chrome/cros_ec_proto_test.c +5 -5
index 08c58d031593..5b9748e0463b 100644
@@ -2371,7 +2371,7 @@ static void cros_ec_proto_test_get_host_event_normal(struct kunit *test)
 static void cros_ec_proto_test_check_features_cached(struct kunit *test)
 {
 	int ret, i;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec.features.flags[0] = EC_FEATURE_MASK_0(EC_FEATURE_FINGERPRINT);
 	ec.features.flags[1] = EC_FEATURE_MASK_0(EC_FEATURE_SCP);
@@ -2396,7 +2396,7 @@ static void cros_ec_proto_test_check_features_not_cached(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret, i;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec_dev->max_request = 0xff;
 	ec_dev->max_response = 0xee;
@@ -2449,7 +2449,7 @@ static void cros_ec_proto_test_get_sensor_count_normal(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec_dev->max_request = 0xff;
 	ec_dev->max_response = 0xee;
@@ -2494,7 +2494,7 @@ static void cros_ec_proto_test_get_sensor_count_xfer_error(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 
 	ec_dev->max_request = 0xff;
 	ec_dev->max_response = 0xee;
@@ -2534,7 +2534,7 @@ static void cros_ec_proto_test_get_sensor_count_legacy(struct kunit *test)
 	struct cros_ec_device *ec_dev = &priv->ec_dev;
 	struct ec_xfer_mock *mock;
 	int ret, i;
-	struct cros_ec_dev ec;
+	static struct cros_ec_dev ec;
 	struct {
 		u8 readmem_data;
 		int expected_result;
#2 lore raw
In reply to Tzung-Bi Shih
This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Quoted 11 lines · On Tue, 17 Jan 2023 16:02:54 +0800 you wrote:

sizeof(struct device) = 680
sizeof(struct cros_ec_dev) = 720

They tend to exceed the stack frame size limit in some specific environment which results in the following compilation error:

Quoted 1 line
Quoted 1 line

drivers/platform/chrome/cros_ec_proto_test.c:2530:13: error: stack

frame size (2128) exceeds limit (2048) in
'cros_ec_proto_test_get_sensor_count_legacy'

[...]

Here is the summary with links:
- platform/chrome: cros_ec_proto: remove big stub objects from stack

    https://git.kernel.org/chrome-platform/c/6514bac4a321

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#3 lore raw
In reply to Tzung-Bi Shih
This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Quoted 11 lines · On Tue, 17 Jan 2023 16:02:54 +0800 you wrote:

sizeof(struct device) = 680
sizeof(struct cros_ec_dev) = 720

They tend to exceed the stack frame size limit in some specific environment which results in the following compilation error:

Quoted 1 line
Quoted 1 line

drivers/platform/chrome/cros_ec_proto_test.c:2530:13: error: stack

frame size (2128) exceeds limit (2048) in
'cros_ec_proto_test_get_sensor_count_legacy'

[...]

Here is the summary with links:
- platform/chrome: cros_ec_proto: remove big stub objects from stack

    https://git.kernel.org/chrome-platform/c/6514bac4a321

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html