[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aXQak2FKyQpdQW2M@smile.fi.intel.com>
Date: Sat, 24 Jan 2026 03:04:19 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>
Subject: Re: [PATCH v1 1/1] mtd: cfi_cmdset_0001: Factor out
do_write_buffer_locked() to reduce stack frame
On Sat, Jan 24, 2026 at 01:52:03AM +0100, Andy Shevchenko wrote:
> Compiler is not happy about used stack frame:
>
> drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer':
> drivers/mtd/chips/cfi_cmdset_0001.c:1887:1: error: the frame size of 1296 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
>
> Fix this by factoring out do_write_buffer_locked().
...
> XIP_INVAL_CACHED_RANGE(map, initial_adr, initial_len);
> ENABLE_VPP(map);
It seems more logical to leave these two in the original call.
...
> +static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
> + unsigned long adr, const struct kvec **pvec,
> + unsigned long *pvec_seek, int len)
> +{
> + struct cfi_private *cfi = map->fldrv_priv;
> + unsigned long cmd_adr;
> + int ret, wbufsize;
> +
> + wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
> + adr += chip->start;
> + cmd_adr = adr & ~(wbufsize - 1);
> +
> + /* Sharp LH28F640BF chips need the first address for the
> + * Page Buffer Program command. See Table 5 of
> + * LH28F320BF, LH28F640BF, LH28F128BF Series (Appendix FUM00701) */
> + if (is_LH28F640BF(cfi))
> + cmd_adr = adr;
> +
> + mutex_lock(&chip->mutex);
> + ret = get_chip(map, chip, cmd_adr, FL_WRITING);
> + if (ret) {
> + mutex_unlock(&chip->mutex);
> + return ret;
> + }
> +
> + ret = do_write_buffer_locked(map, chip, cmd_adr, adr, pvec, pvec_seek, len);
> + DISABLE_VPP(map);
Otherwise this will seem dangling here.
> put_chip(map, chip, cmd_adr);
> mutex_unlock(&chip->mutex);
> return ret;
...
Another approach is to leave goto as is in the _locked() and move DISABLE_VPP()
there.
Tell me what do you prefer?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists