iommu: msm: Correct the data type mis-matches in VA
MSM IOMMU driver presently supports mapping of virtual addresses of 32-bit long only. Because of this, 32-bit long virtual address was okay and some mis-matches were silent. This is harmless but still buggy. Also, for 64-bit virtual address mapping, some API needs update. Make input virtual address always 'unsigned long' and trunk (if necessary) based on the page table format. Change-Id: I5d761246b0e150d9a0d22a9ae25581b5205e0594 Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
This commit is contained in:
parent
cfa0aa937c
commit
e42549ecd2
|
@ -971,8 +971,8 @@ void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(iommu_domain_window_disable);
|
||||
|
||||
int iommu_map_range(struct iommu_domain *domain, unsigned int iova,
|
||||
struct scatterlist *sg, unsigned int len, int prot)
|
||||
int iommu_map_range(struct iommu_domain *domain, unsigned long iova,
|
||||
struct scatterlist *sg, size_t len, int prot)
|
||||
{
|
||||
if (unlikely(domain->ops->map_range == NULL))
|
||||
return -ENODEV;
|
||||
|
@ -983,8 +983,8 @@ int iommu_map_range(struct iommu_domain *domain, unsigned int iova,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(iommu_map_range);
|
||||
|
||||
int iommu_unmap_range(struct iommu_domain *domain, unsigned int iova,
|
||||
unsigned int len)
|
||||
int iommu_unmap_range(struct iommu_domain *domain, unsigned long iova,
|
||||
size_t len)
|
||||
{
|
||||
if (unlikely(domain->ops->unmap_range == NULL))
|
||||
return -ENODEV;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2010-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
|
||||
|
@ -45,8 +45,8 @@
|
|||
#define MSM_IOMMU_ATTR_CACHED_WB_NWA 0x2
|
||||
#define MSM_IOMMU_ATTR_CACHED_WT 0x3
|
||||
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned int va,
|
||||
unsigned int len);
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned long va,
|
||||
size_t len);
|
||||
|
||||
static inline void clean_pte(u32 *start, u32 *end,
|
||||
int redirect)
|
||||
|
@ -1004,8 +1004,8 @@ static int check_range(u32 *fl_table, unsigned int va,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int msm_iommu_map_range(struct iommu_domain *domain, unsigned int va,
|
||||
struct scatterlist *sg, unsigned int len,
|
||||
static int msm_iommu_map_range(struct iommu_domain *domain, unsigned long va,
|
||||
struct scatterlist *sg, size_t len,
|
||||
int prot)
|
||||
{
|
||||
unsigned int pa;
|
||||
|
@ -1154,8 +1154,8 @@ fail:
|
|||
}
|
||||
|
||||
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned int va,
|
||||
unsigned int len)
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned long va,
|
||||
size_t len)
|
||||
{
|
||||
unsigned int offset = 0;
|
||||
u32 *fl_table;
|
||||
|
|
|
@ -1025,8 +1025,8 @@ fail:
|
|||
return len;
|
||||
}
|
||||
|
||||
static int msm_iommu_map_range(struct iommu_domain *domain, unsigned int va,
|
||||
struct scatterlist *sg, unsigned int len,
|
||||
static int msm_iommu_map_range(struct iommu_domain *domain, unsigned long va,
|
||||
struct scatterlist *sg, size_t len,
|
||||
int prot)
|
||||
{
|
||||
int ret;
|
||||
|
@ -1054,8 +1054,8 @@ fail:
|
|||
}
|
||||
|
||||
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned int va,
|
||||
unsigned int len)
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned long va,
|
||||
size_t len)
|
||||
{
|
||||
struct msm_iommu_priv *priv;
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ static inline int is_fully_aligned(unsigned int va, phys_addr_t pa, size_t len,
|
|||
static int __msm_iommu_pagetable_map_range(struct msm_iommu_pt *pt,
|
||||
unsigned long va, void *cookie,
|
||||
struct msm_iommu_map_ops *ops,
|
||||
unsigned int len, int prot)
|
||||
size_t len, int prot)
|
||||
{
|
||||
phys_addr_t pa;
|
||||
unsigned int start_va = va;
|
||||
|
@ -525,8 +525,8 @@ fail:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, unsigned int va,
|
||||
unsigned int len)
|
||||
void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, unsigned long va,
|
||||
size_t len)
|
||||
{
|
||||
unsigned int offset = 0;
|
||||
u32 *fl_pte;
|
||||
|
@ -588,7 +588,7 @@ void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, unsigned int va,
|
|||
}
|
||||
|
||||
int msm_iommu_pagetable_map_range(struct msm_iommu_pt *pt, unsigned long va,
|
||||
struct scatterlist *sg, unsigned int len, int prot)
|
||||
struct scatterlist *sg, size_t len, int prot)
|
||||
{
|
||||
return __msm_iommu_pagetable_map_range(pt, va, sg, &sg_ops, len, prot);
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ int msm_iommu_pagetable_map(struct msm_iommu_pt *pt, unsigned long va,
|
|||
}
|
||||
|
||||
phys_addr_t msm_iommu_iova_to_phys_soft(struct iommu_domain *domain,
|
||||
phys_addr_t va)
|
||||
dma_addr_t va)
|
||||
{
|
||||
struct msm_iommu_priv *priv = domain->priv;
|
||||
struct msm_iommu_pt *pt = &priv->pt;
|
||||
|
|
|
@ -23,11 +23,11 @@ int msm_iommu_pagetable_map(struct msm_iommu_pt *pt, unsigned long va,
|
|||
size_t msm_iommu_pagetable_unmap(struct msm_iommu_pt *pt, unsigned long va,
|
||||
size_t len);
|
||||
int msm_iommu_pagetable_map_range(struct msm_iommu_pt *pt, unsigned long va,
|
||||
struct scatterlist *sg, unsigned int len, int prot);
|
||||
void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, unsigned int va,
|
||||
unsigned int len);
|
||||
struct scatterlist *sg, size_t len, int prot);
|
||||
void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, unsigned long va,
|
||||
size_t len);
|
||||
phys_addr_t msm_iommu_iova_to_phys_soft(struct iommu_domain *domain,
|
||||
phys_addr_t va);
|
||||
dma_addr_t va);
|
||||
void msm_iommu_pagetable_free_tables(struct msm_iommu_pt *pt, unsigned long va,
|
||||
size_t len);
|
||||
#endif
|
||||
|
|
|
@ -85,8 +85,8 @@
|
|||
|
||||
#define FOLLOW_TO_NEXT_TABLE(pte) ((u64 *) __va(((*pte) & FLSL_BASE_MASK)))
|
||||
|
||||
static void __msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, u32 va,
|
||||
u32 len, u32 silent);
|
||||
static void __msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt,
|
||||
unsigned long va, size_t len, u32 silent);
|
||||
|
||||
static inline void clean_pte(u64 *start, u64 *end,
|
||||
s32 redirect)
|
||||
|
@ -527,7 +527,7 @@ static inline int is_fully_aligned(unsigned int va, phys_addr_t pa, size_t len,
|
|||
#endif
|
||||
|
||||
s32 msm_iommu_pagetable_map_range(struct msm_iommu_pt *pt, unsigned long va,
|
||||
struct scatterlist *sg, u32 len, s32 prot)
|
||||
struct scatterlist *sg, size_t len, s32 prot)
|
||||
{
|
||||
phys_addr_t pa;
|
||||
u32 offset = 0;
|
||||
|
@ -612,13 +612,15 @@ fail:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, u32 va, u32 len)
|
||||
void msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, unsigned long va,
|
||||
size_t len)
|
||||
{
|
||||
__msm_iommu_pagetable_unmap_range(pt, va, len, 0);
|
||||
}
|
||||
|
||||
static void __msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, u32 va,
|
||||
u32 len, u32 silent)
|
||||
static void __msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt,
|
||||
unsigned long va,
|
||||
size_t len, u32 silent)
|
||||
{
|
||||
u32 offset = 0;
|
||||
u64 *fl_pte;
|
||||
|
@ -712,7 +714,7 @@ static void __msm_iommu_pagetable_unmap_range(struct msm_iommu_pt *pt, u32 va,
|
|||
}
|
||||
|
||||
phys_addr_t msm_iommu_iova_to_phys_soft(struct iommu_domain *domain,
|
||||
phys_addr_t va)
|
||||
dma_addr_t va)
|
||||
{
|
||||
pr_err("iova_to_phys is not implemented for LPAE\n");
|
||||
return 0;
|
||||
|
|
|
@ -876,8 +876,8 @@ fail:
|
|||
return len;
|
||||
}
|
||||
|
||||
static int msm_iommu_map_range(struct iommu_domain *domain, unsigned int va,
|
||||
struct scatterlist *sg, unsigned int len,
|
||||
static int msm_iommu_map_range(struct iommu_domain *domain, unsigned long va,
|
||||
struct scatterlist *sg, size_t len,
|
||||
int prot)
|
||||
{
|
||||
int ret;
|
||||
|
@ -920,8 +920,8 @@ static size_t msm_iommu_map_sg(struct iommu_domain *domain, unsigned long va,
|
|||
return len;
|
||||
}
|
||||
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned int va,
|
||||
unsigned int len)
|
||||
static int msm_iommu_unmap_range(struct iommu_domain *domain, unsigned long va,
|
||||
size_t len)
|
||||
{
|
||||
struct msm_iommu_drvdata *iommu_drvdata;
|
||||
struct msm_iommu_ctx_drvdata *ctx_drvdata;
|
||||
|
|
|
@ -100,10 +100,10 @@ struct iommu_ops {
|
|||
phys_addr_t paddr, size_t size, int prot);
|
||||
size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
|
||||
size_t size);
|
||||
int (*map_range)(struct iommu_domain *domain, unsigned int iova,
|
||||
struct scatterlist *sg, unsigned int len, int prot);
|
||||
int (*unmap_range)(struct iommu_domain *domain, unsigned int iova,
|
||||
unsigned int len);
|
||||
int (*map_range)(struct iommu_domain *domain, unsigned long iova,
|
||||
struct scatterlist *sg, size_t len, int prot);
|
||||
int (*unmap_range)(struct iommu_domain *domain, unsigned long iova,
|
||||
size_t len);
|
||||
size_t (*map_sg)(struct iommu_domain *domain, unsigned long iova,
|
||||
struct scatterlist *sg, unsigned int nents, int prot);
|
||||
phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
|
||||
|
@ -150,10 +150,10 @@ extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
|
|||
phys_addr_t paddr, size_t size, int prot);
|
||||
extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
|
||||
size_t size);
|
||||
extern int iommu_map_range(struct iommu_domain *domain, unsigned int iova,
|
||||
struct scatterlist *sg, unsigned int len, int prot);
|
||||
extern int iommu_unmap_range(struct iommu_domain *domain, unsigned int iova,
|
||||
unsigned int len);
|
||||
extern int iommu_map_range(struct iommu_domain *domain, unsigned long iova,
|
||||
struct scatterlist *sg, size_t len, int prot);
|
||||
extern int iommu_unmap_range(struct iommu_domain *domain, unsigned long iova,
|
||||
size_t len);
|
||||
extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
|
||||
struct scatterlist *sg,unsigned int nents,
|
||||
int prot);
|
||||
|
@ -307,14 +307,14 @@ static inline void iommu_domain_window_disable(struct iommu_domain *domain,
|
|||
}
|
||||
|
||||
static inline int iommu_map_range(struct iommu_domain *domain,
|
||||
unsigned int iova, struct scatterlist *sg,
|
||||
unsigned int len, int prot)
|
||||
unsigned long iova, struct scatterlist *sg,
|
||||
size_t len, int prot)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static inline int iommu_unmap_range(struct iommu_domain *domain,
|
||||
unsigned int iova, unsigned int len)
|
||||
unsigned long iova, size_t len)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue