[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <201708312044.0MT7qLGe%fengguang.wu@intel.com>
Date: Thu, 31 Aug 2017 20:50:38 +0800
From: kbuild test robot <lkp@...el.com>
To: Andrea Adami <andrea.adami@...il.com>
Cc: kbuild-all@...org, linux-mtd@...ts.infradead.org,
David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
Boris Brezillon <boris.brezillon@...e-electrons.com>,
Marek Vasut <marek.vasut@...il.com>,
Richard Weinberger <richard@....at>,
Cyrille Pitchen <cyrille.pitchen@...ev4u.fr>,
Rafał Miłecki <rafal@...ecki.pl>,
Haojian Zhuang <haojian.zhuang@...il.com>,
Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
Robert Jarzmik <robert.jarzmik@...e.fr>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8] mtd: sharpslpart: Add sharpslpart partition parser
Hi Andrea,
[auto build test ERROR on mtd/master]
[also build test ERROR on v4.13-rc7 next-20170829]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Andrea-Adami/mtd-sharpslpart-Add-sharpslpart-partition-parser/20170831-190713
base: git://git.infradead.org/linux-mtd.git master
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All error/warnings (new ones prefixed by >>):
drivers/mtd/parsers/sharpslpart.c: In function 'sharpsl_nand_init_ftl':
>> drivers/mtd/parsers/sharpslpart.c:47:37: error: 'SZ_1M' undeclared (first use in this function)
#define SHARPSL_FTL_PART_SIZE (7 * SZ_1M)
^
>> drivers/mtd/parsers/sharpslpart.c:176:25: note: in expansion of macro 'SHARPSL_FTL_PART_SIZE'
phymax = mtd_div_by_eb(SHARPSL_FTL_PART_SIZE, mtd);
^~~~~~~~~~~~~~~~~~~~~
drivers/mtd/parsers/sharpslpart.c:47:37: note: each undeclared identifier is reported only once for each function it appears in
#define SHARPSL_FTL_PART_SIZE (7 * SZ_1M)
^
>> drivers/mtd/parsers/sharpslpart.c:176:25: note: in expansion of macro 'SHARPSL_FTL_PART_SIZE'
phymax = mtd_div_by_eb(SHARPSL_FTL_PART_SIZE, mtd);
^~~~~~~~~~~~~~~~~~~~~
vim +/SZ_1M +47 drivers/mtd/parsers/sharpslpart.c
44
45 /* factory defaults */
46 #define SHARPSL_NAND_PARTS 3
> 47 #define SHARPSL_FTL_PART_SIZE (7 * SZ_1M)
48 #define SHARPSL_PARTINFO1_LADDR 0x00060000
49 #define SHARPSL_PARTINFO2_LADDR 0x00064000
50
51 #define BOOT_MAGIC 0x424f4f54
52 #define FSRO_MAGIC 0x4653524f
53 #define FSRW_MAGIC 0x46535257
54
55 /**
56 * struct sharpsl_ftl - Sharp FTL Logical Table
57 * @logmax: number of logical blocks
58 * @log2phy: the logical-to-physical table
59 *
60 * Structure containing the logical-to-physical translation table
61 * used by the SHARP SL FTL.
62 */
63 struct sharpsl_ftl {
64 unsigned int logmax;
65 unsigned int *log2phy;
66 };
67
68 /* verify that the OOB bytes 8 to 15 are free and available for the FTL */
69 static int sharpsl_nand_check_ooblayout(struct mtd_info *mtd)
70 {
71 u8 freebytes = 0;
72 int section = 0;
73
74 while (true) {
75 struct mtd_oob_region oobfree = { };
76 int ret, i;
77
78 ret = mtd_ooblayout_free(mtd, section++, &oobfree);
79 if (ret)
80 break;
81
82 if (!oobfree.length || oobfree.offset > 15 ||
83 (oobfree.offset + oobfree.length) < 8)
84 continue;
85
86 i = oobfree.offset >= 8 ? oobfree.offset : 8;
87 for (; i < oobfree.offset + oobfree.length && i < 16; i++)
88 freebytes |= BIT(i - 8);
89
90 if (freebytes == 0xff)
91 return 0;
92 }
93
94 return -ENOTSUPP;
95 }
96
97 static int sharpsl_nand_read_oob(struct mtd_info *mtd, loff_t offs, u8 *buf)
98 {
99 struct mtd_oob_ops ops = { };
100 int ret;
101
102 ops.mode = MTD_OPS_PLACE_OOB;
103 ops.ooblen = mtd->oobsize;
104 ops.oobbuf = buf;
105
106 ret = mtd_read_oob(mtd, offs, &ops);
107 if (ret != 0 || mtd->oobsize != ops.oobretlen)
108 return -1;
109
110 return 0;
111 }
112
113 /*
114 * The logical block number assigned to a physical block is stored in the OOB
115 * of the first page, in 3 16-bit copies with the following layout:
116 *
117 * 01234567 89abcdef
118 * -------- --------
119 * ECC BB xyxyxy
120 *
121 * When reading we check that the first two copies agree.
122 * In case of error, matching is tried using the following pairs.
123 * Reserved values 0xffff mean the block is kept for wear leveling.
124 *
125 * 01234567 89abcdef
126 * -------- --------
127 * ECC BB xyxy oob[8]==oob[10] && oob[9]==oob[11] -> byte0=8 byte1=9
128 * ECC BB xyxy oob[10]==oob[12] && oob[11]==oob[13] -> byte0=10 byte1=11
129 * ECC BB xy xy oob[12]==oob[8] && oob[13]==oob[9] -> byte0=12 byte1=13
130 */
131 static int sharpsl_nand_get_logical_num(u8 *oob)
132 {
133 u16 us;
134 int good0, good1;
135
136 if (oob[NAND_NOOB_LOGADDR_00] == oob[NAND_NOOB_LOGADDR_10] &&
137 oob[NAND_NOOB_LOGADDR_01] == oob[NAND_NOOB_LOGADDR_11]) {
138 good0 = NAND_NOOB_LOGADDR_00;
139 good1 = NAND_NOOB_LOGADDR_01;
140 } else if (oob[NAND_NOOB_LOGADDR_10] == oob[NAND_NOOB_LOGADDR_20] &&
141 oob[NAND_NOOB_LOGADDR_11] == oob[NAND_NOOB_LOGADDR_21]) {
142 good0 = NAND_NOOB_LOGADDR_10;
143 good1 = NAND_NOOB_LOGADDR_11;
144 } else if (oob[NAND_NOOB_LOGADDR_20] == oob[NAND_NOOB_LOGADDR_00] &&
145 oob[NAND_NOOB_LOGADDR_21] == oob[NAND_NOOB_LOGADDR_01]) {
146 good0 = NAND_NOOB_LOGADDR_20;
147 good1 = NAND_NOOB_LOGADDR_21;
148 } else {
149 return -EINVAL;
150 }
151
152 us = oob[good0] | oob[good1] << 8;
153
154 /* parity check */
155 if (hweight16(us) & BLOCK_UNMASK_COMPLEMENT)
156 return -EINVAL;
157
158 /* reserved */
159 if (us == BLOCK_IS_RESERVED)
160 return BLOCK_IS_RESERVED;
161
162 return (us >> 1) & GENMASK(9, 0);
163 }
164
165 static int sharpsl_nand_init_ftl(struct mtd_info *mtd, struct sharpsl_ftl *ftl)
166 {
167 unsigned int block_num, log_num, phymax;
168 loff_t block_adr;
169 u8 *oob;
170 int i, ret;
171
172 oob = kzalloc(mtd->oobsize, GFP_KERNEL);
173 if (!oob)
174 return -ENOMEM;
175
> 176 phymax = mtd_div_by_eb(SHARPSL_FTL_PART_SIZE, mtd);
177
178 /* FTL reserves 5% of the blocks + 1 spare */
179 ftl->logmax = ((phymax * 95) / 100) - 1;
180
181 ftl->log2phy = kmalloc_array(ftl->logmax, sizeof(*ftl->log2phy),
182 GFP_KERNEL);
183 if (!ftl->log2phy) {
184 ret = -ENOMEM;
185 goto exit;
186 }
187
188 /* initialize ftl->log2phy */
189 for (i = 0; i < ftl->logmax; i++)
190 ftl->log2phy[i] = UINT_MAX;
191
192 /* create physical-logical table */
193 for (block_num = 0; block_num < phymax; block_num++) {
194 block_adr = block_num * mtd->erasesize;
195
196 if (mtd_block_isbad(mtd, block_adr))
197 continue;
198
199 if (sharpsl_nand_read_oob(mtd, block_adr, oob))
200 continue;
201
202 /* get logical block */
203 log_num = sharpsl_nand_get_logical_num(oob);
204
205 /* cut-off errors and skip the out-of-range values */
206 if (log_num > 0 && log_num < ftl->logmax) {
207 if (ftl->log2phy[log_num] == UINT_MAX)
208 ftl->log2phy[log_num] = block_num;
209 }
210 }
211
212 pr_info("Sharp SL FTL: %d blocks used (%d logical, %d reserved)\n",
213 phymax, ftl->logmax, phymax - ftl->logmax);
214
215 ret = 0;
216 exit:
217 kfree(oob);
218 return ret;
219 }
220
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Download attachment ".config.gz" of type "application/gzip" (51477 bytes)
Powered by blists - more mailing lists