Merge "iommu: msm: Convert msm mapping functions to use iommu_map_sg"

This commit is contained in:
Linux Build Service Account 2015-03-18 15:04:53 -07:00 committed by Gerrit - the friendly Code Review server
commit 4bd8e06472
2 changed files with 15 additions and 7 deletions

View File

@ -82,6 +82,7 @@ int msm_iommu_map_extra(struct iommu_domain *domain,
struct scatterlist *sglist;
unsigned int nrpages = PFN_ALIGN(size) >> PAGE_SHIFT;
struct page *dummy_page = phys_to_page(phy_addr);
size_t map_ret;
sglist = vmalloc(sizeof(*sglist) * nrpages);
if (!sglist) {
@ -94,10 +95,14 @@ int msm_iommu_map_extra(struct iommu_domain *domain,
for (i = 0; i < nrpages; i++)
sg_set_page(&sglist[i], dummy_page, PAGE_SIZE, 0);
ret = iommu_map_range(domain, temp_iova, sglist, size, prot);
if (ret) {
map_ret = iommu_map_sg(domain, temp_iova, sglist, nrpages,
prot);
if (map_ret != size) {
pr_err("%s: could not map extra %lx in domain %p\n",
__func__, start_iova, domain);
ret = -EINVAL;
} else {
ret = 0;
}
vfree(sglist);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -195,7 +195,7 @@ static int msm_iommu_map_iommu(struct msm_iommu_meta *meta,
unsigned long extra, size;
struct sg_table *table;
int prot = IOMMU_WRITE | IOMMU_READ;
size_t map_ret;
size = meta->size;
data->mapped_size = iova_length;
@ -224,13 +224,16 @@ static int msm_iommu_map_iommu(struct msm_iommu_meta *meta,
goto out1;
}
ret = iommu_map_range(domain, data->iova_addr,
map_ret = iommu_map_sg(domain, data->iova_addr,
table->sgl,
size, prot);
if (ret) {
table->nents, prot);
if (map_ret != size) {
pr_err("%s: could not map %lx in domain %p\n",
__func__, data->iova_addr, domain);
ret = -EINVAL;
goto out1;
} else {
ret = 0;
}
if (extra) {