Skip to content

Commit be185c2

Browse files
nathanchancedjbw
authored andcommitted
cxl/core: Remove cxld_const_init in cxl_decoder_alloc()
Commit 48667f6 ("cxl/core: Split decoder setup into alloc + add") aimed to fix a large stack frame warning but from v5 to v6, it introduced a new instance of the warning due to allocating cxld_const_init on the stack, which was done due to the use of const on the nr_target member of the cxl_decoder struct. With ARCH=arm allmodconfig minus CONFIG_KASAN: GCC 11.2.0: drivers/cxl/core/bus.c: In function ‘cxl_decoder_alloc’: drivers/cxl/core/bus.c:523:1: error: the frame size of 1032 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] 523 | } | ^ cc1: all warnings being treated as errors Clang 12.0.1: drivers/cxl/core/bus.c:486:21: error: stack frame size of 1056 bytes in function 'cxl_decoder_alloc' [-Werror,-Wframe-larger-than=] struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets) ^ 1 error generated. Revert that part of the change, which makes the stack frame of cxl_decoder_alloc() much more reasonable. Fixes: 48667f6 ("cxl/core: Split decoder setup into alloc + add") Link: ClangBuiltLinux#1539 Signed-off-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 53989fa commit be185c2

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

drivers/cxl/core/bus.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,7 @@ static int decoder_populate_targets(struct cxl_decoder *cxld,
485485

486486
struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets)
487487
{
488-
struct cxl_decoder *cxld, cxld_const_init = {
489-
.nr_targets = nr_targets,
490-
};
488+
struct cxl_decoder *cxld;
491489
struct device *dev;
492490
int rc = 0;
493491

@@ -497,13 +495,13 @@ struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets)
497495
cxld = kzalloc(struct_size(cxld, target, nr_targets), GFP_KERNEL);
498496
if (!cxld)
499497
return ERR_PTR(-ENOMEM);
500-
memcpy(cxld, &cxld_const_init, sizeof(cxld_const_init));
501498

502499
rc = ida_alloc(&port->decoder_ida, GFP_KERNEL);
503500
if (rc < 0)
504501
goto err;
505502

506503
cxld->id = rc;
504+
cxld->nr_targets = nr_targets;
507505
dev = &cxld->dev;
508506
device_initialize(dev);
509507
device_set_pm_not_required(dev);

drivers/cxl/cxl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct cxl_decoder {
191191
int interleave_granularity;
192192
enum cxl_decoder_type target_type;
193193
unsigned long flags;
194-
const int nr_targets;
194+
int nr_targets;
195195
struct cxl_dport *target[];
196196
};
197197

0 commit comments

Comments
 (0)