public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
@ 2026-01-24 13:35 Andy Shevchenko
  2026-01-24 22:41 ` kernel test robot
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2026-01-24 13:35 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

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().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: left ENABLE_VPP() and XIP_INVAL_CACHED_RANGE() where they were originally

 drivers/mtd/chips/cfi_cmdset_0001.c | 82 +++++++++++++++++------------
 1 file changed, 48 insertions(+), 34 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index c10693ba265b..c495bee04053 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1720,42 +1720,24 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
 }
 
 
-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)
+static int __xipram do_write_buffer_locked(struct map_info *map, struct flchip *chip,
+					   unsigned long cmd_adr, unsigned long adr,
+					   const struct kvec **pvec,
+					   unsigned long *pvec_seek, int len)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
 	map_word status, write_cmd, datum;
-	unsigned long cmd_adr;
-	int ret, wbufsize, word_gap, words;
+	int ret, word_gap, words;
 	const struct kvec *vec;
 	unsigned long vec_seek;
 	unsigned long initial_adr;
 	int initial_len = len;
 
-	wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
-	adr += chip->start;
 	initial_adr = adr;
-	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;
 
 	/* Let's determine this according to the interleave only once */
 	write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9);
 
-	mutex_lock(&chip->mutex);
-	ret = get_chip(map, chip, cmd_adr, FL_WRITING);
-	if (ret) {
-		mutex_unlock(&chip->mutex);
-		return ret;
-	}
-
-	XIP_INVAL_CACHED_RANGE(map, initial_adr, initial_len);
-	ENABLE_VPP(map);
 	xip_disable(map, chip, cmd_adr);
 
 	/* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set
@@ -1789,7 +1771,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 		xip_enable(map, chip, cmd_adr);
 		printk(KERN_ERR "%s: Chip not ready for buffer write. Xstatus = %lx, status = %lx\n",
 				map->name, Xstatus.x[0], status.x[0]);
-		goto out;
+		return ret;
 	}
 
 	/* Figure out the number of words to write */
@@ -1853,7 +1835,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 		chip->state = FL_STATUS;
 		xip_enable(map, chip, cmd_adr);
 		printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name);
-		goto out;
+		return ret;
 	}
 
 	/* check for errors */
@@ -1866,21 +1848,53 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 		map_write(map, CMD(0x70), cmd_adr);
 		xip_enable(map, chip, cmd_adr);
 
-		if (chipstatus & 0x02) {
-			ret = -EROFS;
-		} else if (chipstatus & 0x08) {
+		if (chipstatus & 0x02)
+			return -EROFS;
+
+		if (chipstatus & 0x08) {
 			printk(KERN_ERR "%s: buffer write error (bad VPP)\n", map->name);
-			ret = -EIO;
-		} else {
-			printk(KERN_ERR "%s: buffer write error (status 0x%lx)\n", map->name, chipstatus);
-			ret = -EINVAL;
+			return  -EIO;
 		}
 
-		goto out;
+		printk(KERN_ERR "%s: buffer write error (status 0x%lx)\n", map->name, chipstatus);
+		return -EINVAL;
 	}
 
 	xip_enable(map, chip, cmd_adr);
- out:	DISABLE_VPP(map);
+	return 0;
+}
+
+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;
+	}
+
+	XIP_INVAL_CACHED_RANGE(map, adr, len);
+	ENABLE_VPP(map);
+
+	ret = do_write_buffer_locked(map, chip, cmd_adr, adr, pvec, pvec_seek, len);
+
+	DISABLE_VPP(map);
 	put_chip(map, chip, cmd_adr);
 	mutex_unlock(&chip->mutex);
 	return ret;
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-01-24 13:35 Andy Shevchenko
@ 2026-01-24 22:41 ` kernel test robot
  2026-02-10 10:05   ` Vignesh Raghavendra
  0 siblings, 1 reply; 11+ messages in thread
From: kernel test robot @ 2026-01-24 22:41 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mtd, linux-kernel
  Cc: oe-kbuild-all, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra

Hi Andy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mtd/mtd/next]
[also build test WARNING on mtd/mtd/fixes linus/master v6.19-rc6 next-20260123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/mtd-cfi_cmdset_0001-Factor-out-do_write_buffer_locked-to-reduce-stack-frame/20260124-213936
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
patch link:    https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
config: xtensa-randconfig-002-20260125 (https://download.01.org/0day-ci/archive/20260125/202601250653.LXBUL5W6-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260125/202601250653.LXBUL5W6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601250653.LXBUL5W6-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer_locked':
>> drivers/mtd/chips/cfi_cmdset_0001.c:1734:6: warning: unused variable 'initial_len' [-Wunused-variable]
     int initial_len = len;
         ^~~~~~~~~~~
>> drivers/mtd/chips/cfi_cmdset_0001.c:1733:16: warning: variable 'initial_adr' set but not used [-Wunused-but-set-variable]
     unsigned long initial_adr;
                   ^~~~~~~~~~~


vim +/initial_len +1734 drivers/mtd/chips/cfi_cmdset_0001.c

^1da177e4c3f415 Linus Torvalds   2005-04-16  1721  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1722  
b8a0764c058e872 Andy Shevchenko  2026-01-24  1723  static int __xipram do_write_buffer_locked(struct map_info *map, struct flchip *chip,
b8a0764c058e872 Andy Shevchenko  2026-01-24  1724  					   unsigned long cmd_adr, unsigned long adr,
b8a0764c058e872 Andy Shevchenko  2026-01-24  1725  					   const struct kvec **pvec,
e102d54abf6806b Nicolas Pitre    2005-08-06  1726  					   unsigned long *pvec_seek, int len)
^1da177e4c3f415 Linus Torvalds   2005-04-16  1727  {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1728  	struct cfi_private *cfi = map->fldrv_priv;
c172471b78255a5 Nicolas Pitre    2006-03-30  1729  	map_word status, write_cmd, datum;
b8a0764c058e872 Andy Shevchenko  2026-01-24  1730  	int ret, word_gap, words;
e102d54abf6806b Nicolas Pitre    2005-08-06  1731  	const struct kvec *vec;
e102d54abf6806b Nicolas Pitre    2005-08-06  1732  	unsigned long vec_seek;
646fd12784d5061 Massimo Cirillo  2008-01-11 @1733  	unsigned long initial_adr;
646fd12784d5061 Massimo Cirillo  2008-01-11 @1734  	int initial_len = len;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1735  
646fd12784d5061 Massimo Cirillo  2008-01-11  1736  	initial_adr = adr;
812c5fa82bae9f3 Andrea Adami     2014-06-02  1737  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1738  	/* Let's determine this according to the interleave only once */
b5d194ceaeffce6 Guillaume LECERF 2010-10-26  1739  	write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1740  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1741  	xip_disable(map, chip, cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1742  
151e76590f66f54 David Woodhouse  2006-05-14  1743  	/* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set
^1da177e4c3f415 Linus Torvalds   2005-04-16  1744  	   [...], the device will not accept any more Write to Buffer commands".
^1da177e4c3f415 Linus Torvalds   2005-04-16  1745  	   So we must check here and reset those bits if they're set. Otherwise
^1da177e4c3f415 Linus Torvalds   2005-04-16  1746  	   we're just pissing in the wind */
6e7a6809c555aeb Nicolas Pitre    2006-03-29  1747  	if (chip->state != FL_STATUS) {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1748  		map_write(map, CMD(0x70), cmd_adr);
6e7a6809c555aeb Nicolas Pitre    2006-03-29  1749  		chip->state = FL_STATUS;
6e7a6809c555aeb Nicolas Pitre    2006-03-29  1750  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1751  	status = map_read(map, cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1752  	if (map_word_bitsset(map, status, CMD(0x30))) {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1753  		xip_enable(map, chip, cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1754  		printk(KERN_WARNING "SR.4 or SR.5 bits set in buffer write (status %lx). Clearing.\n", status.x[0]);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1755  		xip_disable(map, chip, cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1756  		map_write(map, CMD(0x50), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1757  		map_write(map, CMD(0x70), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1758  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1759  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1760  	chip->state = FL_WRITING_TO_BUFFER;
638d983840bb64e Nicolas Pitre    2005-08-06  1761  	map_write(map, write_cmd, cmd_adr);
e93cafe45fd7493 Anders Grafström 2008-08-05  1762  	ret = WAIT_TIMEOUT(map, chip, cmd_adr, 0, 0);
c172471b78255a5 Nicolas Pitre    2006-03-30  1763  	if (ret) {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1764  		/* Argh. Not ready for write to buffer */
c172471b78255a5 Nicolas Pitre    2006-03-30  1765  		map_word Xstatus = map_read(map, cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1766  		map_write(map, CMD(0x70), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1767  		chip->state = FL_STATUS;
c172471b78255a5 Nicolas Pitre    2006-03-30  1768  		status = map_read(map, cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1769  		map_write(map, CMD(0x50), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1770  		map_write(map, CMD(0x70), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1771  		xip_enable(map, chip, cmd_adr);
c172471b78255a5 Nicolas Pitre    2006-03-30  1772  		printk(KERN_ERR "%s: Chip not ready for buffer write. Xstatus = %lx, status = %lx\n",
c172471b78255a5 Nicolas Pitre    2006-03-30  1773  				map->name, Xstatus.x[0], status.x[0]);
b8a0764c058e872 Andy Shevchenko  2026-01-24  1774  		return ret;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1775  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1776  
e102d54abf6806b Nicolas Pitre    2005-08-06  1777  	/* Figure out the number of words to write */
e102d54abf6806b Nicolas Pitre    2005-08-06  1778  	word_gap = (-adr & (map_bankwidth(map)-1));
c8872b069c53697 Julia Lawall     2008-08-02  1779  	words = DIV_ROUND_UP(len - word_gap, map_bankwidth(map));
e102d54abf6806b Nicolas Pitre    2005-08-06  1780  	if (!word_gap) {
e102d54abf6806b Nicolas Pitre    2005-08-06  1781  		words--;
e102d54abf6806b Nicolas Pitre    2005-08-06  1782  	} else {
e102d54abf6806b Nicolas Pitre    2005-08-06  1783  		word_gap = map_bankwidth(map) - word_gap;
e102d54abf6806b Nicolas Pitre    2005-08-06  1784  		adr -= word_gap;
e102d54abf6806b Nicolas Pitre    2005-08-06  1785  		datum = map_word_ff(map);
e102d54abf6806b Nicolas Pitre    2005-08-06  1786  	}
e102d54abf6806b Nicolas Pitre    2005-08-06  1787  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1788  	/* Write length of data to come */
e102d54abf6806b Nicolas Pitre    2005-08-06  1789  	map_write(map, CMD(words), cmd_adr );
^1da177e4c3f415 Linus Torvalds   2005-04-16  1790  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1791  	/* Write data */
e102d54abf6806b Nicolas Pitre    2005-08-06  1792  	vec = *pvec;
e102d54abf6806b Nicolas Pitre    2005-08-06  1793  	vec_seek = *pvec_seek;
e102d54abf6806b Nicolas Pitre    2005-08-06  1794  	do {
e102d54abf6806b Nicolas Pitre    2005-08-06  1795  		int n = map_bankwidth(map) - word_gap;
e102d54abf6806b Nicolas Pitre    2005-08-06  1796  		if (n > vec->iov_len - vec_seek)
e102d54abf6806b Nicolas Pitre    2005-08-06  1797  			n = vec->iov_len - vec_seek;
e102d54abf6806b Nicolas Pitre    2005-08-06  1798  		if (n > len)
e102d54abf6806b Nicolas Pitre    2005-08-06  1799  			n = len;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1800  
e102d54abf6806b Nicolas Pitre    2005-08-06  1801  		if (!word_gap && len < map_bankwidth(map))
e102d54abf6806b Nicolas Pitre    2005-08-06  1802  			datum = map_word_ff(map);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1803  
e102d54abf6806b Nicolas Pitre    2005-08-06  1804  		datum = map_word_load_partial(map, datum,
e102d54abf6806b Nicolas Pitre    2005-08-06  1805  					      vec->iov_base + vec_seek,
e102d54abf6806b Nicolas Pitre    2005-08-06  1806  					      word_gap, n);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1807  
e102d54abf6806b Nicolas Pitre    2005-08-06  1808  		len -= n;
e102d54abf6806b Nicolas Pitre    2005-08-06  1809  		word_gap += n;
e102d54abf6806b Nicolas Pitre    2005-08-06  1810  		if (!len || word_gap == map_bankwidth(map)) {
e102d54abf6806b Nicolas Pitre    2005-08-06  1811  			map_write(map, datum, adr);
e102d54abf6806b Nicolas Pitre    2005-08-06  1812  			adr += map_bankwidth(map);
e102d54abf6806b Nicolas Pitre    2005-08-06  1813  			word_gap = 0;
e102d54abf6806b Nicolas Pitre    2005-08-06  1814  		}
e102d54abf6806b Nicolas Pitre    2005-08-06  1815  
e102d54abf6806b Nicolas Pitre    2005-08-06  1816  		vec_seek += n;
e102d54abf6806b Nicolas Pitre    2005-08-06  1817  		if (vec_seek == vec->iov_len) {
e102d54abf6806b Nicolas Pitre    2005-08-06  1818  			vec++;
e102d54abf6806b Nicolas Pitre    2005-08-06  1819  			vec_seek = 0;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1820  		}
e102d54abf6806b Nicolas Pitre    2005-08-06  1821  	} while (len);
e102d54abf6806b Nicolas Pitre    2005-08-06  1822  	*pvec = vec;
e102d54abf6806b Nicolas Pitre    2005-08-06  1823  	*pvec_seek = vec_seek;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1824  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1825  	/* GO GO GO */
^1da177e4c3f415 Linus Torvalds   2005-04-16  1826  	map_write(map, CMD(0xd0), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1827  	chip->state = FL_WRITING;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1828  
c172471b78255a5 Nicolas Pitre    2006-03-30  1829  	ret = INVAL_CACHE_AND_WAIT(map, chip, cmd_adr,
646fd12784d5061 Massimo Cirillo  2008-01-11  1830  				   initial_adr, initial_len,
e93cafe45fd7493 Anders Grafström 2008-08-05  1831  				   chip->buffer_write_time,
e93cafe45fd7493 Anders Grafström 2008-08-05  1832  				   chip->buffer_write_time_max);
c172471b78255a5 Nicolas Pitre    2006-03-30  1833  	if (ret) {
4843653cab0db03 Nicolas Pitre    2005-08-06  1834  		map_write(map, CMD(0x70), cmd_adr);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1835  		chip->state = FL_STATUS;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1836  		xip_enable(map, chip, cmd_adr);
4843653cab0db03 Nicolas Pitre    2005-08-06  1837  		printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name);
b8a0764c058e872 Andy Shevchenko  2026-01-24  1838  		return ret;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1839  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1840  
4843653cab0db03 Nicolas Pitre    2005-08-06  1841  	/* check for errors */
c172471b78255a5 Nicolas Pitre    2006-03-30  1842  	status = map_read(map, cmd_adr);
4843653cab0db03 Nicolas Pitre    2005-08-06  1843  	if (map_word_bitsset(map, status, CMD(0x1a))) {
4843653cab0db03 Nicolas Pitre    2005-08-06  1844  		unsigned long chipstatus = MERGESTATUS(status);
4843653cab0db03 Nicolas Pitre    2005-08-06  1845  
4843653cab0db03 Nicolas Pitre    2005-08-06  1846  		/* reset status */
^1da177e4c3f415 Linus Torvalds   2005-04-16  1847  		map_write(map, CMD(0x50), cmd_adr);
4843653cab0db03 Nicolas Pitre    2005-08-06  1848  		map_write(map, CMD(0x70), cmd_adr);
4843653cab0db03 Nicolas Pitre    2005-08-06  1849  		xip_enable(map, chip, cmd_adr);
4843653cab0db03 Nicolas Pitre    2005-08-06  1850  
b8a0764c058e872 Andy Shevchenko  2026-01-24  1851  		if (chipstatus & 0x02)
b8a0764c058e872 Andy Shevchenko  2026-01-24  1852  			return -EROFS;
b8a0764c058e872 Andy Shevchenko  2026-01-24  1853  
b8a0764c058e872 Andy Shevchenko  2026-01-24  1854  		if (chipstatus & 0x08) {
4843653cab0db03 Nicolas Pitre    2005-08-06  1855  			printk(KERN_ERR "%s: buffer write error (bad VPP)\n", map->name);
b8a0764c058e872 Andy Shevchenko  2026-01-24  1856  			return  -EIO;
4843653cab0db03 Nicolas Pitre    2005-08-06  1857  		}
4843653cab0db03 Nicolas Pitre    2005-08-06  1858  
b8a0764c058e872 Andy Shevchenko  2026-01-24  1859  		printk(KERN_ERR "%s: buffer write error (status 0x%lx)\n", map->name, chipstatus);
b8a0764c058e872 Andy Shevchenko  2026-01-24  1860  		return -EINVAL;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1861  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1862  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1863  	xip_enable(map, chip, cmd_adr);
b8a0764c058e872 Andy Shevchenko  2026-01-24  1864  	return 0;
b8a0764c058e872 Andy Shevchenko  2026-01-24  1865  }
b8a0764c058e872 Andy Shevchenko  2026-01-24  1866  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
@ 2026-02-04  1:25 Andy Shevchenko
  2026-02-04 21:12 ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2026-02-04  1:25 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

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().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: kept DIS/ENABLE_VPP paired
 drivers/mtd/chips/cfi_cmdset_0001.c | 82 +++++++++++++++++------------
 1 file changed, 48 insertions(+), 34 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index c10693ba265b..c495bee04053 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1720,42 +1720,24 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
 }
 
 
-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)
+static int __xipram do_write_buffer_locked(struct map_info *map, struct flchip *chip,
+					   unsigned long cmd_adr, unsigned long adr,
+					   const struct kvec **pvec,
+					   unsigned long *pvec_seek, int len)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
 	map_word status, write_cmd, datum;
-	unsigned long cmd_adr;
-	int ret, wbufsize, word_gap, words;
+	int ret, word_gap, words;
 	const struct kvec *vec;
 	unsigned long vec_seek;
 	unsigned long initial_adr;
 	int initial_len = len;
 
-	wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
-	adr += chip->start;
 	initial_adr = adr;
-	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;
 
 	/* Let's determine this according to the interleave only once */
 	Mwrite_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9);
 
-	mutex_lock(&chip->mutex);
-	ret = get_chip(map, chip, cmd_adr, FL_WRITING);
-	if (ret) {
-		mutex_unlock(&chip->mutex);
-		return ret;
-	}
-
-	XIP_INVAL_CACHED_RANGE(map, initial_adr, initial_len);
-	ENABLE_VPP(map);
 	xip_disable(map, chip, cmd_adr);
 
 	/* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set
@@ -1789,7 +1771,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 		xip_enable(map, chip, cmd_adr);
 		printk(KERN_ERR "%s: Chip not ready for buffer write. Xstatus = %lx, status = %lx\n",
 				map->name, Xstatus.x[0], status.x[0]);
-		goto out;
+		return ret;
 	}
 
 	/* Figure out the number of words to write */
@@ -1853,7 +1835,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 		chip->state = FL_STATUS;
 		xip_enable(map, chip, cmd_adr);
 		printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name);
-		goto out;
+		return ret;
 	}
 
 	/* check for errors */
@@ -1866,21 +1848,53 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
 		map_write(map, CMD(0x70), cmd_adr);
 		xip_enable(map, chip, cmd_adr);
 
-		if (chipstatus & 0x02) {
-			ret = -EROFS;
-		} else if (chipstatus & 0x08) {
+		if (chipstatus & 0x02)
+			return -EROFS;
+
+		if (chipstatus & 0x08) {
 			printk(KERN_ERR "%s: buffer write error (bad VPP)\n", map->name);
-			ret = -EIO;
-		} else {
-			printk(KERN_ERR "%s: buffer write error (status 0x%lx)\n", map->name, chipstatus);
-			ret = -EINVAL;
+			return  -EIO;
 		}
 
-		goto out;
+		printk(KERN_ERR "%s: buffer write error (status 0x%lx)\n", map->name, chipstatus);
+		return -EINVAL;
 	}
 
 	xip_enable(map, chip, cmd_adr);
- out:	DISABLE_VPP(map);
+	return 0;
+}
+
+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;
+	}
+
+	XIP_INVAL_CACHED_RANGE(map, adr, len);
+	ENABLE_VPP(map);
+
+	ret = do_write_buffer_locked(map, chip, cmd_adr, adr, pvec, pvec_seek, len);
+
+	DISABLE_VPP(map);
 	put_chip(map, chip, cmd_adr);
 	mutex_unlock(&chip->mutex);
 	return ret;
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-04  1:25 [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame Andy Shevchenko
@ 2026-02-04 21:12 ` Andy Shevchenko
  2026-02-05  8:51   ` Miquel Raynal
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2026-02-04 21:12 UTC (permalink / raw)
  To: linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra

On Wed, Feb 04, 2026 at 02:25:27AM +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().

My gosh, I already sent a v2 earlier and there were some replies,
I need to check...

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-04 21:12 ` Andy Shevchenko
@ 2026-02-05  8:51   ` Miquel Raynal
  2026-02-05 15:57     ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Miquel Raynal @ 2026-02-05  8:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra

Hi Andy,

On 04/02/2026 at 23:12:00 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Wed, Feb 04, 2026 at 02:25:27AM +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().
>
> My gosh, I already sent a v2 earlier and there were some replies,
> I need to check...

I'm not sure I get what you mean here? I got no reply (in my inbox) to
your v2. I am letting a bit of time for Vignesh to take a look, but I
know he's busy so I might take it nevertheless by the end of the week as
we are approaching the merge window.

Cheers,
Miquèl

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-05  8:51   ` Miquel Raynal
@ 2026-02-05 15:57     ` Andy Shevchenko
  2026-02-05 17:34       ` Miquel Raynal
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2026-02-05 15:57 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra

On Thu, Feb 05, 2026 at 09:51:56AM +0100, Miquel Raynal wrote:
> On 04/02/2026 at 23:12:00 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Feb 04, 2026 at 02:25:27AM +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().
> >
> > My gosh, I already sent a v2 earlier and there were some replies,
> > I need to check...
> 
> I'm not sure I get what you mean here? I got no reply (in my inbox) to
> your v2. I am letting a bit of time for Vignesh to take a look, but I
> know he's busy so I might take it nevertheless by the end of the week as
> we are approaching the merge window.

I got some strange LKP reports, I need to check them.
Please, discard this email thread as we have it there

https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko@linux.intel.com

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-05 15:57     ` Andy Shevchenko
@ 2026-02-05 17:34       ` Miquel Raynal
  2026-02-06  5:56         ` Vignesh Raghavendra
  0 siblings, 1 reply; 11+ messages in thread
From: Miquel Raynal @ 2026-02-05 17:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-mtd, linux-kernel, Richard Weinberger, Vignesh Raghavendra

On 05/02/2026 at 17:57:17 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Thu, Feb 05, 2026 at 09:51:56AM +0100, Miquel Raynal wrote:
>> On 04/02/2026 at 23:12:00 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>> > On Wed, Feb 04, 2026 at 02:25:27AM +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().
>> >
>> > My gosh, I already sent a v2 earlier and there were some replies,
>> > I need to check...
>> 
>> I'm not sure I get what you mean here? I got no reply (in my inbox) to
>> your v2. I am letting a bit of time for Vignesh to take a look, but I
>> know he's busy so I might take it nevertheless by the end of the week as
>> we are approaching the merge window.
>
> I got some strange LKP reports, I need to check them.
> Please, discard this email thread as we have it there
>
> https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko@linux.intel.com

Ah, this did not reach my inbox, marked SPAM... I'll discard this patch
for this cycle, feel free to resend once the report has been figured
out.

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-05 17:34       ` Miquel Raynal
@ 2026-02-06  5:56         ` Vignesh Raghavendra
  2026-02-06  7:44           ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Vignesh Raghavendra @ 2026-02-06  5:56 UTC (permalink / raw)
  To: Miquel Raynal, Andy Shevchenko
  Cc: linux-mtd, linux-kernel, Richard Weinberger



On 05/02/26 23:04, Miquel Raynal wrote:
> On 05/02/2026 at 17:57:17 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
>> On Thu, Feb 05, 2026 at 09:51:56AM +0100, Miquel Raynal wrote:
>>> On 04/02/2026 at 23:12:00 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>>>> On Wed, Feb 04, 2026 at 02:25:27AM +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().
>>>>
>>>> My gosh, I already sent a v2 earlier and there were some replies,
>>>> I need to check...
>>>
>>> I'm not sure I get what you mean here? I got no reply (in my inbox) to
>>> your v2. I am letting a bit of time for Vignesh to take a look, but I
>>> know he's busy so I might take it nevertheless by the end of the week as
>>> we are approaching the merge window.
>>
>> I got some strange LKP reports, I need to check them.
>> Please, discard this email thread as we have it there
>>
>> https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko@linux.intel.com
> 
> Ah, this did not reach my inbox, marked SPAM... I'll discard this patch
> for this cycle, feel free to resend once the report has been figured
> out.
> 

Yeah, things become tricky with CONFIG_MTD_XIP enabled. With
XIP_INVAL_CACHED_RANGE() moved to caller, initial_adr becomes unused
when CONFIG_MTD_XIP=y

One solution maybe to move calls to XIP_INVAL_CACHED_RANGE(),
ENABLE_VPP(map) and xip_disable() and their complementary functions to
do_write_buffer_locked() as these calls need to repeated for every
writes (if and when we find need to reuse do_write_buffer_locked())

Alternately move INVAL_CACHE_AND_WAIT() and everything after that to caller


-- 
Regards
Vignesh
https://ti.com/opensource


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-06  5:56         ` Vignesh Raghavendra
@ 2026-02-06  7:44           ` Andy Shevchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-02-06  7:44 UTC (permalink / raw)
  To: Vignesh Raghavendra
  Cc: Miquel Raynal, linux-mtd, linux-kernel, Richard Weinberger

On Fri, Feb 06, 2026 at 11:26:23AM +0530, Vignesh Raghavendra wrote:
> On 05/02/26 23:04, Miquel Raynal wrote:
> > On 05/02/2026 at 17:57:17 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >> On Thu, Feb 05, 2026 at 09:51:56AM +0100, Miquel Raynal wrote:
> >>> On 04/02/2026 at 23:12:00 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >>>> On Wed, Feb 04, 2026 at 02:25:27AM +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().
> >>>>
> >>>> My gosh, I already sent a v2 earlier and there were some replies,
> >>>> I need to check...
> >>>
> >>> I'm not sure I get what you mean here? I got no reply (in my inbox) to
> >>> your v2. I am letting a bit of time for Vignesh to take a look, but I
> >>> know he's busy so I might take it nevertheless by the end of the week as
> >>> we are approaching the merge window.
> >>
> >> I got some strange LKP reports, I need to check them.
> >> Please, discard this email thread as we have it there
> >>
> >> https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko@linux.intel.com
> > 
> > Ah, this did not reach my inbox, marked SPAM... I'll discard this patch
> > for this cycle, feel free to resend once the report has been figured
> > out.
> 
> Yeah, things become tricky with CONFIG_MTD_XIP enabled. With
> XIP_INVAL_CACHED_RANGE() moved to caller, initial_adr becomes unused
> when CONFIG_MTD_XIP=y
> 
> One solution maybe to move calls to XIP_INVAL_CACHED_RANGE(),
> ENABLE_VPP(map) and xip_disable() and their complementary functions to
> do_write_buffer_locked() as these calls need to repeated for every
> writes (if and when we find need to reuse do_write_buffer_locked())
> 
> Alternately move INVAL_CACHE_AND_WAIT() and everything after that to caller

Thanks for the analysis! Can you copy this as the reply to the LKP report?
I don't want to have the report and analysis in different threads, I may
forgot about this one (and actually I closed this thread for myself).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-01-24 22:41 ` kernel test robot
@ 2026-02-10 10:05   ` Vignesh Raghavendra
  2026-02-10 14:45     ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Vignesh Raghavendra @ 2026-02-10 10:05 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger



On 25/01/26 04:11, kernel test robot wrote:
> Hi Andy,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on mtd/mtd/next]
> [also build test WARNING on mtd/mtd/fixes linus/master v6.19-rc6 next-20260123]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/mtd-cfi_cmdset_0001-Factor-out-do_write_buffer_locked-to-reduce-stack-frame/20260124-213936
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
> patch link:    https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko%40linux.intel.com
> patch subject: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
> config: xtensa-randconfig-002-20260125 (https://download.01.org/0day-ci/archive/20260125/202601250653.LXBUL5W6-lkp@intel.com/config)
> compiler: xtensa-linux-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260125/202601250653.LXBUL5W6-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202601250653.LXBUL5W6-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer_locked':
>>> drivers/mtd/chips/cfi_cmdset_0001.c:1734:6: warning: unused variable 'initial_len' [-Wunused-variable]
>      int initial_len = len;
>          ^~~~~~~~~~~
>>> drivers/mtd/chips/cfi_cmdset_0001.c:1733:16: warning: variable 'initial_adr' set but not used [-Wunused-but-set-variable]
>      unsigned long initial_adr;
>                    ^~~~~~~~~~~
> 
> 

Copying my response here again from [1] , as this LKP report seems to on a 
different thread:


Things become tricky with CONFIG_MTD_XIP enabled. With
XIP_INVAL_CACHED_RANGE() moved to caller, initial_adr becomes unused
when CONFIG_MTD_XIP=y

One solution maybe to move calls to XIP_INVAL_CACHED_RANGE(),
ENABLE_VPP(map) and xip_disable() and their complementary functions to
do_write_buffer_locked() as these calls need to repeated for every
writes (if and when we find need to reuse do_write_buffer_locked())

Alternately move INVAL_CACHE_AND_WAIT() and everything after that to 
caller


[...]

[1] https://lore.kernel.org/all/4d4ab8af-3e09-4e48-a79d-0af3453600c3@ti.com/

-- 
Regards
Vignesh
https://ti.com/opensource


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
  2026-02-10 10:05   ` Vignesh Raghavendra
@ 2026-02-10 14:45     ` Andy Shevchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-02-10 14:45 UTC (permalink / raw)
  To: Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Miquel Raynal, Richard Weinberger

On Tue, Feb 10, 2026 at 03:35:39PM +0530, Vignesh Raghavendra wrote:
> On 25/01/26 04:11, kernel test robot wrote:

> > kernel test robot noticed the following build warnings:
> > 
> > [auto build test WARNING on mtd/mtd/next]
> > [also build test WARNING on mtd/mtd/fixes linus/master v6.19-rc6 next-20260123]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > 
> > url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/mtd-cfi_cmdset_0001-Factor-out-do_write_buffer_locked-to-reduce-stack-frame/20260124-213936
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
> > patch link:    https://lore.kernel.org/r/20260124133730.3454241-1-andriy.shevchenko%40linux.intel.com
> > patch subject: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame
> > config: xtensa-randconfig-002-20260125 (https://download.01.org/0day-ci/archive/20260125/202601250653.LXBUL5W6-lkp@intel.com/config)
> > compiler: xtensa-linux-gcc (GCC) 8.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260125/202601250653.LXBUL5W6-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202601250653.LXBUL5W6-lkp@intel.com/
> > 
> > All warnings (new ones prefixed by >>):
> > 
> >    drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer_locked':
> >>> drivers/mtd/chips/cfi_cmdset_0001.c:1734:6: warning: unused variable 'initial_len' [-Wunused-variable]
> >      int initial_len = len;
> >          ^~~~~~~~~~~
> >>> drivers/mtd/chips/cfi_cmdset_0001.c:1733:16: warning: variable 'initial_adr' set but not used [-Wunused-but-set-variable]
> >      unsigned long initial_adr;
> >                    ^~~~~~~~~~~
> 
> Copying my response here again from [1] , as this LKP report seems to on a 
> different thread:

Thanks! I will look at this after -rc1 is out. Maybe earlier, but quite busy
with other issue(s).

> Things become tricky with CONFIG_MTD_XIP enabled. With
> XIP_INVAL_CACHED_RANGE() moved to caller, initial_adr becomes unused
> when CONFIG_MTD_XIP=y
> 
> One solution maybe to move calls to XIP_INVAL_CACHED_RANGE(),
> ENABLE_VPP(map) and xip_disable() and their complementary functions to
> do_write_buffer_locked() as these calls need to repeated for every
> writes (if and when we find need to reuse do_write_buffer_locked())
> 
> Alternately move INVAL_CACHE_AND_WAIT() and everything after that to 
> caller

[...]

> [1] https://lore.kernel.org/all/4d4ab8af-3e09-4e48-a79d-0af3453600c3@ti.com/

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-02-10 14:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04  1:25 [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame Andy Shevchenko
2026-02-04 21:12 ` Andy Shevchenko
2026-02-05  8:51   ` Miquel Raynal
2026-02-05 15:57     ` Andy Shevchenko
2026-02-05 17:34       ` Miquel Raynal
2026-02-06  5:56         ` Vignesh Raghavendra
2026-02-06  7:44           ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2026-01-24 13:35 Andy Shevchenko
2026-01-24 22:41 ` kernel test robot
2026-02-10 10:05   ` Vignesh Raghavendra
2026-02-10 14:45     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox