Patchwork [U-Boot] Do not copy to same address

login
register
mail settings
Submitter Matthias Weisser
Date April 12, 2011, 6:58 a.m.
Message ID <1302591520-12517-1-git-send-email-weisserm@arcor.de>
Download mbox | patch
Permalink /patch/90725/
State Superseded
Delegated to: Albert ARIBAUD
Headers show

Comments

Matthias Weisser - April 12, 2011, 6:58 a.m.
In some cases (e.g. bootm with a elf payload) there is a in place copy of
data to the same address. Catching this saves some ms while booting.

Signed-off-by: Matthias Weisser <weisserm@arcor.de>
---
 lib/string.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Mike Frysinger - April 12, 2011, 7:05 a.m.
this summary is kind of weak.  please prefix it with something like "string:" 
or "memcpy/memmove:".  keep in mind that the summary needs to quickly pick out 
what the changeset is doing from every other changeset in the tree based only 
on that.  or at least give a pretty good idea.

side note, i wonder why we even bother with bcopy at all.  i dont see any 
users of it in the tree ...
-mike
Albert ARIBAUD - April 12, 2011, 7:06 a.m.
Hi Matthias,

Le 12/04/2011 08:58, Matthias Weisser a écrit :
> In some cases (e.g. bootm with a elf payload) there is a in place copy of
> data to the same address. Catching this saves some ms while booting.
>
> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
> ---
>   lib/string.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)

I believe that is a V2 patch, right? Please tag it as V2 in the subject 
line, and add patch history below the commit message delimiter ('---' ).

Amicalement,
Matthias Weisser - April 12, 2011, 7:13 a.m.
Am 12.04.2011 09:06, schrieb Albert ARIBAUD:
> Hi Matthias,
>
> Le 12/04/2011 08:58, Matthias Weisser a écrit :
>> In some cases (e.g. bootm with a elf payload) there is a in place copy of
>> data to the same address. Catching this saves some ms while booting.
>>
>> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
>> ---
>>    lib/string.c |    9 +++++++++
>>    1 files changed, 9 insertions(+), 0 deletions(-)
>
> I believe that is a V2 patch, right? Please tag it as V2 in the subject
> line, and add patch history below the commit message delimiter ('---' ).

No, it is a replacement for http://patchwork.ozlabs.org/patch/79447/ 
which picks up a suggestion from Wolfgang.

Regards,
Matthias
Matthias Weisser - April 12, 2011, 7:16 a.m.
Am 12.04.2011 09:05, schrieb Mike Frysinger:
> this summary is kind of weak.  please prefix it with something like "string:"
> or "memcpy/memmove:".  keep in mind that the summary needs to quickly pick out
> what the changeset is doing from every other changeset in the tree based only
> on that.  or at least give a pretty good idea.

OK. I will wait for additional comments and post a V2 then.

> side note, i wonder why we even bother with bcopy at all.  i dont see any
> users of it in the tree ...

I see the same. But removal of bcopy should be a separate patch.

Regards,
Matthias
Albert ARIBAUD - April 12, 2011, 7:27 a.m.
Hi Matthias,

Le 12/04/2011 09:13, Matthias Weißer a écrit :
> Am 12.04.2011 09:06, schrieb Albert ARIBAUD:
>> Hi Matthias,
>>
>> Le 12/04/2011 08:58, Matthias Weisser a écrit :
>>> In some cases (e.g. bootm with a elf payload) there is a in place
>>> copy of
>>> data to the same address. Catching this saves some ms while booting.
>>>
>>> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
>>> ---
>>> lib/string.c | 9 +++++++++
>>> 1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> I believe that is a V2 patch, right? Please tag it as V2 in the subject
>> line, and add patch history below the commit message delimiter ('---' ).
>
> No, it is a replacement for http://patchwork.ozlabs.org/patch/79447/
> which picks up a suggestion from Wolfgang.

So it is a V3, not V2, but still you must tag it so that readers who see 
the previous patch can relate it to the 'replacement' -- yes, even if 
the files touched by V2 are different.

> Regards,
> Matthias

Amicalement,
Matthias Weisser - April 12, 2011, 7:49 a.m.
Am 12.04.2011 09:27, schrieb Albert ARIBAUD:
> Hi Matthias,
>
> Le 12/04/2011 09:13, Matthias Weißer a écrit :
>> Am 12.04.2011 09:06, schrieb Albert ARIBAUD:
>>> Hi Matthias,
>>>
>>> Le 12/04/2011 08:58, Matthias Weisser a écrit :
>>>> In some cases (e.g. bootm with a elf payload) there is a in place
>>>> copy of
>>>> data to the same address. Catching this saves some ms while booting.
>>>>
>>>> Signed-off-by: Matthias Weisser<weisserm@arcor.de>
>>>> ---
>>>> lib/string.c | 9 +++++++++
>>>> 1 files changed, 9 insertions(+), 0 deletions(-)
>>>
>>> I believe that is a V2 patch, right? Please tag it as V2 in the subject
>>> line, and add patch history below the commit message delimiter ('---' ).
>>
>> No, it is a replacement for http://patchwork.ozlabs.org/patch/79447/
>> which picks up a suggestion from Wolfgang.
>
> So it is a V3, not V2, but still you must tag it so that readers who see
> the previous patch can relate it to the 'replacement' -- yes, even if
> the files touched by V2 are different.

Well, as the patch is only slightly related to my original one I thought 
it is better to start a new patch as I had to change the subject also. 
The only relation between them would be the reference in the mail 
header. Maybe Wolfgang can bring some light into this situation.

What would be the right way to post this patch? And what would be the 
right way to post a patch doing exactly the same to the ARM optimized 
version of memcpy?

Sorry for all that administrative questions.

Regards,
Matthias
Albert ARIBAUD - April 14, 2011, 6:28 a.m.
Hi Matthias,

Le 12/04/2011 09:49, Matthias Weißer a écrit :

> Well, as the patch is only slightly related to my original one I thought
> it is better to start a new patch as I had to change the subject also.
> The only relation between them would be the reference in the mail
> header. Maybe Wolfgang can bring some light into this situation.
>
> What would be the right way to post this patch?

Never mind with the previous patch, then; but please keep history of 
this one (maybe including a patchwork URL pointing to the previous patch 
with the other name) and tag its V2 in the subject line.

> And what would be the
> right way to post a patch doing exactly the same to the ARM optimized
> version of memcpy?

Simply submit a separate patch.

> Regards,
> Matthias

Amicalement,

Patch

diff --git a/lib/string.c b/lib/string.c
index b375b81..b8a9203 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -445,6 +445,9 @@  char * bcopy(const char * src, char * dest, int count)
 {
 	char *tmp = dest;
 
+	if (src == dest)
+		return dest;
+
 	while (count--)
 		*tmp++ = *src++;
 
@@ -467,6 +470,9 @@  void * memcpy(void *dest, const void *src, size_t count)
 	unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
 	char *d8, *s8;
 
+	if (src == dest)
+		return dest;
+
 	/* while all data is aligned (common case), copy a word at a time */
 	if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
 		while (count >= sizeof(*dl)) {
@@ -497,6 +503,9 @@  void * memmove(void * dest,const void *src,size_t count)
 {
 	char *tmp, *s;
 
+	if (src == dest)
+		return dest;
+
 	if (dest <= src) {
 		tmp = (char *) dest;
 		s = (char *) src;