diff options
| -rw-r--r-- | arch/powerpc/include/asm/fsl_pamu_stash.h | 4 | ||||
| -rw-r--r-- | drivers/iommu/fsl_pamu.c | 203 | ||||
| -rw-r--r-- | drivers/iommu/fsl_pamu.h | 15 | ||||
| -rw-r--r-- | drivers/iommu/fsl_pamu_domain.c | 173 |
4 files changed, 179 insertions, 216 deletions
diff --git a/arch/powerpc/include/asm/fsl_pamu_stash.h b/arch/powerpc/include/asm/fsl_pamu_stash.h index caa1b21c25cd..38311c98eed9 100644 --- a/arch/powerpc/include/asm/fsl_pamu_stash.h +++ b/arch/powerpc/include/asm/fsl_pamu_stash.h | |||
| @@ -32,8 +32,8 @@ enum pamu_stash_target { | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | struct pamu_stash_attribute { | 34 | struct pamu_stash_attribute { |
| 35 | u32 cpu; /* cpu number */ | 35 | u32 cpu; /* cpu number */ |
| 36 | u32 cache; /* cache to stash to: L1,L2,L3 */ | 36 | u32 cache; /* cache to stash to: L1,L2,L3 */ |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | #endif /* __FSL_PAMU_STASH_H */ | 39 | #endif /* __FSL_PAMU_STASH_H */ |
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index 6ee947e41870..abeedc9a78c2 100644 --- a/drivers/iommu/fsl_pamu.c +++ b/drivers/iommu/fsl_pamu.c | |||
| @@ -18,22 +18,13 @@ | |||
| 18 | 18 | ||
| 19 | #define pr_fmt(fmt) "fsl-pamu: %s: " fmt, __func__ | 19 | #define pr_fmt(fmt) "fsl-pamu: %s: " fmt, __func__ |
| 20 | 20 | ||
| 21 | #include <linux/init.h> | 21 | #include "fsl_pamu.h" |
| 22 | #include <linux/iommu.h> | 22 | |
| 23 | #include <linux/slab.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/types.h> | ||
| 26 | #include <linux/mm.h> | ||
| 27 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
| 28 | #include <linux/device.h> | ||
| 29 | #include <linux/of_platform.h> | ||
| 30 | #include <linux/bootmem.h> | ||
| 31 | #include <linux/genalloc.h> | 24 | #include <linux/genalloc.h> |
| 32 | #include <asm/io.h> | ||
| 33 | #include <asm/bitops.h> | ||
| 34 | #include <asm/fsl_guts.h> | ||
| 35 | 25 | ||
| 36 | #include "fsl_pamu.h" | 26 | #include <asm/mpc85xx.h> |
| 27 | #include <asm/fsl_guts.h> | ||
| 37 | 28 | ||
| 38 | /* define indexes for each operation mapping scenario */ | 29 | /* define indexes for each operation mapping scenario */ |
| 39 | #define OMI_QMAN 0x00 | 30 | #define OMI_QMAN 0x00 |
| @@ -44,13 +35,13 @@ | |||
| 44 | #define make64(high, low) (((u64)(high) << 32) | (low)) | 35 | #define make64(high, low) (((u64)(high) << 32) | (low)) |
| 45 | 36 | ||
| 46 | struct pamu_isr_data { | 37 | struct pamu_isr_data { |
| 47 | void __iomem *pamu_reg_base; /* Base address of PAMU regs*/ | 38 | void __iomem *pamu_reg_base; /* Base address of PAMU regs */ |
| 48 | unsigned int count; /* The number of PAMUs */ | 39 | unsigned int count; /* The number of PAMUs */ |
| 49 | }; | 40 | }; |
| 50 | 41 | ||
| 51 | static struct paace *ppaact; | 42 | static struct paace *ppaact; |
| 52 | static struct paace *spaact; | 43 | static struct paace *spaact; |
| 53 | static struct ome *omt; | 44 | static struct ome *omt __initdata; |
| 54 | 45 | ||
| 55 | /* | 46 | /* |
| 56 | * Table for matching compatible strings, for device tree | 47 | * Table for matching compatible strings, for device tree |
| @@ -58,14 +49,13 @@ static struct ome *omt; | |||
| 58 | * "fsl,qoriq-device-config-2.0" corresponds to T4 & B4 | 49 | * "fsl,qoriq-device-config-2.0" corresponds to T4 & B4 |
| 59 | * SOCs. For the older SOCs "fsl,qoriq-device-config-1.0" | 50 | * SOCs. For the older SOCs "fsl,qoriq-device-config-1.0" |
| 60 | * string would be used. | 51 | * string would be used. |
| 61 | */ | 52 | */ |
| 62 | static const struct of_device_id guts_device_ids[] = { | 53 | static const struct of_device_id guts_device_ids[] __initconst = { |
| 63 | { .compatible = "fsl,qoriq-device-config-1.0", }, | 54 | { .compatible = "fsl,qoriq-device-config-1.0", }, |
| 64 | { .compatible = "fsl,qoriq-device-config-2.0", }, | 55 | { .compatible = "fsl,qoriq-device-config-2.0", }, |
| 65 | {} | 56 | {} |
| 66 | }; | 57 | }; |
| 67 | 58 | ||
| 68 | |||
| 69 | /* | 59 | /* |
| 70 | * Table for matching compatible strings, for device tree | 60 | * Table for matching compatible strings, for device tree |
| 71 | * L3 cache controller node. | 61 | * L3 cache controller node. |
| @@ -73,7 +63,7 @@ static const struct of_device_id guts_device_ids[] = { | |||
| 73 | * "fsl,b4860-l3-cache-controller" corresponds to B4 & | 63 | * "fsl,b4860-l3-cache-controller" corresponds to B4 & |
| 74 | * "fsl,p4080-l3-cache-controller" corresponds to other, | 64 | * "fsl,p4080-l3-cache-controller" corresponds to other, |
| 75 | * SOCs. | 65 | * SOCs. |
| 76 | */ | 66 | */ |
| 77 | static const struct of_device_id l3_device_ids[] = { | 67 | static const struct of_device_id l3_device_ids[] = { |
| 78 | { .compatible = "fsl,t4240-l3-cache-controller", }, | 68 | { .compatible = "fsl,t4240-l3-cache-controller", }, |
| 79 | { .compatible = "fsl,b4860-l3-cache-controller", }, | 69 | { .compatible = "fsl,b4860-l3-cache-controller", }, |
| @@ -85,7 +75,7 @@ static const struct of_device_id l3_device_ids[] = { | |||
| 85 | static u32 max_subwindow_count; | 75 | static u32 max_subwindow_count; |
| 86 | 76 | ||
| 87 | /* Pool for fspi allocation */ | 77 | /* Pool for fspi allocation */ |
| 88 | struct gen_pool *spaace_pool; | 78 | static struct gen_pool *spaace_pool; |
| 89 | 79 | ||
| 90 | /** | 80 | /** |
| 91 | * pamu_get_max_subwin_cnt() - Return the maximum supported | 81 | * pamu_get_max_subwin_cnt() - Return the maximum supported |
| @@ -170,7 +160,7 @@ int pamu_disable_liodn(int liodn) | |||
| 170 | static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) | 160 | static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) |
| 171 | { | 161 | { |
| 172 | /* Bug if not a power of 2 */ | 162 | /* Bug if not a power of 2 */ |
| 173 | BUG_ON((addrspace_size & (addrspace_size - 1))); | 163 | BUG_ON(addrspace_size & (addrspace_size - 1)); |
| 174 | 164 | ||
| 175 | /* window size is 2^(WSE+1) bytes */ | 165 | /* window size is 2^(WSE+1) bytes */ |
| 176 | return fls64(addrspace_size) - 2; | 166 | return fls64(addrspace_size) - 2; |
| @@ -179,8 +169,8 @@ static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) | |||
| 179 | /* Derive the PAACE window count encoding for the subwindow count */ | 169 | /* Derive the PAACE window count encoding for the subwindow count */ |
| 180 | static unsigned int map_subwindow_cnt_to_wce(u32 subwindow_cnt) | 170 | static unsigned int map_subwindow_cnt_to_wce(u32 subwindow_cnt) |
| 181 | { | 171 | { |
| 182 | /* window count is 2^(WCE+1) bytes */ | 172 | /* window count is 2^(WCE+1) bytes */ |
| 183 | return __ffs(subwindow_cnt) - 1; | 173 | return __ffs(subwindow_cnt) - 1; |
| 184 | } | 174 | } |
| 185 | 175 | ||
| 186 | /* | 176 | /* |
| @@ -241,7 +231,7 @@ static struct paace *pamu_get_spaace(struct paace *paace, u32 wnum) | |||
| 241 | * If no SPAACE entry is available or the allocator can not reserve the required | 231 | * If no SPAACE entry is available or the allocator can not reserve the required |
| 242 | * number of contiguous entries function returns ULONG_MAX indicating a failure. | 232 | * number of contiguous entries function returns ULONG_MAX indicating a failure. |
| 243 | * | 233 | * |
| 244 | */ | 234 | */ |
| 245 | static unsigned long pamu_get_fspi_and_allocate(u32 subwin_cnt) | 235 | static unsigned long pamu_get_fspi_and_allocate(u32 subwin_cnt) |
| 246 | { | 236 | { |
| 247 | unsigned long spaace_addr; | 237 | unsigned long spaace_addr; |
| @@ -288,9 +278,8 @@ int pamu_update_paace_stash(int liodn, u32 subwin, u32 value) | |||
| 288 | } | 278 | } |
| 289 | if (subwin) { | 279 | if (subwin) { |
| 290 | paace = pamu_get_spaace(paace, subwin - 1); | 280 | paace = pamu_get_spaace(paace, subwin - 1); |
| 291 | if (!paace) { | 281 | if (!paace) |
| 292 | return -ENOENT; | 282 | return -ENOENT; |
| 293 | } | ||
| 294 | } | 283 | } |
| 295 | set_bf(paace->impl_attr, PAACE_IA_CID, value); | 284 | set_bf(paace->impl_attr, PAACE_IA_CID, value); |
| 296 | 285 | ||
| @@ -311,14 +300,12 @@ int pamu_disable_spaace(int liodn, u32 subwin) | |||
| 311 | } | 300 | } |
| 312 | if (subwin) { | 301 | if (subwin) { |
| 313 | paace = pamu_get_spaace(paace, subwin - 1); | 302 | paace = pamu_get_spaace(paace, subwin - 1); |
| 314 | if (!paace) { | 303 | if (!paace) |
| 315 | return -ENOENT; | 304 | return -ENOENT; |
| 316 | } | 305 | set_bf(paace->addr_bitfields, PAACE_AF_V, PAACE_V_INVALID); |
| 317 | set_bf(paace->addr_bitfields, PAACE_AF_V, | ||
| 318 | PAACE_V_INVALID); | ||
| 319 | } else { | 306 | } else { |
| 320 | set_bf(paace->addr_bitfields, PAACE_AF_AP, | 307 | set_bf(paace->addr_bitfields, PAACE_AF_AP, |
| 321 | PAACE_AP_PERMS_DENIED); | 308 | PAACE_AP_PERMS_DENIED); |
| 322 | } | 309 | } |
| 323 | 310 | ||
| 324 | mb(); | 311 | mb(); |
| @@ -326,7 +313,6 @@ int pamu_disable_spaace(int liodn, u32 subwin) | |||
| 326 | return 0; | 313 | return 0; |
| 327 | } | 314 | } |
| 328 | 315 | ||
| 329 | |||
| 330 | /** | 316 | /** |
| 331 | * pamu_config_paace() - Sets up PPAACE entry for specified liodn | 317 | * pamu_config_paace() - Sets up PPAACE entry for specified liodn |
| 332 | * | 318 | * |
| @@ -352,7 +338,8 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size, | |||
| 352 | unsigned long fspi; | 338 | unsigned long fspi; |
| 353 | 339 | ||
| 354 | if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) { | 340 | if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) { |
| 355 | pr_debug("window size too small or not a power of two %pa\n", &win_size); | 341 | pr_debug("window size too small or not a power of two %pa\n", |
