2018-07-02 03:57:12

by Li Zhijian

[permalink] [raw]
Subject: [PATCH 0/3] fix selftests compiling errors and warnings


Li Zhijian (3):
selftests/android: fix compiling error
selftests/android: initialize heap_type to avoid compiling warning
selftests/gpio: unset OUTPUT for build tools/gpio

tools/testing/selftests/android/ion/Makefile | 5 ++++-
tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
tools/testing/selftests/gpio/Makefile | 2 +-
3 files changed, 12 insertions(+), 2 deletions(-)

--
2.7.4



2018-07-02 03:56:45

by Li Zhijian

[permalink] [raw]
Subject: [PATCH 2/3] selftests/android: initialize heap_type to avoid compiling warning

root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
make[1]: Entering directory '/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
gcc -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g ionapp_export.c ipcsocket.c ionutils.c -o ionapp_export
ionapp_export.c: In function 'main':
ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
this function [-Wmaybe-uninitialized]
printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CC: Shuah Khan <[email protected]>
CC: Pintu Agarwal <[email protected]>
Signed-off-by: Li Zhijian <[email protected]>
---
tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/android/ion/ionapp_export.c b/tools/testing/selftests/android/ion/ionapp_export.c
index a944e72..e3435c2 100644
--- a/tools/testing/selftests/android/ion/ionapp_export.c
+++ b/tools/testing/selftests/android/ion/ionapp_export.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
return -1;
}

+ heap_type = -1UL;
heap_size = 0;
flags = 0;

@@ -82,6 +83,12 @@ int main(int argc, char *argv[])
}
}

+ if (heap_type == -1UL) {
+ printf("heap_type is invalid\n");
+ print_usage(argc, argv);
+ exit(1);
+ }
+
if (heap_size <= 0) {
printf("heap_size cannot be 0\n");
print_usage(argc, argv);
--
2.7.4


2018-07-02 03:58:21

by Li Zhijian

[permalink] [raw]
Subject: [PATCH 3/3] selftests/gpio: unset OUTPUT for build tools/gpio

when we execute 'make' to build selftests, the TOP Makefile build gpio like:
selftests$ make ARCH= CROSS_COMPILE= OUTPUT=/home/lizj/linux/tools/testing/selftests/gpio -C gpio
...
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/gpio-mockup-chardev.c ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -lmount -o gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
<builtin>: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:84: recipe for target 'all' failed
make: *** [all] Error 2

CC: Bamvor Jian Zhang <[email protected]>
CC: Bartosz Golaszewski <[email protected]>
CC: Shuah Khan <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
tools/testing/selftests/gpio/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 1bbb475..e64a11c 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -24,7 +24,7 @@ LDLIBS += -lmount -I/usr/include/libmount
$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h

../../../gpio/gpio-utils.o:
- make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+ make OUTPUT= ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio

../../../../usr/include/linux/gpio.h:
make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
--
2.7.4


2018-07-02 03:58:21

by Li Zhijian

[permalink] [raw]
Subject: [PATCH 1/3] selftests/android: fix compiling error

lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests/android/ion$ make
gcc -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g ionapp_export.c ipcsocket.c ionutils.c -o ionapp_export
gcc -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g ionapp_import.c ipcsocket.c ionutils.c -o ionapp_import
gcc -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g ionmap_test.c ipcsocket.c ionutils.c -o ionmap_test
ionmap_test.c:12:27: fatal error: linux/dma-buf.h: No such file or directory
compilation terminated.
<builtin>: recipe for target 'ionmap_test' failed
make: *** [ionmap_test] Error 1

It requires headers_install to $TOP/usr

CC: Shuah Khan <[email protected]>
CC: Pintu Agarwal <[email protected]>
Signed-off-by: Li Zhijian <[email protected]>
---
tools/testing/selftests/android/ion/Makefile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile
index e036952..9f83299 100644
--- a/tools/testing/selftests/android/ion/Makefile
+++ b/tools/testing/selftests/android/ion/Makefile
@@ -4,7 +4,10 @@ CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g

TEST_GEN_FILES := ionapp_export ionapp_import ionmap_test

-all: $(TEST_GEN_FILES)
+all: ../../../../../usr/include/linux/dma-buf.h $(TEST_GEN_FILES)
+
+../../../../../usr/include/linux/dma-buf.h:
+ make -C ../../../../../ headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../../usr

$(TEST_GEN_FILES): ipcsocket.c ionutils.c

--
2.7.4


2018-07-10 08:41:08

by Li Zhijian

[permalink] [raw]
Subject: Re: [PATCH 0/3] fix selftests compiling errors and warnings

ping


On 07/02/2018 11:53 AM, Li Zhijian wrote:
> Li Zhijian (3):
> selftests/android: fix compiling error
> selftests/android: initialize heap_type to avoid compiling warning
> selftests/gpio: unset OUTPUT for build tools/gpio
>
> tools/testing/selftests/android/ion/Makefile | 5 ++++-
> tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
> tools/testing/selftests/gpio/Makefile | 2 +-
> 3 files changed, 12 insertions(+), 2 deletions(-)
>



2018-07-10 14:10:01

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 0/3] fix selftests compiling errors and warnings

On 07/10/2018 02:38 AM, Li Zhijian wrote:
> ping
>
>
> On 07/02/2018 11:53 AM, Li Zhijian wrote:
>> Li Zhijian (3):
>>    selftests/android: fix compiling error
>>    selftests/android: initialize heap_type to avoid compiling warning
>>    selftests/gpio: unset OUTPUT for build tools/gpio
>>
>>   tools/testing/selftests/android/ion/Makefile        | 5 ++++-
>>   tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
>>   tools/testing/selftests/gpio/Makefile               | 2 +-
>>   3 files changed, 12 insertions(+), 2 deletions(-)
>>
>
>
>

I was away on vacation all of last week. I will review the series.
Anders Roxell is working on making the change at the main Makefile
level to handle the headers dependency. I have been waiting to hear
from Maintainers to Ack it.

Once Anders patch goes in, is the first and third patches in this series
needed?

No problems with the second one. I can get that in soon.

thanks,
-- Shuah

2018-07-10 14:53:27

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 2/3] selftests/android: initialize heap_type to avoid compiling warning

Hi Li Zhijian,

On 07/01/2018 09:53 PM, Li Zhijian wrote:
> root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
> make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
> make[1]: Entering directory '/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
> gcc -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g ionapp_export.c ipcsocket.c ionutils.c -o ionapp_export
> ionapp_export.c: In function 'main':
> ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
> printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> CC: Shuah Khan <[email protected]>
> CC: Pintu Agarwal <[email protected]>
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/android/ion/ionapp_export.c b/tools/testing/selftests/android/ion/ionapp_export.c
> index a944e72..e3435c2 100644
> --- a/tools/testing/selftests/android/ion/ionapp_export.c
> +++ b/tools/testing/selftests/android/ion/ionapp_export.c
> @@ -49,6 +49,7 @@ int main(int argc, char *argv[])
> return -1;
> }
>
> + heap_type = -1UL;

Initialize it to one of the valid types. ION_HEAP_TYPE_SYSTEM
is one choice.


> heap_size = 0;
> flags = 0;
>
> @@ -82,6 +83,12 @@ int main(int argc, char *argv[])
> }
> }
>
> + if (heap_type == -1UL) {
> + printf("heap_type is invalid\n");
> + print_usage(argc, argv);
> + exit(1);
> + }

This check isn't necessary. The test requires two arguments,
-i <heap id> and -s <size in bytes> and won't run without either
one of them. heap_type is going to be ION_HEAP_TYPE_SYSTEM or
ION_HEAP_TYPE_SYSTEM_CONTIG at this point.

Interesting. Looks like this test doesn't cover all ion_heap_types.

thanks,
-- Shuah

2018-07-10 18:17:48

by Pintu Kumar

[permalink] [raw]
Subject: Re: [PATCH 2/3] selftests/android: initialize heap_type to avoid compiling warning

On Tue, Jul 10, 2018 at 8:20 PM Shuah Khan <[email protected]> wrote:
>
> Hi Li Zhijian,
>
> On 07/01/2018 09:53 PM, Li Zhijian wrote:
> > root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
> > make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
> > make[1]: Entering directory '/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
> > gcc -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -Wall -O2 -g ionapp_export.c ipcsocket.c ionutils.c -o ionapp_export
> > ionapp_export.c: In function 'main':
> > ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
> > this function [-Wmaybe-uninitialized]
> > printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > CC: Shuah Khan <[email protected]>
> > CC: Pintu Agarwal <[email protected]>
> > Signed-off-by: Li Zhijian <[email protected]>
> > ---
> > tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/tools/testing/selftests/android/ion/ionapp_export.c b/tools/testing/selftests/android/ion/ionapp_export.c
> > index a944e72..e3435c2 100644
> > --- a/tools/testing/selftests/android/ion/ionapp_export.c
> > +++ b/tools/testing/selftests/android/ion/ionapp_export.c
> > @@ -49,6 +49,7 @@ int main(int argc, char *argv[])
> > return -1;
> > }
> >
> > + heap_type = -1UL;
>
> Initialize it to one of the valid types. ION_HEAP_TYPE_SYSTEM
> is one choice.
>
Yes, the test requires at least one of the heap type.
If you want, you can set it to the default value (0) at the
initialization time and not -1.

>
> > heap_size = 0;
> > flags = 0;
> >
May be we can set the heap_type as 0 here, to avoid those
uninitialized warnings.

> > @@ -82,6 +83,12 @@ int main(int argc, char *argv[])
> > }
> > }
> >
> > + if (heap_type == -1UL) {
> > + printf("heap_type is invalid\n");
> > + print_usage(argc, argv);
> > + exit(1);
> > + }
>
> This check isn't necessary. The test requires two arguments,
> -i <heap id> and -s <size in bytes> and won't run without either
> one of them. heap_type is going to be ION_HEAP_TYPE_SYSTEM or
> ION_HEAP_TYPE_SYSTEM_CONTIG at this point.
>
> Interesting. Looks like this test doesn't cover all ion_heap_types.
>
Yes, all heap_types were not supported. As per Laura's request I removed it.
Other heap_types actually requires explicit declaration of reserved
memory or CMA region.

If you require other heap_type support then may be you can look into
my github version:
https://github.com/pintuk/LINUX/tree/master/android/ion


> thanks,
> -- Shuah

2018-07-11 01:38:03

by Li Zhijian

[permalink] [raw]
Subject: Re: [PATCH 0/3] fix selftests compiling errors and warnings



On 07/10/2018 10:08 PM, Shuah Khan wrote:
> On 07/10/2018 02:38 AM, Li Zhijian wrote:
>> ping
>>
>>
>> On 07/02/2018 11:53 AM, Li Zhijian wrote:
>>> Li Zhijian (3):
>>>    selftests/android: fix compiling error
>>>    selftests/android: initialize heap_type to avoid compiling warning
>>>    selftests/gpio: unset OUTPUT for build tools/gpio
>>>
>>>   tools/testing/selftests/android/ion/Makefile        | 5 ++++-
>>>   tools/testing/selftests/android/ion/ionapp_export.c | 7 +++++++
>>>   tools/testing/selftests/gpio/Makefile               | 2 +-
>>>   3 files changed, 12 insertions(+), 2 deletions(-)
>>>
>>
>>
> I was away on vacation all of last week. I will review the series.
> Anders Roxell is working on making the change at the main Makefile
> level to handle the headers dependency.

Good to know this, looking forward it


> I have been waiting to hear
> from Maintainers to Ack it.
>
> Once Anders patch goes in, is the first and third patches in this series
> needed?

I will have a check once his patch is merged


Thanks

>
> No problems with the second one. I can get that in soon.
>
> thanks,
> -- Shuah
>
>
> .
>