lkml.org 
[lkml]   [2019]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [Xen-devel] [PATCH 1/3] xen/swiotlb: fix condition for calling xen_destroy_contiguous_region()
From
Date
On 25/04/2019 10:53, Jan Beulich wrote:
>>>> On 23.04.19 at 12:54, <jgross@suse.com> wrote:
>> --- a/drivers/xen/swiotlb-xen.c
>> +++ b/drivers/xen/swiotlb-xen.c
>> @@ -360,8 +360,8 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
>> /* Convert the size to actually allocated. */
>> size = 1UL << (order + XEN_PAGE_SHIFT);
>>
>> - if (((dev_addr + size - 1 <= dma_mask)) ||
>> - range_straddles_page_boundary(phys, size))
>> + if ((dev_addr + size - 1 <= dma_mask) &&
>> + !WARN_ON(range_straddles_page_boundary(phys, size)))
>> xen_destroy_contiguous_region(phys, order);
>
> On the allocation side we have
>
> if (((dev_addr + size - 1 <= dma_mask)) &&
> !range_straddles_page_boundary(phys, size))
> *dma_handle = dev_addr;
> else {
> if (xen_create_contiguous_region(phys, order,
> fls64(dma_mask), dma_handle) != 0) {
> xen_free_coherent_pages(hwdev, size, ret, (dma_addr_t)phys, attrs);
> return NULL;
> }
> }
>
> which is (as far as the function call is concerned)
>
> if ((dev_addr + size - 1 > dma_mask) ||
> range_straddles_page_boundary(phys, size))
> xen_create_contiguous_region(...);
>
> So I don't think your transformation is correct.

I know that I modified the condition. Calling
xen_destroy_contiguous_region() for a non-contiguous region is
destructive, so we have to avoid it in any case.

I could be talked into moving both tests into the WARN_ON(), however.


Juergen

\
 
 \ /
  Last update: 2019-04-25 11:03    [W:0.024 / U:2.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site