lkml.org 
[lkml]   [2020]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 09/10] xen/arm: introduce phys/dma translations in xen_dma_sync_for_*
On Thu, 21 May 2020, Julien Grall wrote:
> > @@ -97,8 +98,7 @@ bool xen_arch_need_swiotlb(struct device *dev,
> > phys_addr_t phys,
> > dma_addr_t dev_addr)
> > {
> > - unsigned int xen_pfn = XEN_PFN_DOWN(phys);
> > - unsigned int bfn = XEN_PFN_DOWN(dev_addr);
> > + unsigned int bfn = XEN_PFN_DOWN(dma_to_phys(dev, dev_addr));
> > /*
> > * The swiotlb buffer should be used if
> > @@ -115,7 +115,7 @@ bool xen_arch_need_swiotlb(struct device *dev,
> > * require a bounce buffer because the device doesn't support coherent
> > * memory and we are not able to flush the cache.
> > */
> > - return (!hypercall_cflush && (xen_pfn != bfn) &&
> > + return (!hypercall_cflush && !pfn_valid(bfn) &&
>
> I believe this change is incorrect. The bfn is a frame based on Xen page
> granularity (always 4K) while pfn_valid() is expecting a frame based on the
> Kernel page granularity.

Given that kernel granularity >= xen granularity it looks like it would
be safe to use PFN_DOWN instead of XEN_PFN_DOWN:

unsigned int bfn = PFN_DOWN(dma_to_phys(dev, dev_addr));
return (!hypercall_cflush && !pfn_valid(bfn) &&

\
 
 \ /
  Last update: 2020-05-21 22:09    [W:0.099 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site