All of lore.kernel.org
 help / color / mirror / Atom feed
* gnttab_end_foreign_access/unmap fails for GNTMAP_device_map?
@ 2016-12-14 14:46 Oleksandr Andrushchenko
  2016-12-14 14:59 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Andrushchenko @ 2016-12-14 14:46 UTC (permalink / raw)
  To: xen-devel

Hi, all!

I am trying to map and then unmap grant refs in Dom0 from DomU
which are used for DMA by a real device in Dom0 (x86_64).
Mapping is done with GNTMAP_host_map | GNTMAP_device_map flags
and device can successfully access the pages and do DMA.
The problem is I cannot unmap the buffer back: Dom0 says
unmapping was done w/o errors, but when DomU tries to
gnttab_end_foreign_access I see lots of
[   55.052979] xen:grant_table: WARNING: g.e. 0xdce still in use!
[   55.052984] deferring g.e. 0xdce (pfn 0xffffffffffffffff)
messages in DomU and those grefs are never freed and system gets
exhausted at some point.

The same code, but with only GNTMAP_host_map flag is able to release
references as expected. Even if I don't give the buffer to any
HW device in Dom0 the use of GNTMAP_device_map flag makes troubles.
I also tried to add GNTMAP_readonly, but it didn't help.
In DomU right before doing gnttab_end_foreign_access I am checking
flags with gnttab_query_foreign_access: both GTF_reading
and GTF_writing are set. With GNTMAP_readonly only GTF_reading
(which I believe is expected).
I tried to look at the Xen sources and thought that it could
probably be related to pin/unpin?
Can anyone please shed some light if anything additional needs to
be done in case GNTMAP_device_map is in use or point me to
what needs to checked so I can find the root cause?

Thank you,
Oleksandr


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gnttab_end_foreign_access/unmap fails for GNTMAP_device_map?
  2016-12-14 14:46 gnttab_end_foreign_access/unmap fails for GNTMAP_device_map? Oleksandr Andrushchenko
@ 2016-12-14 14:59 ` Jan Beulich
  2016-12-14 15:15   ` Oleksandr Andrushchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2016-12-14 14:59 UTC (permalink / raw)
  To: Oleksandr Andrushchenko; +Cc: xen-devel

>>> On 14.12.16 at 15:46, <andr2000@gmail.com> wrote:
> Hi, all!
> 
> I am trying to map and then unmap grant refs in Dom0 from DomU
> which are used for DMA by a real device in Dom0 (x86_64).
> Mapping is done with GNTMAP_host_map | GNTMAP_device_map flags
> and device can successfully access the pages and do DMA.
> The problem is I cannot unmap the buffer back: Dom0 says
> unmapping was done w/o errors, but when DomU tries to
> gnttab_end_foreign_access I see lots of
> [   55.052979] xen:grant_table: WARNING: g.e. 0xdce still in use!
> [   55.052984] deferring g.e. 0xdce (pfn 0xffffffffffffffff)
> messages in DomU and those grefs are never freed and system gets
> exhausted at some point.
> 
> The same code, but with only GNTMAP_host_map flag is able to release
> references as expected. Even if I don't give the buffer to any
> HW device in Dom0 the use of GNTMAP_device_map flag makes troubles.
> I also tried to add GNTMAP_readonly, but it didn't help.
> In DomU right before doing gnttab_end_foreign_access I am checking
> flags with gnttab_query_foreign_access: both GTF_reading
> and GTF_writing are set. With GNTMAP_readonly only GTF_reading
> (which I believe is expected).
> I tried to look at the Xen sources and thought that it could
> probably be related to pin/unpin?

Possibly - looking at __gnttab_unmap_common(), are you passing
GNTMAP_device_map also to the unmap operation (together with
the frame number, or else the flag would be ignored)?

Jan

> Can anyone please shed some light if anything additional needs to
> be done in case GNTMAP_device_map is in use or point me to
> what needs to checked so I can find the root cause?
> 
> Thank you,
> Oleksandr



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gnttab_end_foreign_access/unmap fails for GNTMAP_device_map?
  2016-12-14 14:59 ` Jan Beulich
@ 2016-12-14 15:15   ` Oleksandr Andrushchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Oleksandr Andrushchenko @ 2016-12-14 15:15 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel

Hi, Jan!
On 12/14/2016 04:59 PM, Jan Beulich wrote:
>>>> On 14.12.16 at 15:46, <andr2000@gmail.com> wrote:
>> Hi, all!
>>
>> I am trying to map and then unmap grant refs in Dom0 from DomU
>> which are used for DMA by a real device in Dom0 (x86_64).
>> Mapping is done with GNTMAP_host_map | GNTMAP_device_map flags
>> and device can successfully access the pages and do DMA.
>> The problem is I cannot unmap the buffer back: Dom0 says
>> unmapping was done w/o errors, but when DomU tries to
>> gnttab_end_foreign_access I see lots of
>> [   55.052979] xen:grant_table: WARNING: g.e. 0xdce still in use!
>> [   55.052984] deferring g.e. 0xdce (pfn 0xffffffffffffffff)
>> messages in DomU and those grefs are never freed and system gets
>> exhausted at some point.
>>
>> The same code, but with only GNTMAP_host_map flag is able to release
>> references as expected. Even if I don't give the buffer to any
>> HW device in Dom0 the use of GNTMAP_device_map flag makes troubles.
>> I also tried to add GNTMAP_readonly, but it didn't help.
>> In DomU right before doing gnttab_end_foreign_access I am checking
>> flags with gnttab_query_foreign_access: both GTF_reading
>> and GTF_writing are set. With GNTMAP_readonly only GTF_reading
>> (which I believe is expected).
>> I tried to look at the Xen sources and thought that it could
>> probably be related to pin/unpin?
> Possibly - looking at __gnttab_unmap_common(), are you passing
> GNTMAP_device_map also to the unmap operation (together with
> the frame number, or else the flag would be ignored)?
>
> Jan
Indeed, it helped:
gnttab_set_unmap_op(&unmap_ops[i], addr,
             GNTMAP_host_map | GNTMAP_device_map,
             xen_obj->map_handles[i]);
*unmap_ops[i].dev_bus_addr = xen_obj->dev_bus_addr[i];*
I was confused by gnttab_set_unmap_op which
unmap->dev_bus_addr = 0;
>> Can anyone please shed some light if anything additional needs to
>> be done in case GNTMAP_device_map is in use or point me to
>> what needs to checked so I can find the root cause?
>>
>> Thank you,
>> Oleksandr
>
Thank you,
Oleksandr

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-14 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 14:46 gnttab_end_foreign_access/unmap fails for GNTMAP_device_map? Oleksandr Andrushchenko
2016-12-14 14:59 ` Jan Beulich
2016-12-14 15:15   ` Oleksandr Andrushchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.