IOMMU Fixes for Linux v4.4-rc8

The patches include fixes for:
 
 	* Two build issues, one in the ipmmu-vmsa driver and one for the
 	  new generic dma-api implemention used on arm64
 
 	* A performance fix for said dma-api implemention
 
 	* An issue caused by a wrong offset in map_sg in the same code
 	  as above
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJWjrtUAAoJECvwRC2XARrjBs8P/i+KWbiFqDDnlpk492OAib75
 IlCWw9IydVbn0foshZg5isZyx6UP2t4PoNeK2JLrN48BKw6fs3AFzPMXF7ur6/o5
 UP/S/RsdC8zcy12GvrCONQl2SYqnENvMjZZwtjmobYYrRISJ2RYHNND5VjTwofqh
 SitxPB9/g4MlD8dwFKgkgkA4jEwN8klbkm7qGBq3zeuDY7Gk8SVep+rRTnlXnk50
 6vJVPVvfYD+HIdvNwIQp+Y6iFzLE2aNP090Rq33xHjBNuIgvkpEXE7XPjsKvdC5I
 LbWskbwiUPoviX3ti283Zoijv45My6i9lzn2n2ESOp6JpZb4KytRoWbLhtJ3TvjO
 vTxBqbhj9iok770xecaNpIg9Of5evVRsOpGLwWxpzH/bwzlqtIGvRi+pzFC1atB9
 ye9djC6uA7mUVgHG5XZXH1dO3sHk4AxqnDvzv9N6jZC1Cvp+7NVBRdr7QtVRojnY
 e7cc+DwoZr48bad4WtbiIjRxYRXue6+QjlD02WfqHpiHa3R9mguCyVeFxQzp1JRL
 6QbCzuqqhdR0ie7dDAn30xQXsBzfiHyShlWn8B3z7JshV3vh3BPNVVOFVQMpMt56
 Wlgmry68r0W/HR1R6UuU+EoaBD7NSTBTZvL8illod/esMz6LMnGgPphm8dBvlGrb
 2WtGtIuqA5RvOJGI4aVC
 =AFI4
 -----END PGP SIGNATURE-----

Merge tag 'iommu-fixes-v4.4-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:

 - Two build issues, one in the ipmmu-vmsa driver and one for the new
   generic dma-api implemention used on arm64

 - A performance fix for said dma-api implemention

 - An issue caused by a wrong offset in map_sg in the same code as above

* tag 'iommu-fixes-v4.4-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/dma: Use correct offset in map_sg
  iommu/ipmmu-vmsa: Don't truncate ttbr if LPAE is not enabled
  iommu/dma: Avoid unlikely high-order allocations
  iommu/dma: Add some missing #includes
This commit is contained in:
Linus Torvalds 2016-01-07 12:56:23 -08:00
commit 1d8b0e7908
2 changed files with 9 additions and 4 deletions

View file

@ -21,10 +21,13 @@
#include <linux/device.h>
#include <linux/dma-iommu.h>
#include <linux/gfp.h>
#include <linux/huge_mm.h>
#include <linux/iommu.h>
#include <linux/iova.h>
#include <linux/mm.h>
#include <linux/scatterlist.h>
#include <linux/vmalloc.h>
int iommu_dma_init(void)
{
@ -191,6 +194,7 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count, gfp_t gfp)
{
struct page **pages;
unsigned int i = 0, array_size = count * sizeof(*pages);
unsigned int order = MAX_ORDER;
if (array_size <= PAGE_SIZE)
pages = kzalloc(array_size, GFP_KERNEL);
@ -204,14 +208,15 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count, gfp_t gfp)
while (count) {
struct page *page = NULL;
int j, order = __fls(count);
int j;
/*
* Higher-order allocations are a convenience rather
* than a necessity, hence using __GFP_NORETRY until
* falling back to single-page allocations.
*/
for (order = min(order, MAX_ORDER); order > 0; order--) {
for (order = min_t(unsigned int, order, __fls(count));
order > 0; order--) {
page = alloc_pages(gfp | __GFP_NORETRY, order);
if (!page)
continue;
@ -453,7 +458,7 @@ int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,
size_t s_offset = iova_offset(iovad, s->offset);
size_t s_length = s->length;
sg_dma_address(s) = s->offset;
sg_dma_address(s) = s_offset;
sg_dma_len(s) = s_length;
s->offset -= s_offset;
s_length = iova_align(iovad, s_length + s_offset);

View file

@ -295,7 +295,7 @@ static struct iommu_gather_ops ipmmu_gather_ops = {
static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
{
phys_addr_t ttbr;
u64 ttbr;
/*
* Allocate the page table operations.