Re: query regarding 'map_user_kiobuf'

2001-05-30 Thread David Woodhouse


[EMAIL PROTECTED] said:
>  I have a couple of user DMA drivers up and running, but in light of
> your comment, I am not so sure. 

I'm sorry, it seems I lied. Although map_user_kiobuf in 2.2 used to lock 
the pages, apparently that's no longer necessary. You just need to make 
sure they're marked dirty before you unmap the kiobuf.

--
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: query regarding 'map_user_kiobuf'

2001-05-30 Thread William Waddington

On Tue, 29 May 2001 19:30:06 GMT, in fa.linux.kernel you wrote:

>
>[EMAIL PROTECTED] said:
>> After using the 'map_user_kiobuf', I observed the followiing:
>> 
>> 1. 'kiobuf->maplist[0]->virtual' contains a different virtual address than
>> the user space buffer address
>> 2. But these two addresses are mapped as when i write something using the
>> address 'kiobuf->maplist[0]->virtual' inside the kernel, I see the same
>> data in the user space buffer in my application.
>> 3. I use the 'virt_to_phys' operation to the virtual address
>> 'kiobuf->maplist[0]->virtual' to get the physical address.
>> 4. I use this physical address for DMA operations.
>> 
>> Now, using this information I do a DMA from card to system memory. What I
>> have noticed is that DMA happens somewhere else in the system memory. I am
>> not able to execute most of the commands (ls, chmod, cat, clear etc) after
>> my user program exits.
>> 
>> Am I doing the steps 3 and 4 above right?
>
>After calling map_user_kiobuf(), I believe you should be locking the pages
>in memory by calling lock_kiovec(). Otherwise, nothing prevents them from 
>being paged out again.
>
>Also, the pages may be in high memory and not directly accessible. You should
>use kmap() before touching them from the kernel rather than just using 
>page->virtual, and obviously kunmap() afterwards.
>
>The PCI DMA interface is more complex than simply using virt_to_phys() too, 
>if you want to deal correctly with the highmem case. I'm sure others will 
>give you the details or pointers to the documentation.


David,

I have a couple of user DMA drivers up and running, but in light of your
comment, I am not so sure.

I see the following  w/map_user_kiobuf() in memory.c (2.4.4)

...

/*
 * Force in an entire range of pages from the current process's user VA,
 * and pin them in physical memory.  
 */
 
#define dprintk(x...)
 int map_user_kiobuf(int rw, struct kiobuf *iobuf, unsigned long va, size_t
len)

...

What is the difference between pinning and locking?  I had the impression
that locking had more to do with ownership.

Thanks,
Bill

---
Bill Waddington
Bainbridge Island, WA, USA
[EMAIL PROTECTED]
[EMAIL PROTECTED]
---
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: query regarding 'map_user_kiobuf'

2001-05-30 Thread William Waddington

On Tue, 29 May 2001 19:30:06 GMT, in fa.linux.kernel you wrote:


[EMAIL PROTECTED] said:
 After using the 'map_user_kiobuf', I observed the followiing:
 
 1. 'kiobuf-maplist[0]-virtual' contains a different virtual address than
 the user space buffer address
 2. But these two addresses are mapped as when i write something using the
 address 'kiobuf-maplist[0]-virtual' inside the kernel, I see the same
 data in the user space buffer in my application.
 3. I use the 'virt_to_phys' operation to the virtual address
 'kiobuf-maplist[0]-virtual' to get the physical address.
 4. I use this physical address for DMA operations.
 
 Now, using this information I do a DMA from card to system memory. What I
 have noticed is that DMA happens somewhere else in the system memory. I am
 not able to execute most of the commands (ls, chmod, cat, clear etc) after
 my user program exits.
 
 Am I doing the steps 3 and 4 above right?

After calling map_user_kiobuf(), I believe you should be locking the pages
in memory by calling lock_kiovec(). Otherwise, nothing prevents them from 
being paged out again.

Also, the pages may be in high memory and not directly accessible. You should
use kmap() before touching them from the kernel rather than just using 
page-virtual, and obviously kunmap() afterwards.

The PCI DMA interface is more complex than simply using virt_to_phys() too, 
if you want to deal correctly with the highmem case. I'm sure others will 
give you the details or pointers to the documentation.


David,

I have a couple of user DMA drivers up and running, but in light of your
comment, I am not so sure.

I see the following  w/map_user_kiobuf() in memory.c (2.4.4)

...

/*
 * Force in an entire range of pages from the current process's user VA,
 * and pin them in physical memory.  
 */
 
#define dprintk(x...)
 int map_user_kiobuf(int rw, struct kiobuf *iobuf, unsigned long va, size_t
len)

...

What is the difference between pinning and locking?  I had the impression
that locking had more to do with ownership.

Thanks,
Bill

---
Bill Waddington
Bainbridge Island, WA, USA
[EMAIL PROTECTED]
[EMAIL PROTECTED]
---
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: query regarding 'map_user_kiobuf'

2001-05-30 Thread David Woodhouse


[EMAIL PROTECTED] said:
  I have a couple of user DMA drivers up and running, but in light of
 your comment, I am not so sure. 

I'm sorry, it seems I lied. Although map_user_kiobuf in 2.2 used to lock 
the pages, apparently that's no longer necessary. You just need to make 
sure they're marked dirty before you unmap the kiobuf.

--
dwmw2


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: query regarding 'map_user_kiobuf'

2001-05-29 Thread David Woodhouse


[EMAIL PROTECTED] said:
> After using the 'map_user_kiobuf', I observed the followiing:
> 
> 1. 'kiobuf->maplist[0]->virtual' contains a different virtual address than
> the user space buffer address
> 2. But these two addresses are mapped as when i write something using the
> address 'kiobuf->maplist[0]->virtual' inside the kernel, I see the same
> data in the user space buffer in my application.
> 3. I use the 'virt_to_phys' operation to the virtual address
> 'kiobuf->maplist[0]->virtual' to get the physical address.
> 4. I use this physical address for DMA operations.
> 
> Now, using this information I do a DMA from card to system memory. What I
> have noticed is that DMA happens somewhere else in the system memory. I am
> not able to execute most of the commands (ls, chmod, cat, clear etc) after
> my user program exits.
> 
> Am I doing the steps 3 and 4 above right?

After calling map_user_kiobuf(), I believe you should be locking the pages
in memory by calling lock_kiovec(). Otherwise, nothing prevents them from 
being paged out again.

Also, the pages may be in high memory and not directly accessible. You should
use kmap() before touching them from the kernel rather than just using 
page->virtual, and obviously kunmap() afterwards.

The PCI DMA interface is more complex than simply using virt_to_phys() too, 
if you want to deal correctly with the highmem case. I'm sure others will 
give you the details or pointers to the documentation.

--
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



query regarding 'map_user_kiobuf'

2001-05-29 Thread mdaljeet

I am using linux kernel version 2.4.2 on Intel PC.

I have been trying my luck for over a week regarding usage of
'map_user_kiobuf' for doing a DMA into a memory area that belongs to user
space.

Actually my requirement is that I want to do DMA into a user space memory
area. What I have done through suggestions is that allocate memory in user
space. I pass user space buffer address to a kernel module.
Inside the kernel module, I use 'map_user_kiobuf' passing user space buffer
address to it.

After using the 'map_user_kiobuf', I observed the followiing:

1. 'kiobuf->maplist[0]->virtual' contains a different virtual address than
the user space buffer address
2. But these two addresses are mapped as when i write something using the
address 'kiobuf->maplist[0]->virtual' inside the kernel, I see the same
data in the user space buffer in my application.
3. I use the 'virt_to_phys' operation to the virtual address
'kiobuf->maplist[0]->virtual' to get the physical address.
4. I use this physical address for DMA operations.

Now, using this information I do a DMA from card to system memory. What I
have noticed is that DMA happens somewhere else in the system memory. I am
not able to execute most of the commands (ls, chmod, cat, clear etc) after
my user program exits.

Am I doing the steps 3 and 4 above right?

Regards,
Daljeet.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



query regarding 'map_user_kiobuf'

2001-05-29 Thread mdaljeet

I am using linux kernel version 2.4.2 on Intel PC.

I have been trying my luck for over a week regarding usage of
'map_user_kiobuf' for doing a DMA into a memory area that belongs to user
space.

Actually my requirement is that I want to do DMA into a user space memory
area. What I have done through suggestions is that allocate memory in user
space. I pass user space buffer address to a kernel module.
Inside the kernel module, I use 'map_user_kiobuf' passing user space buffer
address to it.

After using the 'map_user_kiobuf', I observed the followiing:

1. 'kiobuf-maplist[0]-virtual' contains a different virtual address than
the user space buffer address
2. But these two addresses are mapped as when i write something using the
address 'kiobuf-maplist[0]-virtual' inside the kernel, I see the same
data in the user space buffer in my application.
3. I use the 'virt_to_phys' operation to the virtual address
'kiobuf-maplist[0]-virtual' to get the physical address.
4. I use this physical address for DMA operations.

Now, using this information I do a DMA from card to system memory. What I
have noticed is that DMA happens somewhere else in the system memory. I am
not able to execute most of the commands (ls, chmod, cat, clear etc) after
my user program exits.

Am I doing the steps 3 and 4 above right?

Regards,
Daljeet.


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: query regarding 'map_user_kiobuf'

2001-05-29 Thread David Woodhouse


[EMAIL PROTECTED] said:
 After using the 'map_user_kiobuf', I observed the followiing:
 
 1. 'kiobuf-maplist[0]-virtual' contains a different virtual address than
 the user space buffer address
 2. But these two addresses are mapped as when i write something using the
 address 'kiobuf-maplist[0]-virtual' inside the kernel, I see the same
 data in the user space buffer in my application.
 3. I use the 'virt_to_phys' operation to the virtual address
 'kiobuf-maplist[0]-virtual' to get the physical address.
 4. I use this physical address for DMA operations.
 
 Now, using this information I do a DMA from card to system memory. What I
 have noticed is that DMA happens somewhere else in the system memory. I am
 not able to execute most of the commands (ls, chmod, cat, clear etc) after
 my user program exits.
 
 Am I doing the steps 3 and 4 above right?

After calling map_user_kiobuf(), I believe you should be locking the pages
in memory by calling lock_kiovec(). Otherwise, nothing prevents them from 
being paged out again.

Also, the pages may be in high memory and not directly accessible. You should
use kmap() before touching them from the kernel rather than just using 
page-virtual, and obviously kunmap() afterwards.

The PCI DMA interface is more complex than simply using virt_to_phys() too, 
if you want to deal correctly with the highmem case. I'm sure others will 
give you the details or pointers to the documentation.

--
dwmw2


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/