From 008ae09623893ab6618328fa4e8af93637e2433c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 28 Mar 2013 01:42:42 -0700 Subject: [PATCH] compat: backport sg_page_iter_page() and sg_page_iter_dma_address() This should be going into the next kernel release, assuming this will be called 3.10 we stuff into the 3.10 header. Although this commit does modify the struct sg_page_iter data structure that was just done to remove something no longer needed due to the change. This should not impact older kernels so just keep the original implementation. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 2db76d7c next-20130328~64^2~6 commit 2db76d7c3c6db93058f983c8240f7c7c25e87ee6 Author: Imre Deak Date: Tue Mar 26 15:14:18 2013 +0200 lib/scatterlist: sg_page_iter: support sg lists w/o backing pages The i915 driver uses sg lists for memory without backing 'struct page' pages, similarly to other IO memory regions, setting only the DMA address for these. It does this, so that it can program the HW MMU tables in a uniform way both for sg lists with and without backing pages. Without a valid page pointer we can't call nth_page to get the current page in __sg_page_iter_next, so add a helper that relevant users can call separately. Also add a helper to get the DMA address of the current page (idea from Daniel). Convert all places in i915, to use the new API. Signed-off-by: Imre Deak Reviewed-by: Damien Lespiau Signed-off-by: Daniel Vetter Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.10.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 include/linux/compat-3.10.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 5d759193b7f7..1e9effb70442 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -72,6 +72,7 @@ void backport_dependency_symbol(void); #include #include #include +#include #endif /* __ASSEMBLY__ */ diff --git a/include/linux/compat-3.10.h b/include/linux/compat-3.10.h new file mode 100644 index 000000000000..69ddc1153ed8 --- /dev/null +++ b/include/linux/compat-3.10.h @@ -0,0 +1,34 @@ +#ifndef LINUX_3_10_COMPAT_H +#define LINUX_3_10_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) + +#include +#include + +#define sg_page_iter_page LINUX_BACKPORT(sg_page_iter_page) +/** + * sg_page_iter_page - get the current page held by the page iterator + * @piter: page iterator holding the page + */ +static inline struct page *sg_page_iter_page(struct sg_page_iter *piter) +{ + return nth_page(sg_page(piter->sg), piter->sg_pgoffset); +} + +#define sg_page_iter_dma_address LINUX_BACKPORT(sg_page_iter_dma_address) +/** + * sg_page_iter_dma_address - get the dma address of the current page held by + * the page iterator. + * @piter: page iterator holding the page + */ +static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter) +{ + return sg_dma_address(piter->sg) + (piter->sg_pgoffset << PAGE_SHIFT); +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) */ + +#endif /* LINUX_3_10_COMPAT_H */ -- 2.30.2