On 06.10.22 23:13, Oleksandr Tyshchenko wrote: > > On 06.10.22 20:59, Xenia Ragiadakou wrote: > > Hello Xenia > >> >> On 10/6/22 15:09, Oleksandr Tyshchenko wrote: >>> From: Oleksandr Tyshchenko >>> >>> Although XEN_PAGE_SIZE is equal to PAGE_SIZE (4KB) for now, it would >>> be more correct to use Xen specific #define-s as XEN_PAGE_SIZE can >>> be changed at some point in the future. >>> >>> Signed-off-by: Oleksandr Tyshchenko ... >> So, the calculated number of grants may differ. > > Good point, I think you are right, so we need to additionally use > xen_offset_in_page() macro in xen_grant_dma_map_page(), > > something like that to be squashed with current patch: > > > diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c > index 9d5eca6d638a..bb984dc05deb 100644 > --- a/drivers/xen/grant-dma-ops.c > +++ b/drivers/xen/grant-dma-ops.c > @@ -169,7 +169,7 @@ static dma_addr_t xen_grant_dma_map_page(struct > device *dev, struct page *page, >                                          unsigned long attrs) >  { >         struct xen_grant_dma_data *data; > -       unsigned int i, n_pages = XEN_PFN_UP(offset + size); > +       unsigned int i, n_pages = XEN_PFN_UP(xen_offset_in_page(offset) > + size); I'd rather introduce another local variable "xen_offset", as it is used twice.