usb: gadget: don't leak configs when unbinding
Subsystems (3)
PATCH 1/10 usb: gadget: don't leak configs when unbinding
From: Stephen Warren <[email protected]>
By the time g_dnl_unbind() is run, cdev->config has been set to NULL, so the free() there does nothing, and the config struct is leaked. Equally, struct usb_gadget contains a linked list of config structs, so the code should iterate over them all and free each one, rather than freeing one particular config struct.
composite_unbind() already iterates over the list of config structs, and unlinks each from the linked list. Fix this loop to free() each struct as it's unlinked and otherwise forgotten.
--- drivers/usb/gadget/composite.c | 1 + drivers/usb/gadget/g_dnl.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/usb/gadget/composite.c +1 -0
@@ -948,6 +948,7 @@ static void composite_unbind(struct usb_gadget *gadget)debug ("unbind config '%s'/%p\n" , c->label, c); c->unbind (c); } +free (c); }if (composite->unbind) composite->unbind (cdev);
drivers/usb/gadget/g_dnl.c +0 -2
@@ -93,8 +93,6 @@ static int g_dnl_unbind(struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; -free (cdev->config); - cdev->config =NULL ;debug ("%s: calling usb_gadget_disconnect for " "controller '%s'\n" , __func__, gadget->name);usb_gadget_disconnect (gadget);
Signature · 1 line
1.9.1
PATCH 2/10 ext4: avoid calling ext4fs_mount() twice, which leaks
From: Stephen Warren <[email protected]>
ext4_write_file() is only called from the "fs" layer, which calls both ext4fs_mount() and ext4fs_close() before/after calling ext4_write_file(). Fix ext4_write_file() not to call ext4fs_mount() again, since the mount operation malloc()s some RAM which is leaked when a second mount call over-writes the pointer to that data, if no intervening close call is made.
--- fs/ext4/ext4_write.c | 9 --------- 1 file changed, 9 deletions(-)
fs/ext4/ext4_write.c +0 -9
@@ -986,26 +986,17 @@ int ext4_write_file(const char *filename, void *buf, loff_t offset,return -1 ; } -/* mount the filesystem */ -if (!ext4fs_mount (0 )) { -printf ("** Error Bad ext4 partition **\n" ); - goto fail; - } - ret =ext4fs_write (filename, buf, len); -if (ret) {printf ("** Error ext4fs_write() **\n" ); goto fail; } -ext4fs_close (); *actwrite = len;return 0 ; fail: -ext4fs_close (); *actwrite =0 ;return -1 ;
Signature · 1 line
1.9.1
PATCH 2/10 ext4: avoid calling ext4fs_mount() twice, which leaks
Hi Stephen,
Quoted 35 lines
From: Stephen Warren <[email protected]>
ext4_write_file()is only called from the "fs" layer, which calls bothext4fs_mount()andext4fs_close()before/after callingext4_write_file(). Fixext4_write_file()not to callext4fs_mount()again, since the mount operation malloc()s some RAM which is leaked when a second mount call over-writes the pointer to that data, if no intervening close call is made.Signed-off-by Stephen Warren <[email protected]>--- fs/ext4/ext4_write.c | 9 --------- 1 file changed, 9 deletions(-)fs/ext4/ext4_write.c +0
-8@@ -986,26 +986,17 @@ int ext4_write_file(const char *filename, void *buf, loff_t offset, return -1; } -/* mount the filesystem */ -if (!ext4fs_mount (0 )) { -printf ("** Error Bad ext4 partition **\n" ); - goto fail; - } - ret =ext4fs_write (filename, buf, len); -if (ret) {printf ("** Error ext4fs_write() **\n" ); goto fail; } -ext4fs_close ();
fs/ext4/ext4_write.c int ext4_write_file(const char *filename, void · line 1002
Quoted 10 lines
fs/ext4/ext4_write.c +0
-1*actwrite = len;return 0 ; fail: -ext4fs_close (); *actwrite =0 ;return -1 ;
Test HW: Odroid XU3 - Exynos5433
[DFU tests]
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 2/10 ext4: avoid calling ext4fs_mount() twice, which leaks
In reply to Stephen WarrenQuoted 9 lines · Stephen Warren
From: Stephen Warren <[email protected]>
ext4_write_file()is only called from the "fs" layer, which calls bothext4fs_mount()andext4fs_close()before/after callingext4_write_file(). Fixext4_write_file()not to callext4fs_mount()again, since the mount operation malloc()s some RAM which is leaked when a second mount call over-writes the pointer to that data, if no intervening close call is made.
Quoted 3 lines
Signed-off-by Stephen Warren <[email protected]>Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/73236a88/attachment.sig>
PATCH 3/10 ext4: free allocations by parse_path()
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
parse_path() malloc()s the entries in the array it's passed. Those allocations must be free()d by the caller, ext4fs_get_parent_inode_num(). Add code to do this.
For this to work, all the array entries must be dynamically allocated, rather than a mix of dynamic and static allocations. Fix parse_path() not to over-write arr[0] with a pointer to statically allocated data.
--- fs/ext4/ext4_common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/ext4_common.c +6 -2
@@ -614,8 +614,7 @@ static int parse_path(char **arr, char *dirname) arr[i] =zalloc (strlen ("/" ) +1 );if (!arr[i])return -ENOMEM ; - - arr[i++] ="/" ; +memcpy (arr[i++],"/" ,strlen ("/" ));/* add each path entry after root */ while (token !=NULL ) {
@@ -745,6 +744,11 @@ end: fail:free (depth_dirname);free (parse_dirname); +for (i =0 ; i < depth; i++) { +if (!ptr[i]) +break ; +free (ptr[i]); + }free (ptr);free (parent_inode);free (first_inode);
Signature · 1 line
1.9.1
PATCH 3/10 ext4: free allocations by parse_path()
Hi Stephen,
Quoted 31 lines
From: Stephen Warren <[email protected]>
parse_path()malloc()s the entries in the array it's passed. Those allocations must be free()d by the caller,ext4fs_get_parent_inode_num(). Add code to do this.For this to work, all the array entries must be dynamically allocated, rather than a mix of dynamic and static allocations. Fix
parse_path()not to over-write arr[0] with a pointer to statically allocated data.Signed-off-by Stephen Warren <[email protected]>--- fs/ext4/ext4_common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)fs/ext4/ext4_common.c +1
-2@@ -614,8 +614,7 @@ static int parse_path(char **arr, char *dirname) arr[i] =zalloc (strlen ("/" ) +1 );if (!arr[i])return -ENOMEM ; - - arr[i++] ="/" ; +memcpy (arr[i++],"/" ,strlen ("/" ));/* add each path entry after root */ while (token !=NULL ) {@@ -745,6 +744,11 @@ end: fail:
fs/ext4/ext4_common.c end: · line 754
Quoted 10 lines
fs/ext4/ext4_common.c +5
-0free (depth_dirname);free (parse_dirname); +for (i =0 ; i < depth; i++) { +if (!ptr[i]) +break ; +free (ptr[i]); + }free (ptr);free (parent_inode);free (first_inode);
Test HW: Odroid XU3 - Exynos5433
[DFU tests]
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 3/10 ext4: free allocations by parse_path()
In reply to Stephen WarrenQuoted 6 lines · Stephen Warren
From: Stephen Warren <[email protected]>
parse_path()malloc()s the entries in the array it's passed. Those allocations must be free()d by the caller,ext4fs_get_parent_inode_num(). Add code to do this.
Quoted 7 lines
For this to work, all the array entries must be dynamically allocated, rather than a mix of dynamic and static allocations. Fix
parse_path()not to over-write arr[0] with a pointer to statically allocated data.Signed-off-by Stephen Warren <[email protected]>Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/8056f5d7/attachment.sig>
PATCH 4/10 ext4: fix leak in check_filename()
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
root_first_block_buffer should be free()d in all cases, not just when an error occurs. Fix the success exit path of the function to do this.
--- fs/ext4/ext4_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext4/ext4_common.c +3 -2
@@ -769,6 +769,7 @@ static int check_filename(char *filename, unsigned int blknr)struct ext2_dirent *previous_dir =NULL ;char *ptr =NULL ;struct ext_filesystem *fs =get_fs (); +int ret =-1 ;/* get the first block of root */ first_block_no_of_root = blknr;
@@ -822,12 +823,12 @@ static int check_filename(char *filename, unsigned int blknr)if (ext4fs_put_metadata (root_first_block_addr, first_block_no_of_root)) goto fail; -return inodeno; + ret = inodeno; } fail:free (root_first_block_buffer); -return -1 ; +return ret; }int ext4fs_filename_check (char *filename)
Signature · 1 line
1.9.1
PATCH 4/10 ext4: fix leak in check_filename()
Hi Stephen,
Quoted 27 lines
From: Stephen Warren <[email protected]>
root_first_block_buffershould be free()d in all cases, not just when an error occurs. Fix the success exit path of the function to do this.Signed-off-by Stephen Warren <[email protected]>--- fs/ext4/ext4_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/ext4/ext4_common.c +1
-1@@ -769,6 +769,7 @@ static int check_filename(char *filename, unsigned int blknr) struct ext2_dirent *previous_dir = NULL;char *ptr =NULL ;struct ext_filesystem *fs =get_fs (); +int ret =-1 ;/* get the first block of root */ first_block_no_of_root = blknr;@@ -822,12 +823,12 @@ static int check_filename(char *filename, unsigned int blknr) if (ext4fs_put_metadata(root_first_block_addr, first_block_no_of_root)) goto fail; -return inodeno;
fs/ext4/ext4_common.c static int check_filename(char *filename, · line 834
Quoted 10 lines
fs/ext4/ext4_common.c +2
-1+ ret = inodeno; } fail:free (root_first_block_buffer); -return -1 ; +return ret; }int ext4fs_filename_check (char *filename)
Test HW: Odroid XU3 - Exynos5433
[DFU tests]
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 4/10 ext4: fix leak in check_filename()
In reply to Stephen WarrenQuoted 8 lines · Stephen Warren
From: Stephen Warren <[email protected]>
root_first_block_buffershould be free()d in all cases, not just when an error occurs. Fix the success exit path of the function to do this.Signed-off-by Stephen Warren <[email protected]>Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/45d56ad1/attachment.sig>
PATCH 5/10 dfu: don't keep freeing/reallocating
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
DFU currently allocates buffer memory at the start of each data transfer operation and frees it at the end. Especially since memalign() is used to allocate the buffer, and various other allocations happen during the transfer, this can expose the code to heap fragmentation, which prevents the allocation from succeeding on subsequent transfers.
Fix the code to allocate the buffer once when DFU mode is initialized, and free the buffer once when DFU mode is exited, to reduce the exposure to heap fragmentation.
The failure mode is:
// Internally to memalign(), this allocates a lot more than s to guarantee // that alignment can occur, then returns chunks of memory at the start/ // end of the allocated buffer to the heap.
p = memalign(a, s);
// Various other malloc()s occur here, some of which allocate the RAM // immediately before/after "p".
//
// DFU transfer is complete, so buffer is released.
free(p);
// By chance, no other malloc()/free() here, in DFU at least. //
// A new DFU transfer starts, so the buffer is allocated again. // In theory this should succeed since we just free()d a buffer of the // same size. However, this fails because memalign() internally attempts // to allocate much more than "s", yet free(p) above only free()d a // little more than "s".
p = memalign(a, s);
--- drivers/dfu/dfu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dfu/dfu.c +2 -2
@@ -164,7 +164,6 @@ static int dfu_write_buffer_drain(struct dfu_entity *dfu)void dfu_write_transaction_cleanup (struct dfu_entity *dfu) {/* clear everything */ -dfu_free_buf (); dfu->crc =0 ; dfu->offset =0 ; dfu->i_blk_seq_num =0 ;
@@ -385,7 +384,6 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) dfu_hash_algo->name, dfu->crc);puts ("\nUPLOAD ... done\nCtrl+C to exit ...\n" ); -dfu_free_buf (); dfu->i_blk_seq_num =0 ; dfu->crc =0 ; dfu->offset =0 ;
@@ -433,6 +431,7 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt, __func__, interface);return -1 ; } +dfu_get_buf (dfu);return 0 ; }
@@ -441,6 +440,7 @@ void dfu_free_entities(void) {struct dfu_entity *dfu, *p, *t =NULL ; +dfu_free_buf ();list_for_each_entry_safe_reverse (dfu, p, &dfu_list, list) {list_del (&dfu->list);if (dfu->free_entity)
Signature · 1 line
1.9.1
PATCH 5/10 dfu: don't keep freeing/reallocating
Hi Stephen,
Quoted 67 lines
From: Stephen Warren <[email protected]>
DFU currently allocates buffer memory at the start of each data transfer operation and frees it at the end. Especially since
memalign()is used to allocate the buffer, and various other allocations happen during the transfer, this can expose the code to heap fragmentation, which prevents the allocation from succeeding on subsequent transfers.Fix the code to allocate the buffer once when DFU mode is initialized, and free the buffer once when DFU mode is exited, to reduce the exposure to heap fragmentation.
The failure mode is:
// Internally to
memalign(), this allocates a lot more than s to guarantee // that alignment can occur, then returns chunks of memory at the start/ // end of the allocated buffer to the heap.
p =memalign(a, s);
// Various other malloc()s occur here, some of which allocate the RAM // immediately before/after "p".
//
// DFU transfer is complete, so buffer is released. free(p);
// By chance, no other malloc()/free() here, in DFU at least. //
// A new DFU transfer starts, so the buffer is allocated again. // In theory this should succeed since we just free()d a buffer of the // same size. However, this fails becausememalign()internally attempts // to allocate much more than "s", yet free(p) above only free()d a // little more than "s".
p =memalign(a, s);Signed-off-by Stephen Warren <[email protected]>--- drivers/dfu/dfu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dfu/dfu.c +0
-0@@ -164,7 +164,6 @@ static int dfu_write_buffer_drain(struct
dfu_entity*dfu) voiddfu_write_transaction_cleanup(struct dfu_entity *dfu){drivers/dfu/dfu.c +1
-2/* clear everything */ -dfu_free_buf (); dfu->crc =0 ; dfu->offset =0 ; dfu->i_blk_seq_num =0 ;@@ -385,7 +384,6 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) dfu_hash_algo->name, dfu->crc);puts ("\nUPLOAD ... done\nCtrl+C to exit ...\n" ); -dfu_free_buf (); dfu->i_blk_seq_num =0 ; dfu->crc =0 ; dfu->offset =0 ;@@ -433,6 +431,7 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt, __func__, interface);return -1 ; } +dfu_get_buf (dfu);return 0 ; }
drivers/dfu/dfu.c void dfu_free_entities(void) · line 446
Quoted 7 lines
drivers/dfu/dfu.c +1
-0@@ -441,6 +440,7 @@ void dfu_free_entities(void) {struct dfu_entity *dfu, *p, *t =NULL ; +dfu_free_buf ();list_for_each_entry_safe_reverse (dfu, p, &dfu_list, list) {list_del (&dfu->list);if (dfu->free_entity)
Test HW: Odroid XU3 - Exynos5433
[DFU tests]
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 5/10 dfu: don't keep freeing/reallocating
In reply to Stephen WarrenQuoted 32 lines · Stephen Warren
From: Stephen Warren <[email protected]>
DFU currently allocates buffer memory at the start of each data transfer operation and frees it at the end. Especially since
memalign()is used to allocate the buffer, and various other allocations happen during the transfer, this can expose the code to heap fragmentation, which prevents the allocation from succeeding on subsequent transfers.Fix the code to allocate the buffer once when DFU mode is initialized, and free the buffer once when DFU mode is exited, to reduce the exposure to heap fragmentation.
The failure mode is:
// Internally to
memalign(), this allocates a lot more than s to guarantee // that alignment can occur, then returns chunks of memory at the start/ // end of the allocated buffer to the heap.
p =memalign(a, s);
// Various other malloc()s occur here, some of which allocate the RAM // immediately before/after "p".
//
// DFU transfer is complete, so buffer is released.
free(p);
// By chance, no other malloc()/free() here, in DFU at least. //
// A new DFU transfer starts, so the buffer is allocated again. // In theory this should succeed since we just free()d a buffer of the // same size. However, this fails becausememalign()internally attempts // to allocate much more than "s", yet free(p) above only free()d a // little more than "s".
p =memalign(a, s);
Quoted 3 lines
Signed-off-by Stephen Warren <[email protected]>Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/a37082fa/attachment.sig>
PATCH 6/10 dfu: mmc: buffer file reads too
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
When writing to files in a filesystem on MMC, dfu_mmc.c buffers up the entire file content until the end of the transaction, at which point the file is written in one go. This allows writing files larger than the USB transfer size (CONFIG_SYS_DFU_DATA_BUF_SIZE); the maximum written file size is CONFIG_SYS_DFU_MAX_FILE_SIZE (the size of the temporary buffer).
The current file reading code does not do any buffering, and so limits the maximum read file size to the USB transfer size. Enhance the code to do the same kind of buffering as the write path, so the same file size limits apply.
Remove the size checking code from dfu_read() since all read paths now support larger files than the USB transfer buffer.
--- drivers/dfu/dfu.c | 11 ----------- drivers/dfu/dfu_mmc.c | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 12 deletions(-)
drivers/dfu/dfu.c +0 -11
@@ -338,17 +338,6 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) dfu->r_left = dfu->get_medium_size (dfu);if (dfu->r_left <0 )return dfu->r_left; -switch (dfu->layout) { -case DFU_RAW_ADDR : -case DFU_RAM_ADDR : -break ; -default : -if (dfu->r_left > dfu_buf_size) { -printf ("%s: File too big for buffer\n" , - __func__); -return -EOVERFLOW ; - } - }debug ("%s: %s %ld [B]\n" , __func__, dfu->name, dfu->r_left);
drivers/dfu/dfu_mmc.c +26 -1
@@ -18,6 +18,7 @@static unsigned char *dfu_file_buf;static long dfu_file_buf_len; +static long dfu_file_buf_filled;static int mmc_access_part (struct dfu_entity *dfu,struct mmc *mmc,int part) {
@@ -230,9 +231,12 @@ long dfu_get_medium_size_mmc(struct dfu_entity *dfu)return dfu->data.mmc.lba_size * dfu->data.mmc.lba_blk_size;case DFU_FS_FAT :case DFU_FS_EXT4 : + dfu_file_buf_filled =-1 ; ret =mmc_file_op (DFU_OP_SIZE , dfu,NULL , &len);if (ret <0 )return ret; +if (len >CONFIG_SYS_DFU_MAX_FILE_SIZE ) +return -1 ;return len;default : printf("%s: Layout (%s) not (yet) supported!\n", __func__,
@@ -241,6 +245,27 @@ long dfu_get_medium_size_mmc(struct dfu_entity *dfu) } } +static int mmc_file_unbuffer (struct dfu_entity *dfu,u64 offset,void *buf, +long *len) +{ +int ret; +long file_len; + +if (dfu_file_buf_filled ==-1 ) { + ret =mmc_file_op (DFU_OP_READ , dfu, dfu_file_buf, &file_len); +if (ret <0 ) +return ret; + dfu_file_buf_filled = file_len; + } +if (offset + *len > dfu_file_buf_filled) +return -EINVAL ; + +/* Add to the current buffer. */ +memcpy (buf, dfu_file_buf + offset, *len); + +return 0 ; +} +int dfu_read_medium_mmc (struct dfu_entity *dfu,u64 offset,void *buf,long *len) {
@@ -252,7 +277,7 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, u64 offset, void *buf,break ;case DFU_FS_FAT :case DFU_FS_EXT4 : - ret =mmc_file_op (DFU_OP_READ , dfu, buf, len); + ret =mmc_file_unbuffer (dfu, offset, buf, len);break ;default : printf("%s: Layout (%s) not (yet) supported!\n", __func__,
Signature · 1 line
1.9.1
PATCH 6/10 dfu: mmc: buffer file reads too
Hi Stephen,
Quoted 110 lines
From: Stephen Warren <[email protected]>
When writing to files in a filesystem on MMC,
dfu_mmc.cbuffers up the entire file content until the end of the transaction, at which point the file is written in one go. This allows writing files larger than the USB transfer size (CONFIG_SYS_DFU_DATA_BUF_SIZE); the maximum written file size isCONFIG_SYS_DFU_MAX_FILE_SIZE(the size of the temporary buffer).The current file reading code does not do any buffering, and so limits the maximum read file size to the USB transfer size. Enhance the code to do the same kind of buffering as the write path, so the same file size limits apply.
Remove the size checking code from
dfu_read()since all read paths now support larger files than the USB transfer buffer.Signed-off-by Stephen Warren <[email protected]>--- drivers/dfu/dfu.c | 11 ----------- drivers/dfu/dfu_mmc.c | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 12 deletions(-)drivers/dfu/dfu.c +0
-11@@ -338,17 +338,6 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) dfu->r_left = dfu->get_medium_size(dfu);if (dfu->r_left <0 )return dfu->r_left; -switch (dfu->layout) { -case DFU_RAW_ADDR : -case DFU_RAM_ADDR : -break ; -default : -if (dfu->r_left > dfu_buf_size) { -printf ("%s: File too big for buffer\n", - __func__); -return -EOVERFLOW ; - } - } debug("%s: %s %ld [B]\n", __func__, dfu->name,
dfu->r_left);drivers/dfu/dfu_mmc.c +4
-0@@ -18,6 +18,7 @@static unsigned char *dfu_file_buf;static long dfu_file_buf_len; +static long dfu_file_buf_filled;static int mmc_access_part (struct dfu_entity *dfu,struct mmc *mmc,int part) {@@ -230,9 +231,12 @@ long dfu_get_medium_size_mmc(struct dfu_entity *dfu) return dfu->data.mmc.lba_size * dfu->data.mmc.lba_blk_size;case DFU_FS_FAT :case DFU_FS_EXT4 : + dfu_file_buf_filled =-1 ; ret =mmc_file_op (DFU_OP_SIZE , dfu,NULL , &len);if (ret <0 )return ret; +if (len >CONFIG_SYS_DFU_MAX_FILE_SIZE ) +return -1 ;return len;default : printf("%s: Layout (%s) not (yet) supported!\n",
__func__, @@ -241,6 +245,27 @@ longdfu_get_medium_size_mmc(struct dfu_entity *dfu)}
}+static int mmc_file_unbuffer(struct
dfu_entity*dfu, u64 offset, void *buf,drivers/dfu/dfu_mmc.c +7
-0+ long *len) +{ +int ret; +long file_len; + +if (dfu_file_buf_filled ==-1 ) { + ret = mmc_file_op(DFU_OP_READ, dfu, dfu_file_buf,
&file_len);drivers/dfu/dfu_mmc.c +13
-0+if (ret <0 ) +return ret; + dfu_file_buf_filled = file_len; + } +if (offset + *len > dfu_file_buf_filled) +return -EINVAL ; + +/* Add to the current buffer. */ +memcpy (buf, dfu_file_buf + offset, *len); + +return 0 ; +} + int dfu_read_medium_mmc(struct dfu_entity *dfu, u64 offset, void*buf, long *len)
{drivers/dfu/dfu_mmc.c +1
-1@@ -252,7 +277,7 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, u64 offset, void *buf, break;case DFU_FS_FAT :case DFU_FS_EXT4 : - ret =mmc_file_op (DFU_OP_READ , dfu, buf, len); + ret =mmc_file_unbuffer (dfu, offset, buf, len);break ;default : printf("%s: Layout (%s) not (yet) supported!\n",
Quoted 1 line
__func__,
Test HW: Odroid XU3 - Exynos5433
[DFU Tests]
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 6/10 dfu: mmc: buffer file reads too
In reply to Stephen WarrenQuoted 13 lines · Stephen Warren
From: Stephen Warren <[email protected]>
When writing to files in a filesystem on MMC,
dfu_mmc.cbuffers up the entire file content until the end of the transaction, at which point the file is written in one go. This allows writing files larger than the USB transfer size (CONFIG_SYS_DFU_DATA_BUF_SIZE); the maximum written file size isCONFIG_SYS_DFU_MAX_FILE_SIZE(the size of the temporary buffer).The current file reading code does not do any buffering, and so limits the maximum read file size to the USB transfer size. Enhance the code to do the same kind of buffering as the write path, so the same file size limits apply.
Quoted 6 lines
Remove the size checking code from
dfu_read()since all read paths now support larger files than the USB transfer buffer.Signed-off-by Stephen Warren <[email protected]>Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/05b1c8a0/attachment.sig>
PATCH 7/10 ARM: tegra: fix malloc region sizing
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
Commit 52a7c98a1772 "tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition of CONFIG_SYS_MALLOC_LEN for Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until after tegra-common.h is included. Fix this by moving the affected conditional code to tegra-common-post.h, which is included last. Also move the definition of SYS_NONCACHED_MEMORY since it's a related and adjacent definition.
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
--- include/configs/tegra-common-post.h | 14 ++++++++++++++ include/configs/tegra-common.h | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-)
include/configs/tegra-common-post.h +14 -0
@@ -8,6 +8,20 @@#ifndef __TEGRA_COMMON_POST_H#define __TEGRA_COMMON_POST_H +/* +* Size of malloc() pool +*/ +#ifdef CONFIG_USB_FUNCTION_DFU +#define CONFIG_SYS_MALLOC_LEN ((4 << 20) + \ + CONFIG_SYS_DFU_DATA_BUF_SIZE) +#else +#define CONFIG_SYS_MALLOC_LEN (4 << 20)/* 4MB */ +#endif + +#ifndef CONFIG_ARM64 +#define CONFIG_SYS_NONCACHED_MEMORY (1 << 20)/* 1 MiB */ +#endif +#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES (func) \ func(MMC, mmc, 1) \
include/configs/tegra-common.h +0 -14
@@ -37,20 +37,6 @@#define CONFIG_ENV_SIZE 0x2000/* Total Size Environment */ /* -* Size of malloc() pool -*/ -#ifdef CONFIG_DFU_MMC -#define CONFIG_SYS_MALLOC_LEN ((4 << 20) + \ - CONFIG_SYS_DFU_DATA_BUF_SIZE) -#else -#define CONFIG_SYS_MALLOC_LEN (4 << 20)/* 4MB */ -#endif - -#ifndef CONFIG_ARM64 -#define CONFIG_SYS_NONCACHED_MEMORY (1 << 20)/* 1 MiB */ -#endif - -/* * NS16550 Configuration */ #define CONFIG_TEGRA_SERIAL
Signature · 1 line
1.9.1
PATCH 7/10 ARM: tegra: fix malloc region sizing
Stephen,
Quoted 18 lines
-----Original Message-----
From: Stephen Warren [mailto:swarren at wwwdotorg.org]
Sent: Friday, September 04, 2015 9:04 PM
To: Tom Rini
Cc: u-boot at lists.denx.de; Simon Glass; Tom Warren; Stephen Warren; Lukasz Majewski; Przemyslaw Marczak
Subject: [PATCH 07/10] ARM: tegra: fix malloc region sizingFrom: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.
Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>
Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
Thanks,
Tom
--
nvpublic
Quoted 61 lines
--- include/configs/tegra-common-post.h | 14 ++++++++++++++ include/configs/tegra-common.h | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-)include/configs/tegra- renamed from include/configs/tegra-common-post.h +0
-0
common-post.h
indexe67ff7b95715..594fa456d17f100644include/configs/tegra-common-post.h +14
-0@@ -8,6 +8,20 @@#ifndef __TEGRA_COMMON_POST_H#define __TEGRA_COMMON_POST_H +/* +* Size of malloc() pool +*/ +#ifdef CONFIG_USB_FUNCTION_DFU +#define CONFIG_SYS_MALLOC_LEN ((4 << 20) + \ + CONFIG_SYS_DFU_DATA_BUF_SIZE) +#else +#define CONFIG_SYS_MALLOC_LEN (4 << 20)/* 4MB */ +#endif + +#ifndef CONFIG_ARM64 +#define CONFIG_SYS_NONCACHED_MEMORY (1 << 20)/* 1 MiB */ +#endif +#ifndef CONFIG_SPL_BUILD #define
BOOT_TARGET_DEVICES(func)\include/configs/tegra-common-post.h +0
-0func (MMC , mmc,1 ) \include/configs/tegra- renamed from include/configs/tegra-common.h +0
-0
common.hindex6fe5f2ce6543..b886c6450763100644include/configs/tegra-common.h +0
-0@@ -37,20 +37,6 @@#define CONFIG_ENV_SIZE 0x2000/* Total Size Environment */
/*
- * Size ofmalloc()pool
- */include/configs/tegra-common.h +0
-13-#ifdef CONFIG_DFU_MMC -#define CONFIG_SYS_MALLOC_LEN ((4 << 20) + \ - CONFIG_SYS_DFU_DATA_BUF_SIZE) -#else -#define CONFIG_SYS_MALLOC_LEN (4 << 20)/* 4MB */ -#endif - -#ifndef CONFIG_ARM64 -#define CONFIG_SYS_NONCACHED_MEMORY (1 << 20)/* 1 MiB */ -#endif - -/* * NS16550 Configuration */ #define CONFIG_TEGRA_SERIAL --1.9.1
PATCH 7/10 ARM: tegra: fix malloc region sizing
Quoted 13 lines · Tom Warren
Stephen,
Stephen Warren wrote at Friday, September 04, 2015 9:04 PM:
Quoted 10 lines
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.
Quoted 6 lines
Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
I believe the 4 "ARM: tegra:" patches can go through the Tegra tree since they're independent from the other patches in the series. Thanks.
PATCH 7/10 ARM: tegra: fix malloc region sizing
Quoted 17 lines · Stephen Warren
Quoted 16 lines · Tom Warren
Stephen,
Stephen Warren wrote at Friday, September 04, 2015 9:04 PM:
Quoted 13 lines
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Stephen Warren <[email protected]>Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
I believe the 4 "ARM: tegra:" patches can go through the Tegra tree since they're independent from the other patches in the series. Thanks.
I note that Lukasz has ack'd all the other patches, so perhaps you can just take the whole series through the Tegra tree? At least the DFU patches since he's maintainer there. Perhaps TomR can ack the ext4 patches since they don't seem to have a maintainer.
PATCH 7/10 ARM: tegra: fix malloc region sizing
Quoted 22 lines · Stephen Warren
Quoted 21 lines · Stephen Warren
Quoted 19 lines · Tom Warren
Stephen,
Stephen Warren wrote at Friday, September 04, 2015 9:04 PM:
Quoted 10 lines
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
Quoted 7 lines
Quoted 2 lines
I believe the 4 "ARM: tegra:" patches can go through the Tegra tree since they're independent from the other patches in the series. Thanks.
I note that Lukasz has ack'd all the other patches, so perhaps you can just take the whole series through the Tegra tree? At least the DFU patches since he's maintainer there. Perhaps TomR can ack the ext4 patches since they don't seem to have a maintainer.
I think I snagged them all in patchwork for myself. Do the Tegra ones depend on anything else?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150908/fc3ed162/attachment.sig>
PATCH 7/10 ARM: tegra: fix malloc region sizing
Quoted 31 lines · Tom Rini
Quoted 30 lines · Stephen Warren
Quoted 28 lines · Stephen Warren
Quoted 16 lines · Tom Warren
Stephen,
Stephen Warren wrote at Friday, September 04, 2015 9:04 PM:
Quoted 13 lines
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.Quoted 7 lines
Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
I believe the 4 "ARM: tegra:" patches can go through the Tegra tree since they're independent from the other patches in the series. Thanks.
Quoted 8 lines
Quoted 5 lines
I note that Lukasz has ack'd all the other patches, so perhaps you can just take the whole series through the Tegra tree? At least the DFU patches since he's maintainer there. Perhaps TomR can ack the ext4 patches since they don't seem to have a maintainer.
I think I snagged them all in patchwork for myself. Do the Tegra ones depend on anything else?
I don't believe the Tegra patches depend on anything to compile or run; they're just all conceptually related to DFU support on Tegra.
PATCH 7/10 ARM: tegra: fix malloc region sizing
In reply to Stephen WarrenHi Stephen,
Quoted 25 lines · Stephen Warren
Quoted 24 lines · Tom Warren
Quoted 22 lines
Stephen,
Stephen Warren wrote at Friday, September 04, 2015 9:04 PM:
Quoted 12 lines
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
Quoted 7 lines
Quoted 3 lines
I believe the 4 "ARM: tegra:" patches can go through the Tegra tree since they're independent from the other patches in the series. Thanks.
I note that Lukasz has ack'd all the other patches, so perhaps you can just take the whole series through the Tegra tree? At least the DFU patches since he's maintainer there.
I personally would opt for applying this series to one tree. I've already ack'ed those patches, so those can go to any other tree (or even -dfu one when nobody wants to pick them :-)).
Quoted 2 lines
Perhaps TomR can ack the ext4
patches since they don't seem to have a maintainer.
Lack of FS (FAT, EXT4) maintainer is PITTA. I hope that somebody would step up for this position.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 7/10 ARM: tegra: fix malloc region sizing
Quoted 39 lines
-----Original Message-----
From: Lukasz Majewski [mailto:l.majewski at samsung.com]
Sent: Tuesday, September 08, 2015 11:51 PM
To: Stephen Warren
Cc: Tom Warren; Tom Rini; Stephen Warren; u-boot at lists.denx.de; Simon Glass; Przemyslaw Marczak
Subject: Re: [PATCH 07/10] ARM: tegra: fix malloc region sizingHi Stephen,
Quoted 29 lines · Stephen Warren
Quoted 27 lines · Tom Warren
Quoted 15 lines
Stephen,
Stephen Warren wrote at Friday, September 04, 2015 9:04 PM:
Quoted 12 lines
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.Quoted 7 lines
Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>Do you want me to take these last four in to u-boot-tegra for the pending PR, or do you expect them to go in another way?
I believe the 4 "ARM: tegra:" patches can go through the Tegra tree since they're independent from the other patches in the series. Thanks.
Quoted 7 lines
Quoted 3 lines
I note that Lukasz has ack'd all the other patches, so perhaps you can just take the whole series through the Tegra tree? At least the DFU patches since he's maintainer there.
I personally would opt for applying this series to one tree. I've already ack'ed those patches, so those can go to any other tree (or even -dfu one when nobody wants to pick them :-)).
I believe TomR has taken over all of these patches in Patchwork, so perhaps he's going to take them in to u-boot/master.
Tom
--
nvpublic
Quoted 13 lines
Quoted 3 lines
Perhaps TomR can ack the ext4
patches since they don't seem to have a maintainer.Lack of FS (FAT, EXT4) maintainer is PITTA. I hope that somebody would step up for this position.
--
Best regards,Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 7/10 ARM: tegra: fix malloc region sizing
In reply to Stephen WarrenQuoted 11 lines · Stephen Warren
From: Stephen Warren <[email protected]>
Commit
52a7c98a1772"tegra-common: increase malloc pool len by dfu mmc file buffer size" updated the definition ofCONFIG_SYS_MALLOC_LENfor Tegra to take account of the DFU buffer size. However, this change had no effect, since typical Tegra board config headers don't set the DFU- related defines until aftertegra-common.his included. Fix this by moving the affected conditional code totegra-common-post.h, which is included last. Also move the definition ofSYS_NONCACHED_MEMORYsince it's a related and adjacent definition.
Quoted 4 lines
Fix the condition to test for the DFU feature, rather than specifically MMC DFU support, so it applies in all cases.
Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/460d0de6/attachment.sig>
PATCH 8/10 ARM: tegra: tweak DFU buffer sizes
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
CONFIG_SYS_DFU_DATA_BUF_SIZE defines the size of chunks transferred across USB. This doesn't need to be particularly large, since it doesn't limit the overall transfer size.
CONFIG_SYS_DFU_MAX_FILE_SIZE is used to buffer an entire file before writing it to a filesystem. This define limits the maximum file size that may be transferred. Bump this up to 32MiB in order to support large uncompressed kernel images.
Both of these buffers are dynamically allocated, and so the size of both needs to be taken into account when calculating the required malloc region size.
--- include/configs/tegra-common-post.h | 5 +++-- include/configs/tegra-common-usb-gadget.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)
include/configs/tegra-common-post.h +3 -2
@@ -12,8 +12,9 @@* Size of malloc() pool */ #ifdef CONFIG_USB_FUNCTION_DFU -#define CONFIG_SYS_MALLOC_LEN ((4 << 20) + \ - CONFIG_SYS_DFU_DATA_BUF_SIZE) +#define CONFIG_SYS_MALLOC_LEN (SZ_4M + \ + CONFIG_SYS_DFU_DATA_BUF_SIZE + \ + CONFIG_SYS_DFU_MAX_FILE_SIZE)#else #define CONFIG_SYS_MALLOC_LEN (4 << 20)/* 4MB */ #endif
include/configs/tegra-common-usb-gadget.h +2 -1
@@ -30,7 +30,8 @@#define CONFIG_CMD_USB_MASS_STORAGE /* DFU protocol */ #define CONFIG_USB_FUNCTION_DFU -#define CONFIG_SYS_DFU_DATA_BUF_SIZE (1 * 1024 * 1024) +#define CONFIG_SYS_DFU_DATA_BUF_SIZE SZ_1M +#define CONFIG_SYS_DFU_MAX_FILE_SIZE SZ_32M#define CONFIG_CMD_DFU #ifdef CONFIG_MMC #define CONFIG_DFU_MMC
Signature · 1 line
1.9.1
PATCH 8/10 ARM: tegra: tweak DFU buffer sizes
Quoted 11 lines · Stephen Warren
From: Stephen Warren <[email protected]>
CONFIG_SYS_DFU_DATA_BUF_SIZEdefines the size of chunks transferred across USB. This doesn't need to be particularly large, since it doesn't limit the overall transfer size.
CONFIG_SYS_DFU_MAX_FILE_SIZEis used to buffer an entire file before writing it to a filesystem. This define limits the maximum file size that may be transferred. Bump this up to 32MiB in order to support large uncompressed kernel images.
Quoted 5 lines
Both of these buffers are dynamically allocated, and so the size of both needs to be taken into account when calculating the required malloc region size.
Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/c9ebe9b2/attachment.sig>
PATCH 9/10 ARM: tegra: enable filesystem writing
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
Writing to files is a useful feature in general, so enable it everywhere. The primary purpose is to make DFU useful on filesystems in addition to raw devices.
--- include/configs/tegra-common.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/tegra-common.h +2 -0
@@ -140,6 +140,8 @@#ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h> +#define CONFIG_CMD_EXT4_WRITE +#define CONFIG_FAT_WRITE #endif #endif /* _TEGRA_COMMON_H_ */
Signature · 1 line
1.9.1
PATCH 9/10 ARM: tegra: enable filesystem writing
Quoted 7 lines · Stephen Warren
From: Stephen Warren <[email protected]>
Writing to files is a useful feature in general, so enable it everywhere. The primary purpose is to make DFU useful on filesystems in addition to raw devices.
Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/497872f9/attachment.sig>
PATCH 10/10 ARM: tegra: enable DFU for RAM
In reply to Stephen WarrenFrom: Stephen Warren <[email protected]>
This allows transferring data directly to/from RAM. For example, one could create a boot script that starts DFU on a RAM region, then once DFU exits (which is under the control of the attached USB host, via a USB bus reset), uses the code/data that was received over DFU.
--- include/configs/tegra-common-usb-gadget.h | 1 + 1 file changed, 1 insertion(+)
include/configs/tegra-common-usb-gadget.h +1 -0
@@ -39,6 +39,7 @@#ifdef CONFIG_SPI_FLASH #define CONFIG_DFU_SF #endif +#define CONFIG_DFU_RAM #endif #endif /* _TEGRA_COMMON_USB_GADGET_H_ */
Signature · 1 line
1.9.1
PATCH 10/10 ARM: tegra: enable DFU for RAM
Quoted 8 lines · Stephen Warren
From: Stephen Warren <[email protected]>
This allows transferring data directly to/from RAM. For example, one could create a boot script that starts DFU on a RAM region, then once DFU exits (which is under the control of the attached USB host, via a USB bus reset), uses the code/data that was received over DFU.
Signed-off-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/68935ad5/attachment.sig>
PATCH 1/10 usb: gadget: don't leak configs when unbinding
In reply to Stephen WarrenHi Stephen,
Quoted 35 lines
From: Stephen Warren <[email protected]>
By the time
g_dnl_unbind()is run,cdev->confighas been set to NULL, so thefree()there does nothing, and the config struct is leaked. Equally, structusb_gadgetcontains a linked list of config structs, so the code should iterate over them all and free each one, rather than freeing one particular config struct.
composite_unbind()already iterates over the list of config structs, and unlinks each from the linked list. Fix this loop tofree()each struct as it's unlinked and otherwise forgotten.Signed-off-by Stephen Warren <[email protected]>--- drivers/usb/gadget/composite.c | 1 + drivers/usb/gadget/g_dnl.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/composite.cindexd96296cd73b1..a13b21d0a0f2100644 ---a/drivers/usb/gadget/composite.c
+++b/drivers/usb/gadget/composite.cdrivers/usb/gadget/composite.c +1
-0@@ -948,6 +948,7 @@ static void composite_unbind(struct usb_gadget *gadget) debug("unbind config '%s'/%p\n", c->label, c); c->unbind (c); } +free (c); }if (composite->unbind) composite->unbind (cdev);drivers/usb/gadget/g_dnl.c +0
-0
drivers/usb/gadget/g_dnl.c static int g_dnl_unbind(struct usb_composite_dev · line 98
Quoted 8 lines
drivers/usb/gadget/g_dnl.c +0
-2@@ -93,8 +93,6 @@ static int g_dnl_unbind(struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; -free (cdev->config); - cdev->config =NULL ;debug ("%s: calling usb_gadget_disconnect for " "controller '%s'\n" , __func__, gadget->name);usb_gadget_disconnect (gadget);
Test HW: Odroid XU3 - Exynos5433.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 1/10 usb: gadget: don't leak configs when unbinding
Quoted 13 lines · Lukasz Majewski
Hi Stephen,
Quoted 11 lines
From: Stephen Warren <[email protected]>
By the time
g_dnl_unbind()is run,cdev->confighas been set to NULL, so thefree()there does nothing, and the config struct is leaked. Equally, structusb_gadgetcontains a linked list of config structs, so the code should iterate over them all and free each one, rather than freeing one particular config struct.
composite_unbind()already iterates over the list of config structs, and unlinks each from the linked list. Fix this loop tofree()each struct as it's unlinked and otherwise forgotten.
...
Quoted 5 lines
Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>Test HW: Odroid XU3 - Exynos5433.
Thanks for all the tests/acks.
PATCH 1/10 usb: gadget: don't leak configs when unbinding
In reply to Stephen WarrenQuoted 8 lines · Stephen Warren
From: Stephen Warren <[email protected]>
By the time
g_dnl_unbind()is run,cdev->confighas been set to NULL, so thefree()there does nothing, and the config struct is leaked. Equally, structusb_gadgetcontains a linked list of config structs, so the code should iterate over them all and free each one, rather than freeing one particular config struct.
Quoted 7 lines
composite_unbind()already iterates over the list of config structs, and unlinks each from the linked list. Fix this loop tofree()each struct as it's unlinked and otherwise forgotten.Signed-off-by Stephen Warren <[email protected]>Acked-by Lukasz Majewski <[email protected]>Tested-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/e0a8d093/attachment.sig>