[RFC PATCH v2 03/13] mmc: mmc_test: Allocate the scratch buffer with the test buffer
From: Eric Curtin
Date: Tue Dec 01 2026 - 22:17:23 EST
From: Eric Curtin <eric.curtin@xxxxxxxxxx>
With arm64 boot-time page size selection PAGE_SIZE is not a
compile-time constant. BUFFER_SIZE is derived from it, so struct
mmc_test_card can no longer embed a scratch[BUFFER_SIZE] array.
Make scratch a pointer into the same allocation as the flexible buffer
member: allocate 2 * BUFFER_SIZE in mtf_test_write() and point scratch
at the second half.
No functional change for compile-time page sizes.
Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
---
drivers/mmc/core/mmc_test.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 4dc16649e61d..686e91b36ab6 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -138,12 +138,12 @@ struct mmc_test_dbgfs_file {
* @highmem: buffer for highmem tests
* @area: information for performance tests
* @gr: pointer to results of current testcase
- * @buffer: transfer buffer
+ * @buffer: transfer buffer, followed by the scratch buffer
*/
struct mmc_test_card {
struct mmc_card *card;
- u8 scratch[BUFFER_SIZE];
+ u8 *scratch;
#ifdef CONFIG_HIGHMEM
struct page *highmem;
#endif
@@ -3088,7 +3088,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
if (ret)
return ret;
- test = kzalloc_flex(*test, buffer, BUFFER_SIZE);
+ test = kzalloc_flex(*test, buffer, 2 * BUFFER_SIZE);
if (!test)
return -ENOMEM;
@@ -3099,6 +3099,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
mmc_test_free_result(card);
test->card = card;
+ test->scratch = test->buffer + BUFFER_SIZE;
#ifdef CONFIG_HIGHMEM
test->highmem = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, BUFFER_ORDER);