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

Merge git://git.infradead.org/~dwmw2/iommu-2.6.31

* git://git.infradead.org/~dwmw2/iommu-2.6.31:
intel-iommu: Fix one last ia64 build problem in Pass Through Support
VT-d: support the device IOTLB
VT-d: cleanup iommu_flush_iotlb_psi and flush_unmaps
VT-d: add device IOTLB invalidation support
VT-d: parse ATSR in DMA Remapping Reporting Structure
PCI: handle Virtual Function ATS enabling
PCI: support the ATS capability
intel-iommu: dmar_set_interrupt return error value
intel-iommu: Tidy up iommu->gcmd handling
intel-iommu: Fix tiny theoretical race in write-buffer flush.
intel-iommu: Clean up handling of "caching mode" vs. IOTLB flushing.
intel-iommu: Clean up handling of "caching mode" vs. context flushing.
VT-d: fix invalid domain id for KVM context flush
Fix !CONFIG_DMAR build failure introduced by Intel IOMMU Pass Through Support
Intel IOMMU Pass Through Support

Fix up trivial conflicts in drivers/pci/{intel-iommu.c,intr_remapping.c}

+754 -217
+1
Documentation/kernel-parameters.txt
··· 1006 1006 nomerge 1007 1007 forcesac 1008 1008 soft 1009 + pt [x86, IA64] 1009 1010 1010 1011 io7= [HW] IO7 for Marvel based alpha systems 1011 1012 See comment before marvel_specify_io7 in
+5
arch/ia64/include/asm/iommu.h
··· 9 9 extern void no_iommu_init(void); 10 10 extern int force_iommu, no_iommu; 11 11 extern int iommu_detected; 12 + #ifdef CONFIG_DMAR 13 + extern int iommu_pass_through; 14 + #else 15 + #define iommu_pass_through (0) 16 + #endif 12 17 extern void iommu_dma_init(void); 13 18 extern void machvec_init(const char *name); 14 19
+2
arch/ia64/kernel/pci-dma.c
··· 32 32 int force_iommu __read_mostly; 33 33 #endif 34 34 35 + int iommu_pass_through; 36 + 35 37 /* Dummy device used for NULL arguments (normally ISA). Better would 36 38 be probably a smaller DMA mask, but this is bug-to-bug compatible 37 39 to i386. */
+1 -1
arch/ia64/kernel/pci-swiotlb.c
··· 46 46 47 47 void __init pci_swiotlb_init(void) 48 48 { 49 - if (!iommu_detected) { 49 + if (!iommu_detected || iommu_pass_through) { 50 50 #ifdef CONFIG_IA64_GENERIC 51 51 swiotlb = 1; 52 52 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
+1
arch/x86/include/asm/iommu.h
··· 6 6 extern struct dma_map_ops nommu_dma_ops; 7 7 extern int force_iommu, no_iommu; 8 8 extern int iommu_detected; 9 + extern int iommu_pass_through; 9 10 10 11 /* 10 seconds */ 11 12 #define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)
+6
arch/x86/kernel/pci-dma.c
··· 32 32 /* Set this to 1 if there is a HW IOMMU in the system */ 33 33 int iommu_detected __read_mostly = 0; 34 34 35 + int iommu_pass_through; 36 + 35 37 dma_addr_t bad_dma_address __read_mostly = 0; 36 38 EXPORT_SYMBOL(bad_dma_address); 37 39 ··· 211 209 #ifdef CONFIG_SWIOTLB 212 210 if (!strncmp(p, "soft", 4)) 213 211 swiotlb = 1; 212 + if (!strncmp(p, "pt", 2)) { 213 + iommu_pass_through = 1; 214 + return 1; 215 + } 214 216 #endif 215 217 216 218 gart_parse_options(p);
+2 -1
arch/x86/kernel/pci-swiotlb.c
··· 71 71 { 72 72 /* don't initialize swiotlb if iommu=off (no_iommu=1) */ 73 73 #ifdef CONFIG_X86_64 74 - if (!iommu_detected && !no_iommu && max_pfn > MAX_DMA32_PFN) 74 + if ((!iommu_detected && !no_iommu && max_pfn > MAX_DMA32_PFN) || 75 + iommu_pass_through) 75 76 swiotlb = 1; 76 77 #endif 77 78 if (swiotlb_force)
+194 -41
drivers/pci/dmar.c
··· 267 267 } 268 268 return ret; 269 269 } 270 + 271 + static LIST_HEAD(dmar_atsr_units); 272 + 273 + static int __init dmar_parse_one_atsr(struct acpi_dmar_header *hdr) 274 + { 275 + struct acpi_dmar_atsr *atsr; 276 + struct dmar_atsr_unit *atsru; 277 + 278 + atsr = container_of(hdr, struct acpi_dmar_atsr, header); 279 + atsru = kzalloc(sizeof(*atsru), GFP_KERNEL); 280 + if (!atsru) 281 + return -ENOMEM; 282 + 283 + atsru->hdr = hdr; 284 + atsru->include_all = atsr->flags & 0x1; 285 + 286 + list_add(&atsru->list, &dmar_atsr_units); 287 + 288 + return 0; 289 + } 290 + 291 + static int __init atsr_parse_dev(struct dmar_atsr_unit *atsru) 292 + { 293 + int rc; 294 + struct acpi_dmar_atsr *atsr; 295 + 296 + if (atsru->include_all) 297 + return 0; 298 + 299 + atsr = container_of(atsru->hdr, struct acpi_dmar_atsr, header); 300 + rc = dmar_parse_dev_scope((void *)(atsr + 1), 301 + (void *)atsr + atsr->header.length, 302 + &atsru->devices_cnt, &atsru->devices, 303 + atsr->segment); 304 + if (rc || !atsru->devices_cnt) { 305 + list_del(&atsru->list); 306 + kfree(atsru); 307 + } 308 + 309 + return rc; 310 + } 311 + 312 + int dmar_find_matched_atsr_unit(struct pci_dev *dev) 313 + { 314 + int i; 315 + struct pci_bus *bus; 316 + struct acpi_dmar_atsr *atsr; 317 + struct dmar_atsr_unit *atsru; 318 + 319 + list_for_each_entry(atsru, &dmar_atsr_units, list) { 320 + atsr = container_of(atsru->hdr, struct acpi_dmar_atsr, header); 321 + if (atsr->segment == pci_domain_nr(dev->bus)) 322 + goto found; 323 + } 324 + 325 + return 0; 326 + 327 + found: 328 + for (bus = dev->bus; bus; bus = bus->parent) { 329 + struct pci_dev *bridge = bus->self; 330 + 331 + if (!bridge || !bridge->is_pcie || 332 + bridge->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) 333 + return 0; 334 + 335 + if (bridge->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { 336 + for (i = 0; i < atsru->devices_cnt; i++) 337 + if (atsru->devices[i] == bridge) 338 + return 1; 339 + break; 340 + } 341 + } 342 + 343 + if (atsru->include_all) 344 + return 1; 345 + 346 + return 0; 347 + } 270 348 #endif 271 349 272 350 static void __init ··· 352 274 { 353 275 struct acpi_dmar_hardware_unit *drhd; 354 276 struct acpi_dmar_reserved_memory *rmrr; 277 + struct acpi_dmar_atsr *atsr; 355 278 356 279 switch (header->type) { 357 280 case ACPI_DMAR_TYPE_HARDWARE_UNIT: 358 - drhd = (struct acpi_dmar_hardware_unit *)header; 281 + drhd = container_of(header, struct acpi_dmar_hardware_unit, 282 + header); 359 283 printk (KERN_INFO PREFIX 360 - "DRHD (flags: 0x%08x)base: 0x%016Lx\n", 361 - drhd->flags, (unsigned long long)drhd->address); 284 + "DRHD base: %#016Lx flags: %#x\n", 285 + (unsigned long long)drhd->address, drhd->flags); 362 286 break; 363 287 case ACPI_DMAR_TYPE_RESERVED_MEMORY: 364 - rmrr = (struct acpi_dmar_reserved_memory *)header; 365 - 288 + rmrr = container_of(header, struct acpi_dmar_reserved_memory, 289 + header); 366 290 printk (KERN_INFO PREFIX 367 - "RMRR base: 0x%016Lx end: 0x%016Lx\n", 291 + "RMRR base: %#016Lx end: %#016Lx\n", 368 292 (unsigned long long)rmrr->base_address, 369 293 (unsigned long long)rmrr->end_address); 294 + break; 295 + case ACPI_DMAR_TYPE_ATSR: 296 + atsr = container_of(header, struct acpi_dmar_atsr, header); 297 + printk(KERN_INFO PREFIX "ATSR flags: %#x\n", atsr->flags); 370 298 break; 371 299 } 372 300 } ··· 447 363 ret = dmar_parse_one_rmrr(entry_header); 448 364 #endif 449 365 break; 366 + case ACPI_DMAR_TYPE_ATSR: 367 + #ifdef CONFIG_DMAR 368 + ret = dmar_parse_one_atsr(entry_header); 369 + #endif 370 + break; 450 371 default: 451 372 printk(KERN_WARNING PREFIX 452 373 "Unknown DMAR structure type\n"); ··· 520 431 #ifdef CONFIG_DMAR 521 432 { 522 433 struct dmar_rmrr_unit *rmrr, *rmrr_n; 434 + struct dmar_atsr_unit *atsr, *atsr_n; 435 + 523 436 list_for_each_entry_safe(rmrr, rmrr_n, &dmar_rmrr_units, list) { 524 437 ret = rmrr_parse_dev(rmrr); 438 + if (ret) 439 + return ret; 440 + } 441 + 442 + list_for_each_entry_safe(atsr, atsr_n, &dmar_atsr_units, list) { 443 + ret = atsr_parse_dev(atsr); 525 444 if (ret) 526 445 return ret; 527 446 } ··· 565 468 #ifdef CONFIG_DMAR 566 469 if (list_empty(&dmar_rmrr_units)) 567 470 printk(KERN_INFO PREFIX "No RMRR found\n"); 471 + 472 + if (list_empty(&dmar_atsr_units)) 473 + printk(KERN_INFO PREFIX "No ATSR found\n"); 568 474 #endif 569 475 570 476 #ifdef CONFIG_INTR_REMAP ··· 615 515 u32 ver; 616 516 static int iommu_allocated = 0; 617 517 int agaw = 0; 518 + int msagaw = 0; 618 519 619 520 iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); 620 521 if (!iommu) ··· 636 535 agaw = iommu_calculate_agaw(iommu); 637 536 if (agaw < 0) { 638 537 printk(KERN_ERR 639 - "Cannot get a valid agaw for iommu (seq_id = %d)\n", 538 + "Cannot get a valid agaw for iommu (seq_id = %d)\n", 539 + iommu->seq_id); 540 + goto error; 541 + } 542 + msagaw = iommu_calculate_max_sagaw(iommu); 543 + if (msagaw < 0) { 544 + printk(KERN_ERR 545 + "Cannot get a valid max agaw for iommu (seq_id = %d)\n", 640 546 iommu->seq_id); 641 547 goto error; 642 548 } 643 549 #endif 644 550 iommu->agaw = agaw; 551 + iommu->msagaw = msagaw; 645 552 646 553 /* the registers might be more than one page */ 647 554 map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), ··· 699 590 */ 700 591 static inline void reclaim_free_desc(struct q_inval *qi) 701 592 { 702 - while (qi->desc_status[qi->free_tail] == QI_DONE) { 593 + while (qi->desc_status[qi->free_tail] == QI_DONE || 594 + qi->desc_status[qi->free_tail] == QI_ABORT) { 703 595 qi->desc_status[qi->free_tail] = QI_FREE; 704 596 qi->free_tail = (qi->free_tail + 1) % QI_LENGTH; 705 597 qi->free_cnt++; ··· 710 600 static int qi_check_fault(struct intel_iommu *iommu, int index) 711 601 { 712 602 u32 fault; 713 - int head; 603 + int head, tail; 714 604 struct q_inval *qi = iommu->qi; 715 605 int wait_index = (index + 1) % QI_LENGTH; 606 + 607 + if (qi->desc_status[wait_index] == QI_ABORT) 608 + return -EAGAIN; 716 609 717 610 fault = readl(iommu->reg + DMAR_FSTS_REG); 718 611 ··· 726 613 */ 727 614 if (fault & DMA_FSTS_IQE) { 728 615 head = readl(iommu->reg + DMAR_IQH_REG); 729 - if ((head >> 4) == index) { 616 + if ((head >> DMAR_IQ_SHIFT) == index) { 617 + printk(KERN_ERR "VT-d detected invalid descriptor: " 618 + "low=%llx, high=%llx\n", 619 + (unsigned long long)qi->desc[index].low, 620 + (unsigned long long)qi->desc[index].high); 730 621 memcpy(&qi->desc[index], &qi->desc[wait_index], 731 622 sizeof(struct qi_desc)); 732 623 __iommu_flush_cache(iommu, &qi->desc[index], ··· 739 622 return -EINVAL; 740 623 } 741 624 } 625 + 626 + /* 627 + * If ITE happens, all pending wait_desc commands are aborted. 628 + * No new descriptors are fetched until the ITE is cleared. 629 + */ 630 + if (fault & DMA_FSTS_ITE) { 631 + head = readl(iommu->reg + DMAR_IQH_REG); 632 + head = ((head >> DMAR_IQ_SHIFT) - 1 + QI_LENGTH) % QI_LENGTH; 633 + head |= 1; 634 + tail = readl(iommu->reg + DMAR_IQT_REG); 635 + tail = ((tail >> DMAR_IQ_SHIFT) - 1 + QI_LENGTH) % QI_LENGTH; 636 + 637 + writel(DMA_FSTS_ITE, iommu->reg + DMAR_FSTS_REG); 638 + 639 + do { 640 + if (qi->desc_status[head] == QI_IN_USE) 641 + qi->desc_status[head] = QI_ABORT; 642 + head = (head - 2 + QI_LENGTH) % QI_LENGTH; 643 + } while (head != tail); 644 + 645 + if (qi->desc_status[wait_index] == QI_ABORT) 646 + return -EAGAIN; 647 + } 648 + 649 + if (fault & DMA_FSTS_ICE) 650 + writel(DMA_FSTS_ICE, iommu->reg + DMAR_FSTS_REG); 742 651 743 652 return 0; 744 653 } ··· 775 632 */ 776 633 int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu) 777 634 { 778 - int rc = 0; 635 + int rc; 779 636 struct q_inval *qi = iommu->qi; 780 637 struct qi_desc *hw, wait_desc; 781 638 int wait_index, index; ··· 785 642 return 0; 786 643 787 644 hw = qi->desc; 645 + 646 + restart: 647 + rc = 0; 788 648 789 649 spin_lock_irqsave(&qi->q_lock, flags); 790 650 while (qi->free_cnt < 3) { ··· 819 673 * update the HW tail register indicating the presence of 820 674 * new descriptors. 821 675 */ 822 - writel(qi->free_head << 4, iommu->reg + DMAR_IQT_REG); 676 + writel(qi->free_head << DMAR_IQ_SHIFT, iommu->reg + DMAR_IQT_REG); 823 677 824 678 while (qi->desc_status[wait_index] != QI_DONE) { 825 679 /* ··· 831 685 */ 832 686 rc = qi_check_fault(iommu, index); 833 687 if (rc) 834 - goto out; 688 + break; 835 689 836 690 spin_unlock(&qi->q_lock); 837 691 cpu_relax(); 838 692 spin_lock(&qi->q_lock); 839 693 } 840 - out: 841 - qi->desc_status[index] = qi->desc_status[wait_index] = QI_DONE; 694 + 695 + qi->desc_status[index] = QI_DONE; 842 696 843 697 reclaim_free_desc(qi); 844 698 spin_unlock_irqrestore(&qi->q_lock, flags); 699 + 700 + if (rc == -EAGAIN) 701 + goto restart; 845 702 846 703 return rc; 847 704 } ··· 863 714 qi_submit_sync(&desc, iommu); 864 715 } 865 716 866 - int qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm, 867 - u64 type, int non_present_entry_flush) 717 + void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm, 718 + u64 type) 868 719 { 869 720 struct qi_desc desc; 870 - 871 - if (non_present_entry_flush) { 872 - if (!cap_caching_mode(iommu->cap)) 873 - return 1; 874 - else 875 - did = 0; 876 - } 877 721 878 722 desc.low = QI_CC_FM(fm) | QI_CC_SID(sid) | QI_CC_DID(did) 879 723 | QI_CC_GRAN(type) | QI_CC_TYPE; 880 724 desc.high = 0; 881 725 882 - return qi_submit_sync(&desc, iommu); 726 + qi_submit_sync(&desc, iommu); 883 727 } 884 728 885 - int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, 886 - unsigned int size_order, u64 type, 887 - int non_present_entry_flush) 729 + void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, 730 + unsigned int size_order, u64 type) 888 731 { 889 732 u8 dw = 0, dr = 0; 890 733 891 734 struct qi_desc desc; 892 735 int ih = 0; 893 - 894 - if (non_present_entry_flush) { 895 - if (!cap_caching_mode(iommu->cap)) 896 - return 1; 897 - else 898 - did = 0; 899 - } 900 736 901 737 if (cap_write_drain(iommu->cap)) 902 738 dw = 1; ··· 894 760 desc.high = QI_IOTLB_ADDR(addr) | QI_IOTLB_IH(ih) 895 761 | QI_IOTLB_AM(size_order); 896 762 897 - return qi_submit_sync(&desc, iommu); 763 + qi_submit_sync(&desc, iommu); 764 + } 765 + 766 + void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep, 767 + u64 addr, unsigned mask) 768 + { 769 + struct qi_desc desc; 770 + 771 + if (mask) { 772 + BUG_ON(addr & ((1 << (VTD_PAGE_SHIFT + mask)) - 1)); 773 + addr |= (1 << (VTD_PAGE_SHIFT + mask - 1)) - 1; 774 + desc.high = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE; 775 + } else 776 + desc.high = QI_DEV_IOTLB_ADDR(addr); 777 + 778 + if (qdep >= QI_DEV_IOTLB_MAX_INVS) 779 + qdep = 0; 780 + 781 + desc.low = QI_DEV_IOTLB_SID(sid) | QI_DEV_IOTLB_QDEP(qdep) | 782 + QI_DIOTLB_TYPE; 783 + 784 + qi_submit_sync(&desc, iommu); 898 785 } 899 786 900 787 /* ··· 945 790 cpu_relax(); 946 791 947 792 iommu->gcmd &= ~DMA_GCMD_QIE; 948 - 949 793 writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); 950 794 951 795 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, ··· 958 804 */ 959 805 static void __dmar_enable_qi(struct intel_iommu *iommu) 960 806 { 961 - u32 cmd, sts; 807 + u32 sts; 962 808 unsigned long flags; 963 809 struct q_inval *qi = iommu->qi; 964 810 ··· 972 818 973 819 dmar_writeq(iommu->reg + DMAR_IQA_REG, virt_to_phys(qi->desc)); 974 820 975 - cmd = iommu->gcmd | DMA_GCMD_QIE; 976 821 iommu->gcmd |= DMA_GCMD_QIE; 977 - writel(cmd, iommu->reg + DMAR_GCMD_REG); 822 + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); 978 823 979 824 /* Make sure hardware complete it */ 980 825 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_QIES), sts); ··· 1249 1096 set_irq_data(irq, NULL); 1250 1097 iommu->irq = 0; 1251 1098 destroy_irq(irq); 1252 - return 0; 1099 + return ret; 1253 1100 } 1254 1101 1255 1102 ret = request_irq(irq, dmar_fault, 0, iommu->name, iommu);
+296 -153
drivers/pci/intel-iommu.c
··· 53 53 54 54 #define DEFAULT_DOMAIN_ADDRESS_WIDTH 48 55 55 56 + #define MAX_AGAW_WIDTH 64 57 + 56 58 #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) 57 59 58 60 #define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT) ··· 132 130 { 133 131 context->lo &= (((u64)-1) << 2) | 1; 134 132 } 135 - 136 - #define CONTEXT_TT_MULTI_LEVEL 0 137 133 138 134 static inline void context_set_translation_type(struct context_entry *context, 139 135 unsigned long value) ··· 256 256 u8 bus; /* PCI bus number */ 257 257 u8 devfn; /* PCI devfn number */ 258 258 struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */ 259 + struct intel_iommu *iommu; /* IOMMU used by this device */ 259 260 struct dmar_domain *domain; /* pointer to domain */ 260 261 }; 261 262 ··· 402 401 403 402 static inline int width_to_agaw(int width); 404 403 405 - /* calculate agaw for each iommu. 406 - * "SAGAW" may be different across iommus, use a default agaw, and 407 - * get a supported less agaw for iommus that don't support the default agaw. 408 - */ 409 - int iommu_calculate_agaw(struct intel_iommu *iommu) 404 + static int __iommu_calculate_agaw(struct intel_iommu *iommu, int max_gaw) 410 405 { 411 406 unsigned long sagaw; 412 407 int agaw = -1; 413 408 414 409 sagaw = cap_sagaw(iommu->cap); 415 - for (agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH); 410 + for (agaw = width_to_agaw(max_gaw); 416 411 agaw >= 0; agaw--) { 417 412 if (test_bit(agaw, &sagaw)) 418 413 break; 419 414 } 420 415 421 416 return agaw; 417 + } 418 + 419 + /* 420 + * Calculate max SAGAW for each iommu. 421 + */ 422 + int iommu_calculate_max_sagaw(struct intel_iommu *iommu) 423 + { 424 + return __iommu_calculate_agaw(iommu, MAX_AGAW_WIDTH); 425 + } 426 + 427 + /* 428 + * calculate agaw for each iommu. 429 + * "SAGAW" may be different across iommus, use a default agaw, and 430 + * get a supported less agaw for iommus that don't support the default agaw. 431 + */ 432 + int iommu_calculate_agaw(struct intel_iommu *iommu) 433 + { 434 + return __iommu_calculate_agaw(iommu, DEFAULT_DOMAIN_ADDRESS_WIDTH); 422 435 } 423 436 424 437 /* in native case, each domain is related to only one iommu */ ··· 824 809 static void iommu_set_root_entry(struct intel_iommu *iommu) 825 810 { 826 811 void *addr; 827 - u32 cmd, sts; 812 + u32 sts; 828 813 unsigned long flag; 829 814 830 815 addr = iommu->root_entry; ··· 832 817 spin_lock_irqsave(&iommu->register_lock, flag); 833 818 dmar_writeq(iommu->reg + DMAR_RTADDR_REG, virt_to_phys(addr)); 834 819 835 - cmd = iommu->gcmd | DMA_GCMD_SRTP; 836 - writel(cmd, iommu->reg + DMAR_GCMD_REG); 820 + writel(iommu->gcmd | DMA_GCMD_SRTP, iommu->reg + DMAR_GCMD_REG); 837 821 838 822 /* Make sure hardware complete it */ 839 823 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 840 - readl, (sts & DMA_GSTS_RTPS), sts); 824 + readl, (sts & DMA_GSTS_RTPS), sts); 841 825 842 826 spin_unlock_irqrestore(&iommu->register_lock, flag); 843 827 } ··· 848 834 849 835 if (!rwbf_quirk && !cap_rwbf(iommu->cap)) 850 836 return; 851 - val = iommu->gcmd | DMA_GCMD_WBF; 852 837 853 838 spin_lock_irqsave(&iommu->register_lock, flag); 854 - writel(val, iommu->reg + DMAR_GCMD_REG); 839 + writel(iommu->gcmd | DMA_GCMD_WBF, iommu->reg + DMAR_GCMD_REG); 855 840 856 841 /* Make sure hardware complete it */ 857 842 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 858 - readl, (!(val & DMA_GSTS_WBFS)), val); 843 + readl, (!(val & DMA_GSTS_WBFS)), val); 859 844 860 845 spin_unlock_irqrestore(&iommu->register_lock, flag); 861 846 } 862 847 863 848 /* return value determine if we need a write buffer flush */ 864 - static int __iommu_flush_context(struct intel_iommu *iommu, 865 - u16 did, u16 source_id, u8 function_mask, u64 type, 866 - int non_present_entry_flush) 849 + static void __iommu_flush_context(struct intel_iommu *iommu, 850 + u16 did, u16 source_id, u8 function_mask, 851 + u64 type) 867 852 { 868 853 u64 val = 0; 869 854 unsigned long flag; 870 - 871 - /* 872 - * In the non-present entry flush case, if hardware doesn't cache 873 - * non-present entry we do nothing and if hardware cache non-present 874 - * entry, we flush entries of domain 0 (the domain id is used to cache 875 - * any non-present entries) 876 - */ 877 - if (non_present_entry_flush) { 878 - if (!cap_caching_mode(iommu->cap)) 879 - return 1; 880 - else 881 - did = 0; 882 - } 883 855 884 856 switch (type) { 885 857 case DMA_CCMD_GLOBAL_INVL: ··· 891 891 dmar_readq, (!(val & DMA_CCMD_ICC)), val); 892 892 893 893 spin_unlock_irqrestore(&iommu->register_lock, flag); 894 - 895 - /* flush context entry will implicitly flush write buffer */ 896 - return 0; 897 894 } 898 895 899 896 /* return value determine if we need a write buffer flush */ 900 - static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did, 901 - u64 addr, unsigned int size_order, u64 type, 902 - int non_present_entry_flush) 897 + static void __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did, 898 + u64 addr, unsigned int size_order, u64 type) 903 899 { 904 900 int tlb_offset = ecap_iotlb_offset(iommu->ecap); 905 901 u64 val = 0, val_iva = 0; 906 902 unsigned long flag; 907 - 908 - /* 909 - * In the non-present entry flush case, if hardware doesn't cache 910 - * non-present entry we do nothing and if hardware cache non-present 911 - * entry, we flush entries of domain 0 (the domain id is used to cache 912 - * any non-present entries) 913 - */ 914 - if (non_present_entry_flush) { 915 - if (!cap_caching_mode(iommu->cap)) 916 - return 1; 917 - else 918 - did = 0; 919 - } 920 903 921 904 switch (type) { 922 905 case DMA_TLB_GLOBAL_FLUSH: ··· 948 965 pr_debug("IOMMU: tlb flush request %Lx, actual %Lx\n", 949 966 (unsigned long long)DMA_TLB_IIRG(type), 950 967 (unsigned long long)DMA_TLB_IAIG(val)); 951 - /* flush iotlb entry will implicitly flush write buffer */ 952 - return 0; 953 968 } 954 969 955 - static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, 956 - u64 addr, unsigned int pages, int non_present_entry_flush) 970 + static struct device_domain_info *iommu_support_dev_iotlb( 971 + struct dmar_domain *domain, int segment, u8 bus, u8 devfn) 957 972 { 958 - unsigned int mask; 973 + int found = 0; 974 + unsigned long flags; 975 + struct device_domain_info *info; 976 + struct intel_iommu *iommu = device_to_iommu(segment, bus, devfn); 977 + 978 + if (!ecap_dev_iotlb_support(iommu->ecap)) 979 + return NULL; 980 + 981 + if (!iommu->qi) 982 + return NULL; 983 + 984 + spin_lock_irqsave(&device_domain_lock, flags); 985 + list_for_each_entry(info, &domain->devices, link) 986 + if (info->bus == bus && info->devfn == devfn) { 987 + found = 1; 988 + break; 989 + } 990 + spin_unlock_irqrestore(&device_domain_lock, flags); 991 + 992 + if (!found || !info->dev) 993 + return NULL; 994 + 995 + if (!pci_find_ext_capability(info->dev, PCI_EXT_CAP_ID_ATS)) 996 + return NULL; 997 + 998 + if (!dmar_find_matched_atsr_unit(info->dev)) 999 + return NULL; 1000 + 1001 + info->iommu = iommu; 1002 + 1003 + return info; 1004 + } 1005 + 1006 + static void iommu_enable_dev_iotlb(struct device_domain_info *info) 1007 + { 1008 + if (!info) 1009 + return; 1010 + 1011 + pci_enable_ats(info->dev, VTD_PAGE_SHIFT); 1012 + } 1013 + 1014 + static void iommu_disable_dev_iotlb(struct device_domain_info *info) 1015 + { 1016 + if (!info->dev || !pci_ats_enabled(info->dev)) 1017 + return; 1018 + 1019 + pci_disable_ats(info->dev); 1020 + } 1021 + 1022 + static void iommu_flush_dev_iotlb(struct dmar_domain *domain, 1023 + u64 addr, unsigned mask) 1024 + { 1025 + u16 sid, qdep; 1026 + unsigned long flags; 1027 + struct device_domain_info *info; 1028 + 1029 + spin_lock_irqsave(&device_domain_lock, flags); 1030 + list_for_each_entry(info, &domain->devices, link) { 1031 + if (!info->dev || !pci_ats_enabled(info->dev)) 1032 + continue; 1033 + 1034 + sid = info->bus << 8 | info->devfn; 1035 + qdep = pci_ats_queue_depth(info->dev); 1036 + qi_flush_dev_iotlb(info->iommu, sid, qdep, addr, mask); 1037 + } 1038 + spin_unlock_irqrestore(&device_domain_lock, flags); 1039 + } 1040 + 1041 + static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, 1042 + u64 addr, unsigned int pages) 1043 + { 1044 + unsigned int mask = ilog2(__roundup_pow_of_two(pages)); 959 1045 960 1046 BUG_ON(addr & (~VTD_PAGE_MASK)); 961 1047 BUG_ON(pages == 0); 962 1048 963 - /* Fallback to domain selective flush if no PSI support */ 964 - if (!cap_pgsel_inv(iommu->cap)) 965 - return iommu->flush.flush_iotlb(iommu, did, 0, 0, 966 - DMA_TLB_DSI_FLUSH, 967 - non_present_entry_flush); 968 - 969 1049 /* 1050 + * Fallback to domain selective flush if no PSI support or the size is 1051 + * too big. 970 1052 * PSI requires page size to be 2 ^ x, and the base address is naturally 971 1053 * aligned to the size 972 1054 */ 973 - mask = ilog2(__roundup_pow_of_two(pages)); 974 - /* Fallback to domain selective flush if size is too big */ 975 - if (mask > cap_max_amask_val(iommu->cap)) 976 - return iommu->flush.flush_iotlb(iommu, did, 0, 0, 977 - DMA_TLB_DSI_FLUSH, non_present_entry_flush); 978 - 979 - return iommu->flush.flush_iotlb(iommu, did, addr, mask, 980 - DMA_TLB_PSI_FLUSH, 981 - non_present_entry_flush); 1055 + if (!cap_pgsel_inv(iommu->cap) || mask > cap_max_amask_val(iommu->cap)) 1056 + iommu->flush.flush_iotlb(iommu, did, 0, 0, 1057 + DMA_TLB_DSI_FLUSH); 1058 + else 1059 + iommu->flush.flush_iotlb(iommu, did, addr, mask, 1060 + DMA_TLB_PSI_FLUSH); 1061 + if (did) 1062 + iommu_flush_dev_iotlb(iommu->domains[did], addr, mask); 982 1063 } 983 1064 984 1065 static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu) ··· 1068 1021 unsigned long flags; 1069 1022 1070 1023 spin_lock_irqsave(&iommu->register_lock, flags); 1071 - writel(iommu->gcmd|DMA_GCMD_TE, iommu->reg + DMAR_GCMD_REG); 1024 + iommu->gcmd |= DMA_GCMD_TE; 1025 + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); 1072 1026 1073 1027 /* Make sure hardware complete it */ 1074 1028 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 1075 - readl, (sts & DMA_GSTS_TES), sts); 1029 + readl, (sts & DMA_GSTS_TES), sts); 1076 1030 1077 - iommu->gcmd |= DMA_GCMD_TE; 1078 1031 spin_unlock_irqrestore(&iommu->register_lock, flags); 1079 1032 return 0; 1080 1033 } ··· 1090 1043 1091 1044 /* Make sure hardware complete it */ 1092 1045 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 1093 - readl, (!(sts & DMA_GSTS_TES)), sts); 1046 + readl, (!(sts & DMA_GSTS_TES)), sts); 1094 1047 1095 1048 spin_unlock_irqrestore(&iommu->register_lock, flag); 1096 1049 return 0; ··· 1372 1325 free_domain_mem(domain); 1373 1326 } 1374 1327 1375 - static int domain_context_mapping_one(struct dmar_domain *domain, 1376 - int segment, u8 bus, u8 devfn) 1328 + static int domain_context_mapping_one(struct dmar_domain *domain, int segment, 1329 + u8 bus, u8 devfn, int translation) 1377 1330 { 1378 1331 struct context_entry *context; 1379 1332 unsigned long flags; ··· 1383 1336 unsigned long ndomains; 1384 1337 int id; 1385 1338 int agaw; 1339 + struct device_domain_info *info = NULL; 1386 1340 1387 1341 pr_debug("Set context mapping for %02x:%02x.%d\n", 1388 1342 bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 1343 + 1389 1344 BUG_ON(!domain->pgd); 1345 + BUG_ON(translation != CONTEXT_TT_PASS_THROUGH && 1346 + translation != CONTEXT_TT_MULTI_LEVEL); 1390 1347 1391 1348 iommu = device_to_iommu(segment, bus, devfn); 1392 1349 if (!iommu) ··· 1450 1399 } 1451 1400 1452 1401 context_set_domain_id(context, id); 1453 - context_set_address_width(context, iommu->agaw); 1454 - context_set_address_root(context, virt_to_phys(pgd)); 1455 - context_set_translation_type(context, CONTEXT_TT_MULTI_LEVEL); 1402 + 1403 + if (translation != CONTEXT_TT_PASS_THROUGH) { 1404 + info = iommu_support_dev_iotlb(domain, segment, bus, devfn); 1405 + translation = info ? CONTEXT_TT_DEV_IOTLB : 1406 + CONTEXT_TT_MULTI_LEVEL; 1407 + } 1408 + /* 1409 + * In pass through mode, AW must be programmed to indicate the largest 1410 + * AGAW value supported by hardware. And ASR is ignored by hardware. 1411 + */ 1412 + if (unlikely(translation == CONTEXT_TT_PASS_THROUGH)) 1413 + context_set_address_width(context, iommu->msagaw); 1414 + else { 1415 + context_set_address_root(context, virt_to_phys(pgd)); 1416 + context_set_address_width(context, iommu->agaw); 1417 + } 1418 + 1419 + context_set_translation_type(context, translation); 1456 1420 context_set_fault_enable(context); 1457 1421 context_set_present(context); 1458 1422 domain_flush_cache(domain, context, sizeof(*context)); 1459 1423 1460 - /* it's a non-present to present mapping */ 1461 - if (iommu->flush.flush_context(iommu, domain->id, 1462 - (((u16)bus) << 8) | devfn, DMA_CCMD_MASK_NOBIT, 1463 - DMA_CCMD_DEVICE_INVL, 1)) 1424 + /* 1425 + * It's a non-present to present mapping. If hardware doesn't cache 1426 + * non-present entry we only need to flush the write-buffer. If the 1427 + * _does_ cache non-present entries, then it does so in the special 1428 + * domain #0, which we have to flush: 1429 + */ 1430 + if (cap_caching_mode(iommu->cap)) { 1431 + iommu->flush.flush_context(iommu, 0, 1432 + (((u16)bus) << 8) | devfn, 1433 + DMA_CCMD_MASK_NOBIT, 1434 + DMA_CCMD_DEVICE_INVL); 1435 + iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH); 1436 + } else { 1464 1437 iommu_flush_write_buffer(iommu); 1465 - else 1466 - iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0); 1467 - 1438 + } 1439 + iommu_enable_dev_iotlb(info); 1468 1440 spin_unlock_irqrestore(&iommu->lock, flags); 1469 1441 1470 1442 spin_lock_irqsave(&domain->iommu_lock, flags); ··· 1500 1426 } 1501 1427 1502 1428 static int 1503 - domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev) 1429 + domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev, 1430 + int translation) 1504 1431 { 1505 1432 int ret; 1506 1433 struct pci_dev *tmp, *parent; 1507 1434 1508 1435 ret = domain_context_mapping_one(domain, pci_domain_nr(pdev->bus), 1509 - pdev->bus->number, pdev->devfn); 1436 + pdev->bus->number, pdev->devfn, 1437 + translation); 1510 1438 if (ret) 1511 1439 return ret; 1512 1440 ··· 1522 1446 ret = domain_context_mapping_one(domain, 1523 1447 pci_domain_nr(parent->bus), 1524 1448 parent->bus->number, 1525 - parent->devfn); 1449 + parent->devfn, translation); 1526 1450 if (ret) 1527 1451 return ret; 1528 1452 parent = parent->bus->self; ··· 1530 1454 if (tmp->is_pcie) /* this is a PCIE-to-PCI bridge */ 1531 1455 return domain_context_mapping_one(domain, 1532 1456 pci_domain_nr(tmp->subordinate), 1533 - tmp->subordinate->number, 0); 1457 + tmp->subordinate->number, 0, 1458 + translation); 1534 1459 else /* this is a legacy PCI bridge */ 1535 1460 return domain_context_mapping_one(domain, 1536 1461 pci_domain_nr(tmp->bus), 1537 1462 tmp->bus->number, 1538 - tmp->devfn); 1463 + tmp->devfn, 1464 + translation); 1539 1465 } 1540 1466 1541 1467 static int domain_context_mapped(struct pci_dev *pdev) ··· 1618 1540 1619 1541 clear_context_table(iommu, bus, devfn); 1620 1542 iommu->flush.flush_context(iommu, 0, 0, 0, 1621 - DMA_CCMD_GLOBAL_INVL, 0); 1622 - iommu->flush.flush_iotlb(iommu, 0, 0, 0, 1623 - DMA_TLB_GLOBAL_FLUSH, 0); 1543 + DMA_CCMD_GLOBAL_INVL); 1544 + iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); 1624 1545 } 1625 1546 1626 1547 static void domain_remove_dev_info(struct dmar_domain *domain) ··· 1638 1561 info->dev->dev.archdata.iommu = NULL; 1639 1562 spin_unlock_irqrestore(&device_domain_lock, flags); 1640 1563 1564 + iommu_disable_dev_iotlb(info); 1641 1565 iommu = device_to_iommu(info->segment, info->bus, info->devfn); 1642 1566 iommu_detach_dev(iommu, info->bus, info->devfn); 1643 1567 free_devinfo_mem(info); ··· 1834 1756 goto error; 1835 1757 1836 1758 /* context entry init */ 1837 - ret = domain_context_mapping(domain, pdev); 1759 + ret = domain_context_mapping(domain, pdev, CONTEXT_TT_MULTI_LEVEL); 1838 1760 if (!ret) 1839 1761 return 0; 1840 1762 error: ··· 1935 1857 } 1936 1858 #endif /* !CONFIG_DMAR_FLPY_WA */ 1937 1859 1860 + /* Initialize each context entry as pass through.*/ 1861 + static int __init init_context_pass_through(void) 1862 + { 1863 + struct pci_dev *pdev = NULL; 1864 + struct dmar_domain *domain; 1865 + int ret; 1866 + 1867 + for_each_pci_dev(pdev) { 1868 + domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH); 1869 + ret = domain_context_mapping(domain, pdev, 1870 + CONTEXT_TT_PASS_THROUGH); 1871 + if (ret) 1872 + return ret; 1873 + } 1874 + return 0; 1875 + } 1876 + 1938 1877 static int __init init_dmars(void) 1939 1878 { 1940 1879 struct dmar_drhd_unit *drhd; ··· 1959 1864 struct pci_dev *pdev; 1960 1865 struct intel_iommu *iommu; 1961 1866 int i, ret; 1867 + int pass_through = 1; 1962 1868 1963 1869 /* 1964 1870 * for each drhd ··· 2013 1917 printk(KERN_ERR "IOMMU: allocate root entry failed\n"); 2014 1918 goto error; 2015 1919 } 1920 + if (!ecap_pass_through(iommu->ecap)) 1921 + pass_through = 0; 2016 1922 } 1923 + if (iommu_pass_through) 1924 + if (!pass_through) { 1925 + printk(KERN_INFO 1926 + "Pass Through is not supported by hardware.\n"); 1927 + iommu_pass_through = 0; 1928 + } 2017 1929 2018 1930 /* 2019 1931 * Start from the sane iommu hardware state. ··· 2077 1973 } 2078 1974 2079 1975 /* 2080 - * For each rmrr 2081 - * for each dev attached to rmrr 2082 - * do 2083 - * locate drhd for dev, alloc domain for dev 2084 - * allocate free domain 2085 - * allocate page table entries for rmrr 2086 - * if context not allocated for bus 2087 - * allocate and init context 2088 - * set present in root table for this bus 2089 - * init context with domain, translation etc 2090 - * endfor 2091 - * endfor 1976 + * If pass through is set and enabled, context entries of all pci 1977 + * devices are intialized by pass through translation type. 2092 1978 */ 2093 - for_each_rmrr_units(rmrr) { 2094 - for (i = 0; i < rmrr->devices_cnt; i++) { 2095 - pdev = rmrr->devices[i]; 2096 - /* some BIOS lists non-exist devices in DMAR table */ 2097 - if (!pdev) 2098 - continue; 2099 - ret = iommu_prepare_rmrr_dev(rmrr, pdev); 2100 - if (ret) 2101 - printk(KERN_ERR 2102 - "IOMMU: mapping reserved region failed\n"); 1979 + if (iommu_pass_through) { 1980 + ret = init_context_pass_through(); 1981 + if (ret) { 1982 + printk(KERN_ERR "IOMMU: Pass through init failed.\n"); 1983 + iommu_pass_through = 0; 2103 1984 } 2104 1985 } 2105 1986 2106 - iommu_prepare_gfx_mapping(); 1987 + /* 1988 + * If pass through is not set or not enabled, setup context entries for 1989 + * identity mappings for rmrr, gfx, and isa. 1990 + */ 1991 + if (!iommu_pass_through) { 1992 + /* 1993 + * For each rmrr 1994 + * for each dev attached to rmrr 1995 + * do 1996 + * locate drhd for dev, alloc domain for dev 1997 + * allocate free domain 1998 + * allocate page table entries for rmrr 1999 + * if context not allocated for bus 2000 + * allocate and init context 2001 + * set present in root table for this bus 2002 + * init context with domain, translation etc 2003 + * endfor 2004 + * endfor 2005 + */ 2006 + for_each_rmrr_units(rmrr) { 2007 + for (i = 0; i < rmrr->devices_cnt; i++) { 2008 + pdev = rmrr->devices[i]; 2009 + /* 2010 + * some BIOS lists non-exist devices in DMAR 2011 + * table. 2012 + */ 2013 + if (!pdev) 2014 + continue; 2015 + ret = iommu_prepare_rmrr_dev(rmrr, pdev); 2016 + if (ret) 2017 + printk(KERN_ERR 2018 + "IOMMU: mapping reserved region failed\n"); 2019 + } 2020 + } 2107 2021 2108 - iommu_prepare_isa(); 2022 + iommu_prepare_gfx_mapping(); 2023 + 2024 + iommu_prepare_isa(); 2025 + } 2109 2026 2110 2027 /* 2111 2028 * for each drhd ··· 2148 2023 2149 2024 iommu_set_root_entry(iommu); 2150 2025 2151 - iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL, 2152 - 0); 2153 - iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH, 2154 - 0); 2026 + iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL); 2027 + iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH); 2155 2028 iommu_disable_protect_mem_regions(iommu); 2156 2029 2157 2030 ret = iommu_enable_translation(iommu); ··· 2235 2112 2236 2113 /* make sure context mapping is ok */ 2237 2114 if (unlikely(!domain_context_mapped(pdev))) { 2238 - ret = domain_context_mapping(domain, pdev); 2115 + ret = domain_context_mapping(domain, pdev, 2116 + CONTEXT_TT_MULTI_LEVEL); 2239 2117 if (ret) { 2240 2118 printk(KERN_ERR 2241 2119 "Domain context map for %s failed", ··· 2297 2173 if (ret) 2298 2174 goto error; 2299 2175 2300 - /* it's a non-present to present mapping */ 2301 - ret = iommu_flush_iotlb_psi(iommu, domain->id, 2302 - start_paddr, size >> VTD_PAGE_SHIFT, 1); 2303 - if (ret) 2176 + /* it's a non-present to present mapping. Only flush if caching mode */ 2177 + if (cap_caching_mode(iommu->cap)) 2178 + iommu_flush_iotlb_psi(iommu, 0, start_paddr, 2179 + size >> VTD_PAGE_SHIFT); 2180 + else 2304 2181 iommu_flush_write_buffer(iommu); 2305 2182 2306 2183 return start_paddr + ((u64)paddr & (~PAGE_MASK)); ··· 2335 2210 if (!iommu) 2336 2211 continue; 2337 2212 2338 - if (deferred_flush[i].next) { 2339 - iommu->flush.flush_iotlb(iommu, 0, 0, 0, 2340 - DMA_TLB_GLOBAL_FLUSH, 0); 2341 - for (j = 0; j < deferred_flush[i].next; j++) { 2342 - __free_iova(&deferred_flush[i].domain[j]->iovad, 2343 - deferred_flush[i].iova[j]); 2344 - } 2345 - deferred_flush[i].next = 0; 2213 + if (!deferred_flush[i].next) 2214 + continue; 2215 + 2216 + iommu->flush.flush_iotlb(iommu, 0, 0, 0, 2217 + DMA_TLB_GLOBAL_FLUSH); 2218 + for (j = 0; j < deferred_flush[i].next; j++) { 2219 + unsigned long mask; 2220 + struct iova *iova = deferred_flush[i].iova[j]; 2221 + 2222 + mask = (iova->pfn_hi - iova->pfn_lo + 1) << PAGE_SHIFT; 2223 + mask = ilog2(mask >> VTD_PAGE_SHIFT); 2224 + iommu_flush_dev_iotlb(deferred_flush[i].domain[j], 2225 + iova->pfn_lo << PAGE_SHIFT, mask); 2226 + __free_iova(&deferred_flush[i].domain[j]->iovad, iova); 2346 2227 } 2228 + deferred_flush[i].next = 0; 2347 2229 } 2348 2230 2349 2231 list_size = 0; ··· 2423 2291 /* free page tables */ 2424 2292 dma_pte_free_pagetable(domain, start_addr, start_addr + size); 2425 2293 if (intel_iommu_strict) { 2426 - if (iommu_flush_iotlb_psi(iommu, 2427 - domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0)) 2428 - iommu_flush_write_buffer(iommu); 2294 + iommu_flush_iotlb_psi(iommu, domain->id, start_addr, 2295 + size >> VTD_PAGE_SHIFT); 2429 2296 /* free iova */ 2430 2297 __free_iova(&domain->iovad, iova); 2431 2298 } else { ··· 2515 2384 /* free page tables */ 2516 2385 dma_pte_free_pagetable(domain, start_addr, start_addr + size); 2517 2386 2518 - if (iommu_flush_iotlb_psi(iommu, domain->id, start_addr, 2519 - size >> VTD_PAGE_SHIFT, 0)) 2520 - iommu_flush_write_buffer(iommu); 2387 + iommu_flush_iotlb_psi(iommu, domain->id, start_addr, 2388 + size >> VTD_PAGE_SHIFT); 2521 2389 2522 2390 /* free iova */ 2523 2391 __free_iova(&domain->iovad, iova); ··· 2608 2478 offset += size; 2609 2479 } 2610 2480 2611 - /* it's a non-present to present mapping */ 2612 - if (iommu_flush_iotlb_psi(iommu, domain->id, 2613 - start_addr, offset >> VTD_PAGE_SHIFT, 1)) 2481 + /* it's a non-present to present mapping. Only flush if caching mode */ 2482 + if (cap_caching_mode(iommu->cap)) 2483 + iommu_flush_iotlb_psi(iommu, 0, start_addr, 2484 + offset >> VTD_PAGE_SHIFT); 2485 + else 2614 2486 iommu_flush_write_buffer(iommu); 2487 + 2615 2488 return nelems; 2616 2489 } 2617 2490 ··· 2773 2640 iommu_set_root_entry(iommu); 2774 2641 2775 2642 iommu->flush.flush_context(iommu, 0, 0, 0, 2776 - DMA_CCMD_GLOBAL_INVL, 0); 2643 + DMA_CCMD_GLOBAL_INVL); 2777 2644 iommu->flush.flush_iotlb(iommu, 0, 0, 0, 2778 - DMA_TLB_GLOBAL_FLUSH, 0); 2645 + DMA_TLB_GLOBAL_FLUSH); 2779 2646 iommu_disable_protect_mem_regions(iommu); 2780 2647 iommu_enable_translation(iommu); 2781 2648 } ··· 2790 2657 2791 2658 for_each_active_iommu(iommu, drhd) { 2792 2659 iommu->flush.flush_context(iommu, 0, 0, 0, 2793 - DMA_CCMD_GLOBAL_INVL, 0); 2660 + DMA_CCMD_GLOBAL_INVL); 2794 2661 iommu->flush.flush_iotlb(iommu, 0, 0, 0, 2795 - DMA_TLB_GLOBAL_FLUSH, 0); 2662 + DMA_TLB_GLOBAL_FLUSH); 2796 2663 } 2797 2664 } 2798 2665 ··· 2915 2782 * Check the need for DMA-remapping initialization now. 2916 2783 * Above initialization will also be used by Interrupt-remapping. 2917 2784 */ 2918 - if (no_iommu || swiotlb || dmar_disabled) 2785 + if (no_iommu || (swiotlb && !iommu_pass_through) || dmar_disabled) 2919 2786 return -ENODEV; 2920 2787 2921 2788 iommu_init_mempool(); ··· 2935 2802 2936 2803 init_timer(&unmap_timer); 2937 2804 force_iommu = 1; 2938 - dma_ops = &intel_dma_ops; 2805 + 2806 + if (!iommu_pass_through) { 2807 + printk(KERN_INFO 2808 + "Multi-level page-table translation for DMAR.\n"); 2809 + dma_ops = &intel_dma_ops; 2810 + } else 2811 + printk(KERN_INFO 2812 + "DMAR: Pass through translation for DMAR.\n"); 2813 + 2939 2814 init_iommu_sysfs(); 2940 2815 2941 2816 register_iommu(&intel_iommu_ops); ··· 3029 2888 info->dev->dev.archdata.iommu = NULL; 3030 2889 spin_unlock_irqrestore(&device_domain_lock, flags); 3031 2890 2891 + iommu_disable_dev_iotlb(info); 3032 2892 iommu_detach_dev(iommu, info->bus, info->devfn); 3033 2893 iommu_detach_dependent_devices(iommu, pdev); 3034 2894 free_devinfo_mem(info); ··· 3080 2938 3081 2939 spin_unlock_irqrestore(&device_domain_lock, flags1); 3082 2940 2941 + iommu_disable_dev_iotlb(info); 3083 2942 iommu = device_to_iommu(info->segment, info->bus, info->devfn); 3084 2943 iommu_detach_dev(iommu, info->bus, info->devfn); 3085 2944 iommu_detach_dependent_devices(iommu, info->dev); ··· 3285 3142 return -EFAULT; 3286 3143 } 3287 3144 3288 - ret = domain_context_mapping(dmar_domain, pdev); 3145 + ret = vm_domain_add_dev_info(dmar_domain, pdev); 3289 3146 if (ret) 3290 3147 return ret; 3291 3148 3292 - ret = vm_domain_add_dev_info(dmar_domain, pdev); 3149 + ret = domain_context_mapping(dmar_domain, pdev, CONTEXT_TT_MULTI_LEVEL); 3293 3150 return ret; 3294 3151 } 3295 3152
+3 -5
drivers/pci/intr_remapping.c
··· 409 409 static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode) 410 410 { 411 411 u64 addr; 412 - u32 cmd, sts; 412 + u32 sts; 413 413 unsigned long flags; 414 414 415 415 addr = virt_to_phys((void *)iommu->ir_table->base); ··· 420 420 (addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE); 421 421 422 422 /* Set interrupt-remapping table pointer */ 423 - cmd = iommu->gcmd | DMA_GCMD_SIRTP; 424 423 iommu->gcmd |= DMA_GCMD_SIRTP; 425 - writel(cmd, iommu->reg + DMAR_GCMD_REG); 424 + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); 426 425 427 426 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 428 427 readl, (sts & DMA_GSTS_IRTPS), sts); ··· 436 437 spin_lock_irqsave(&iommu->register_lock, flags); 437 438 438 439 /* Enable interrupt-remapping */ 439 - cmd = iommu->gcmd | DMA_GCMD_IRE; 440 440 iommu->gcmd |= DMA_GCMD_IRE; 441 - writel(cmd, iommu->reg + DMAR_GCMD_REG); 441 + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); 442 442 443 443 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 444 444 readl, (sts & DMA_GSTS_IRES), sts);
+149 -6
drivers/pci/iov.c
··· 5 5 * 6 6 * PCI Express I/O Virtualization (IOV) support. 7 7 * Single Root IOV 1.0 8 + * Address Translation Service 1.0 8 9 */ 9 10 10 11 #include <linux/pci.h> ··· 493 492 494 493 if (pdev) 495 494 iov->dev = pci_dev_get(pdev); 496 - else { 495 + else 497 496 iov->dev = dev; 498 - mutex_init(&iov->lock); 499 - } 497 + 498 + mutex_init(&iov->lock); 500 499 501 500 dev->sriov = iov; 502 501 dev->is_physfn = 1; ··· 516 515 { 517 516 BUG_ON(dev->sriov->nr_virtfn); 518 517 519 - if (dev == dev->sriov->dev) 520 - mutex_destroy(&dev->sriov->lock); 521 - else 518 + if (dev != dev->sriov->dev) 522 519 pci_dev_put(dev->sriov->dev); 520 + 521 + mutex_destroy(&dev->sriov->lock); 523 522 524 523 kfree(dev->sriov); 525 524 dev->sriov = NULL; ··· 682 681 return sriov_migration(dev) ? IRQ_HANDLED : IRQ_NONE; 683 682 } 684 683 EXPORT_SYMBOL_GPL(pci_sriov_migration); 684 + 685 + static int ats_alloc_one(struct pci_dev *dev, int ps) 686 + { 687 + int pos; 688 + u16 cap; 689 + struct pci_ats *ats; 690 + 691 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS); 692 + if (!pos) 693 + return -ENODEV; 694 + 695 + ats = kzalloc(sizeof(*ats), GFP_KERNEL); 696 + if (!ats) 697 + return -ENOMEM; 698 + 699 + ats->pos = pos; 700 + ats->stu = ps; 701 + pci_read_config_word(dev, pos + PCI_ATS_CAP, &cap); 702 + ats->qdep = PCI_ATS_CAP_QDEP(cap) ? PCI_ATS_CAP_QDEP(cap) : 703 + PCI_ATS_MAX_QDEP; 704 + dev->ats = ats; 705 + 706 + return 0; 707 + } 708 + 709 + static void ats_free_one(struct pci_dev *dev) 710 + { 711 + kfree(dev->ats); 712 + dev->ats = NULL; 713 + } 714 + 715 + /** 716 + * pci_enable_ats - enable the ATS capability 717 + * @dev: the PCI device 718 + * @ps: the IOMMU page shift 719 + * 720 + * Returns 0 on success, or negative on failure. 721 + */ 722 + int pci_enable_ats(struct pci_dev *dev, int ps) 723 + { 724 + int rc; 725 + u16 ctrl; 726 + 727 + BUG_ON(dev->ats && dev->ats->is_enabled); 728 + 729 + if (ps < PCI_ATS_MIN_STU) 730 + return -EINVAL; 731 + 732 + if (dev->is_physfn || dev->is_virtfn) { 733 + struct pci_dev *pdev = dev->is_physfn ? dev : dev->physfn; 734 + 735 + mutex_lock(&pdev->sriov->lock); 736 + if (pdev->ats) 737 + rc = pdev->ats->stu == ps ? 0 : -EINVAL; 738 + else 739 + rc = ats_alloc_one(pdev, ps); 740 + 741 + if (!rc) 742 + pdev->ats->ref_cnt++; 743 + mutex_unlock(&pdev->sriov->lock); 744 + if (rc) 745 + return rc; 746 + } 747 + 748 + if (!dev->is_physfn) { 749 + rc = ats_alloc_one(dev, ps); 750 + if (rc) 751 + return rc; 752 + } 753 + 754 + ctrl = PCI_ATS_CTRL_ENABLE; 755 + if (!dev->is_virtfn) 756 + ctrl |= PCI_ATS_CTRL_STU(ps - PCI_ATS_MIN_STU); 757 + pci_write_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, ctrl); 758 + 759 + dev->ats->is_enabled = 1; 760 + 761 + return 0; 762 + } 763 + 764 + /** 765 + * pci_disable_ats - disable the ATS capability 766 + * @dev: the PCI device 767 + */ 768 + void pci_disable_ats(struct pci_dev *dev) 769 + { 770 + u16 ctrl; 771 + 772 + BUG_ON(!dev->ats || !dev->ats->is_enabled); 773 + 774 + pci_read_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, &ctrl); 775 + ctrl &= ~PCI_ATS_CTRL_ENABLE; 776 + pci_write_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, ctrl); 777 + 778 + dev->ats->is_enabled = 0; 779 + 780 + if (dev->is_physfn || dev->is_virtfn) { 781 + struct pci_dev *pdev = dev->is_physfn ? dev : dev->physfn; 782 + 783 + mutex_lock(&pdev->sriov->lock); 784 + pdev->ats->ref_cnt--; 785 + if (!pdev->ats->ref_cnt) 786 + ats_free_one(pdev); 787 + mutex_unlock(&pdev->sriov->lock); 788 + } 789 + 790 + if (!dev->is_physfn) 791 + ats_free_one(dev); 792 + } 793 + 794 + /** 795 + * pci_ats_queue_depth - query the ATS Invalidate Queue Depth 796 + * @dev: the PCI device 797 + * 798 + * Returns the queue depth on success, or negative on failure. 799 + * 800 + * The ATS spec uses 0 in the Invalidate Queue Depth field to 801 + * indicate that the function can accept 32 Invalidate Request. 802 + * But here we use the `real' values (i.e. 1~32) for the Queue 803 + * Depth; and 0 indicates the function shares the Queue with 804 + * other functions (doesn't exclusively own a Queue). 805 + */ 806 + int pci_ats_queue_depth(struct pci_dev *dev) 807 + { 808 + int pos; 809 + u16 cap; 810 + 811 + if (dev->is_virtfn) 812 + return 0; 813 + 814 + if (dev->ats) 815 + return dev->ats->qdep; 816 + 817 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS); 818 + if (!pos) 819 + return -ENODEV; 820 + 821 + pci_read_config_word(dev, pos + PCI_ATS_CAP, &cap); 822 + 823 + return PCI_ATS_CAP_QDEP(cap) ? PCI_ATS_CAP_QDEP(cap) : 824 + PCI_ATS_MAX_QDEP; 825 + }
+39
drivers/pci/pci.h
··· 229 229 u8 __iomem *mstate; /* VF Migration State Array */ 230 230 }; 231 231 232 + /* Address Translation Service */ 233 + struct pci_ats { 234 + int pos; /* capability position */ 235 + int stu; /* Smallest Translation Unit */ 236 + int qdep; /* Invalidate Queue Depth */ 237 + int ref_cnt; /* Physical Function reference count */ 238 + int is_enabled:1; /* Enable bit is set */ 239 + }; 240 + 232 241 #ifdef CONFIG_PCI_IOV 233 242 extern int pci_iov_init(struct pci_dev *dev); 234 243 extern void pci_iov_release(struct pci_dev *dev); ··· 245 236 enum pci_bar_type *type); 246 237 extern void pci_restore_iov_state(struct pci_dev *dev); 247 238 extern int pci_iov_bus_range(struct pci_bus *bus); 239 + 240 + extern int pci_enable_ats(struct pci_dev *dev, int ps); 241 + extern void pci_disable_ats(struct pci_dev *dev); 242 + extern int pci_ats_queue_depth(struct pci_dev *dev); 243 + /** 244 + * pci_ats_enabled - query the ATS status 245 + * @dev: the PCI device 246 + * 247 + * Returns 1 if ATS capability is enabled, or 0 if not. 248 + */ 249 + static inline int pci_ats_enabled(struct pci_dev *dev) 250 + { 251 + return dev->ats && dev->ats->is_enabled; 252 + } 248 253 #else 249 254 static inline int pci_iov_init(struct pci_dev *dev) 250 255 { ··· 277 254 { 278 255 } 279 256 static inline int pci_iov_bus_range(struct pci_bus *bus) 257 + { 258 + return 0; 259 + } 260 + 261 + static inline int pci_enable_ats(struct pci_dev *dev, int ps) 262 + { 263 + return -ENODEV; 264 + } 265 + static inline void pci_disable_ats(struct pci_dev *dev) 266 + { 267 + } 268 + static inline int pci_ats_queue_depth(struct pci_dev *dev) 269 + { 270 + return -ENODEV; 271 + } 272 + static inline int pci_ats_enabled(struct pci_dev *dev) 280 273 { 281 274 return 0; 282 275 }
+9
include/linux/dma_remapping.h
··· 13 13 #define DMA_PTE_WRITE (2) 14 14 #define DMA_PTE_SNP (1 << 11) 15 15 16 + #define CONTEXT_TT_MULTI_LEVEL 0 17 + #define CONTEXT_TT_DEV_IOTLB 1 18 + #define CONTEXT_TT_PASS_THROUGH 2 19 + 16 20 struct intel_iommu; 17 21 struct dmar_domain; 18 22 struct root_entry; ··· 25 21 26 22 #ifdef CONFIG_DMAR 27 23 extern int iommu_calculate_agaw(struct intel_iommu *iommu); 24 + extern int iommu_calculate_max_sagaw(struct intel_iommu *iommu); 28 25 #else 29 26 static inline int iommu_calculate_agaw(struct intel_iommu *iommu) 27 + { 28 + return 0; 29 + } 30 + static inline int iommu_calculate_max_sagaw(struct intel_iommu *iommu) 30 31 { 31 32 return 0; 32 33 }
+9
include/linux/dmar.h
··· 188 188 189 189 #define for_each_rmrr_units(rmrr) \ 190 190 list_for_each_entry(rmrr, &dmar_rmrr_units, list) 191 + 192 + struct dmar_atsr_unit { 193 + struct list_head list; /* list of ATSR units */ 194 + struct acpi_dmar_header *hdr; /* ACPI header */ 195 + struct pci_dev **devices; /* target devices */ 196 + int devices_cnt; /* target device count */ 197 + u8 include_all:1; /* include all ports */ 198 + }; 199 + 191 200 /* Intel DMAR initialization functions */ 192 201 extern int intel_iommu_init(void); 193 202 #else
+25 -10
include/linux/intel-iommu.h
··· 53 53 #define DMAR_PHMLIMIT_REG 0x78 /* pmrr high limit */ 54 54 #define DMAR_IQH_REG 0x80 /* Invalidation queue head register */ 55 55 #define DMAR_IQT_REG 0x88 /* Invalidation queue tail register */ 56 + #define DMAR_IQ_SHIFT 4 /* Invalidation queue head/tail shift */ 56 57 #define DMAR_IQA_REG 0x90 /* Invalidation queue addr register */ 57 58 #define DMAR_ICS_REG 0x98 /* Invalidation complete status register */ 58 59 #define DMAR_IRTA_REG 0xb8 /* Interrupt remapping table addr register */ ··· 121 120 (ecap_iotlb_offset(e) + ecap_niotlb_iunits(e) * 16) 122 121 #define ecap_coherent(e) ((e) & 0x1) 123 122 #define ecap_qis(e) ((e) & 0x2) 123 + #define ecap_pass_through(e) ((e >> 6) & 0x1) 124 124 #define ecap_eim_support(e) ((e >> 4) & 0x1) 125 125 #define ecap_ir_support(e) ((e >> 3) & 0x1) 126 + #define ecap_dev_iotlb_support(e) (((e) >> 2) & 0x1) 126 127 #define ecap_max_handle_mask(e) ((e >> 20) & 0xf) 127 128 #define ecap_sc_support(e) ((e >> 7) & 0x1) /* Snooping Control */ 128 129 ··· 200 197 #define DMA_FSTS_PPF ((u32)2) 201 198 #define DMA_FSTS_PFO ((u32)1) 202 199 #define DMA_FSTS_IQE (1 << 4) 200 + #define DMA_FSTS_ICE (1 << 5) 201 + #define DMA_FSTS_ITE (1 << 6) 203 202 #define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff) 204 203 205 204 /* FRCD_REG, 32 bits access */ ··· 230 225 enum { 231 226 QI_FREE, 232 227 QI_IN_USE, 233 - QI_DONE 228 + QI_DONE, 229 + QI_ABORT 234 230 }; 235 231 236 232 #define QI_CC_TYPE 0x1 ··· 260 254 #define QI_CC_DID(did) (((u64)did) << 16) 261 255 #define QI_CC_GRAN(gran) (((u64)gran) >> (DMA_CCMD_INVL_GRANU_OFFSET-4)) 262 256 257 + #define QI_DEV_IOTLB_SID(sid) ((u64)((sid) & 0xffff) << 32) 258 + #define QI_DEV_IOTLB_QDEP(qdep) (((qdep) & 0x1f) << 16) 259 + #define QI_DEV_IOTLB_ADDR(addr) ((u64)(addr) & VTD_PAGE_MASK) 260 + #define QI_DEV_IOTLB_SIZE 1 261 + #define QI_DEV_IOTLB_MAX_INVS 32 262 + 263 263 struct qi_desc { 264 264 u64 low, high; 265 265 }; ··· 292 280 #endif 293 281 294 282 struct iommu_flush { 295 - int (*flush_context)(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm, 296 - u64 type, int non_present_entry_flush); 297 - int (*flush_iotlb)(struct intel_iommu *iommu, u16 did, u64 addr, 298 - unsigned int size_order, u64 type, int non_present_entry_flush); 283 + void (*flush_context)(struct intel_iommu *iommu, u16 did, u16 sid, 284 + u8 fm, u64 type); 285 + void (*flush_iotlb)(struct intel_iommu *iommu, u16 did, u64 addr, 286 + unsigned int size_order, u64 type); 299 287 }; 300 288 301 289 enum { ··· 314 302 spinlock_t register_lock; /* protect register handling */ 315 303 int seq_id; /* sequence id of the iommu */ 316 304 int agaw; /* agaw of this iommu */ 305 + int msagaw; /* max sagaw of this iommu */ 317 306 unsigned int irq; 318 307 unsigned char name[13]; /* Device Name */ 319 308 ··· 342 329 } 343 330 344 331 extern struct dmar_drhd_unit * dmar_find_matched_drhd_unit(struct pci_dev *dev); 332 + extern int dmar_find_matched_atsr_unit(struct pci_dev *dev); 345 333 346 334 extern int alloc_iommu(struct dmar_drhd_unit *drhd); 347 335 extern void free_iommu(struct intel_iommu *iommu); ··· 351 337 extern int dmar_reenable_qi(struct intel_iommu *iommu); 352 338 extern void qi_global_iec(struct intel_iommu *iommu); 353 339 354 - extern int qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, 355 - u8 fm, u64 type, int non_present_entry_flush); 356 - extern int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, 357 - unsigned int size_order, u64 type, 358 - int non_present_entry_flush); 340 + extern void qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid, 341 + u8 fm, u64 type); 342 + extern void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, 343 + unsigned int size_order, u64 type); 344 + extern void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 qdep, 345 + u64 addr, unsigned mask); 359 346 360 347 extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); 361 348
+2
include/linux/pci.h
··· 196 196 struct pcie_link_state; 197 197 struct pci_vpd; 198 198 struct pci_sriov; 199 + struct pci_ats; 199 200 200 201 /* 201 202 * The pci_dev structure is used to describe PCI devices. ··· 294 293 struct pci_sriov *sriov; /* SR-IOV capability related */ 295 294 struct pci_dev *physfn; /* the PF this VF is associated with */ 296 295 }; 296 + struct pci_ats *ats; /* Address Translation Service */ 297 297 #endif 298 298 }; 299 299
+10
include/linux/pci_regs.h
··· 502 502 #define PCI_EXT_CAP_ID_DSN 3 503 503 #define PCI_EXT_CAP_ID_PWR 4 504 504 #define PCI_EXT_CAP_ID_ARI 14 505 + #define PCI_EXT_CAP_ID_ATS 15 505 506 #define PCI_EXT_CAP_ID_SRIOV 16 506 507 507 508 /* Advanced Error Reporting */ ··· 620 619 #define PCI_ARI_CTRL_MFVC 0x0001 /* MFVC Function Groups Enable */ 621 620 #define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */ 622 621 #define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */ 622 + 623 + /* Address Translation Service */ 624 + #define PCI_ATS_CAP 0x04 /* ATS Capability Register */ 625 + #define PCI_ATS_CAP_QDEP(x) ((x) & 0x1f) /* Invalidate Queue Depth */ 626 + #define PCI_ATS_MAX_QDEP 32 /* Max Invalidate Queue Depth */ 627 + #define PCI_ATS_CTRL 0x06 /* ATS Control Register */ 628 + #define PCI_ATS_CTRL_ENABLE 0x8000 /* ATS Enable */ 629 + #define PCI_ATS_CTRL_STU(x) ((x) & 0x1f) /* Smallest Translation Unit */ 630 + #define PCI_ATS_MIN_STU 12 /* shift of minimum STU block */ 623 631 624 632 /* Single Root I/O Virtualization */ 625 633 #define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */