Lines Matching refs:cookie

79 static inline size_t cookie_msi_granule(struct iommu_dma_cookie *cookie)  in cookie_msi_granule()  argument
81 if (cookie->type == IOMMU_DMA_IOVA_COOKIE) in cookie_msi_granule()
82 return cookie->iovad.granule; in cookie_msi_granule()
88 struct iommu_dma_cookie *cookie; in cookie_alloc() local
90 cookie = kzalloc(sizeof(*cookie), GFP_KERNEL); in cookie_alloc()
91 if (cookie) { in cookie_alloc()
92 INIT_LIST_HEAD(&cookie->msi_page_list); in cookie_alloc()
93 cookie->type = type; in cookie_alloc()
95 return cookie; in cookie_alloc()
128 struct iommu_dma_cookie *cookie; in iommu_get_msi_cookie() local
136 cookie = cookie_alloc(IOMMU_DMA_MSI_COOKIE); in iommu_get_msi_cookie()
137 if (!cookie) in iommu_get_msi_cookie()
140 cookie->msi_iova = base; in iommu_get_msi_cookie()
141 domain->iova_cookie = cookie; in iommu_get_msi_cookie()
153 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_put_dma_cookie() local
156 if (!cookie) in iommu_put_dma_cookie()
159 if (cookie->type == IOMMU_DMA_IOVA_COOKIE && cookie->iovad.granule) in iommu_put_dma_cookie()
160 put_iova_domain(&cookie->iovad); in iommu_put_dma_cookie()
162 list_for_each_entry_safe(msi, tmp, &cookie->msi_page_list, list) { in iommu_put_dma_cookie()
166 kfree(cookie); in iommu_put_dma_cookie()
189 static int cookie_init_hw_msi_region(struct iommu_dma_cookie *cookie, in cookie_init_hw_msi_region() argument
192 struct iova_domain *iovad = &cookie->iovad; in cookie_init_hw_msi_region()
207 list_add(&msi_page->list, &cookie->msi_page_list); in cookie_init_hw_msi_region()
262 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iova_reserve_iommu_regions() local
263 struct iova_domain *iovad = &cookie->iovad; in iova_reserve_iommu_regions()
287 ret = cookie_init_hw_msi_region(cookie, region->start, in iova_reserve_iommu_regions()
299 struct iommu_dma_cookie *cookie; in iommu_dma_flush_iotlb_all() local
302 cookie = container_of(iovad, struct iommu_dma_cookie, iovad); in iommu_dma_flush_iotlb_all()
303 domain = cookie->fq_domain; in iommu_dma_flush_iotlb_all()
321 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_dma_init_fq() local
324 if (cookie->fq_domain) in iommu_dma_init_fq()
327 ret = init_iova_flush_queue(&cookie->iovad, iommu_dma_flush_iotlb_all, in iommu_dma_init_fq()
338 WRITE_ONCE(cookie->fq_domain, domain); in iommu_dma_init_fq()
357 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_dma_init_domain() local
361 if (!cookie || cookie->type != IOMMU_DMA_IOVA_COOKIE) in iommu_dma_init_domain()
364 iovad = &cookie->iovad; in iommu_dma_init_domain()
434 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_dma_alloc_iova() local
435 struct iova_domain *iovad = &cookie->iovad; in iommu_dma_alloc_iova()
438 if (cookie->type == IOMMU_DMA_MSI_COOKIE) { in iommu_dma_alloc_iova()
439 cookie->msi_iova += size; in iommu_dma_alloc_iova()
440 return cookie->msi_iova - size; in iommu_dma_alloc_iova()
471 static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie, in iommu_dma_free_iova() argument
474 struct iova_domain *iovad = &cookie->iovad; in iommu_dma_free_iova()
477 if (cookie->type == IOMMU_DMA_MSI_COOKIE) in iommu_dma_free_iova()
478 cookie->msi_iova -= size; in iommu_dma_free_iova()
492 struct iommu_dma_cookie *cookie = domain->iova_cookie; in __iommu_dma_unmap() local
493 struct iova_domain *iovad = &cookie->iovad; in __iommu_dma_unmap()
501 iotlb_gather.queued = READ_ONCE(cookie->fq_domain); in __iommu_dma_unmap()
508 iommu_dma_free_iova(cookie, dma_addr, size, &iotlb_gather); in __iommu_dma_unmap()
515 struct iommu_dma_cookie *cookie = domain->iova_cookie; in __iommu_dma_map() local
516 struct iova_domain *iovad = &cookie->iovad; in __iommu_dma_map()
531 iommu_dma_free_iova(cookie, iova, size, NULL); in __iommu_dma_map()
608 struct iommu_dma_cookie *cookie = domain->iova_cookie; in __iommu_dma_alloc_noncontiguous() local
609 struct iova_domain *iovad = &cookie->iovad; in __iommu_dma_alloc_noncontiguous()
663 iommu_dma_free_iova(cookie, iova, size, NULL); in __iommu_dma_alloc_noncontiguous()
800 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_dma_map_page() local
801 struct iova_domain *iovad = &cookie->iovad; in iommu_dma_map_page()
978 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_dma_map_sg() local
979 struct iova_domain *iovad = &cookie->iovad; in iommu_dma_map_sg()
1056 iommu_dma_free_iova(cookie, iova, iova_len, NULL); in iommu_dma_map_sg()
1338 struct iommu_dma_cookie *cookie = domain->iova_cookie; in iommu_dma_get_msi_page() local
1342 size_t size = cookie_msi_granule(cookie); in iommu_dma_get_msi_page()
1345 list_for_each_entry(msi_page, &cookie->msi_page_list, list) in iommu_dma_get_msi_page()
1363 list_add(&msi_page->list, &cookie->msi_page_list); in iommu_dma_get_msi_page()
1367 iommu_dma_free_iova(cookie, iova, size, NULL); in iommu_dma_get_msi_page()