Re: Memory sharing issue by application on V4L2 based device driver with system mmu.

Started by InKi Dae on Jan 7, 2011 · 7 messages from 5 authors · Last reply Jan 13, 2011

open the first message on its own page

Message details and related content
thank you for your comments.

your second comment has no any problem as I said before, user virtual
addess could be translated in page unit. but the problem, as you said,
is that when cpu access to the memory in user mode, the memory
allocated by malloc, page fault occurs so we can't find pfn to user
virtual address. I missed that. but I think we could resolve this one.

as before, user application allocates memory through malloc function
and then send it to device driver(using userptr feature). if the pfn
is null when device driver translated user virtual address in page
unit then it allocates phsical memory in page unit using some
interface such as alloc_page() and then mapping them. when pfn is
null, to check it and allocate physical memory in page unit could be
processed by videobuf2.

of course, videobuf2 has no any duty considered for system mmu. so
videobuf2 just provides callback for 3rd party and any platform with
system mmu such as Samsung SoC C210 implements the function(allocating
physical memory and mapping it) and registers it to callback of
videobuf2. by doing so, I think your first comment could be cleared.

please, feel free to give me your opinion and pointing out.

thank you.

2011년 1월 7일 오전 8:57, Jonghun Han [off-list ref]님의 말:
Hello,

There are two reasons why malloc isn't suitable for it.

The first is that malloc doesn't allocate memory when malloc is called.
So driver or vb2 cannot find PFN for it in the VIDIOC_QBUF.

The second is that malloc uses 4KB page allocation.
SYS.MMU(IO-MMU) can handle scattered memory. But it has a penalty when TLB
miss is occurred.
So as possible as physically contiguous pages are needed for performance
enhancement.

So new allocator which can clear two main issues is needed.

Best regards,
quoted
-----Original Message-----
From: <redacted> [mailto:linux-media-
owner@vger.kernel.org] On Behalf Of InKi Dae
Sent: Thursday, January 06, 2011 10:25 PM
To: <redacted>
Subject: Memory sharing issue by application on V4L2 based device driver
with
quoted
system mmu.

Hello, all.

I'd like to discuss memory sharing issue by application on v4l2 based
device driver
quoted
with system mmu and get some advices about that.

Now I am working on Samsung SoC C210 platform and this platform has some
multimedia devices with system mmu such as fimc, and mfc also we have
implemented device drivers for them. those drivers are based on V4L2
framework
quoted
with videobuf2. for system mmu of each device, we used VCM(Virtual
Contiguous
quoted
Memory) framework.

99 more quoted lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Message details and related content
Hello,

That's not a translation issue. What I mention is the size of allocation.
The malloc uses 4KB page allocation and SYS.MMU can handle it.
But 64KB or 1MB physically contiguous memory is better than 4KB page in the
point of performance.

Best regards,
-----Original Message-----
From: <redacted> [mailto:linux-media-
owner@vger.kernel.org] On Behalf Of InKi Dae
Sent: Friday, January 07, 2011 11:17 AM
To: Jonghun Han
Cc: <redacted>; <redacted>;
linux-fbdev;
kyungmin.park@samsung.com
Subject: Re: Memory sharing issue by application on V4L2 based device
driver
with system mmu.

thank you for your comments.

your second comment has no any problem as I said before, user virtual
addess
could be translated in page unit. but the problem, as you said, is that
when cpu
access to the memory in user mode, the memory allocated by malloc, page
fault
occurs so we can't find pfn to user virtual address. I missed that. but I
think we
could resolve this one.

as before, user application allocates memory through malloc function and
then
send it to device driver(using userptr feature). if the pfn is null when
device driver
translated user virtual address in page unit then it allocates phsical
memory in
page unit using some interface such as alloc_page() and then mapping
them. when
pfn is null, to check it and allocate physical memory in page unit could
be
processed by videobuf2.

of course, videobuf2 has no any duty considered for system mmu. so
videobuf2 just provides callback for 3rd party and any platform with
system mmu
such as Samsung SoC C210 implements the function(allocating physical
memory
and mapping it) and registers it to callback of videobuf2. by doing so, I
think your
first comment could be cleared.

please, feel free to give me your opinion and pointing out.

thank you.

2011년 1월 7일 오전 8:57, Jonghun Han [off-list ref]님의 말:
quoted
Hello,

There are two reasons why malloc isn't suitable for it.

The first is that malloc doesn't allocate memory when malloc is called.
So driver or vb2 cannot find PFN for it in the VIDIOC_QBUF.

The second is that malloc uses 4KB page allocation.
SYS.MMU(IO-MMU) can handle scattered memory. But it has a penalty when
TLB miss is occurred.
So as possible as physically contiguous pages are needed for
performance enhancement.

So new allocator which can clear two main issues is needed.

Best regards,
quoted
-----Original Message-----
From: <redacted> [mailto:linux-media-
owner@vger.kernel.org] On Behalf Of InKi Dae
Sent: Thursday, January 06, 2011 10:25 PM
To: <redacted>
Subject: Memory sharing issue by application on V4L2 based device
driver
with
quoted
system mmu.

Hello, all.

I'd like to discuss memory sharing issue by application on v4l2 based
device driver
quoted
with system mmu and get some advices about that.

118 more quoted lines

the body
of a message to majordomo@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Message details and related content
Hello, Mr. Jonghun.

please, note that user process's pgd and device's pgd with system mmu
are differnent. first, the memory allocated by user malloc should be
mapped to physical memory in page unit because user app also should be
accessed to own memory region. and when mapping the physical memory to
device virtual address, it creates page table entry for 64k or 1M and
then could map physical address to those entries. therefore what you
mention has no problem.

actual issue is not to need demend paging, some issues we don't
understand may exist as side effects.

thank you.

Jonghun Han 쓴 글:
Hello,

That's not a translation issue. What I mention is the size of allocation.
The malloc uses 4KB page allocation and SYS.MMU can handle it.
But 64KB or 1MB physically contiguous memory is better than 4KB page in the
point of performance.

Best regards,
quoted
-----Original Message-----
From: <redacted> [mailto:linux-media-
owner@vger.kernel.org] On Behalf Of InKi Dae
Sent: Friday, January 07, 2011 11:17 AM
To: Jonghun Han
Cc: <redacted>; <redacted>;
linux-fbdev;
quoted
kyungmin.park@samsung.com
Subject: Re: Memory sharing issue by application on V4L2 based device
driver
quoted
with system mmu.

thank you for your comments.

your second comment has no any problem as I said before, user virtual
addess
quoted
could be translated in page unit. but the problem, as you said, is that
when cpu
quoted
access to the memory in user mode, the memory allocated by malloc, page
fault
quoted
occurs so we can't find pfn to user virtual address. I missed that. but I
think we
quoted
could resolve this one.

as before, user application allocates memory through malloc function and
then
quoted
send it to device driver(using userptr feature). if the pfn is null when
device driver
quoted
translated user virtual address in page unit then it allocates phsical
memory in
quoted
page unit using some interface such as alloc_page() and then mapping

176 more quoted lines

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Message details and related content
On Fre, 2011-01-07 at 11:17 +0900, InKi Dae wrote: 
thank you for your comments.

your second comment has no any problem as I said before, user virtual
addess could be translated in page unit. but the problem, as you said,
is that when cpu access to the memory in user mode, the memory
allocated by malloc, page fault occurs so we can't find pfn to user
virtual address. I missed that. but I think we could resolve this one.

as before, user application allocates memory through malloc function
and then send it to device driver(using userptr feature). if the pfn
is null when device driver translated user virtual address in page
unit then it allocates phsical memory in page unit using some
interface such as alloc_page() and then mapping them. when pfn is
null, to check it and allocate physical memory in page unit could be
processed by videobuf2.

of course, videobuf2 has no any duty considered for system mmu. so
videobuf2 just provides callback for 3rd party and any platform with
system mmu such as Samsung SoC C210 implements the function(allocating
physical memory and mapping it) and registers it to callback of
videobuf2. by doing so, I think your first comment could be cleared.
FWIW, TTM (drivers/gpu/drm/ttm, include/drm/ttm) is designed and used
for managing memory between CPU/GPU and kernel/userspace access. I
haven't looked at your requirements in detail, but if you haven't looked
at TTM yet, it sounds like it might be worth a look.


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer
Message details and related content
Michel Dänzer 쓴 글:
On Fre, 2011-01-07 at 11:17 +0900, InKi Dae wrote: 
quoted
thank you for your comments.

your second comment has no any problem as I said before, user virtual
addess could be translated in page unit. but the problem, as you said,
is that when cpu access to the memory in user mode, the memory
allocated by malloc, page fault occurs so we can't find pfn to user
virtual address. I missed that. but I think we could resolve this one.

as before, user application allocates memory through malloc function
and then send it to device driver(using userptr feature). if the pfn
is null when device driver translated user virtual address in page
unit then it allocates phsical memory in page unit using some
interface such as alloc_page() and then mapping them. when pfn is
null, to check it and allocate physical memory in page unit could be
processed by videobuf2.

of course, videobuf2 has no any duty considered for system mmu. so
videobuf2 just provides callback for 3rd party and any platform with
system mmu such as Samsung SoC C210 implements the function(allocating
physical memory and mapping it) and registers it to callback of
videobuf2. by doing so, I think your first comment could be cleared.
FWIW, TTM (drivers/gpu/drm/ttm, include/drm/ttm) is designed and used
for managing memory between CPU/GPU and kernel/userspace access. I
haven't looked at your requirements in detail, but if you haven't looked
at TTM yet, it sounds like it might be worth a look.
Thank you for your advice. I would look at TTM driver.
Message details and related content
 .. snip..
But 64KB or 1MB physically contiguous memory is better than 4KB page in the
point of performance.
Could you explain that in more details please? I presume you are
talking about a CPU that has a MMU unit, right?
Message details and related content
Sorry for late reply.

Samsung SoC C210 has many multimedia IPs.
Each IP has its own MMU named SYSTEM MMU like CPU's MMU.
So it can handle discontiguous memory using device own virtual address.

What Inki Dae wants to discuss is how to allocate the memory and how to
share it with other multimedia IPs. 

Thank you for interesting.

Best regards,
-----Original Message-----
From: <redacted> [mailto:linux-fbdev-
owner@vger.kernel.org] On Behalf Of Konrad Rzeszutek Wilk
Sent: Wednesday, January 12, 2011 2:35 AM
To: Jonghun Han
Cc: 'InKi Dae'; <redacted>;
linux-arm-kernel@lists.infradead.org;
'linux-fbdev'; kyungmin.park@samsung.com
Subject: Re: Memory sharing issue by application on V4L2 based device
driver
with system mmu.


 .. snip..
quoted
But 64KB or 1MB physically contiguous memory is better than 4KB page
in the point of performance.
Could you explain that in more details please? I presume you are talking
about a
CPU that has a MMU unit, right?
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body
of a message to majordomo@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help