Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branches 'iommu/fixes', 'dma-debug', 'x86/amd', 'x86/vt-d', 'arm/tegra' and 'arm/omap' into next

+765 -594
+126
Documentation/DMA-API-HOWTO.txt
··· 468 468 size_t size = buffer->len; 469 469 470 470 dma_handle = dma_map_single(dev, addr, size, direction); 471 + if (dma_mapping_error(dma_handle)) { 472 + /* 473 + * reduce current DMA mapping usage, 474 + * delay and try again later or 475 + * reset driver. 476 + */ 477 + goto map_error_handling; 478 + } 471 479 472 480 and to unmap it: 473 481 474 482 dma_unmap_single(dev, dma_handle, size, direction); 483 + 484 + You should call dma_mapping_error() as dma_map_single() could fail and return 485 + error. Not all dma implementations support dma_mapping_error() interface. 486 + However, it is a good practice to call dma_mapping_error() interface, which 487 + will invoke the generic mapping error check interface. Doing so will ensure 488 + that the mapping code will work correctly on all dma implementations without 489 + any dependency on the specifics of the underlying implementation. Using the 490 + returned address without checking for errors could result in failures ranging 491 + from panics to silent data corruption. Couple of example of incorrect ways to 492 + check for errors that make assumptions about the underlying dma implementation 493 + are as follows and these are applicable to dma_map_page() as well. 494 + 495 + Incorrect example 1: 496 + dma_addr_t dma_handle; 497 + 498 + dma_handle = dma_map_single(dev, addr, size, direction); 499 + if ((dma_handle & 0xffff != 0) || (dma_handle >= 0x1000000)) { 500 + goto map_error; 501 + } 502 + 503 + Incorrect example 2: 504 + dma_addr_t dma_handle; 505 + 506 + dma_handle = dma_map_single(dev, addr, size, direction); 507 + if (dma_handle == DMA_ERROR_CODE) { 508 + goto map_error; 509 + } 475 510 476 511 You should call dma_unmap_single when the DMA activity is finished, e.g. 477 512 from the interrupt which told you that the DMA transfer is done. ··· 524 489 size_t size = buffer->len; 525 490 526 491 dma_handle = dma_map_page(dev, page, offset, size, direction); 492 + if (dma_mapping_error(dma_handle)) { 493 + /* 494 + * reduce current DMA mapping usage, 495 + * delay and try again later or 496 + * reset driver. 497 + */ 498 + goto map_error_handling; 499 + } 527 500 528 501 ... 529 502 530 503 dma_unmap_page(dev, dma_handle, size, direction); 531 504 532 505 Here, "offset" means byte offset within the given page. 506 + 507 + You should call dma_mapping_error() as dma_map_page() could fail and return 508 + error as outlined under the dma_map_single() discussion. 509 + 510 + You should call dma_unmap_page when the DMA activity is finished, e.g. 511 + from the interrupt which told you that the DMA transfer is done. 533 512 534 513 With scatterlists, you map a region gathered from several regions by: 535 514 ··· 627 578 dma_addr_t mapping; 628 579 629 580 mapping = dma_map_single(cp->dev, buffer, len, DMA_FROM_DEVICE); 581 + if (dma_mapping_error(dma_handle)) { 582 + /* 583 + * reduce current DMA mapping usage, 584 + * delay and try again later or 585 + * reset driver. 586 + */ 587 + goto map_error_handling; 588 + } 630 589 631 590 cp->rx_buf = buffer; 632 591 cp->rx_len = len; ··· 715 658 * delay and try again later or 716 659 * reset driver. 717 660 */ 661 + goto map_error_handling; 662 + } 663 + 664 + - unmap pages that are already mapped, when mapping error occurs in the middle 665 + of a multiple page mapping attempt. These example are applicable to 666 + dma_map_page() as well. 667 + 668 + Example 1: 669 + dma_addr_t dma_handle1; 670 + dma_addr_t dma_handle2; 671 + 672 + dma_handle1 = dma_map_single(dev, addr, size, direction); 673 + if (dma_mapping_error(dev, dma_handle1)) { 674 + /* 675 + * reduce current DMA mapping usage, 676 + * delay and try again later or 677 + * reset driver. 678 + */ 679 + goto map_error_handling1; 680 + } 681 + dma_handle2 = dma_map_single(dev, addr, size, direction); 682 + if (dma_mapping_error(dev, dma_handle2)) { 683 + /* 684 + * reduce current DMA mapping usage, 685 + * delay and try again later or 686 + * reset driver. 687 + */ 688 + goto map_error_handling2; 689 + } 690 + 691 + ... 692 + 693 + map_error_handling2: 694 + dma_unmap_single(dma_handle1); 695 + map_error_handling1: 696 + 697 + Example 2: (if buffers are allocated a loop, unmap all mapped buffers when 698 + mapping error is detected in the middle) 699 + 700 + dma_addr_t dma_addr; 701 + dma_addr_t array[DMA_BUFFERS]; 702 + int save_index = 0; 703 + 704 + for (i = 0; i < DMA_BUFFERS; i++) { 705 + 706 + ... 707 + 708 + dma_addr = dma_map_single(dev, addr, size, direction); 709 + if (dma_mapping_error(dev, dma_addr)) { 710 + /* 711 + * reduce current DMA mapping usage, 712 + * delay and try again later or 713 + * reset driver. 714 + */ 715 + goto map_error_handling; 716 + } 717 + array[i].dma_addr = dma_addr; 718 + save_index++; 719 + } 720 + 721 + ... 722 + 723 + map_error_handling: 724 + 725 + for (i = 0; i < save_index; i++) { 726 + 727 + ... 728 + 729 + dma_unmap_single(array[i].dma_addr); 718 730 } 719 731 720 732 Networking drivers must call dev_kfree_skb to free the socket buffer
+12
Documentation/DMA-API.txt
··· 678 678 of preallocated entries is defined per architecture. If it is too low for you 679 679 boot with 'dma_debug_entries=<your_desired_number>' to overwrite the 680 680 architectural default. 681 + 682 + void debug_dmap_mapping_error(struct device *dev, dma_addr_t dma_addr); 683 + 684 + dma-debug interface debug_dma_mapping_error() to debug drivers that fail 685 + to check dma mapping errors on addresses returned by dma_map_single() and 686 + dma_map_page() interfaces. This interface clears a flag set by 687 + debug_dma_map_page() to indicate that dma_mapping_error() has been called by 688 + the driver. When driver does unmap, debug_dma_unmap() checks the flag and if 689 + this flag is still set, prints warning message that includes call trace that 690 + leads up to the unmap. This interface can be called from dma_mapping_error() 691 + routines to enable dma mapping error check debugging. 692 +
+1
arch/arm/include/asm/dma-mapping.h
··· 91 91 */ 92 92 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 93 93 { 94 + debug_dma_mapping_error(dev, dma_addr); 94 95 return dma_addr == DMA_ERROR_CODE; 95 96 } 96 97
-2
arch/arm/mach-omap2/Makefile
··· 184 184 obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o 185 185 mailbox_mach-objs := mailbox.o 186 186 187 - obj-$(CONFIG_OMAP_IOMMU) += iommu2.o 188 - 189 187 iommu-$(CONFIG_OMAP_IOMMU) := omap-iommu.o 190 188 obj-y += $(iommu-m) $(iommu-y) 191 189
-22
arch/arm/mach-omap2/clock44xx_data.c
··· 1316 1316 .clkdm_name = "abe_clkdm", 1317 1317 }; 1318 1318 1319 - static struct clk dsp_fck = { 1320 - .name = "dsp_fck", 1321 - .ops = &clkops_omap2_dflt, 1322 - .enable_reg = OMAP4430_CM_TESLA_TESLA_CLKCTRL, 1323 - .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1324 - .clkdm_name = "tesla_clkdm", 1325 - .parent = &dpll_iva_m4x2_ck, 1326 - .recalc = &followparent_recalc, 1327 - }; 1328 - 1329 1319 static struct clk dss_sys_clk = { 1330 1320 .name = "dss_sys_clk", 1331 1321 .ops = &clkops_omap2_dflt, ··· 1683 1693 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 1684 1694 .clkdm_name = "l4_per_clkdm", 1685 1695 .parent = &func_96m_fclk, 1686 - .recalc = &followparent_recalc, 1687 - }; 1688 - 1689 - static struct clk ipu_fck = { 1690 - .name = "ipu_fck", 1691 - .ops = &clkops_omap2_dflt, 1692 - .enable_reg = OMAP4430_CM_DUCATI_DUCATI_CLKCTRL, 1693 - .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1694 - .clkdm_name = "ducati_clkdm", 1695 - .parent = &ducati_clk_mux_ck, 1696 1696 .recalc = &followparent_recalc, 1697 1697 }; 1698 1698 ··· 3131 3151 CLK(NULL, "div_ts_ck", &div_ts_ck, CK_446X), 3132 3152 CLK(NULL, "dmic_sync_mux_ck", &dmic_sync_mux_ck, CK_443X), 3133 3153 CLK(NULL, "dmic_fck", &dmic_fck, CK_443X), 3134 - CLK(NULL, "dsp_fck", &dsp_fck, CK_443X), 3135 3154 CLK(NULL, "dss_sys_clk", &dss_sys_clk, CK_443X), 3136 3155 CLK(NULL, "dss_tv_clk", &dss_tv_clk, CK_443X), 3137 3156 CLK(NULL, "dss_48mhz_clk", &dss_48mhz_clk, CK_443X), ··· 3162 3183 CLK(NULL, "i2c2_fck", &i2c2_fck, CK_443X), 3163 3184 CLK(NULL, "i2c3_fck", &i2c3_fck, CK_443X), 3164 3185 CLK(NULL, "i2c4_fck", &i2c4_fck, CK_443X), 3165 - CLK(NULL, "ipu_fck", &ipu_fck, CK_443X), 3166 3186 CLK(NULL, "iss_ctrlclk", &iss_ctrlclk, CK_443X), 3167 3187 CLK(NULL, "iss_fck", &iss_fck, CK_443X), 3168 3188 CLK(NULL, "iva_fck", &iva_fck, CK_443X),
+2 -2
arch/arm/mach-omap2/devices.c
··· 127 127 128 128 #if defined(CONFIG_IOMMU_API) 129 129 130 - #include <plat/iommu.h> 130 + #include <linux/platform_data/iommu-omap.h> 131 131 132 132 static struct resource omap3isp_resources[] = { 133 133 { ··· 214 214 }; 215 215 216 216 static struct omap_iommu_arch_data omap3_isp_iommu = { 217 - .name = "isp", 217 + .name = "mmu_isp", 218 218 }; 219 219 220 220 int omap3_init_camera(struct isp_platform_data *pdata)
+10 -37
arch/arm/mach-omap2/iommu2.c drivers/iommu/omap-iommu2.c
··· 13 13 14 14 #include <linux/err.h> 15 15 #include <linux/device.h> 16 + #include <linux/io.h> 16 17 #include <linux/jiffies.h> 17 18 #include <linux/module.h> 19 + #include <linux/omap-iommu.h> 18 20 #include <linux/slab.h> 19 21 #include <linux/stringify.h> 22 + #include <linux/platform_data/iommu-omap.h> 20 23 21 - #include <plat/iommu.h> 24 + #include "omap-iommu.h" 22 25 23 26 /* 24 27 * omap2 architecture specific register bit definitions 25 28 */ 26 29 #define IOMMU_ARCH_VERSION 0x00000011 27 - 28 - /* SYSCONF */ 29 - #define MMU_SYS_IDLE_SHIFT 3 30 - #define MMU_SYS_IDLE_FORCE (0 << MMU_SYS_IDLE_SHIFT) 31 - #define MMU_SYS_IDLE_NONE (1 << MMU_SYS_IDLE_SHIFT) 32 - #define MMU_SYS_IDLE_SMART (2 << MMU_SYS_IDLE_SHIFT) 33 - #define MMU_SYS_IDLE_MASK (3 << MMU_SYS_IDLE_SHIFT) 34 - 35 - #define MMU_SYS_SOFTRESET (1 << 1) 36 - #define MMU_SYS_AUTOIDLE 1 37 - 38 - /* SYSSTATUS */ 39 - #define MMU_SYS_RESETDONE 1 40 30 41 31 /* IRQSTATUS & IRQENABLE */ 42 32 #define MMU_IRQ_MULTIHITFAULT (1 << 4) ··· 55 65 ((pgsz) == MMU_CAM_PGSZ_64K) ? 0xffff0000 : \ 56 66 ((pgsz) == MMU_CAM_PGSZ_4K) ? 0xfffff000 : 0) 57 67 68 + /* IOMMU errors */ 69 + #define OMAP_IOMMU_ERR_TLB_MISS (1 << 0) 70 + #define OMAP_IOMMU_ERR_TRANS_FAULT (1 << 1) 71 + #define OMAP_IOMMU_ERR_EMU_MISS (1 << 2) 72 + #define OMAP_IOMMU_ERR_TBLWALK_FAULT (1 << 3) 73 + #define OMAP_IOMMU_ERR_MULTIHIT_FAULT (1 << 4) 58 74 59 75 static void __iommu_set_twl(struct omap_iommu *obj, bool on) 60 76 { ··· 84 88 static int omap2_iommu_enable(struct omap_iommu *obj) 85 89 { 86 90 u32 l, pa; 87 - unsigned long timeout; 88 91 89 92 if (!obj->iopgd || !IS_ALIGNED((u32)obj->iopgd, SZ_16K)) 90 93 return -EINVAL; ··· 92 97 if (!IS_ALIGNED(pa, SZ_16K)) 93 98 return -EINVAL; 94 99 95 - iommu_write_reg(obj, MMU_SYS_SOFTRESET, MMU_SYSCONFIG); 96 - 97 - timeout = jiffies + msecs_to_jiffies(20); 98 - do { 99 - l = iommu_read_reg(obj, MMU_SYSSTATUS); 100 - if (l & MMU_SYS_RESETDONE) 101 - break; 102 - } while (!time_after(jiffies, timeout)); 103 - 104 - if (!(l & MMU_SYS_RESETDONE)) { 105 - dev_err(obj->dev, "can't take mmu out of reset\n"); 106 - return -ENODEV; 107 - } 108 - 109 100 l = iommu_read_reg(obj, MMU_REVISION); 110 101 dev_info(obj->dev, "%s: version %d.%d\n", obj->name, 111 102 (l >> 4) & 0xf, l & 0xf); 112 - 113 - l = iommu_read_reg(obj, MMU_SYSCONFIG); 114 - l &= ~MMU_SYS_IDLE_MASK; 115 - l |= (MMU_SYS_IDLE_SMART | MMU_SYS_AUTOIDLE); 116 - iommu_write_reg(obj, l, MMU_SYSCONFIG); 117 103 118 104 iommu_write_reg(obj, pa, MMU_TTB); 119 105 ··· 109 133 110 134 l &= ~MMU_CNTL_MASK; 111 135 iommu_write_reg(obj, l, MMU_CNTL); 112 - iommu_write_reg(obj, MMU_SYS_IDLE_FORCE, MMU_SYSCONFIG); 113 136 114 137 dev_dbg(obj->dev, "%s is shutting down\n", obj->name); 115 138 } ··· 237 262 char *p = buf; 238 263 239 264 pr_reg(REVISION); 240 - pr_reg(SYSCONFIG); 241 - pr_reg(SYSSTATUS); 242 265 pr_reg(IRQSTATUS); 243 266 pr_reg(IRQENABLE); 244 267 pr_reg(WALKING_ST);
+39 -132
arch/arm/mach-omap2/omap-iommu.c
··· 12 12 13 13 #include <linux/module.h> 14 14 #include <linux/platform_device.h> 15 + #include <linux/err.h> 16 + #include <linux/slab.h> 15 17 16 - #include <plat/iommu.h> 18 + #include <linux/platform_data/iommu-omap.h> 19 + #include <plat/omap_hwmod.h> 20 + #include <plat/omap_device.h> 17 21 18 - #include "soc.h" 19 - #include "common.h" 22 + static int __init omap_iommu_dev_init(struct omap_hwmod *oh, void *unused) 23 + { 24 + struct platform_device *pdev; 25 + struct iommu_platform_data *pdata; 26 + struct omap_mmu_dev_attr *a = (struct omap_mmu_dev_attr *)oh->dev_attr; 27 + static int i; 20 28 21 - struct iommu_device { 22 - resource_size_t base; 23 - int irq; 24 - struct iommu_platform_data pdata; 25 - struct resource res[2]; 26 - }; 27 - static struct iommu_device *devices; 28 - static int num_iommu_devices; 29 + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 30 + if (!pdata) 31 + return -ENOMEM; 29 32 30 - #ifdef CONFIG_ARCH_OMAP3 31 - static struct iommu_device omap3_devices[] = { 32 - { 33 - .base = 0x480bd400, 34 - .irq = 24 + OMAP_INTC_START, 35 - .pdata = { 36 - .name = "isp", 37 - .nr_tlb_entries = 8, 38 - .clk_name = "cam_ick", 39 - .da_start = 0x0, 40 - .da_end = 0xFFFFF000, 41 - }, 42 - }, 43 - #if defined(CONFIG_OMAP_IOMMU_IVA2) 44 - { 45 - .base = 0x5d000000, 46 - .irq = 28 + OMAP_INTC_START, 47 - .pdata = { 48 - .name = "iva2", 49 - .nr_tlb_entries = 32, 50 - .clk_name = "iva2_ck", 51 - .da_start = 0x11000000, 52 - .da_end = 0xFFFFF000, 53 - }, 54 - }, 55 - #endif 56 - }; 57 - #define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices) 58 - static struct platform_device *omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES]; 59 - #else 60 - #define omap3_devices NULL 61 - #define NR_OMAP3_IOMMU_DEVICES 0 62 - #define omap3_iommu_pdev NULL 63 - #endif 33 + pdata->name = oh->name; 34 + pdata->nr_tlb_entries = a->nr_tlb_entries; 35 + pdata->da_start = a->da_start; 36 + pdata->da_end = a->da_end; 64 37 65 - #ifdef CONFIG_ARCH_OMAP4 66 - static struct iommu_device omap4_devices[] = { 67 - { 68 - .base = OMAP4_MMU1_BASE, 69 - .irq = 100 + OMAP44XX_IRQ_GIC_START, 70 - .pdata = { 71 - .name = "ducati", 72 - .nr_tlb_entries = 32, 73 - .clk_name = "ipu_fck", 74 - .da_start = 0x0, 75 - .da_end = 0xFFFFF000, 76 - }, 77 - }, 78 - { 79 - .base = OMAP4_MMU2_BASE, 80 - .irq = 28 + OMAP44XX_IRQ_GIC_START, 81 - .pdata = { 82 - .name = "tesla", 83 - .nr_tlb_entries = 32, 84 - .clk_name = "dsp_fck", 85 - .da_start = 0x0, 86 - .da_end = 0xFFFFF000, 87 - }, 88 - }, 89 - }; 90 - #define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices) 91 - static struct platform_device *omap4_iommu_pdev[NR_OMAP4_IOMMU_DEVICES]; 92 - #else 93 - #define omap4_devices NULL 94 - #define NR_OMAP4_IOMMU_DEVICES 0 95 - #define omap4_iommu_pdev NULL 96 - #endif 38 + if (oh->rst_lines_cnt == 1) { 39 + pdata->reset_name = oh->rst_lines->name; 40 + pdata->assert_reset = omap_device_assert_hardreset; 41 + pdata->deassert_reset = omap_device_deassert_hardreset; 42 + } 97 43 98 - static struct platform_device **omap_iommu_pdev; 44 + pdev = omap_device_build("omap-iommu", i, oh, pdata, sizeof(*pdata), 45 + NULL, 0, 0); 46 + 47 + kfree(pdata); 48 + 49 + if (IS_ERR(pdev)) { 50 + pr_err("%s: device build err: %ld\n", __func__, PTR_ERR(pdev)); 51 + return PTR_ERR(pdev); 52 + } 53 + 54 + i++; 55 + 56 + return 0; 57 + } 99 58 100 59 static int __init omap_iommu_init(void) 101 60 { 102 - int i, err; 103 - struct resource res[] = { 104 - { .flags = IORESOURCE_MEM }, 105 - { .flags = IORESOURCE_IRQ }, 106 - }; 107 - 108 - if (cpu_is_omap34xx()) { 109 - devices = omap3_devices; 110 - omap_iommu_pdev = omap3_iommu_pdev; 111 - num_iommu_devices = NR_OMAP3_IOMMU_DEVICES; 112 - } else if (cpu_is_omap44xx()) { 113 - devices = omap4_devices; 114 - omap_iommu_pdev = omap4_iommu_pdev; 115 - num_iommu_devices = NR_OMAP4_IOMMU_DEVICES; 116 - } else 117 - return -ENODEV; 118 - 119 - for (i = 0; i < num_iommu_devices; i++) { 120 - struct platform_device *pdev; 121 - const struct iommu_device *d = &devices[i]; 122 - 123 - pdev = platform_device_alloc("omap-iommu", i); 124 - if (!pdev) { 125 - err = -ENOMEM; 126 - goto err_out; 127 - } 128 - 129 - res[0].start = d->base; 130 - res[0].end = d->base + MMU_REG_SIZE - 1; 131 - res[1].start = res[1].end = d->irq; 132 - 133 - err = platform_device_add_resources(pdev, res, 134 - ARRAY_SIZE(res)); 135 - if (err) 136 - goto err_out; 137 - err = platform_device_add_data(pdev, &d->pdata, 138 - sizeof(d->pdata)); 139 - if (err) 140 - goto err_out; 141 - err = platform_device_add(pdev); 142 - if (err) 143 - goto err_out; 144 - omap_iommu_pdev[i] = pdev; 145 - } 146 - return 0; 147 - 148 - err_out: 149 - while (i--) 150 - platform_device_put(omap_iommu_pdev[i]); 151 - return err; 61 + return omap_hwmod_for_each_by_class("mmu", omap_iommu_dev_init, NULL); 152 62 } 153 63 /* must be ready before omap3isp is probed */ 154 64 subsys_initcall(omap_iommu_init); 155 65 156 66 static void __exit omap_iommu_exit(void) 157 67 { 158 - int i; 159 - 160 - for (i = 0; i < num_iommu_devices; i++) 161 - platform_device_unregister(omap_iommu_pdev[i]); 68 + /* Do nothing */ 162 69 } 163 70 module_exit(omap_iommu_exit); 164 71
+1 -1
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
··· 26 26 #include <plat/mmc.h> 27 27 #include <linux/platform_data/asoc-ti-mcbsp.h> 28 28 #include <linux/platform_data/spi-omap2-mcspi.h> 29 + #include <linux/platform_data/iommu-omap.h> 29 30 #include <plat/dmtimer.h> 30 - #include <plat/iommu.h> 31 31 32 32 #include "am35xx.h" 33 33
+3 -3
arch/arm/mach-omap2/omap_hwmod_44xx_data.c
··· 28 28 #include <plat/dma.h> 29 29 #include <linux/platform_data/spi-omap2-mcspi.h> 30 30 #include <linux/platform_data/asoc-ti-mcbsp.h> 31 + #include <linux/platform_data/iommu-omap.h> 31 32 #include <plat/mmc.h> 32 33 #include <plat/dmtimer.h> 33 34 #include <plat/common.h> 34 - #include <plat/iommu.h> 35 35 36 36 #include "omap_hwmod_common_data.h" 37 37 #include "cm1_44xx.h" ··· 651 651 .mpu_irqs = omap44xx_dsp_irqs, 652 652 .rst_lines = omap44xx_dsp_resets, 653 653 .rst_lines_cnt = ARRAY_SIZE(omap44xx_dsp_resets), 654 - .main_clk = "dsp_fck", 654 + .main_clk = "dpll_iva_m4x2_ck", 655 655 .prcm = { 656 656 .omap4 = { 657 657 .clkctrl_offs = OMAP4_CM_TESLA_TESLA_CLKCTRL_OFFSET, ··· 1678 1678 .mpu_irqs = omap44xx_ipu_irqs, 1679 1679 .rst_lines = omap44xx_ipu_resets, 1680 1680 .rst_lines_cnt = ARRAY_SIZE(omap44xx_ipu_resets), 1681 - .main_clk = "ipu_fck", 1681 + .main_clk = "ducati_clk_mux_ck", 1682 1682 .prcm = { 1683 1683 .omap4 = { 1684 1684 .clkctrl_offs = OMAP4_CM_DUCATI_DUCATI_CLKCTRL_OFFSET,
+68 -64
arch/arm/plat-omap/include/plat/iommu.h drivers/iommu/omap-iommu.h
··· 10 10 * published by the Free Software Foundation. 11 11 */ 12 12 13 - #ifndef __MACH_IOMMU_H 14 - #define __MACH_IOMMU_H 13 + #if defined(CONFIG_ARCH_OMAP1) 14 + #error "iommu for this processor not implemented yet" 15 + #endif 15 16 16 17 struct iotlb_entry { 17 18 u32 da; ··· 29 28 struct omap_iommu { 30 29 const char *name; 31 30 struct module *owner; 32 - struct clk *clk; 33 31 void __iomem *regbase; 34 32 struct device *dev; 35 33 void *isr_priv; ··· 71 71 }; 72 72 }; 73 73 74 - struct iotlb_lock { 75 - short base; 76 - short vict; 77 - }; 78 - 79 74 /* architecture specific functions */ 80 75 struct iommu_functions { 81 76 unsigned long version; ··· 98 103 ssize_t (*dump_ctx)(struct omap_iommu *obj, char *buf, ssize_t len); 99 104 }; 100 105 101 - /** 102 - * struct omap_mmu_dev_attr - OMAP mmu device attributes for omap_hwmod 103 - * @da_start: device address where the va space starts. 104 - * @da_end: device address where the va space ends. 105 - * @nr_tlb_entries: number of entries supported by the translation 106 - * look-aside buffer (TLB). 107 - */ 108 - struct omap_mmu_dev_attr { 109 - u32 da_start; 110 - u32 da_end; 111 - int nr_tlb_entries; 112 - }; 113 - 114 - struct iommu_platform_data { 115 - const char *name; 116 - const char *clk_name; 117 - const int nr_tlb_entries; 118 - u32 da_start; 119 - u32 da_end; 120 - }; 121 - 122 - /** 123 - * struct iommu_arch_data - omap iommu private data 124 - * @name: name of the iommu device 125 - * @iommu_dev: handle of the iommu device 126 - * 127 - * This is an omap iommu private data object, which binds an iommu user 128 - * to its iommu device. This object should be placed at the iommu user's 129 - * dev_archdata so generic IOMMU API can be used without having to 130 - * utilize omap-specific plumbing anymore. 131 - */ 132 - struct omap_iommu_arch_data { 133 - const char *name; 134 - struct omap_iommu *iommu_dev; 135 - }; 136 - 137 106 #ifdef CONFIG_IOMMU_API 138 107 /** 139 108 * dev_to_omap_iommu() - retrieves an omap iommu object from a user device ··· 111 152 } 112 153 #endif 113 154 114 - /* IOMMU errors */ 115 - #define OMAP_IOMMU_ERR_TLB_MISS (1 << 0) 116 - #define OMAP_IOMMU_ERR_TRANS_FAULT (1 << 1) 117 - #define OMAP_IOMMU_ERR_EMU_MISS (1 << 2) 118 - #define OMAP_IOMMU_ERR_TBLWALK_FAULT (1 << 3) 119 - #define OMAP_IOMMU_ERR_MULTIHIT_FAULT (1 << 4) 155 + /* 156 + * MMU Register offsets 157 + */ 158 + #define MMU_REVISION 0x00 159 + #define MMU_IRQSTATUS 0x18 160 + #define MMU_IRQENABLE 0x1c 161 + #define MMU_WALKING_ST 0x40 162 + #define MMU_CNTL 0x44 163 + #define MMU_FAULT_AD 0x48 164 + #define MMU_TTB 0x4c 165 + #define MMU_LOCK 0x50 166 + #define MMU_LD_TLB 0x54 167 + #define MMU_CAM 0x58 168 + #define MMU_RAM 0x5c 169 + #define MMU_GFLUSH 0x60 170 + #define MMU_FLUSH_ENTRY 0x64 171 + #define MMU_READ_CAM 0x68 172 + #define MMU_READ_RAM 0x6c 173 + #define MMU_EMU_FAULT_AD 0x70 120 174 121 - #if defined(CONFIG_ARCH_OMAP1) 122 - #error "iommu for this processor not implemented yet" 123 - #else 124 - #include <plat/iommu2.h> 125 - #endif 175 + #define MMU_REG_SIZE 256 176 + 177 + /* 178 + * MMU Register bit definitions 179 + */ 180 + #define MMU_CAM_VATAG_SHIFT 12 181 + #define MMU_CAM_VATAG_MASK \ 182 + ((~0UL >> MMU_CAM_VATAG_SHIFT) << MMU_CAM_VATAG_SHIFT) 183 + #define MMU_CAM_P (1 << 3) 184 + #define MMU_CAM_V (1 << 2) 185 + #define MMU_CAM_PGSZ_MASK 3 186 + #define MMU_CAM_PGSZ_1M (0 << 0) 187 + #define MMU_CAM_PGSZ_64K (1 << 0) 188 + #define MMU_CAM_PGSZ_4K (2 << 0) 189 + #define MMU_CAM_PGSZ_16M (3 << 0) 190 + 191 + #define MMU_RAM_PADDR_SHIFT 12 192 + #define MMU_RAM_PADDR_MASK \ 193 + ((~0UL >> MMU_RAM_PADDR_SHIFT) << MMU_RAM_PADDR_SHIFT) 194 + 195 + #define MMU_RAM_ENDIAN_MASK (1 << MMU_RAM_ENDIAN_SHIFT) 196 + #define MMU_RAM_ENDIAN_BIG (1 << MMU_RAM_ENDIAN_SHIFT) 197 + 198 + #define MMU_RAM_ELSZ_MASK (3 << MMU_RAM_ELSZ_SHIFT) 199 + #define MMU_RAM_ELSZ_8 (0 << MMU_RAM_ELSZ_SHIFT) 200 + #define MMU_RAM_ELSZ_16 (1 << MMU_RAM_ELSZ_SHIFT) 201 + #define MMU_RAM_ELSZ_32 (2 << MMU_RAM_ELSZ_SHIFT) 202 + #define MMU_RAM_ELSZ_NONE (3 << MMU_RAM_ELSZ_SHIFT) 203 + #define MMU_RAM_MIXED_SHIFT 6 204 + #define MMU_RAM_MIXED_MASK (1 << MMU_RAM_MIXED_SHIFT) 205 + #define MMU_RAM_MIXED MMU_RAM_MIXED_MASK 126 206 127 207 /* 128 208 * utilities for super page(16MB, 1MB, 64KB and 4KB) ··· 197 199 extern int 198 200 omap_iopgtable_store_entry(struct omap_iommu *obj, struct iotlb_entry *e); 199 201 200 - extern int omap_iommu_set_isr(const char *name, 201 - int (*isr)(struct omap_iommu *obj, u32 da, u32 iommu_errs, 202 - void *priv), 203 - void *isr_priv); 204 - 205 202 extern void omap_iommu_save_ctx(struct device *dev); 206 203 extern void omap_iommu_restore_ctx(struct device *dev); 207 204 208 - extern int omap_install_iommu_arch(const struct iommu_functions *ops); 209 - extern void omap_uninstall_iommu_arch(const struct iommu_functions *ops); 210 - 211 205 extern int omap_foreach_iommu_device(void *data, 212 206 int (*fn)(struct device *, void *)); 207 + 208 + extern int omap_install_iommu_arch(const struct iommu_functions *ops); 209 + extern void omap_uninstall_iommu_arch(const struct iommu_functions *ops); 213 210 214 211 extern ssize_t 215 212 omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len); 216 213 extern size_t 217 214 omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len); 218 215 219 - #endif /* __MACH_IOMMU_H */ 216 + /* 217 + * register accessors 218 + */ 219 + static inline u32 iommu_read_reg(struct omap_iommu *obj, size_t offs) 220 + { 221 + return __raw_readl(obj->regbase + offs); 222 + } 223 + 224 + static inline void iommu_write_reg(struct omap_iommu *obj, u32 val, size_t offs) 225 + { 226 + __raw_writel(val, obj->regbase + offs); 227 + }
-96
arch/arm/plat-omap/include/plat/iommu2.h
··· 1 - /* 2 - * omap iommu: omap2 architecture specific definitions 3 - * 4 - * Copyright (C) 2008-2009 Nokia Corporation 5 - * 6 - * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com> 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - */ 12 - 13 - #ifndef __MACH_IOMMU2_H 14 - #define __MACH_IOMMU2_H 15 - 16 - #include <linux/io.h> 17 - 18 - /* 19 - * MMU Register offsets 20 - */ 21 - #define MMU_REVISION 0x00 22 - #define MMU_SYSCONFIG 0x10 23 - #define MMU_SYSSTATUS 0x14 24 - #define MMU_IRQSTATUS 0x18 25 - #define MMU_IRQENABLE 0x1c 26 - #define MMU_WALKING_ST 0x40 27 - #define MMU_CNTL 0x44 28 - #define MMU_FAULT_AD 0x48 29 - #define MMU_TTB 0x4c 30 - #define MMU_LOCK 0x50 31 - #define MMU_LD_TLB 0x54 32 - #define MMU_CAM 0x58 33 - #define MMU_RAM 0x5c 34 - #define MMU_GFLUSH 0x60 35 - #define MMU_FLUSH_ENTRY 0x64 36 - #define MMU_READ_CAM 0x68 37 - #define MMU_READ_RAM 0x6c 38 - #define MMU_EMU_FAULT_AD 0x70 39 - 40 - #define MMU_REG_SIZE 256 41 - 42 - /* 43 - * MMU Register bit definitions 44 - */ 45 - #define MMU_LOCK_BASE_SHIFT 10 46 - #define MMU_LOCK_BASE_MASK (0x1f << MMU_LOCK_BASE_SHIFT) 47 - #define MMU_LOCK_BASE(x) \ 48 - ((x & MMU_LOCK_BASE_MASK) >> MMU_LOCK_BASE_SHIFT) 49 - 50 - #define MMU_LOCK_VICT_SHIFT 4 51 - #define MMU_LOCK_VICT_MASK (0x1f << MMU_LOCK_VICT_SHIFT) 52 - #define MMU_LOCK_VICT(x) \ 53 - ((x & MMU_LOCK_VICT_MASK) >> MMU_LOCK_VICT_SHIFT) 54 - 55 - #define MMU_CAM_VATAG_SHIFT 12 56 - #define MMU_CAM_VATAG_MASK \ 57 - ((~0UL >> MMU_CAM_VATAG_SHIFT) << MMU_CAM_VATAG_SHIFT) 58 - #define MMU_CAM_P (1 << 3) 59 - #define MMU_CAM_V (1 << 2) 60 - #define MMU_CAM_PGSZ_MASK 3 61 - #define MMU_CAM_PGSZ_1M (0 << 0) 62 - #define MMU_CAM_PGSZ_64K (1 << 0) 63 - #define MMU_CAM_PGSZ_4K (2 << 0) 64 - #define MMU_CAM_PGSZ_16M (3 << 0) 65 - 66 - #define MMU_RAM_PADDR_SHIFT 12 67 - #define MMU_RAM_PADDR_MASK \ 68 - ((~0UL >> MMU_RAM_PADDR_SHIFT) << MMU_RAM_PADDR_SHIFT) 69 - #define MMU_RAM_ENDIAN_SHIFT 9 70 - #define MMU_RAM_ENDIAN_MASK (1 << MMU_RAM_ENDIAN_SHIFT) 71 - #define MMU_RAM_ENDIAN_BIG (1 << MMU_RAM_ENDIAN_SHIFT) 72 - #define MMU_RAM_ENDIAN_LITTLE (0 << MMU_RAM_ENDIAN_SHIFT) 73 - #define MMU_RAM_ELSZ_SHIFT 7 74 - #define MMU_RAM_ELSZ_MASK (3 << MMU_RAM_ELSZ_SHIFT) 75 - #define MMU_RAM_ELSZ_8 (0 << MMU_RAM_ELSZ_SHIFT) 76 - #define MMU_RAM_ELSZ_16 (1 << MMU_RAM_ELSZ_SHIFT) 77 - #define MMU_RAM_ELSZ_32 (2 << MMU_RAM_ELSZ_SHIFT) 78 - #define MMU_RAM_ELSZ_NONE (3 << MMU_RAM_ELSZ_SHIFT) 79 - #define MMU_RAM_MIXED_SHIFT 6 80 - #define MMU_RAM_MIXED_MASK (1 << MMU_RAM_MIXED_SHIFT) 81 - #define MMU_RAM_MIXED MMU_RAM_MIXED_MASK 82 - 83 - /* 84 - * register accessors 85 - */ 86 - static inline u32 iommu_read_reg(struct omap_iommu *obj, size_t offs) 87 - { 88 - return __raw_readl(obj->regbase + offs); 89 - } 90 - 91 - static inline void iommu_write_reg(struct omap_iommu *obj, u32 val, size_t offs) 92 - { 93 - __raw_writel(val, obj->regbase + offs); 94 - } 95 - 96 - #endif /* __MACH_IOMMU2_H */
-22
arch/arm/plat-omap/include/plat/iopgtable.h drivers/iommu/omap-iopgtable.h
··· 10 10 * published by the Free Software Foundation. 11 11 */ 12 12 13 - #ifndef __PLAT_OMAP_IOMMU_H 14 - #define __PLAT_OMAP_IOMMU_H 15 - 16 13 /* 17 14 * "L2 table" address mask and size definitions. 18 15 */ ··· 94 97 #define iopte_index(da) (((da) >> IOPTE_SHIFT) & (PTRS_PER_IOPTE - 1)) 95 98 #define iopte_offset(iopgd, da) (iopgd_page_vaddr(iopgd) + iopte_index(da)) 96 99 97 - static inline u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, 98 - u32 flags) 99 - { 100 - memset(e, 0, sizeof(*e)); 101 - 102 - e->da = da; 103 - e->pa = pa; 104 - e->valid = 1; 105 - /* FIXME: add OMAP1 support */ 106 - e->pgsz = flags & MMU_CAM_PGSZ_MASK; 107 - e->endian = flags & MMU_RAM_ENDIAN_MASK; 108 - e->elsz = flags & MMU_RAM_ELSZ_MASK; 109 - e->mixed = flags & MMU_RAM_MIXED_MASK; 110 - 111 - return iopgsz_to_bytes(e->pgsz); 112 - } 113 - 114 100 #define to_iommu(dev) \ 115 101 (struct omap_iommu *)platform_get_drvdata(to_platform_device(dev)) 116 - 117 - #endif /* __PLAT_OMAP_IOMMU_H */
-89
arch/arm/plat-omap/include/plat/iovmm.h
··· 1 - /* 2 - * omap iommu: simple virtual address space management 3 - * 4 - * Copyright (C) 2008-2009 Nokia Corporation 5 - * 6 - * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com> 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - */ 12 - 13 - #ifndef __IOMMU_MMAP_H 14 - #define __IOMMU_MMAP_H 15 - 16 - #include <linux/iommu.h> 17 - 18 - struct iovm_struct { 19 - struct omap_iommu *iommu; /* iommu object which this belongs to */ 20 - u32 da_start; /* area definition */ 21 - u32 da_end; 22 - u32 flags; /* IOVMF_: see below */ 23 - struct list_head list; /* linked in ascending order */ 24 - const struct sg_table *sgt; /* keep 'page' <-> 'da' mapping */ 25 - void *va; /* mpu side mapped address */ 26 - }; 27 - 28 - /* 29 - * IOVMF_FLAGS: attribute for iommu virtual memory area(iovma) 30 - * 31 - * lower 16 bit is used for h/w and upper 16 bit is for s/w. 32 - */ 33 - #define IOVMF_SW_SHIFT 16 34 - 35 - /* 36 - * iovma: h/w flags derived from cam and ram attribute 37 - */ 38 - #define IOVMF_CAM_MASK (~((1 << 10) - 1)) 39 - #define IOVMF_RAM_MASK (~IOVMF_CAM_MASK) 40 - 41 - #define IOVMF_PGSZ_MASK (3 << 0) 42 - #define IOVMF_PGSZ_1M MMU_CAM_PGSZ_1M 43 - #define IOVMF_PGSZ_64K MMU_CAM_PGSZ_64K 44 - #define IOVMF_PGSZ_4K MMU_CAM_PGSZ_4K 45 - #define IOVMF_PGSZ_16M MMU_CAM_PGSZ_16M 46 - 47 - #define IOVMF_ENDIAN_MASK (1 << 9) 48 - #define IOVMF_ENDIAN_BIG MMU_RAM_ENDIAN_BIG 49 - #define IOVMF_ENDIAN_LITTLE MMU_RAM_ENDIAN_LITTLE 50 - 51 - #define IOVMF_ELSZ_MASK (3 << 7) 52 - #define IOVMF_ELSZ_8 MMU_RAM_ELSZ_8 53 - #define IOVMF_ELSZ_16 MMU_RAM_ELSZ_16 54 - #define IOVMF_ELSZ_32 MMU_RAM_ELSZ_32 55 - #define IOVMF_ELSZ_NONE MMU_RAM_ELSZ_NONE 56 - 57 - #define IOVMF_MIXED_MASK (1 << 6) 58 - #define IOVMF_MIXED MMU_RAM_MIXED 59 - 60 - /* 61 - * iovma: s/w flags, used for mapping and umapping internally. 62 - */ 63 - #define IOVMF_MMIO (1 << IOVMF_SW_SHIFT) 64 - #define IOVMF_ALLOC (2 << IOVMF_SW_SHIFT) 65 - #define IOVMF_ALLOC_MASK (3 << IOVMF_SW_SHIFT) 66 - 67 - /* "superpages" is supported just with physically linear pages */ 68 - #define IOVMF_DISCONT (1 << (2 + IOVMF_SW_SHIFT)) 69 - #define IOVMF_LINEAR (2 << (2 + IOVMF_SW_SHIFT)) 70 - #define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT)) 71 - 72 - #define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT)) 73 - 74 - 75 - extern struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da); 76 - extern u32 77 - omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da, 78 - const struct sg_table *sgt, u32 flags); 79 - extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain, 80 - struct device *dev, u32 da); 81 - extern u32 82 - omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev, 83 - u32 da, size_t bytes, u32 flags); 84 - extern void 85 - omap_iommu_vfree(struct iommu_domain *domain, struct device *dev, 86 - const u32 da); 87 - extern void *omap_da_to_va(struct device *dev, u32 da); 88 - 89 - #endif /* __IOMMU_MMAP_H */
+1
arch/arm64/include/asm/dma-mapping.h
··· 50 50 static inline int dma_mapping_error(struct device *dev, dma_addr_t dev_addr) 51 51 { 52 52 struct dma_map_ops *ops = get_dma_ops(dev); 53 + debug_dma_mapping_error(dev, dev_addr); 53 54 return ops->mapping_error(dev, dev_addr); 54 55 } 55 56
+1
arch/c6x/include/asm/dma-mapping.h
··· 32 32 */ 33 33 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 34 34 { 35 + debug_dma_mapping_error(dev, dma_addr); 35 36 return dma_addr == ~0; 36 37 } 37 38
+1
arch/ia64/include/asm/dma-mapping.h
··· 58 58 static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr) 59 59 { 60 60 struct dma_map_ops *ops = platform_dma_get_ops(dev); 61 + debug_dma_mapping_error(dev, daddr); 61 62 return ops->mapping_error(dev, daddr); 62 63 } 63 64
+2
arch/microblaze/include/asm/dma-mapping.h
··· 114 114 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 115 115 { 116 116 struct dma_map_ops *ops = get_dma_ops(dev); 117 + 118 + debug_dma_mapping_error(dev, dma_addr); 117 119 if (ops->mapping_error) 118 120 return ops->mapping_error(dev, dma_addr); 119 121
+2
arch/mips/include/asm/dma-mapping.h
··· 40 40 static inline int dma_mapping_error(struct device *dev, u64 mask) 41 41 { 42 42 struct dma_map_ops *ops = get_dma_ops(dev); 43 + 44 + debug_dma_mapping_error(dev, mask); 43 45 return ops->mapping_error(dev, mask); 44 46 } 45 47
+1
arch/powerpc/include/asm/dma-mapping.h
··· 172 172 { 173 173 struct dma_map_ops *dma_ops = get_dma_ops(dev); 174 174 175 + debug_dma_mapping_error(dev, dma_addr); 175 176 if (dma_ops->mapping_error) 176 177 return dma_ops->mapping_error(dev, dma_addr); 177 178
+1
arch/sh/include/asm/dma-mapping.h
··· 46 46 { 47 47 struct dma_map_ops *ops = get_dma_ops(dev); 48 48 49 + debug_dma_mapping_error(dev, dma_addr); 49 50 if (ops->mapping_error) 50 51 return ops->mapping_error(dev, dma_addr); 51 52
+1
arch/sparc/include/asm/dma-mapping.h
··· 59 59 60 60 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 61 61 { 62 + debug_dma_mapping_error(dev, dma_addr); 62 63 return (dma_addr == DMA_ERROR_CODE); 63 64 } 64 65
+1
arch/tile/include/asm/dma-mapping.h
··· 72 72 static inline int 73 73 dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 74 74 { 75 + debug_dma_mapping_error(dev, dma_addr); 75 76 return get_dma_ops(dev)->mapping_error(dev, dma_addr); 76 77 } 77 78
+1
arch/x86/include/asm/dma-mapping.h
··· 47 47 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 48 48 { 49 49 struct dma_map_ops *ops = get_dma_ops(dev); 50 + debug_dma_mapping_error(dev, dma_addr); 50 51 if (ops->mapping_error) 51 52 return ops->mapping_error(dev, dma_addr); 52 53
+1
drivers/iommu/Makefile
··· 7 7 obj-$(CONFIG_INTEL_IOMMU) += iova.o intel-iommu.o 8 8 obj-$(CONFIG_IRQ_REMAP) += intel_irq_remapping.o irq_remapping.o 9 9 obj-$(CONFIG_OMAP_IOMMU) += omap-iommu.o 10 + obj-$(CONFIG_OMAP_IOMMU) += omap-iommu2.o 10 11 obj-$(CONFIG_OMAP_IOVMM) += omap-iovmm.o 11 12 obj-$(CONFIG_OMAP_IOMMU_DEBUG) += omap-iommu-debug.o 12 13 obj-$(CONFIG_TEGRA_IOMMU_GART) += tegra-gart.o
+155 -65
drivers/iommu/amd_iommu.c
··· 57 57 * physically contiguous memory regions it is mapping into page sizes 58 58 * that we support. 59 59 * 60 - * Traditionally the IOMMU core just handed us the mappings directly, 61 - * after making sure the size is an order of a 4KiB page and that the 62 - * mapping has natural alignment. 63 - * 64 - * To retain this behavior, we currently advertise that we support 65 - * all page sizes that are an order of 4KiB. 66 - * 67 - * If at some point we'd like to utilize the IOMMU core's new behavior, 68 - * we could change this to advertise the real page sizes we support. 60 + * 512GB Pages are not supported due to a hardware bug 69 61 */ 70 - #define AMD_IOMMU_PGSIZES (~0xFFFUL) 62 + #define AMD_IOMMU_PGSIZES ((~0xFFFUL) & ~(2ULL << 38)) 71 63 72 64 static DEFINE_RWLOCK(amd_iommu_devtable_lock); 73 65 ··· 131 139 spin_lock_irqsave(&dev_data_list_lock, flags); 132 140 list_del(&dev_data->dev_data_list); 133 141 spin_unlock_irqrestore(&dev_data_list_lock, flags); 142 + 143 + if (dev_data->group) 144 + iommu_group_put(dev_data->group); 134 145 135 146 kfree(dev_data); 136 147 } ··· 269 274 *from = to; 270 275 } 271 276 277 + static struct pci_bus *find_hosted_bus(struct pci_bus *bus) 278 + { 279 + while (!bus->self) { 280 + if (!pci_is_root_bus(bus)) 281 + bus = bus->parent; 282 + else 283 + return ERR_PTR(-ENODEV); 284 + } 285 + 286 + return bus; 287 + } 288 + 272 289 #define REQ_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF) 290 + 291 + static struct pci_dev *get_isolation_root(struct pci_dev *pdev) 292 + { 293 + struct pci_dev *dma_pdev = pdev; 294 + 295 + /* Account for quirked devices */ 296 + swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev)); 297 + 298 + /* 299 + * If it's a multifunction device that does not support our 300 + * required ACS flags, add to the same group as function 0. 301 + */ 302 + if (dma_pdev->multifunction && 303 + !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS)) 304 + swap_pci_ref(&dma_pdev, 305 + pci_get_slot(dma_pdev->bus, 306 + PCI_DEVFN(PCI_SLOT(dma_pdev->devfn), 307 + 0))); 308 + 309 + /* 310 + * Devices on the root bus go through the iommu. If that's not us, 311 + * find the next upstream device and test ACS up to the root bus. 312 + * Finding the next device may require skipping virtual buses. 313 + */ 314 + while (!pci_is_root_bus(dma_pdev->bus)) { 315 + struct pci_bus *bus = find_hosted_bus(dma_pdev->bus); 316 + if (IS_ERR(bus)) 317 + break; 318 + 319 + if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS)) 320 + break; 321 + 322 + swap_pci_ref(&dma_pdev, pci_dev_get(bus->self)); 323 + } 324 + 325 + return dma_pdev; 326 + } 327 + 328 + static int use_pdev_iommu_group(struct pci_dev *pdev, struct device *dev) 329 + { 330 + struct iommu_group *group = iommu_group_get(&pdev->dev); 331 + int ret; 332 + 333 + if (!group) { 334 + group = iommu_group_alloc(); 335 + if (IS_ERR(group)) 336 + return PTR_ERR(group); 337 + 338 + WARN_ON(&pdev->dev != dev); 339 + } 340 + 341 + ret = iommu_group_add_device(group, dev); 342 + iommu_group_put(group); 343 + return ret; 344 + } 345 + 346 + static int use_dev_data_iommu_group(struct iommu_dev_data *dev_data, 347 + struct device *dev) 348 + { 349 + if (!dev_data->group) { 350 + struct iommu_group *group = iommu_group_alloc(); 351 + if (IS_ERR(group)) 352 + return PTR_ERR(group); 353 + 354 + dev_data->group = group; 355 + } 356 + 357 + return iommu_group_add_device(dev_data->group, dev); 358 + } 359 + 360 + static int init_iommu_group(struct device *dev) 361 + { 362 + struct iommu_dev_data *dev_data; 363 + struct iommu_group *group; 364 + struct pci_dev *dma_pdev; 365 + int ret; 366 + 367 + group = iommu_group_get(dev); 368 + if (group) { 369 + iommu_group_put(group); 370 + return 0; 371 + } 372 + 373 + dev_data = find_dev_data(get_device_id(dev)); 374 + if (!dev_data) 375 + return -ENOMEM; 376 + 377 + if (dev_data->alias_data) { 378 + u16 alias; 379 + struct pci_bus *bus; 380 + 381 + if (dev_data->alias_data->group) 382 + goto use_group; 383 + 384 + /* 385 + * If the alias device exists, it's effectively just a first 386 + * level quirk for finding the DMA source. 387 + */ 388 + alias = amd_iommu_alias_table[dev_data->devid]; 389 + dma_pdev = pci_get_bus_and_slot(alias >> 8, alias & 0xff); 390 + if (dma_pdev) { 391 + dma_pdev = get_isolation_root(dma_pdev); 392 + goto use_pdev; 393 + } 394 + 395 + /* 396 + * If the alias is virtual, try to find a parent device 397 + * and test whether the IOMMU group is actualy rooted above 398 + * the alias. Be careful to also test the parent device if 399 + * we think the alias is the root of the group. 400 + */ 401 + bus = pci_find_bus(0, alias >> 8); 402 + if (!bus) 403 + goto use_group; 404 + 405 + bus = find_hosted_bus(bus); 406 + if (IS_ERR(bus) || !bus->self) 407 + goto use_group; 408 + 409 + dma_pdev = get_isolation_root(pci_dev_get(bus->self)); 410 + if (dma_pdev != bus->self || (dma_pdev->multifunction && 411 + !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS))) 412 + goto use_pdev; 413 + 414 + pci_dev_put(dma_pdev); 415 + goto use_group; 416 + } 417 + 418 + dma_pdev = get_isolation_root(pci_dev_get(to_pci_dev(dev))); 419 + use_pdev: 420 + ret = use_pdev_iommu_group(dma_pdev, dev); 421 + pci_dev_put(dma_pdev); 422 + return ret; 423 + use_group: 424 + return use_dev_data_iommu_group(dev_data->alias_data, dev); 425 + } 273 426 274 427 static int iommu_init_device(struct device *dev) 275 428 { 276 - struct pci_dev *dma_pdev = NULL, *pdev = to_pci_dev(dev); 429 + struct pci_dev *pdev = to_pci_dev(dev); 277 430 struct iommu_dev_data *dev_data; 278 - struct iommu_group *group; 279 431 u16 alias; 280 432 int ret; 281 433 ··· 445 303 return -ENOTSUPP; 446 304 } 447 305 dev_data->alias_data = alias_data; 448 - 449 - dma_pdev = pci_get_bus_and_slot(alias >> 8, alias & 0xff); 450 306 } 451 307 452 - if (dma_pdev == NULL) 453 - dma_pdev = pci_dev_get(pdev); 454 - 455 - /* Account for quirked devices */ 456 - swap_pci_ref(&dma_pdev, pci_get_dma_source(dma_pdev)); 457 - 458 - /* 459 - * If it's a multifunction device that does not support our 460 - * required ACS flags, add to the same group as function 0. 461 - */ 462 - if (dma_pdev->multifunction && 463 - !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS)) 464 - swap_pci_ref(&dma_pdev, 465 - pci_get_slot(dma_pdev->bus, 466 - PCI_DEVFN(PCI_SLOT(dma_pdev->devfn), 467 - 0))); 468 - 469 - /* 470 - * Devices on the root bus go through the iommu. If that's not us, 471 - * find the next upstream device and test ACS up to the root bus. 472 - * Finding the next device may require skipping virtual buses. 473 - */ 474 - while (!pci_is_root_bus(dma_pdev->bus)) { 475 - struct pci_bus *bus = dma_pdev->bus; 476 - 477 - while (!bus->self) { 478 - if (!pci_is_root_bus(bus)) 479 - bus = bus->parent; 480 - else 481 - goto root_bus; 482 - } 483 - 484 - if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS)) 485 - break; 486 - 487 - swap_pci_ref(&dma_pdev, pci_dev_get(bus->self)); 488 - } 489 - 490 - root_bus: 491 - group = iommu_group_get(&dma_pdev->dev); 492 - pci_dev_put(dma_pdev); 493 - if (!group) { 494 - group = iommu_group_alloc(); 495 - if (IS_ERR(group)) 496 - return PTR_ERR(group); 497 - } 498 - 499 - ret = iommu_group_add_device(group, dev); 500 - 501 - iommu_group_put(group); 502 - 308 + ret = init_iommu_group(dev); 503 309 if (ret) 504 310 return ret; 505 311
+1
drivers/iommu/amd_iommu_types.h
··· 426 426 struct iommu_dev_data *alias_data;/* The alias dev_data */ 427 427 struct protection_domain *domain; /* Domain the device is bound to */ 428 428 atomic_t bind; /* Domain attach reference count */ 429 + struct iommu_group *group; /* IOMMU group for virtual aliases */ 429 430 u16 devid; /* PCI Device ID */ 430 431 bool iommu_v2; /* Device can make use of IOMMUv2 */ 431 432 bool passthrough; /* Default for device is pt_domain */
+31
drivers/iommu/intel-iommu.c
··· 2320 2320 return 0; 2321 2321 } 2322 2322 2323 + static bool device_has_rmrr(struct pci_dev *dev) 2324 + { 2325 + struct dmar_rmrr_unit *rmrr; 2326 + int i; 2327 + 2328 + for_each_rmrr_units(rmrr) { 2329 + for (i = 0; i < rmrr->devices_cnt; i++) { 2330 + /* 2331 + * Return TRUE if this RMRR contains the device that 2332 + * is passed in. 2333 + */ 2334 + if (rmrr->devices[i] == dev) 2335 + return true; 2336 + } 2337 + } 2338 + return false; 2339 + } 2340 + 2323 2341 static int iommu_should_identity_map(struct pci_dev *pdev, int startup) 2324 2342 { 2343 + 2344 + /* 2345 + * We want to prevent any device associated with an RMRR from 2346 + * getting placed into the SI Domain. This is done because 2347 + * problems exist when devices are moved in and out of domains 2348 + * and their respective RMRR info is lost. We exempt USB devices 2349 + * from this process due to their usage of RMRRs that are known 2350 + * to not be needed after BIOS hand-off to OS. 2351 + */ 2352 + if (device_has_rmrr(pdev) && 2353 + (pdev->class >> 8) != PCI_CLASS_SERIAL_USB) 2354 + return 0; 2355 + 2325 2356 if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev)) 2326 2357 return 1; 2327 2358
+4 -4
drivers/iommu/omap-iommu-debug.c
··· 18 18 #include <linux/uaccess.h> 19 19 #include <linux/platform_device.h> 20 20 #include <linux/debugfs.h> 21 + #include <linux/omap-iommu.h> 22 + #include <linux/platform_data/iommu-omap.h> 21 23 22 - #include <plat/iommu.h> 23 - #include <plat/iovmm.h> 24 - 25 - #include <plat/iopgtable.h> 24 + #include "omap-iopgtable.h" 25 + #include "omap-iommu.h" 26 26 27 27 #define MAXCOLUMN 100 /* for short messages */ 28 28
+74 -33
drivers/iommu/omap-iommu.c
··· 16 16 #include <linux/slab.h> 17 17 #include <linux/interrupt.h> 18 18 #include <linux/ioport.h> 19 - #include <linux/clk.h> 20 19 #include <linux/platform_device.h> 21 20 #include <linux/iommu.h> 21 + #include <linux/omap-iommu.h> 22 22 #include <linux/mutex.h> 23 23 #include <linux/spinlock.h> 24 + #include <linux/io.h> 25 + #include <linux/pm_runtime.h> 24 26 25 27 #include <asm/cacheflush.h> 26 28 27 - #include <plat/iommu.h> 29 + #include <linux/platform_data/iommu-omap.h> 28 30 29 - #include <plat/iopgtable.h> 31 + #include "omap-iopgtable.h" 32 + #include "omap-iommu.h" 30 33 31 34 #define for_each_iotlb_cr(obj, n, __i, cr) \ 32 35 for (__i = 0; \ ··· 52 49 struct omap_iommu *iommu_dev; 53 50 struct device *dev; 54 51 spinlock_t lock; 52 + }; 53 + 54 + #define MMU_LOCK_BASE_SHIFT 10 55 + #define MMU_LOCK_BASE_MASK (0x1f << MMU_LOCK_BASE_SHIFT) 56 + #define MMU_LOCK_BASE(x) \ 57 + ((x & MMU_LOCK_BASE_MASK) >> MMU_LOCK_BASE_SHIFT) 58 + 59 + #define MMU_LOCK_VICT_SHIFT 4 60 + #define MMU_LOCK_VICT_MASK (0x1f << MMU_LOCK_VICT_SHIFT) 61 + #define MMU_LOCK_VICT(x) \ 62 + ((x & MMU_LOCK_VICT_MASK) >> MMU_LOCK_VICT_SHIFT) 63 + 64 + struct iotlb_lock { 65 + short base; 66 + short vict; 55 67 }; 56 68 57 69 /* accommodate the difference between omap1 and omap2/3 */ ··· 143 125 static int iommu_enable(struct omap_iommu *obj) 144 126 { 145 127 int err; 128 + struct platform_device *pdev = to_platform_device(obj->dev); 129 + struct iommu_platform_data *pdata = pdev->dev.platform_data; 146 130 147 - if (!obj) 131 + if (!obj || !pdata) 148 132 return -EINVAL; 149 133 150 134 if (!arch_iommu) 151 135 return -ENODEV; 152 136 153 - clk_enable(obj->clk); 137 + if (pdata->deassert_reset) { 138 + err = pdata->deassert_reset(pdev, pdata->reset_name); 139 + if (err) { 140 + dev_err(obj->dev, "deassert_reset failed: %d\n", err); 141 + return err; 142 + } 143 + } 144 + 145 + pm_runtime_get_sync(obj->dev); 154 146 155 147 err = arch_iommu->enable(obj); 156 148 157 - clk_disable(obj->clk); 158 149 return err; 159 150 } 160 151 161 152 static void iommu_disable(struct omap_iommu *obj) 162 153 { 163 - if (!obj) 164 - return; 154 + struct platform_device *pdev = to_platform_device(obj->dev); 155 + struct iommu_platform_data *pdata = pdev->dev.platform_data; 165 156 166 - clk_enable(obj->clk); 157 + if (!obj || !pdata) 158 + return; 167 159 168 160 arch_iommu->disable(obj); 169 161 170 - clk_disable(obj->clk); 162 + pm_runtime_put_sync(obj->dev); 163 + 164 + if (pdata->assert_reset) 165 + pdata->assert_reset(pdev, pdata->reset_name); 171 166 } 172 167 173 168 /* ··· 303 272 if (!obj || !obj->nr_tlb_entries || !e) 304 273 return -EINVAL; 305 274 306 - clk_enable(obj->clk); 275 + pm_runtime_get_sync(obj->dev); 307 276 308 277 iotlb_lock_get(obj, &l); 309 278 if (l.base == obj->nr_tlb_entries) { ··· 333 302 334 303 cr = iotlb_alloc_cr(obj, e); 335 304 if (IS_ERR(cr)) { 336 - clk_disable(obj->clk); 305 + pm_runtime_put_sync(obj->dev); 337 306 return PTR_ERR(cr); 338 307 } 339 308 ··· 347 316 l.vict = l.base; 348 317 iotlb_lock_set(obj, &l); 349 318 out: 350 - clk_disable(obj->clk); 319 + pm_runtime_put_sync(obj->dev); 351 320 return err; 352 321 } 353 322 ··· 377 346 int i; 378 347 struct cr_regs cr; 379 348 380 - clk_enable(obj->clk); 349 + pm_runtime_get_sync(obj->dev); 381 350 382 351 for_each_iotlb_cr(obj, obj->nr_tlb_entries, i, cr) { 383 352 u32 start; ··· 396 365 iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY); 397 366 } 398 367 } 399 - clk_disable(obj->clk); 368 + pm_runtime_put_sync(obj->dev); 400 369 401 370 if (i == obj->nr_tlb_entries) 402 371 dev_dbg(obj->dev, "%s: no page for %08x\n", __func__, da); ··· 410 379 { 411 380 struct iotlb_lock l; 412 381 413 - clk_enable(obj->clk); 382 + pm_runtime_get_sync(obj->dev); 414 383 415 384 l.base = 0; 416 385 l.vict = 0; ··· 418 387 419 388 iommu_write_reg(obj, 1, MMU_GFLUSH); 420 389 421 - clk_disable(obj->clk); 390 + pm_runtime_put_sync(obj->dev); 422 391 } 423 392 424 393 #if defined(CONFIG_OMAP_IOMMU_DEBUG) || defined(CONFIG_OMAP_IOMMU_DEBUG_MODULE) ··· 428 397 if (!obj || !buf) 429 398 return -EINVAL; 430 399 431 - clk_enable(obj->clk); 400 + pm_runtime_get_sync(obj->dev); 432 401 433 402 bytes = arch_iommu->dump_ctx(obj, buf, bytes); 434 403 435 - clk_disable(obj->clk); 404 + pm_runtime_put_sync(obj->dev); 436 405 437 406 return bytes; 438 407 } ··· 446 415 struct cr_regs tmp; 447 416 struct cr_regs *p = crs; 448 417 449 - clk_enable(obj->clk); 418 + pm_runtime_get_sync(obj->dev); 450 419 iotlb_lock_get(obj, &saved); 451 420 452 421 for_each_iotlb_cr(obj, num, i, tmp) { ··· 456 425 } 457 426 458 427 iotlb_lock_set(obj, &saved); 459 - clk_disable(obj->clk); 428 + pm_runtime_put_sync(obj->dev); 460 429 461 430 return p - crs; 462 431 } ··· 820 789 if (!obj->refcount) 821 790 return IRQ_NONE; 822 791 823 - clk_enable(obj->clk); 824 792 errs = iommu_report_fault(obj, &da); 825 - clk_disable(obj->clk); 826 793 if (errs == 0) 827 794 return IRQ_HANDLED; 828 795 ··· 942 913 struct resource *res; 943 914 struct iommu_platform_data *pdata = pdev->dev.platform_data; 944 915 945 - if (pdev->num_resources != 2) 946 - return -EINVAL; 947 - 948 916 obj = kzalloc(sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL); 949 917 if (!obj) 950 918 return -ENOMEM; 951 - 952 - obj->clk = clk_get(&pdev->dev, pdata->clk_name); 953 - if (IS_ERR(obj->clk)) 954 - goto err_clk; 955 919 956 920 obj->nr_tlb_entries = pdata->nr_tlb_entries; 957 921 obj->name = pdata->name; ··· 988 966 goto err_irq; 989 967 platform_set_drvdata(pdev, obj); 990 968 969 + pm_runtime_irq_safe(obj->dev); 970 + pm_runtime_enable(obj->dev); 971 + 991 972 dev_info(&pdev->dev, "%s registered\n", obj->name); 992 973 return 0; 993 974 ··· 999 974 err_ioremap: 1000 975 release_mem_region(res->start, resource_size(res)); 1001 976 err_mem: 1002 - clk_put(obj->clk); 1003 - err_clk: 1004 977 kfree(obj); 1005 978 return err; 1006 979 } ··· 1019 996 release_mem_region(res->start, resource_size(res)); 1020 997 iounmap(obj->regbase); 1021 998 1022 - clk_put(obj->clk); 999 + pm_runtime_disable(obj->dev); 1000 + 1023 1001 dev_info(&pdev->dev, "%s removed\n", obj->name); 1024 1002 kfree(obj); 1025 1003 return 0; ··· 1037 1013 static void iopte_cachep_ctor(void *iopte) 1038 1014 { 1039 1015 clean_dcache_area(iopte, IOPTE_TABLE_SIZE); 1016 + } 1017 + 1018 + static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, 1019 + u32 flags) 1020 + { 1021 + memset(e, 0, sizeof(*e)); 1022 + 1023 + e->da = da; 1024 + e->pa = pa; 1025 + e->valid = 1; 1026 + /* FIXME: add OMAP1 support */ 1027 + e->pgsz = flags & MMU_CAM_PGSZ_MASK; 1028 + e->endian = flags & MMU_RAM_ENDIAN_MASK; 1029 + e->elsz = flags & MMU_RAM_ELSZ_MASK; 1030 + e->mixed = flags & MMU_RAM_MIXED_MASK; 1031 + 1032 + return iopgsz_to_bytes(e->pgsz); 1040 1033 } 1041 1034 1042 1035 static int omap_iommu_map(struct iommu_domain *domain, unsigned long da,
+47 -3
drivers/iommu/omap-iovmm.c
··· 17 17 #include <linux/device.h> 18 18 #include <linux/scatterlist.h> 19 19 #include <linux/iommu.h> 20 + #include <linux/omap-iommu.h> 21 + #include <linux/platform_data/iommu-omap.h> 20 22 21 23 #include <asm/cacheflush.h> 22 24 #include <asm/mach/map.h> 23 25 24 - #include <plat/iommu.h> 25 - #include <plat/iovmm.h> 26 + #include "omap-iopgtable.h" 27 + #include "omap-iommu.h" 26 28 27 - #include <plat/iopgtable.h> 29 + /* 30 + * IOVMF_FLAGS: attribute for iommu virtual memory area(iovma) 31 + * 32 + * lower 16 bit is used for h/w and upper 16 bit is for s/w. 33 + */ 34 + #define IOVMF_SW_SHIFT 16 35 + 36 + /* 37 + * iovma: h/w flags derived from cam and ram attribute 38 + */ 39 + #define IOVMF_CAM_MASK (~((1 << 10) - 1)) 40 + #define IOVMF_RAM_MASK (~IOVMF_CAM_MASK) 41 + 42 + #define IOVMF_PGSZ_MASK (3 << 0) 43 + #define IOVMF_PGSZ_1M MMU_CAM_PGSZ_1M 44 + #define IOVMF_PGSZ_64K MMU_CAM_PGSZ_64K 45 + #define IOVMF_PGSZ_4K MMU_CAM_PGSZ_4K 46 + #define IOVMF_PGSZ_16M MMU_CAM_PGSZ_16M 47 + 48 + #define IOVMF_ENDIAN_MASK (1 << 9) 49 + #define IOVMF_ENDIAN_BIG MMU_RAM_ENDIAN_BIG 50 + 51 + #define IOVMF_ELSZ_MASK (3 << 7) 52 + #define IOVMF_ELSZ_16 MMU_RAM_ELSZ_16 53 + #define IOVMF_ELSZ_32 MMU_RAM_ELSZ_32 54 + #define IOVMF_ELSZ_NONE MMU_RAM_ELSZ_NONE 55 + 56 + #define IOVMF_MIXED_MASK (1 << 6) 57 + #define IOVMF_MIXED MMU_RAM_MIXED 58 + 59 + /* 60 + * iovma: s/w flags, used for mapping and umapping internally. 61 + */ 62 + #define IOVMF_MMIO (1 << IOVMF_SW_SHIFT) 63 + #define IOVMF_ALLOC (2 << IOVMF_SW_SHIFT) 64 + #define IOVMF_ALLOC_MASK (3 << IOVMF_SW_SHIFT) 65 + 66 + /* "superpages" is supported just with physically linear pages */ 67 + #define IOVMF_DISCONT (1 << (2 + IOVMF_SW_SHIFT)) 68 + #define IOVMF_LINEAR (2 << (2 + IOVMF_SW_SHIFT)) 69 + #define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT)) 70 + 71 + #define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT)) 28 72 29 73 static struct kmem_cache *iovm_area_cachep; 30 74
+1 -1
drivers/iommu/tegra-gart.c
··· 398 398 do_gart_setup(gart, NULL); 399 399 400 400 gart_handle = gart; 401 + bus_set_iommu(&platform_bus_type, &gart_iommu_ops); 401 402 return 0; 402 403 403 404 fail: ··· 451 450 452 451 static int __devinit tegra_gart_init(void) 453 452 { 454 - bus_set_iommu(&platform_bus_type, &gart_iommu_ops); 455 453 return platform_driver_register(&tegra_gart_driver); 456 454 } 457 455
+2 -4
drivers/iommu/tegra-smmu.c
··· 696 696 *pte = _PTE_VACANT(iova); 697 697 FLUSH_CPU_DCACHE(pte, page, sizeof(*pte)); 698 698 flush_ptc_and_tlb(as->smmu, as, iova, pte, page, 0); 699 - if (!--(*count)) { 699 + if (!--(*count)) 700 700 free_ptbl(as, iova); 701 - smmu_flush_regs(as->smmu, 0); 702 - } 703 701 } 704 702 705 703 static void __smmu_iommu_map_pfn(struct smmu_as *as, dma_addr_t iova, ··· 1232 1234 1233 1235 smmu_debugfs_create(smmu); 1234 1236 smmu_handle = smmu; 1237 + bus_set_iommu(&platform_bus_type, &smmu_iommu_ops); 1235 1238 return 0; 1236 1239 } 1237 1240 ··· 1277 1278 1278 1279 static int __devinit tegra_smmu_init(void) 1279 1280 { 1280 - bus_set_iommu(&platform_bus_type, &smmu_iommu_ops); 1281 1281 return platform_driver_register(&tegra_smmu_driver); 1282 1282 } 1283 1283
+1
drivers/media/platform/omap3isp/isp.c
··· 61 61 #include <linux/i2c.h> 62 62 #include <linux/interrupt.h> 63 63 #include <linux/module.h> 64 + #include <linux/omap-iommu.h> 64 65 #include <linux/platform_device.h> 65 66 #include <linux/regulator/consumer.h> 66 67 #include <linux/slab.h>
+1 -3
drivers/media/platform/omap3isp/isp.h
··· 31 31 #include <media/v4l2-device.h> 32 32 #include <linux/device.h> 33 33 #include <linux/io.h> 34 + #include <linux/iommu.h> 34 35 #include <linux/platform_device.h> 35 36 #include <linux/wait.h> 36 - #include <linux/iommu.h> 37 - #include <plat/iommu.h> 38 - #include <plat/iovmm.h> 39 37 40 38 #include "ispstat.h" 41 39 #include "ispccdc.h"
+1
drivers/media/platform/omap3isp/ispccdc.c
··· 30 30 #include <linux/device.h> 31 31 #include <linux/dma-mapping.h> 32 32 #include <linux/mm.h> 33 + #include <linux/omap-iommu.h> 33 34 #include <linux/sched.h> 34 35 #include <linux/slab.h> 35 36 #include <media/v4l2-event.h>
+1
drivers/media/platform/omap3isp/ispstat.c
··· 26 26 */ 27 27 28 28 #include <linux/dma-mapping.h> 29 + #include <linux/omap-iommu.h> 29 30 #include <linux/slab.h> 30 31 #include <linux/uaccess.h> 31 32
+1 -2
drivers/media/platform/omap3isp/ispvideo.c
··· 27 27 #include <linux/clk.h> 28 28 #include <linux/mm.h> 29 29 #include <linux/module.h> 30 + #include <linux/omap-iommu.h> 30 31 #include <linux/pagemap.h> 31 32 #include <linux/scatterlist.h> 32 33 #include <linux/sched.h> ··· 35 34 #include <linux/vmalloc.h> 36 35 #include <media/v4l2-dev.h> 37 36 #include <media/v4l2-ioctl.h> 38 - #include <plat/iommu.h> 39 - #include <plat/iovmm.h> 40 37 #include <plat/omap-pm.h> 41 38 42 39 #include "ispvideo.h"
+7
include/linux/dma-debug.h
··· 39 39 int direction, dma_addr_t dma_addr, 40 40 bool map_single); 41 41 42 + extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr); 43 + 42 44 extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, 43 45 size_t size, int direction, bool map_single); 44 46 ··· 104 102 size_t offset, size_t size, 105 103 int direction, dma_addr_t dma_addr, 106 104 bool map_single) 105 + { 106 + } 107 + 108 + static inline void debug_dma_mapping_error(struct device *dev, 109 + dma_addr_t dma_addr) 107 110 { 108 111 } 109 112
+52
include/linux/omap-iommu.h
··· 1 + /* 2 + * omap iommu: simple virtual address space management 3 + * 4 + * Copyright (C) 2008-2009 Nokia Corporation 5 + * 6 + * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #ifndef _INTEL_IOMMU_H_ 14 + #define _INTEL_IOMMU_H_ 15 + 16 + struct iovm_struct { 17 + struct omap_iommu *iommu; /* iommu object which this belongs to */ 18 + u32 da_start; /* area definition */ 19 + u32 da_end; 20 + u32 flags; /* IOVMF_: see below */ 21 + struct list_head list; /* linked in ascending order */ 22 + const struct sg_table *sgt; /* keep 'page' <-> 'da' mapping */ 23 + void *va; /* mpu side mapped address */ 24 + }; 25 + 26 + #define MMU_RAM_ENDIAN_SHIFT 9 27 + #define MMU_RAM_ENDIAN_LITTLE (0 << MMU_RAM_ENDIAN_SHIFT) 28 + #define MMU_RAM_ELSZ_8 (0 << MMU_RAM_ELSZ_SHIFT) 29 + #define IOVMF_ENDIAN_LITTLE MMU_RAM_ENDIAN_LITTLE 30 + #define MMU_RAM_ELSZ_SHIFT 7 31 + #define IOVMF_ELSZ_8 MMU_RAM_ELSZ_8 32 + 33 + struct iommu_domain; 34 + 35 + extern struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da); 36 + extern u32 37 + omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da, 38 + const struct sg_table *sgt, u32 flags); 39 + extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain, 40 + struct device *dev, u32 da); 41 + extern u32 42 + omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev, 43 + u32 da, size_t bytes, u32 flags); 44 + extern void 45 + omap_iommu_vfree(struct iommu_domain *domain, struct device *dev, 46 + const u32 da); 47 + extern void *omap_da_to_va(struct device *dev, u32 da); 48 + 49 + extern void omap_iommu_save_ctx(struct device *dev); 50 + extern void omap_iommu_restore_ctx(struct device *dev); 51 + 52 + #endif
+54
include/linux/platform_data/iommu-omap.h
··· 1 + /* 2 + * omap iommu: main structures 3 + * 4 + * Copyright (C) 2008-2009 Nokia Corporation 5 + * 6 + * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #include <linux/platform_device.h> 14 + 15 + #define MMU_REG_SIZE 256 16 + 17 + /** 18 + * struct iommu_arch_data - omap iommu private data 19 + * @name: name of the iommu device 20 + * @iommu_dev: handle of the iommu device 21 + * 22 + * This is an omap iommu private data object, which binds an iommu user 23 + * to its iommu device. This object should be placed at the iommu user's 24 + * dev_archdata so generic IOMMU API can be used without having to 25 + * utilize omap-specific plumbing anymore. 26 + */ 27 + struct omap_iommu_arch_data { 28 + const char *name; 29 + struct omap_iommu *iommu_dev; 30 + }; 31 + 32 + /** 33 + * struct omap_mmu_dev_attr - OMAP mmu device attributes for omap_hwmod 34 + * @da_start: device address where the va space starts. 35 + * @da_end: device address where the va space ends. 36 + * @nr_tlb_entries: number of entries supported by the translation 37 + * look-aside buffer (TLB). 38 + */ 39 + struct omap_mmu_dev_attr { 40 + u32 da_start; 41 + u32 da_end; 42 + int nr_tlb_entries; 43 + }; 44 + 45 + struct iommu_platform_data { 46 + const char *name; 47 + const char *reset_name; 48 + int nr_tlb_entries; 49 + u32 da_start; 50 + u32 da_end; 51 + 52 + int (*assert_reset)(struct platform_device *pdev, const char *name); 53 + int (*deassert_reset)(struct platform_device *pdev, const char *name); 54 + };
+57 -9
lib/dma-debug.c
··· 45 45 dma_debug_coherent, 46 46 }; 47 47 48 + enum map_err_types { 49 + MAP_ERR_CHECK_NOT_APPLICABLE, 50 + MAP_ERR_NOT_CHECKED, 51 + MAP_ERR_CHECKED, 52 + }; 53 + 48 54 #define DMA_DEBUG_STACKTRACE_ENTRIES 5 49 55 50 56 struct dma_debug_entry { ··· 63 57 int direction; 64 58 int sg_call_ents; 65 59 int sg_mapped_ents; 60 + enum map_err_types map_err_type; 66 61 #ifdef CONFIG_STACKTRACE 67 62 struct stack_trace stacktrace; 68 63 unsigned long st_entries[DMA_DEBUG_STACKTRACE_ENTRIES]; ··· 120 113 static struct device_driver *current_driver __read_mostly; 121 114 122 115 static DEFINE_RWLOCK(driver_name_lock); 116 + 117 + static const char *const maperr2str[] = { 118 + [MAP_ERR_CHECK_NOT_APPLICABLE] = "dma map error check not applicable", 119 + [MAP_ERR_NOT_CHECKED] = "dma map error not checked", 120 + [MAP_ERR_CHECKED] = "dma map error checked", 121 + }; 123 122 124 123 static const char *type2name[4] = { "single", "page", 125 124 "scather-gather", "coherent" }; ··· 389 376 list_for_each_entry(entry, &bucket->list, list) { 390 377 if (!dev || dev == entry->dev) { 391 378 dev_info(entry->dev, 392 - "%s idx %d P=%Lx D=%Lx L=%Lx %s\n", 379 + "%s idx %d P=%Lx D=%Lx L=%Lx %s %s\n", 393 380 type2name[entry->type], idx, 394 381 (unsigned long long)entry->paddr, 395 382 entry->dev_addr, entry->size, 396 - dir2name[entry->direction]); 383 + dir2name[entry->direction], 384 + maperr2str[entry->map_err_type]); 397 385 } 398 386 } 399 387 ··· 858 844 struct hash_bucket *bucket; 859 845 unsigned long flags; 860 846 861 - if (dma_mapping_error(ref->dev, ref->dev_addr)) { 862 - err_printk(ref->dev, NULL, "DMA-API: device driver tries " 863 - "to free an invalid DMA memory address\n"); 864 - return; 865 - } 866 - 867 847 bucket = get_hash_bucket(ref, &flags); 868 848 entry = bucket_find_exact(bucket, ref); 869 849 870 850 if (!entry) { 851 + if (dma_mapping_error(ref->dev, ref->dev_addr)) { 852 + err_printk(ref->dev, NULL, 853 + "DMA-API: device driver tries " 854 + "to free an invalid DMA memory address\n"); 855 + return; 856 + } 871 857 err_printk(ref->dev, NULL, "DMA-API: device driver tries " 872 858 "to free DMA memory it has not allocated " 873 859 "[device address=0x%016llx] [size=%llu bytes]\n", ··· 922 908 ref->dev_addr, ref->size, 923 909 dir2name[entry->direction], 924 910 dir2name[ref->direction]); 911 + } 912 + 913 + if (entry->map_err_type == MAP_ERR_NOT_CHECKED) { 914 + err_printk(ref->dev, entry, 915 + "DMA-API: device driver failed to check map error" 916 + "[device address=0x%016llx] [size=%llu bytes] " 917 + "[mapped as %s]", 918 + ref->dev_addr, ref->size, 919 + type2name[entry->type]); 925 920 } 926 921 927 922 hash_bucket_del(entry); ··· 1040 1017 if (unlikely(global_disable)) 1041 1018 return; 1042 1019 1043 - if (unlikely(dma_mapping_error(dev, dma_addr))) 1020 + if (dma_mapping_error(dev, dma_addr)) 1044 1021 return; 1045 1022 1046 1023 entry = dma_entry_alloc(); ··· 1053 1030 entry->dev_addr = dma_addr; 1054 1031 entry->size = size; 1055 1032 entry->direction = direction; 1033 + entry->map_err_type = MAP_ERR_NOT_CHECKED; 1056 1034 1057 1035 if (map_single) 1058 1036 entry->type = dma_debug_single; ··· 1068 1044 add_dma_entry(entry); 1069 1045 } 1070 1046 EXPORT_SYMBOL(debug_dma_map_page); 1047 + 1048 + void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 1049 + { 1050 + struct dma_debug_entry ref; 1051 + struct dma_debug_entry *entry; 1052 + struct hash_bucket *bucket; 1053 + unsigned long flags; 1054 + 1055 + if (unlikely(global_disable)) 1056 + return; 1057 + 1058 + ref.dev = dev; 1059 + ref.dev_addr = dma_addr; 1060 + bucket = get_hash_bucket(&ref, &flags); 1061 + entry = bucket_find_exact(bucket, &ref); 1062 + 1063 + if (!entry) 1064 + goto out; 1065 + 1066 + entry->map_err_type = MAP_ERR_CHECKED; 1067 + out: 1068 + put_hash_bucket(bucket, &flags); 1069 + } 1070 + EXPORT_SYMBOL(debug_dma_mapping_error); 1071 1071 1072 1072 void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, 1073 1073 size_t size, int direction, bool map_single)