Skip to contentSkip to conversation

mm: cma: add a simple kernel module as the helper to test CMA

PATCH Superseded Barry Song 4 participants 8 messages Mar 7, 2012 – Jul 4, 2012

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v4 1/1 mm: cma: add a simple kernel module as the helper to test CMA

From: Barry Song <[email protected]>

Any write request to /dev/cma_test will let the module to allocate memory from CMA, for example:

1st time

$ echo 1024 > /dev/cma_test
will require cma_test to request 1MB(1024KB)
2nd time
$ echo 2048 > /dev/cma_test
will require cma_test to request 2MB(2048KB)

Any read request to /dev/cma_test will let the module to free the 1st valid memory from CMA, for example:

1st time

$ cat /dev/cma_test
will require cma_test to free the 1MB allocated in the first write request
2nd time
$ cat /dev/cma_test
will require cma_test to free the 2MB allocated in the second write request
---
 tools/cma/Makefile   |   13 +++++
 tools/cma/cma_test.c |  140 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 153 insertions(+), 0 deletions(-)
 create mode 100644 tools/cma/Makefile
 create mode 100644 tools/cma/cma_test.c
tools/cma/Makefile new file +13 -0
new file mode 100644
index 0000000..d15c2c0
@@ -0,0 +1,13 @@
+# Kernel modules
+#
+# To compile for ARM:
+# make ARCH=arm CC=arm-none-linux-gnueabi-gcc
+#
+obj-m	+= cma_test.o
+
+build: kernel_modules
+
+kernel_modules:
+	${MAKE} -C $(CURDIR)/../.. M=$(CURDIR)
+clean:
+	${MAKE} -C $(CURDIR)/../.. M=$(CURDIR) clean
tools/cma/cma_test.c new file +140 -0

140 lines not on this page · raw message

Signature · 6 lines
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Reviewed-by on v4 1/1
#1 lore raw
Quoted 13 lines · Barry Song

Any write request to /dev/cma_test will let the module to allocate memory from CMA, for example:

1st time

$ echo 1024 > /dev/cma_test
will require cma_test to request 1MB(1024KB)
2nd time
$ echo 2048 > /dev/cma_test
will require cma_test to request 2MB(2048KB)

Any read request to /dev/cma_test will let the module to free the 1st valid memory from CMA, for example:

Quoted 8 lines

1st time

$ cat /dev/cma_test
will require cma_test to free the 1MB allocated in the first write request
2nd time
$ cat /dev/cma_test
will require cma_test to free the 2MB allocated in the second write request
Signature · 4 lines
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz    (o o)
ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo--
#2 lore raw
In reply to Barry Song

Hello,

Quoted 22 lines · Barry Song

From: Barry Song <[email protected]>

Any write request to /dev/cma_test will let the module to allocate memory from CMA, for example:

1st time

$ echo 1024 > /dev/cma_test
will require cma_test to request 1MB(1024KB)
2nd time
$ echo 2048 > /dev/cma_test
will require cma_test to request 2MB(2048KB)

Any read request to /dev/cma_test will let the module to free the 1st valid memory from CMA, for example:

1st time

$ cat /dev/cma_test
will require cma_test to free the 1MB allocated in the first write request
2nd time
$ cat /dev/cma_test
will require cma_test to free the 2MB allocated in the second write request
Quoted 4 lines
---
 tools/cma/Makefile   |   13 +++++
 tools/cma/cma_test.c |  140 ++++++++++++++++++++++++++++++++++++++++++++++++++

I'm sorry for such a long delay in processing this patch, but I wanted first to be sure that the core CMA code gets into mainline, then I got busy with other dma-mapping related stuff.

IMHO the right place for such code is in drivers/misc instead of tools/cma.

This patch contains a kernel module source code so it should be put with other kernel modules. tools/ directory is aimed to contain user space code useful for developing and testing Linux kernel.

Make sure that you also add Greg Kroah-Hartman <[email protected]> on CC:, he maintains misc drivers.

Quoted 1 line

(snipped)

Best regards

Signature · 2 lines
Marek Szyprowski
Samsung Poland R&D Center
#3 lore raw

Hi Marek,

2012/7/3 Marek Szyprowski <[email protected]>:

Quoted 26 lines

Hello,

Quoted 22 lines · Barry Song

From: Barry Song <[email protected]>

Any write request to /dev/cma_test will let the module to allocate memory from CMA, for example:

1st time

$ echo 1024 > /dev/cma_test
will require cma_test to request 1MB(1024KB)
2nd time
$ echo 2048 > /dev/cma_test
will require cma_test to request 2MB(2048KB)

Any read request to /dev/cma_test will let the module to free the 1st valid memory from CMA, for example:

1st time

$ cat /dev/cma_test
will require cma_test to free the 1MB allocated in the first write request
2nd time
$ cat /dev/cma_test
will require cma_test to free the 2MB allocated in the second write request
Quoted 8 lines
Quoted 4 lines
---
 tools/cma/Makefile   |   13 +++++
 tools/cma/cma_test.c |  140 ++++++++++++++++++++++++++++++++++++++++++++++++++

I'm sorry for such a long delay in processing this patch, but I wanted first to be sure that the core CMA code gets into mainline, then I got busy with other dma-mapping related stuff.

now CMA stuff has been in mainline, i think it makes more senses if you involve this while you let people merge CMA because it is a CMA test component.

Quoted 6 lines

IMHO the right place for such code is in drivers/misc instead of tools/cma.

This patch contains a kernel module source code so it should be put with other kernel modules. tools/ directory is aimed to contain user space code useful for developing and testing Linux kernel.

this one is aiming to test CMA, it should be in tools/ as Michal Nazarewicz and i have talked about that.
it is not a real driver at all.

Quoted 10 lines

Make sure that you also add Greg Kroah-Hartman <[email protected]> on CC:, he maintains misc drivers.

Quoted 1 line

(snipped)

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

-barry

#4 lore raw
Quoted 6 lines

2012/7/3 Marek Szyprowski <[email protected]>:

Quoted 5 lines

IMHO the right place for such code is in drivers/misc instead of tools/cma.

This patch contains a kernel module source code so it should be put with other kernel modules. tools/ directory is aimed to contain user space code useful for developing and testing Linux kernel.

Quoted 3 lines · Barry Song

this one is aiming to test CMA, it should be in tools/ as Michal Nazarewicz and i have talked about that.
it is not a real driver at all.

Yeah, I feel like it's better placed in tools/ not to pollute other directories with drivers that are of no use to regular users. I don't have strong feelings about it though, so I'm fine either way.

Signature · 4 lines
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz    (o o)
ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo--
#5 lore raw

Hello,

Quoted 7 lines · Michal Nazarewicz
Quoted 6 lines

2012/7/3 Marek Szyprowski <[email protected]>:

Quoted 5 lines

IMHO the right place for such code is in drivers/misc instead of tools/cma.

This patch contains a kernel module source code so it should be put with other kernel modules. tools/ directory is aimed to contain user space code useful for developing and testing Linux kernel.

Quoted 8 lines
Quoted 3 lines · Barry Song

this one is aiming to test CMA, it should be in tools/ as Michal Nazarewicz and i have talked about that.
it is not a real driver at all.

Yeah, I feel like it's better placed in tools/ not to pollute other directories with drivers that are of no use to regular users. I don't have strong feelings about it though, so I'm fine either way.

Other test devices/drivers are in drivers directory (drivers/usb/misc/usbtest.c for example), I don't see any good reason for polluting tools/ directory with kernel code.

IMHO the right person to decide if it makes sense to have such drivers in drivers/mics/ or tools/cma/ is Greg KH. Barry, please resend it and ask Greg for the decision.

Best regards

Signature · 2 lines
Marek Szyprowski
Samsung Poland R&D Center
#6 lore raw

Hi Marek,

2012/7/4 Marek Szyprowski <[email protected]>:

Quoted 20 lines

Hello,

Quoted 7 lines · Michal Nazarewicz
Quoted 6 lines

2012/7/3 Marek Szyprowski <[email protected]>:

Quoted 5 lines

IMHO the right place for such code is in drivers/misc instead of tools/cma.

This patch contains a kernel module source code so it should be put with other kernel modules. tools/ directory is aimed to contain user space code useful for developing and testing Linux kernel.

Quoted 8 lines
Quoted 3 lines · Barry Song

this one is aiming to test CMA, it should be in tools/ as Michal Nazarewicz and i have talked about that.
it is not a real driver at all.

Yeah, I feel like it's better placed in tools/ not to pollute other directories with drivers that are of no use to regular users. I don't have strong feelings about it though, so I'm fine either way.

Quoted 5 lines

Other test devices/drivers are in drivers directory (drivers/usb/misc/usbtest.c for example), I don't see any good reason for polluting tools/ directory with kernel code.

IMHO the right person to decide if it makes sense to have such drivers in drivers/mics/ or tools/cma/ is Greg KH. Barry, please resend it and ask Greg for the decision.

sure. thanks.

Quoted 7 lines

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

-barry

#7 lore raw

2012/7/4 Barry Song <[email protected]>:

Quoted 23 lines

Hi Marek,

2012/7/4 Marek Szyprowski <[email protected]>:

Quoted 20 lines

Hello,

Quoted 15 lines · Michal Nazarewicz
Quoted 6 lines

2012/7/3 Marek Szyprowski <[email protected]>:

Quoted 5 lines

IMHO the right place for such code is in drivers/misc instead of tools/cma.

This patch contains a kernel module source code so it should be put with other kernel modules. tools/ directory is aimed to contain user space code useful for developing and testing Linux kernel.

Quoted 3 lines · Barry Song

this one is aiming to test CMA, it should be in tools/ as Michal Nazarewicz and i have talked about that.
it is not a real driver at all.

Yeah, I feel like it's better placed in tools/ not to pollute other directories with drivers that are of no use to regular users. I don't have strong feelings about it though, so I'm fine either way.

Quoted 7 lines
Quoted 5 lines

Other test devices/drivers are in drivers directory (drivers/usb/misc/usbtest.c for example), I don't see any good reason for polluting tools/ directory with kernel code.

IMHO the right person to decide if it makes sense to have such drivers in drivers/mics/ or tools/cma/ is Greg KH. Barry, please resend it and ask Greg for the decision.

sure. thanks.

and BTW, if the only issue is the dir it should be placed to let Greg decide, would i also have your reviewed-by before sending to Greg KH?

Quoted 7 lines
Quoted 7 lines

Best regards
--
Marek Szyprowski
Samsung Poland R&D Center

-barry