Lines Matching full:area

25 	struct iopt_area *area;
40 iter->area = iopt_area_iter_first(iopt, iova, iova);
41 if (!iter->area)
43 if (!iter->area->pages) {
44 iter->area = NULL;
47 return iter->area;
54 if (!iter->area)
56 last_iova = iopt_area_last_iova(iter->area);
61 iter->area = iopt_area_iter_next(iter->area, iter->cur_iova,
63 if (!iter->area)
65 if (iter->cur_iova != iopt_area_iova(iter->area) ||
66 !iter->area->pages) {
67 iter->area = NULL;
70 return iter->area;
205 * The area takes a slice of the pages from start_bytes to start_byte + length
207 static int iopt_insert_area(struct io_pagetable *iopt, struct iopt_area *area,
217 area->iommu_prot = iommu_prot;
218 area->page_offset = start_byte % PAGE_SIZE;
219 if (area->page_offset & (iopt->iova_alignment - 1))
222 area->node.start = iova;
223 if (check_add_overflow(iova, length - 1, &area->node.last))
226 area->pages_node.start = start_byte / PAGE_SIZE;
227 if (check_add_overflow(start_byte, length - 1, &area->pages_node.last))
229 area->pages_node.last = area->pages_node.last / PAGE_SIZE;
230 if (WARN_ON(area->pages_node.last >= pages->npages))
234 * The area is inserted with a NULL pages indicating it is not fully
237 area->iopt = iopt;
238 interval_tree_insert(&area->node, &iopt->area_itree);
244 struct iopt_area *area;
246 area = kzalloc(sizeof(*area), GFP_KERNEL_ACCOUNT);
247 if (!area)
249 RB_CLEAR_NODE(&area->node.rb);
250 RB_CLEAR_NODE(&area->pages_node.rb);
251 return area;
265 elm->area = iopt_area_alloc();
266 if (!elm->area)
308 rc = iopt_insert_area(iopt, elm->area, elm->pages, iova,
320 static void iopt_abort_area(struct iopt_area *area)
323 WARN_ON(area->pages);
324 if (area->iopt) {
325 down_write(&area->iopt->iova_rwsem);
326 interval_tree_remove(&area->node, &area->iopt->area_itree);
327 up_write(&area->iopt->iova_rwsem);
329 kfree(area);
338 if (elm->area)
339 iopt_abort_area(elm->area);
354 rc = iopt_area_fill_domains(elm->area, elm->pages);
364 iopt_area_unfill_domains(undo_elm->area, undo_elm->pages);
389 * area->pages must be set inside the domains_rwsem to ensure
393 elm->area->pages = elm->pages;
395 elm->area = NULL;
422 if (elm.area)
423 iopt_abort_area(elm.area);
503 struct iopt_area *area;
513 iopt_for_each_contig_area(&iter, area, arg->iopt, iova, last_iova) {
514 unsigned long last = min(last_iova, iopt_area_last_iova(area));
615 struct iopt_area *area;
622 for (area = iopt_area_iter_first(iopt, 0, ULONG_MAX); area;
623 area = iopt_area_iter_next(area, 0, ULONG_MAX)) {
624 if (!area->pages)
627 ret = ops->read_and_clear_dirty(domain, iopt_area_iova(area),
628 iopt_area_length(area), 0,
668 struct iopt_area *area;
677 iopt_for_each_contig_area(&iter, area, iopt, iova, last_iova) {
679 unsigned long last = min(last_iova, iopt_area_last_iova(area));
686 elm->start_byte = iopt_area_start_byte(area, iter.cur_iova);
687 elm->pages = area->pages;
707 struct iopt_area *area;
713 * The domains_rwsem must be held in read mode any time any area->pages
715 * concurrently with cleaning up the area.
720 while ((area = iopt_area_iter_first(iopt, start, last))) {
721 unsigned long area_last = iopt_area_last_iova(area);
722 unsigned long area_first = iopt_area_iova(area);
725 /* Userspace should not race map/unmap's of the same area */
726 if (!area->pages) {
731 /* The area is locked by an object that has not been destroyed */
732 if (area->num_locks) {
750 if (area->num_accesses) {
751 size_t length = iopt_area_length(area);
754 area->prevent_access = true;
768 pages = area->pages;
769 area->pages = NULL;
772 iopt_area_unfill_domains(area, pages);
773 iopt_abort_area(area);
937 * This is used when removing a domain from the iopt. Every area in the iopt
944 struct iopt_area *area;
958 for (area = iopt_area_iter_first(iopt, 0, ULONG_MAX); area;
959 area = iopt_area_iter_next(area, 0, ULONG_MAX)) {
960 struct iopt_pages *pages = area->pages;
967 WARN_ON(!area->storage_domain);
968 if (area->storage_domain == domain)
969 area->storage_domain = storage_domain;
972 iopt_area_unmap_domain(area, domain);
977 for (area = iopt_area_iter_first(iopt, 0, ULONG_MAX); area;
978 area = iopt_area_iter_next(area, 0, ULONG_MAX)) {
979 struct iopt_pages *pages = area->pages;
985 interval_tree_remove(&area->pages_node, &pages->domains_itree);
986 WARN_ON(area->storage_domain != domain);
987 area->storage_domain = NULL;
988 iopt_area_unfill_domain(area, pages, domain);
998 * Fill the domain with PFNs from every area in the iopt. On failure the domain
1005 struct iopt_area *area;
1011 for (area = iopt_area_iter_first(iopt, 0, ULONG_MAX); area;
1012 area = iopt_area_iter_next(area, 0, ULONG_MAX)) {
1013 struct iopt_pages *pages = area->pages;
1019 rc = iopt_area_fill_domain(area, domain);
1024 if (!area->storage_domain) {
1026 area->storage_domain = domain;
1027 interval_tree_insert(&area->pages_node,
1035 end_area = area;
1036 for (area = iopt_area_iter_first(iopt, 0, ULONG_MAX); area;
1037 area = iopt_area_iter_next(area, 0, ULONG_MAX)) {
1038 struct iopt_pages *pages = area->pages;
1040 if (area == end_area)
1046 interval_tree_remove(&area->pages_node,
1048 area->storage_domain = NULL;
1050 iopt_area_unfill_domain(area, pages, domain);
1056 /* All existing area's conform to an increased page size */
1061 struct iopt_area *area;
1066 for (area = iopt_area_iter_first(iopt, 0, ULONG_MAX); area;
1067 area = iopt_area_iter_next(area, 0, ULONG_MAX))
1068 if ((iopt_area_iova(area) & align_mask) ||
1069 (iopt_area_length(area) & align_mask) ||
1070 (area->page_offset & align_mask))
1125 /* No area exists that is outside the allowed domain aperture */
1233 * iopt_area_split - Split an area into two parts at iova
1234 * @area: The area to split
1235 * @iova: Becomes the last of a new area
1237 * This splits an area into two. It is part of the VFIO compatibility to allow
1241 static int iopt_area_split(struct iopt_area *area, unsigned long iova)
1243 unsigned long alignment = area->iopt->iova_alignment;
1244 unsigned long last_iova = iopt_area_last_iova(area);
1245 unsigned long start_iova = iopt_area_iova(area);
1247 struct io_pagetable *iopt = area->iopt;
1248 struct iopt_pages *pages = area->pages;
1258 if (!pages || area->prevent_access)
1262 iopt_area_start_byte(area, new_start) & (alignment - 1))
1280 if (area->num_accesses) {
1289 if (area->storage_domain && !iopt->disable_large_pages) {
1294 interval_tree_remove(&area->node, &iopt->area_itree);
1295 rc = iopt_insert_area(iopt, lhs, area->pages, start_iova,
1296 iopt_area_start_byte(area, start_iova),
1298 area->iommu_prot);
1302 rc = iopt_insert_area(iopt, rhs, area->pages, new_start,
1303 iopt_area_start_byte(area, new_start),
1304 last_iova - new_start + 1, area->iommu_prot);
1309 * If the original area has filled a domain, domains_itree has to be
1312 if (area->storage_domain) {
1313 interval_tree_remove(&area->pages_node, &pages->domains_itree);
1318 lhs->storage_domain = area->storage_domain;
1319 lhs->pages = area->pages;
1320 rhs->storage_domain = area->storage_domain;
1321 rhs->pages = area->pages;
1323 kfree(area);
1335 interval_tree_insert(&area->node, &iopt->area_itree);
1352 struct iopt_area *area;
1354 area = iopt_area_iter_first(iopt, iovas[i], iovas[i]);
1355 if (!area)
1357 rc = iopt_area_split(area, iovas[i]);