Lines Matching +full:page +full:- +full:offset
69 pgprot_t tmp = vm_get_page_prot(vma->vm_flags); in drm_io_prot()
73 if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) in drm_io_prot()
78 if (efi_range_is_wc(vma->vm_start, vma->vm_end - in drm_io_prot()
79 vma->vm_start)) in drm_io_prot()
91 pgprot_t tmp = vm_get_page_prot(vma->vm_flags); in drm_dma_prot()
104 * \return pointer to the page structure.
106 * Find the right map and if it's AGP memory find the real physical page to
107 * map, get the page, increment the use count and return it.
112 struct vm_area_struct *vma = vmf->vma; in drm_vm_fault()
113 struct drm_file *priv = vma->vm_file->private_data; in drm_vm_fault()
114 struct drm_device *dev = priv->minor->dev; in drm_vm_fault()
122 if (!dev->agp) in drm_vm_fault()
125 if (!dev->agp || !dev->agp->cant_use_aperture) in drm_vm_fault()
128 if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash)) in drm_vm_fault()
132 map = r_list->map; in drm_vm_fault()
134 if (map && map->type == _DRM_AGP) { in drm_vm_fault()
139 resource_size_t offset = vmf->address - vma->vm_start; in drm_vm_fault() local
140 resource_size_t baddr = map->offset + offset; in drm_vm_fault()
142 struct page *page; in drm_vm_fault() local
146 * Adjust to a bus-relative address in drm_vm_fault()
148 baddr -= dev->hose->mem_space->start; in drm_vm_fault()
152 * It's AGP memory - find the real physical page to map in drm_vm_fault()
154 list_for_each_entry(agpmem, &dev->agp->memory, head) { in drm_vm_fault()
155 if (agpmem->bound <= baddr && in drm_vm_fault()
156 agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) in drm_vm_fault()
160 if (&agpmem->head == &dev->agp->memory) in drm_vm_fault()
164 * Get the page, inc the use count, and return it in drm_vm_fault()
166 offset = (baddr - agpmem->bound) >> PAGE_SHIFT; in drm_vm_fault()
167 page = agpmem->memory->pages[offset]; in drm_vm_fault()
168 get_page(page); in drm_vm_fault()
169 vmf->page = page; in drm_vm_fault()
172 ("baddr = 0x%llx page = 0x%p, offset = 0x%llx, count=%d\n", in drm_vm_fault()
174 agpmem->memory->pages[offset], in drm_vm_fault()
175 (unsigned long long)offset, in drm_vm_fault()
176 page_count(page)); in drm_vm_fault()
194 * \return pointer to the page structure.
196 * Get the mapping, find the real physical page to map, get the page, and
201 struct vm_area_struct *vma = vmf->vma; in drm_vm_shm_fault()
202 struct drm_local_map *map = vma->vm_private_data; in drm_vm_shm_fault()
203 unsigned long offset; in drm_vm_shm_fault() local
205 struct page *page; in drm_vm_shm_fault() local
210 offset = vmf->address - vma->vm_start; in drm_vm_shm_fault()
211 i = (unsigned long)map->handle + offset; in drm_vm_shm_fault()
212 page = vmalloc_to_page((void *)i); in drm_vm_shm_fault()
213 if (!page) in drm_vm_shm_fault()
215 get_page(page); in drm_vm_shm_fault()
216 vmf->page = page; in drm_vm_shm_fault()
218 DRM_DEBUG("shm_fault 0x%lx\n", offset); in drm_vm_shm_fault()
232 struct drm_file *priv = vma->vm_file->private_data; in drm_vm_shm_close()
233 struct drm_device *dev = priv->minor->dev; in drm_vm_shm_close()
240 vma->vm_start, vma->vm_end - vma->vm_start); in drm_vm_shm_close()
242 map = vma->vm_private_data; in drm_vm_shm_close()
244 mutex_lock(&dev->struct_mutex); in drm_vm_shm_close()
245 list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { in drm_vm_shm_close()
246 if (pt->vma->vm_private_data == map) in drm_vm_shm_close()
248 if (pt->vma == vma) { in drm_vm_shm_close()
249 list_del(&pt->head); in drm_vm_shm_close()
255 if (found_maps == 1 && map->flags & _DRM_REMOVABLE) { in drm_vm_shm_close()
260 list_for_each_entry(r_list, &dev->maplist, head) { in drm_vm_shm_close()
261 if (r_list->map == map) in drm_vm_shm_close()
266 switch (map->type) { in drm_vm_shm_close()
269 arch_phys_wc_del(map->mtrr); in drm_vm_shm_close()
270 iounmap(map->handle); in drm_vm_shm_close()
273 vfree(map->handle); in drm_vm_shm_close()
279 dma_free_coherent(dev->dev, in drm_vm_shm_close()
280 map->size, in drm_vm_shm_close()
281 map->handle, in drm_vm_shm_close()
282 map->offset); in drm_vm_shm_close()
288 mutex_unlock(&dev->struct_mutex); in drm_vm_shm_close()
295 * \return pointer to the page structure.
297 * Determine the page number from the page offset and get it from drm_device_dma::pagelist.
301 struct vm_area_struct *vma = vmf->vma; in drm_vm_dma_fault()
302 struct drm_file *priv = vma->vm_file->private_data; in drm_vm_dma_fault()
303 struct drm_device *dev = priv->minor->dev; in drm_vm_dma_fault()
304 struct drm_device_dma *dma = dev->dma; in drm_vm_dma_fault()
305 unsigned long offset; in drm_vm_dma_fault() local
307 struct page *page; in drm_vm_dma_fault() local
311 if (!dma->pagelist) in drm_vm_dma_fault()
314 offset = vmf->address - vma->vm_start; in drm_vm_dma_fault()
316 page_nr = offset >> PAGE_SHIFT; /* page_nr could just be vmf->pgoff */ in drm_vm_dma_fault()
317 page = virt_to_page((void *)dma->pagelist[page_nr]); in drm_vm_dma_fault()
319 get_page(page); in drm_vm_dma_fault()
320 vmf->page = page; in drm_vm_dma_fault()
322 DRM_DEBUG("dma_fault 0x%lx (page %lu)\n", offset, page_nr); in drm_vm_dma_fault()
327 * \c fault method for scatter-gather virtual memory.
330 * \return pointer to the page structure.
332 * Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
336 struct vm_area_struct *vma = vmf->vma; in drm_vm_sg_fault()
337 struct drm_local_map *map = vma->vm_private_data; in drm_vm_sg_fault()
338 struct drm_file *priv = vma->vm_file->private_data; in drm_vm_sg_fault()
339 struct drm_device *dev = priv->minor->dev; in drm_vm_sg_fault()
340 struct drm_sg_mem *entry = dev->sg; in drm_vm_sg_fault()
341 unsigned long offset; in drm_vm_sg_fault() local
344 struct page *page; in drm_vm_sg_fault() local
348 if (!entry->pagelist) in drm_vm_sg_fault()
351 offset = vmf->address - vma->vm_start; in drm_vm_sg_fault()
352 map_offset = map->offset - (unsigned long)dev->sg->virtual; in drm_vm_sg_fault()
353 page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT); in drm_vm_sg_fault()
354 page = entry->pagelist[page_offset]; in drm_vm_sg_fault()
355 get_page(page); in drm_vm_sg_fault()
356 vmf->page = page; in drm_vm_sg_fault()
382 /** Scatter-gather virtual memory operations */
395 vma->vm_start, vma->vm_end - vma->vm_start); in drm_vm_open_locked()
399 vma_entry->vma = vma; in drm_vm_open_locked()
400 vma_entry->pid = current->pid; in drm_vm_open_locked()
401 list_add(&vma_entry->head, &dev->vmalist); in drm_vm_open_locked()
407 struct drm_file *priv = vma->vm_file->private_data; in drm_vm_open()
408 struct drm_device *dev = priv->minor->dev; in drm_vm_open()
410 mutex_lock(&dev->struct_mutex); in drm_vm_open()
412 mutex_unlock(&dev->struct_mutex); in drm_vm_open()
421 vma->vm_start, vma->vm_end - vma->vm_start); in drm_vm_close_locked()
423 list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { in drm_vm_close_locked()
424 if (pt->vma == vma) { in drm_vm_close_locked()
425 list_del(&pt->head); in drm_vm_close_locked()
442 struct drm_file *priv = vma->vm_file->private_data; in drm_vm_close()
443 struct drm_device *dev = priv->minor->dev; in drm_vm_close()
445 mutex_lock(&dev->struct_mutex); in drm_vm_close()
447 mutex_unlock(&dev->struct_mutex); in drm_vm_close()
462 struct drm_file *priv = filp->private_data; in drm_mmap_dma()
465 unsigned long length = vma->vm_end - vma->vm_start; in drm_mmap_dma()
467 dev = priv->minor->dev; in drm_mmap_dma()
468 dma = dev->dma; in drm_mmap_dma()
469 DRM_DEBUG("start = 0x%lx, end = 0x%lx, page offset = 0x%lx\n", in drm_mmap_dma()
470 vma->vm_start, vma->vm_end, vma->vm_pgoff); in drm_mmap_dma()
472 /* Length must match exact page count */ in drm_mmap_dma()
473 if (!dma || (length >> PAGE_SHIFT) != dma->page_count) { in drm_mmap_dma()
474 return -EINVAL; in drm_mmap_dma()
478 (dma->flags & _DRM_DMA_USE_PCI_RO)) { in drm_mmap_dma()
479 vma->vm_flags &= ~(VM_WRITE | VM_MAYWRITE); in drm_mmap_dma()
481 pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; in drm_mmap_dma()
486 vma->vm_page_prot = in drm_mmap_dma()
489 (__pte(pgprot_val(vma->vm_page_prot))))); in drm_mmap_dma()
493 vma->vm_ops = &drm_vm_dma_ops; in drm_mmap_dma()
495 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; in drm_mmap_dma()
504 return dev->hose->dense_mem_base; in drm_core_get_reg_ofs()
517 * If the virtual memory area has no offset associated with it then it's a DMA
525 struct drm_file *priv = filp->private_data; in drm_mmap_locked()
526 struct drm_device *dev = priv->minor->dev; in drm_mmap_locked()
528 resource_size_t offset = 0; in drm_mmap_locked() local
531 DRM_DEBUG("start = 0x%lx, end = 0x%lx, page offset = 0x%lx\n", in drm_mmap_locked()
532 vma->vm_start, vma->vm_end, vma->vm_pgoff); in drm_mmap_locked()
534 if (!priv->authenticated) in drm_mmap_locked()
535 return -EACCES; in drm_mmap_locked()
539 * --BenH. in drm_mmap_locked()
541 if (!vma->vm_pgoff in drm_mmap_locked()
543 && (!dev->agp in drm_mmap_locked()
544 || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE) in drm_mmap_locked()
549 if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash)) { in drm_mmap_locked()
551 return -EINVAL; in drm_mmap_locked()
554 map = drm_hash_entry(hash, struct drm_map_list, hash)->map; in drm_mmap_locked()
555 if (!map || ((map->flags & _DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN))) in drm_mmap_locked()
556 return -EPERM; in drm_mmap_locked()
559 if (map->size < vma->vm_end - vma->vm_start) in drm_mmap_locked()
560 return -EINVAL; in drm_mmap_locked()
562 if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) { in drm_mmap_locked()
563 vma->vm_flags &= ~(VM_WRITE | VM_MAYWRITE); in drm_mmap_locked()
565 pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; in drm_mmap_locked()
570 vma->vm_page_prot = in drm_mmap_locked()
573 (__pte(pgprot_val(vma->vm_page_prot))))); in drm_mmap_locked()
577 switch (map->type) { in drm_mmap_locked()
580 if (dev->agp && dev->agp->cant_use_aperture) { in drm_mmap_locked()
587 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); in drm_mmap_locked()
589 vma->vm_ops = &drm_vm_ops; in drm_mmap_locked()
596 offset = drm_core_get_reg_ofs(dev); in drm_mmap_locked()
597 vma->vm_page_prot = drm_io_prot(map, vma); in drm_mmap_locked()
598 if (io_remap_pfn_range(vma, vma->vm_start, in drm_mmap_locked()
599 (map->offset + offset) >> PAGE_SHIFT, in drm_mmap_locked()
600 vma->vm_end - vma->vm_start, in drm_mmap_locked()
601 vma->vm_page_prot)) in drm_mmap_locked()
602 return -EAGAIN; in drm_mmap_locked()
604 " offset = 0x%llx\n", in drm_mmap_locked()
605 map->type, in drm_mmap_locked()
606 vma->vm_start, vma->vm_end, (unsigned long long)(map->offset + offset)); in drm_mmap_locked()
608 vma->vm_ops = &drm_vm_ops; in drm_mmap_locked()
613 if (remap_pfn_range(vma, vma->vm_start, in drm_mmap_locked()
614 page_to_pfn(virt_to_page(map->handle)), in drm_mmap_locked()
615 vma->vm_end - vma->vm_start, vma->vm_page_prot)) in drm_mmap_locked()
616 return -EAGAIN; in drm_mmap_locked()
617 vma->vm_page_prot = drm_dma_prot(map->type, vma); in drm_mmap_locked()
620 vma->vm_ops = &drm_vm_shm_ops; in drm_mmap_locked()
621 vma->vm_private_data = (void *)map; in drm_mmap_locked()
624 vma->vm_ops = &drm_vm_sg_ops; in drm_mmap_locked()
625 vma->vm_private_data = (void *)map; in drm_mmap_locked()
626 vma->vm_page_prot = drm_dma_prot(map->type, vma); in drm_mmap_locked()
629 return -EINVAL; /* This should never happen. */ in drm_mmap_locked()
631 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; in drm_mmap_locked()
639 struct drm_file *priv = filp->private_data; in drm_legacy_mmap()
640 struct drm_device *dev = priv->minor->dev; in drm_legacy_mmap()
644 return -ENODEV; in drm_legacy_mmap()
646 mutex_lock(&dev->struct_mutex); in drm_legacy_mmap()
648 mutex_unlock(&dev->struct_mutex); in drm_legacy_mmap()
660 list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { in drm_legacy_vma_flush()
661 list_del(&vma->head); in drm_legacy_vma_flush()