diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2011-11-09 06:06:03 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2011-12-12 08:54:23 -0500 |
commit | ee6c28684585a64fd79c5a56e849af58ebdc5948 (patch) | |
tree | c58aea90ae017d89a53833097b0ecd95a072c8ec /drivers/iommu | |
parent | dc47ce90c3a822cd7c9e9339fe4d5f61dcb26b50 (diff) |
iommu/amd: Convert dev_table_entry to u64
Convert the contents of 'struct dev_table_entry' to u64 to
allow updating the DTE wit 64bit writes as required by the
spec.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 18 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_init.c | 12 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_types.h | 4 |
3 files changed, 18 insertions, 16 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 4ee277a8521a..661e2bb4ac15 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -365,8 +365,8 @@ static void dump_dte_entry(u16 devid) | |||
365 | { | 365 | { |
366 | int i; | 366 | int i; |
367 | 367 | ||
368 | for (i = 0; i < 8; ++i) | 368 | for (i = 0; i < 4; ++i) |
369 | pr_err("AMD-Vi: DTE[%d]: %08x\n", i, | 369 | pr_err("AMD-Vi: DTE[%d]: %016llx\n", i, |
370 | amd_iommu_dev_table[devid].data[i]); | 370 | amd_iommu_dev_table[devid].data[i]); |
371 | } | 371 | } |
372 | 372 | ||
@@ -1583,19 +1583,22 @@ static bool dma_ops_domain(struct protection_domain *domain) | |||
1583 | static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats) | 1583 | static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats) |
1584 | { | 1584 | { |
1585 | u64 pte_root = virt_to_phys(domain->pt_root); | 1585 | u64 pte_root = virt_to_phys(domain->pt_root); |
1586 | u32 flags = 0; | 1586 | u64 flags = 0; |
1587 | 1587 | ||
1588 | pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK) | 1588 | pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK) |
1589 | << DEV_ENTRY_MODE_SHIFT; | 1589 | << DEV_ENTRY_MODE_SHIFT; |
1590 | pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV; | 1590 | pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV; |
1591 | 1591 | ||
1592 | flags = amd_iommu_dev_table[devid].data[1]; | ||
1593 | |||
1592 | if (ats) | 1594 | if (ats) |
1593 | flags |= DTE_FLAG_IOTLB; | 1595 | flags |= DTE_FLAG_IOTLB; |
1594 | 1596 | ||
1595 | amd_iommu_dev_table[devid].data[3] |= flags; | 1597 | flags &= ~(0xffffUL); |
1596 | amd_iommu_dev_table[devid].data[2] = domain->id; | 1598 | flags |= domain->id; |
1597 | amd_iommu_dev_table[devid].data[1] = upper_32_bits(pte_root); | 1599 | |
1598 | amd_iommu_dev_table[devid].data[0] = lower_32_bits(pte_root); | 1600 | amd_iommu_dev_table[devid].data[1] = flags; |
1601 | amd_iommu_dev_table[devid].data[0] = pte_root; | ||
1599 | } | 1602 | } |
1600 | 1603 | ||
1601 | static void clear_dte_entry(u16 devid) | 1604 | static void clear_dte_entry(u16 devid) |
@@ -1603,7 +1606,6 @@ static void clear_dte_entry(u16 devid) | |||
1603 | /* remove entry from the device table seen by the hardware */ | 1606 | /* remove entry from the device table seen by the hardware */ |
1604 | amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV; | 1607 | amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV; |
1605 | amd_iommu_dev_table[devid].data[1] = 0; | 1608 | amd_iommu_dev_table[devid].data[1] = 0; |
1606 | amd_iommu_dev_table[devid].data[2] = 0; | ||
1607 | 1609 | ||
1608 | amd_iommu_apply_erratum_63(devid); | 1610 | amd_iommu_apply_erratum_63(devid); |
1609 | } | 1611 | } |
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 82d2410f4205..17e0f77c7dad 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c | |||
@@ -584,18 +584,18 @@ static void __init free_event_buffer(struct amd_iommu *iommu) | |||
584 | /* sets a specific bit in the device table entry. */ | 584 | /* sets a specific bit in the device table entry. */ |
585 | static void set_dev_entry_bit(u16 devid, u8 bit) | 585 | static void set_dev_entry_bit(u16 devid, u8 bit) |
586 | { | 586 | { |
587 | int i = (bit >> 5) & 0x07; | 587 | int i = (bit >> 6) & 0x03; |
588 | int _bit = bit & 0x1f; | 588 | int _bit = bit & 0x3f; |
589 | 589 | ||
590 | amd_iommu_dev_table[devid].data[i] |= (1 << _bit); | 590 | amd_iommu_dev_table[devid].data[i] |= (1UL << _bit); |
591 | } | 591 | } |
592 | 592 | ||
593 | static int get_dev_entry_bit(u16 devid, u8 bit) | 593 | static int get_dev_entry_bit(u16 devid, u8 bit) |
594 | { | 594 | { |
595 | int i = (bit >> 5) & 0x07; | 595 | int i = (bit >> 6) & 0x03; |
596 | int _bit = bit & 0x1f; | 596 | int _bit = bit & 0x3f; |
597 | 597 | ||
598 | return (amd_iommu_dev_table[devid].data[i] & (1 << _bit)) >> _bit; | 598 | return (amd_iommu_dev_table[devid].data[i] & (1UL << _bit)) >> _bit; |
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 5b9c5075e81a..f8dd9ae693d1 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
@@ -230,7 +230,7 @@ | |||
230 | #define IOMMU_PTE_IR (1ULL << 61) | 230 | #define IOMMU_PTE_IR (1ULL << 61) |
231 | #define IOMMU_PTE_IW (1ULL << 62) | 231 | #define IOMMU_PTE_IW (1ULL << 62) |
232 | 232 | ||
233 | #define DTE_FLAG_IOTLB 0x01 | 233 | #define DTE_FLAG_IOTLB (0x01UL << 32) |
234 | 234 | ||
235 | #define IOMMU_PAGE_MASK (((1ULL << 52) - 1) & ~0xfffULL) | 235 | #define IOMMU_PAGE_MASK (((1ULL << 52) - 1) & ~0xfffULL) |
236 | #define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_P) | 236 | #define IOMMU_PTE_PRESENT(pte) ((pte) & IOMMU_PTE_P) |
@@ -484,7 +484,7 @@ extern struct list_head amd_iommu_pd_list; | |||
484 | * Structure defining one entry in the device table | 484 | * Structure defining one entry in the device table |
485 | */ | 485 | */ |
486 | struct dev_table_entry { | 486 | struct dev_table_entry { |
487 | u32 data[8]; | 487 | u64 data[4]; |
488 | }; | 488 | }; |
489 | 489 | ||
490 | /* | 490 | /* |