Commit be185c29 authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Dan Williams

cxl/core: Remove cxld_const_init in cxl_decoder_alloc()

Commit 48667f67 ("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: 48667f67 ("cxl/core: Split decoder setup into alloc + add")
Link: https://github.com/ClangBuiltLinux/linux/issues/1539Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211210213627.2477370-1-nathan@kernel.orgSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 53989fad
...@@ -485,9 +485,7 @@ static int decoder_populate_targets(struct cxl_decoder *cxld, ...@@ -485,9 +485,7 @@ static int decoder_populate_targets(struct cxl_decoder *cxld,
struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets) struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets)
{ {
struct cxl_decoder *cxld, cxld_const_init = { struct cxl_decoder *cxld;
.nr_targets = nr_targets,
};
struct device *dev; struct device *dev;
int rc = 0; int rc = 0;
...@@ -497,13 +495,13 @@ struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets) ...@@ -497,13 +495,13 @@ struct cxl_decoder *cxl_decoder_alloc(struct cxl_port *port, int nr_targets)
cxld = kzalloc(struct_size(cxld, target, nr_targets), GFP_KERNEL); cxld = kzalloc(struct_size(cxld, target, nr_targets), GFP_KERNEL);
if (!cxld) if (!cxld)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
memcpy(cxld, &cxld_const_init, sizeof(cxld_const_init));
rc = ida_alloc(&port->decoder_ida, GFP_KERNEL); rc = ida_alloc(&port->decoder_ida, GFP_KERNEL);
if (rc < 0) if (rc < 0)
goto err; goto err;
cxld->id = rc; cxld->id = rc;
cxld->nr_targets = nr_targets;
dev = &cxld->dev; dev = &cxld->dev;
device_initialize(dev); device_initialize(dev);
device_set_pm_not_required(dev); device_set_pm_not_required(dev);
......
...@@ -191,7 +191,7 @@ struct cxl_decoder { ...@@ -191,7 +191,7 @@ struct cxl_decoder {
int interleave_granularity; int interleave_granularity;
enum cxl_decoder_type target_type; enum cxl_decoder_type target_type;
unsigned long flags; unsigned long flags;
const int nr_targets; int nr_targets;
struct cxl_dport *target[]; struct cxl_dport *target[];
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment