Commit f7110b75 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

hinic: reduce rss_init stack usage

On 32-bit architectures, putting an array of 256 u32 values on the
stack uses more space than the warning limit:

drivers/net/ethernet/huawei/hinic/hinic_main.c: In function 'hinic_rss_init':
drivers/net/ethernet/huawei/hinic/hinic_main.c:286:1: error: the frame size of 1068 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

I considered changing the code to use u8 values here, since that's
all the hardware supports, but dynamically allocating the array is
a more isolated fix here.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8792e82d
...@@ -256,37 +256,43 @@ static int hinic_configure_max_qnum(struct hinic_dev *nic_dev) ...@@ -256,37 +256,43 @@ static int hinic_configure_max_qnum(struct hinic_dev *nic_dev)
static int hinic_rss_init(struct hinic_dev *nic_dev) static int hinic_rss_init(struct hinic_dev *nic_dev)
{ {
u32 indir_tbl[HINIC_RSS_INDIR_SIZE] = { 0 };
u8 default_rss_key[HINIC_RSS_KEY_SIZE]; u8 default_rss_key[HINIC_RSS_KEY_SIZE];
u8 tmpl_idx = nic_dev->rss_tmpl_idx; u8 tmpl_idx = nic_dev->rss_tmpl_idx;
u32 *indir_tbl;
int err, i; int err, i;
indir_tbl = kcalloc(HINIC_RSS_INDIR_SIZE, sizeof(u32), GFP_KERNEL);
if (!indir_tbl)
return -ENOMEM;
netdev_rss_key_fill(default_rss_key, sizeof(default_rss_key)); netdev_rss_key_fill(default_rss_key, sizeof(default_rss_key));
for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++)
indir_tbl[i] = ethtool_rxfh_indir_default(i, nic_dev->num_rss); indir_tbl[i] = ethtool_rxfh_indir_default(i, nic_dev->num_rss);
err = hinic_rss_set_template_tbl(nic_dev, tmpl_idx, default_rss_key); err = hinic_rss_set_template_tbl(nic_dev, tmpl_idx, default_rss_key);
if (err) if (err)
return err; goto out;
err = hinic_rss_set_indir_tbl(nic_dev, tmpl_idx, indir_tbl); err = hinic_rss_set_indir_tbl(nic_dev, tmpl_idx, indir_tbl);
if (err) if (err)
return err; goto out;
err = hinic_set_rss_type(nic_dev, tmpl_idx, nic_dev->rss_type); err = hinic_set_rss_type(nic_dev, tmpl_idx, nic_dev->rss_type);
if (err) if (err)
return err; goto out;
err = hinic_rss_set_hash_engine(nic_dev, tmpl_idx, err = hinic_rss_set_hash_engine(nic_dev, tmpl_idx,
nic_dev->rss_hash_engine); nic_dev->rss_hash_engine);
if (err) if (err)
return err; goto out;
err = hinic_rss_cfg(nic_dev, 1, tmpl_idx); err = hinic_rss_cfg(nic_dev, 1, tmpl_idx);
if (err) if (err)
return err; goto out;
return 0; out:
kfree(indir_tbl);
return err;
} }
static void hinic_rss_deinit(struct hinic_dev *nic_dev) static void hinic_rss_deinit(struct hinic_dev *nic_dev)
......
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