diff options
author | Josselin Costanzi <josselin.costanzi@mobile-devices.fr> | 2012-02-22 10:37:05 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-03-09 02:39:31 -0500 |
commit | 43b043e78b876ce27034f167897b57fd2556ad29 (patch) | |
tree | 3397ed09387b4f74b4c2f23b1d04943baa0c7b11 /drivers/mtd/ubi | |
parent | 7eb3aa65853e1b223bfc786b023b702018cb76c0 (diff) |
UBI: reduce memory consumption
Remove the pre-allocated 'peb_buf2' buffer because we do not really need it.
The only reason UBI has it is to check that the data were written correctly.
But we do not have to have 2 buffers for this and waste RAM - we can just
compare CRC checksums instead. This reduces UBI memory consumption.
Artem bityutskiy: massaged the patch and commit message
Signed-off-by: Josselin Costanzi <josselin.costanzi@mobile-devices.fr>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r-- | drivers/mtd/ubi/build.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/eba.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 4 |
3 files changed, 4 insertions, 12 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 115749f20f9e..6e0806bff9f7 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -949,10 +949,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) | |||
949 | if (!ubi->peb_buf1) | 949 | if (!ubi->peb_buf1) |
950 | goto out_free; | 950 | goto out_free; |
951 | 951 | ||
952 | ubi->peb_buf2 = vmalloc(ubi->peb_size); | ||
953 | if (!ubi->peb_buf2) | ||
954 | goto out_free; | ||
955 | |||
956 | err = ubi_debugging_init_dev(ubi); | 952 | err = ubi_debugging_init_dev(ubi); |
957 | if (err) | 953 | if (err) |
958 | goto out_free; | 954 | goto out_free; |
@@ -1030,7 +1026,6 @@ out_debugging: | |||
1030 | ubi_debugging_exit_dev(ubi); | 1026 | ubi_debugging_exit_dev(ubi); |
1031 | out_free: | 1027 | out_free: |
1032 | vfree(ubi->peb_buf1); | 1028 | vfree(ubi->peb_buf1); |
1033 | vfree(ubi->peb_buf2); | ||
1034 | if (ref) | 1029 | if (ref) |
1035 | put_device(&ubi->dev); | 1030 | put_device(&ubi->dev); |
1036 | else | 1031 | else |
@@ -1102,7 +1097,6 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) | |||
1102 | put_mtd_device(ubi->mtd); | 1097 | put_mtd_device(ubi->mtd); |
1103 | ubi_debugging_exit_dev(ubi); | 1098 | ubi_debugging_exit_dev(ubi); |
1104 | vfree(ubi->peb_buf1); | 1099 | vfree(ubi->peb_buf1); |
1105 | vfree(ubi->peb_buf2); | ||
1106 | ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); | 1100 | ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); |
1107 | put_device(&ubi->dev); | 1101 | put_device(&ubi->dev); |
1108 | return 0; | 1102 | return 0; |
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index cd26da8ad225..f548af3c98bb 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -1134,8 +1134,8 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1134 | * We've written the data and are going to read it back to make | 1134 | * We've written the data and are going to read it back to make |
1135 | * sure it was written correctly. | 1135 | * sure it was written correctly. |
1136 | */ | 1136 | */ |
1137 | 1137 | memset(ubi->peb_buf1, 0xFF, aldata_size); | |
1138 | err = ubi_io_read_data(ubi, ubi->peb_buf2, to, 0, aldata_size); | 1138 | err = ubi_io_read_data(ubi, ubi->peb_buf1, to, 0, aldata_size); |
1139 | if (err) { | 1139 | if (err) { |
1140 | if (err != UBI_IO_BITFLIPS) { | 1140 | if (err != UBI_IO_BITFLIPS) { |
1141 | ubi_warn("error %d while reading data back " | 1141 | ubi_warn("error %d while reading data back " |
@@ -1149,7 +1149,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, | |||
1149 | 1149 | ||
1150 | cond_resched(); | 1150 | cond_resched(); |
1151 | 1151 | ||
1152 | if (memcmp(ubi->peb_buf1, ubi->peb_buf2, aldata_size)) { | 1152 | if (crc != crc32(UBI_CRC32_INIT, ubi->peb_buf1, data_size)) { |
1153 | ubi_warn("read data back from PEB %d and it is " | 1153 | ubi_warn("read data back from PEB %d and it is " |
1154 | "different", to); | 1154 | "different", to); |
1155 | err = -EINVAL; | 1155 | err = -EINVAL; |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index d51d75d34446..cb93ad97468b 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -388,8 +388,7 @@ struct ubi_wl_entry; | |||
388 | * @mtd: MTD device descriptor | 388 | * @mtd: MTD device descriptor |
389 | * | 389 | * |
390 | * @peb_buf1: a buffer of PEB size used for different purposes | 390 | * @peb_buf1: a buffer of PEB size used for different purposes |
391 | * @peb_buf2: another buffer of PEB size used for different purposes | 391 | * @buf_mutex: protects @peb_buf1 |
392 | * @buf_mutex: protects @peb_buf1 and @peb_buf2 | ||
393 | * @ckvol_mutex: serializes static volume checking when opening | 392 | * @ckvol_mutex: serializes static volume checking when opening |
394 | * | 393 | * |
395 | * @dbg: debugging information for this UBI device | 394 | * @dbg: debugging information for this UBI device |
@@ -472,7 +471,6 @@ struct ubi_device { | |||
472 | struct mtd_info *mtd; | 471 | struct mtd_info *mtd; |
473 | 472 | ||
474 | void *peb_buf1; | 473 | void *peb_buf1; |
475 | void *peb_buf2; | ||
476 | struct mutex buf_mutex; | 474 | struct mutex buf_mutex; |
477 | struct mutex ckvol_mutex; | 475 | struct mutex ckvol_mutex; |
478 | 476 | ||