kernel: bump 5.10 to 5.10.52
[openwrt/staging/chunkeey.git] / target / linux / generic / hack-5.10 / 410-block-fit-partition-parser.patch
1 --- a/block/blk.h
2 +++ b/block/blk.h
3 @@ -357,6 +357,7 @@ char *disk_name(struct gendisk *hd, int
4 #define ADDPART_FLAG_NONE 0
5 #define ADDPART_FLAG_RAID 1
6 #define ADDPART_FLAG_WHOLEDISK 2
7 +#define ADDPART_FLAG_ROOTDEV 4
8 void delete_partition(struct hd_struct *part);
9 int bdev_add_partition(struct block_device *bdev, int partno,
10 sector_t start, sector_t length);
11 --- a/block/partitions/Kconfig
12 +++ b/block/partitions/Kconfig
13 @@ -101,6 +101,13 @@ config ATARI_PARTITION
14 Say Y here if you would like to use hard disks under Linux which
15 were partitioned under the Atari OS.
16
17 +config FIT_PARTITION
18 + bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED
19 + default n
20 + help
21 + Say Y here if your system needs to mount the filesystem part of
22 + a Flattened-Image-Tree (FIT) image commonly used with Das U-Boot.
23 +
24 config IBM_PARTITION
25 bool "IBM disk label and partition support"
26 depends on PARTITION_ADVANCED && S390
27 --- a/block/partitions/Makefile
28 +++ b/block/partitions/Makefile
29 @@ -8,6 +8,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o
30 obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
31 obj-$(CONFIG_ATARI_PARTITION) += atari.o
32 obj-$(CONFIG_AIX_PARTITION) += aix.o
33 +obj-$(CONFIG_FIT_PARTITION) += fit.o
34 obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o
35 obj-$(CONFIG_MAC_PARTITION) += mac.o
36 obj-$(CONFIG_LDM_PARTITION) += ldm.o
37 --- a/block/partitions/check.h
38 +++ b/block/partitions/check.h
39 @@ -58,6 +58,7 @@ int amiga_partition(struct parsed_partit
40 int atari_partition(struct parsed_partitions *state);
41 int cmdline_partition(struct parsed_partitions *state);
42 int efi_partition(struct parsed_partitions *state);
43 +int fit_partition(struct parsed_partitions *state);
44 int ibm_partition(struct parsed_partitions *);
45 int karma_partition(struct parsed_partitions *state);
46 int ldm_partition(struct parsed_partitions *state);
47 @@ -68,3 +69,5 @@ int sgi_partition(struct parsed_partitio
48 int sun_partition(struct parsed_partitions *state);
49 int sysv68_partition(struct parsed_partitions *state);
50 int ultrix_partition(struct parsed_partitions *state);
51 +
52 +int parse_fit_partitions(struct parsed_partitions *state, u64 start_sector, u64 nr_sectors, int *slot, int add_remain);
53 --- a/block/partitions/core.c
54 +++ b/block/partitions/core.c
55 @@ -10,6 +10,10 @@
56 #include <linux/vmalloc.h>
57 #include <linux/blktrace_api.h>
58 #include <linux/raid/detect.h>
59 +#ifdef CONFIG_FIT_PARTITION
60 +#include <linux/root_dev.h>
61 +#endif
62 +
63 #include "check.h"
64
65 static int (*check_part[])(struct parsed_partitions *) = {
66 @@ -46,6 +50,9 @@ static int (*check_part[])(struct parsed
67 #ifdef CONFIG_EFI_PARTITION
68 efi_partition, /* this must come before msdos */
69 #endif
70 +#ifdef CONFIG_FIT_PARTITION
71 + fit_partition,
72 +#endif
73 #ifdef CONFIG_SGI_PARTITION
74 sgi_partition,
75 #endif
76 @@ -215,6 +222,18 @@ static ssize_t part_discard_alignment_sh
77 p->start_sect));
78 }
79
80 +static ssize_t part_name_show(struct device *dev,
81 + struct device_attribute *attr, char *buf)
82 +{
83 + struct hd_struct *p = dev_to_part(dev);
84 +
85 + if (p->info && p->info->volname)
86 + return sprintf(buf, "%s\n", p->info->volname);
87 +
88 + buf[0] = '\0';
89 + return 0;
90 +}
91 +
92 static DEVICE_ATTR(partition, 0444, part_partition_show, NULL);
93 static DEVICE_ATTR(start, 0444, part_start_show, NULL);
94 static DEVICE_ATTR(size, 0444, part_size_show, NULL);
95 @@ -223,6 +242,7 @@ static DEVICE_ATTR(alignment_offset, 044
96 static DEVICE_ATTR(discard_alignment, 0444, part_discard_alignment_show, NULL);
97 static DEVICE_ATTR(stat, 0444, part_stat_show, NULL);
98 static DEVICE_ATTR(inflight, 0444, part_inflight_show, NULL);
99 +static DEVICE_ATTR(name, 0444, part_name_show, NULL);
100 #ifdef CONFIG_FAIL_MAKE_REQUEST
101 static struct device_attribute dev_attr_fail =
102 __ATTR(make-it-fail, 0644, part_fail_show, part_fail_store);
103 @@ -237,6 +257,7 @@ static struct attribute *part_attrs[] =
104 &dev_attr_discard_alignment.attr,
105 &dev_attr_stat.attr,
106 &dev_attr_inflight.attr,
107 + &dev_attr_name.attr,
108 #ifdef CONFIG_FAIL_MAKE_REQUEST
109 &dev_attr_fail.attr,
110 #endif
111 @@ -694,6 +715,11 @@ static bool blk_add_partition(struct gen
112 (state->parts[p].flags & ADDPART_FLAG_RAID))
113 md_autodetect_dev(part_to_dev(part)->devt);
114
115 +#ifdef CONFIG_FIT_PARTITION
116 + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
117 + ROOT_DEV = part_to_dev(part)->devt;
118 +#endif
119 +
120 return true;
121 }
122
123 --- a/drivers/mtd/ubi/block.c
124 +++ b/drivers/mtd/ubi/block.c
125 @@ -396,7 +396,11 @@ int ubiblock_create(struct ubi_volume_in
126 dev->leb_size = vi->usable_leb_size;
127
128 /* Initialize the gendisk of this ubiblock device */
129 +#ifdef CONFIG_FIT_PARTITION
130 + gd = alloc_disk(0);
131 +#else
132 gd = alloc_disk(1);
133 +#endif
134 if (!gd) {
135 pr_err("UBI: block: alloc_disk failed\n");
136 ret = -ENODEV;
137 @@ -413,6 +417,9 @@ int ubiblock_create(struct ubi_volume_in
138 goto out_put_disk;
139 }
140 gd->private_data = dev;
141 +#ifdef CONFIG_FIT_PARTITION
142 + gd->flags |= GENHD_FL_EXT_DEVT;
143 +#endif
144 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
145 set_capacity(gd, disk_capacity);
146 dev->gd = gd;
147 --- a/block/partitions/efi.c
148 +++ b/block/partitions/efi.c
149 @@ -706,6 +706,9 @@ int efi_partition(struct parsed_partitio
150 gpt_entry *ptes = NULL;
151 u32 i;
152 unsigned ssz = bdev_logical_block_size(state->bdev) / 512;
153 +#ifdef CONFIG_FIT_PARTITION
154 + u32 extra_slot = 64;
155 +#endif
156
157 if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
158 kfree(gpt);
159 @@ -739,6 +742,11 @@ int efi_partition(struct parsed_partitio
160 ARRAY_SIZE(ptes[i].partition_name));
161 utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
162 state->parts[i + 1].has_info = true;
163 +#ifdef CONFIG_FIT_PARTITION
164 + /* If this is a U-Boot FIT volume it may have subpartitions */
165 + if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
166 + (void) parse_fit_partitions(state, start * ssz, size * ssz, &extra_slot, 1);
167 +#endif
168 }
169 kfree(ptes);
170 kfree(gpt);
171 --- a/block/partitions/efi.h
172 +++ b/block/partitions/efi.h
173 @@ -52,6 +52,9 @@
174 #define PARTITION_LINUX_LVM_GUID \
175 EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
176 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
177 +#define PARTITION_LINUX_FIT_GUID \
178 + EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
179 + 0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
180
181 typedef struct _gpt_header {
182 __le64 signature;
183 --- a/drivers/mtd/mtdblock.c
184 +++ b/drivers/mtd/mtdblock.c
185 @@ -334,7 +334,11 @@ static void mtdblock_remove_dev(struct m
186 static struct mtd_blktrans_ops mtdblock_tr = {
187 .name = "mtdblock",
188 .major = MTD_BLOCK_MAJOR,
189 +#ifdef CONFIG_FIT_PARTITION
190 + .part_bits = 1,
191 +#else
192 .part_bits = 0,
193 +#endif
194 .blksize = 512,
195 .open = mtdblock_open,
196 .flush = mtdblock_flush,
197 --- a/drivers/mtd/mtd_blkdevs.c
198 +++ b/drivers/mtd/mtd_blkdevs.c
199 @@ -407,18 +407,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt
200 gd->first_minor = (new->devnum) << tr->part_bits;
201 gd->fops = &mtd_block_ops;
202
203 - if (tr->part_bits)
204 - if (new->devnum < 26)
205 - snprintf(gd->disk_name, sizeof(gd->disk_name),
206 - "%s%c", tr->name, 'a' + new->devnum);
207 - else
208 - snprintf(gd->disk_name, sizeof(gd->disk_name),
209 - "%s%c%c", tr->name,
210 - 'a' - 1 + new->devnum / 26,
211 - 'a' + new->devnum % 26);
212 - else
213 - snprintf(gd->disk_name, sizeof(gd->disk_name),
214 - "%s%d", tr->name, new->devnum);
215 + snprintf(gd->disk_name, sizeof(gd->disk_name),
216 + "%s%d", tr->name, new->devnum);
217
218 set_capacity(gd, ((u64)new->size * tr->blksize) >> 9);
219
220 --- a/block/partitions/msdos.c
221 +++ b/block/partitions/msdos.c
222 @@ -563,6 +563,15 @@ static void parse_minix(struct parsed_pa
223 #endif /* CONFIG_MINIX_SUBPARTITION */
224 }
225
226 +static void parse_fit_mbr(struct parsed_partitions *state,
227 + sector_t offset, sector_t size, int origin)
228 +{
229 +#ifdef CONFIG_FIT_PARTITION
230 + u32 extra_slot = 64;
231 + (void) parse_fit_partitions(state, offset, size, &extra_slot, 1);
232 +#endif /* CONFIG_FIT_PARTITION */
233 +}
234 +
235 static struct {
236 unsigned char id;
237 void (*parse)(struct parsed_partitions *, sector_t, sector_t, int);
238 @@ -574,6 +583,7 @@ static struct {
239 {UNIXWARE_PARTITION, parse_unixware},
240 {SOLARIS_X86_PARTITION, parse_solaris_x86},
241 {NEW_SOLARIS_X86_PARTITION, parse_solaris_x86},
242 + {FIT_PARTITION, parse_fit_mbr},
243 {0, NULL},
244 };
245
246 --- a/include/linux/msdos_partition.h
247 +++ b/include/linux/msdos_partition.h
248 @@ -31,6 +31,7 @@ enum msdos_sys_ind {
249 LINUX_LVM_PARTITION = 0x8e,
250 LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
251
252 + FIT_PARTITION = 0x2e, /* U-Boot uImage.FIT */
253 SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */
254 NEW_SOLARIS_X86_PARTITION = 0xbf,
255