Re: [PATCH v4 05/17] drm: add mmap() to drm_gem_object_funcs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  Hi,

> > +               vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
> > +               vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
> > +               vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
> > +       }
> 
> Totally unrelated discussion around HMM lead me to a bit a chase, and
> realizing that we probably want a
> 
>     WARN_ON(!(vma->vm_flags & VM_SPECIAL));
> 
> here, to make sure drivers set at least one of the "this is a special
> vma, don't try to treat it like pagecache/anon memory". Just to be on
> the safe side. Maybe we also want to keep the entire vma->vm_flags
> assignment in the common code, but at least the WARN_ON would be a
> good check I think. Maybe also check for VM_DONTEXPAND while at it

Hmm.  VM_SPECIAL is this:

  #define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP | VM_MIXEDMAP)

Requiring VM_DONTEXPAND makes sense for sure.  Dunno about the other
ones.  For drm_gem_vram_helper VM_IO + VM_PFNMAP are needed.

But we also have drm_gem_shmem_helper which backs objects with normal
pages.  In fact drm_gem_shmem_mmap does this:

	/* VM_PFNMAP was set by drm_gem_mmap() */
	vma->vm_flags &= ~VM_PFNMAP;
	vma->vm_flags |= VM_MIXEDMAP;

include/linux/mm.h isn't very helpful in explaining how VM_MIXEDMAP
should be used, only saying can be both "struct page" and pfnmap, so I'm
not sure why VM_MIXEDMAP is set here, it should always be "struct page"
for shmem, no?

cheers,
  Gerd

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux