/* Remap-pfn-range will mark the range VM_IO */ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, size, vma->vm_page_prot)) { return -EAGAIN; } return0; }
/* * check if an address is reserved in the iomem resource tree * returns 1 if reserved, 0 if not reserved. */ intiomem_is_exclusive(u64 addr) { structresource *p = &iomem_resource; int err = 0; loff_t l; int size = PAGE_SIZE;
if (!strict_iomem_checks) return0;
addr = addr & PAGE_MASK;
read_lock(&resource_lock); for (p = p->child; p ; p = r_next(NULL, p, &l)) { /* * We can probably skip the resources without * IORESOURCE_IO attribute? */ if (p->start >= addr + size) break; if (p->end < addr) continue; /* * A resource is exclusive if IORESOURCE_EXCLUSIVE is set * or CONFIG_IO_STRICT_DEVMEM is enabled and the * resource is busy. */ if ((p->flags & IORESOURCE_BUSY) == 0) continue; if (IS_ENABLED(CONFIG_IO_STRICT_DEVMEM) || p->flags & IORESOURCE_EXCLUSIVE) { err = 1; break; } } read_unlock(&resource_lock);