lkml.org 
[lkml]   [2008]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 19/21] AMD IOMMU: add domain unmap function for IOMMU API
    Date
    Impact: add a generic function to unmap pages into protection domains

    Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
    ---
    arch/x86/kernel/amd_iommu.c | 39 +++++++++++++++++++++++++++++++++++++++
    1 files changed, 39 insertions(+), 0 deletions(-)

    diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
    index 511f782..6ee9377 100644
    --- a/arch/x86/kernel/amd_iommu.c
    +++ b/arch/x86/kernel/amd_iommu.c
    @@ -438,6 +438,28 @@ static int iommu_map_page(struct protection_domain *dom,
    return 0;
    }

    +static void iommu_unmap_page(struct protection_domain *dom,
    + unsigned long bus_addr)
    +{
    + u64 *pte;
    +
    + pte = &dom->pt_root[IOMMU_PTE_L2_INDEX(bus_addr)];
    +
    + if (!IOMMU_PTE_PRESENT(*pte))
    + return;
    +
    + pte = IOMMU_PTE_PAGE(*pte);
    + pte = &pte[IOMMU_PTE_L1_INDEX(bus_addr)];
    +
    + if (!IOMMU_PTE_PRESENT(*pte))
    + return;
    +
    + pte = IOMMU_PTE_PAGE(*pte);
    + pte = &pte[IOMMU_PTE_L1_INDEX(bus_addr)];
    +
    + *pte = 0;
    +}
    +
    /*
    * This function checks if a specific unity mapping entry is needed for
    * this specific IOMMU.
    @@ -1663,3 +1685,20 @@ static int amd_iommu_map_range(struct iommu_domain *dom,

    return 0;
    }
    +
    +static void amd_iommu_unmap_range(struct iommu_domain *dom,
    + unsigned long iova, size_t size)
    +{
    +
    + struct protection_domain *domain = dom->priv;
    + unsigned long i, npages = iommu_num_pages(iova, size, PAGE_SIZE);
    +
    + iova &= PAGE_MASK;
    +
    + for (i = 0; i < npages; ++i) {
    + iommu_unmap_page(domain, iova);
    + iova += PAGE_SIZE;
    + }
    +
    + iommu_flush_domain(domain->id);
    +}
    --
    1.5.6.4



    \
     
     \ /
      Last update: 2008-12-09 15:31    [W:0.022 / U:1.620 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site