From mboxrd@z Thu Jan 1 00:00:00 1970 From: Inki Dae Subject: RE: [PATCH 2/2 v4] drm/exynos: added userptr feature. Date: Mon, 14 May 2012 15:52:37 +0900 Message-ID: <003001cd319e$263c9230$72b5b690$%dae@samsung.com> References: <1336544259-17222-1-git-send-email-inki.dae@samsung.com> <1336976268-14328-1-git-send-email-inki.dae@samsung.com> <1336976268-14328-3-git-send-email-inki.dae@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AA3A9E730 for ; Sun, 13 May 2012 23:52:48 -0700 (PDT) Received: from epcpsbgm1.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M400023632W7BG0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 14 May 2012 15:52:42 +0900 (KST) Received: from NOINKIDAE02 ([165.213.219.102]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M40006UR33SBV30@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 14 May 2012 15:52:41 +0900 (KST) In-reply-to: Content-language: ko List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: 'KOSAKI Motohiro' Cc: sw0312.kim@samsung.com, dri-devel@lists.freedesktop.org, minchan@kernel.org, kyungmin.park@samsung.com List-Id: dri-devel@lists.freedesktop.org > -----Original Message----- > From: KOSAKI Motohiro [mailto:kosaki.motohiro@gmail.com] > Sent: Monday, May 14, 2012 3:33 PM > To: Inki Dae > Cc: airlied@linux.ie; dri-devel@lists.freedesktop.org; j.glisse@gmail.com; > minchan@kernel.org; kyungmin.park@samsung.com; sw0312.kim@samsung.com; > jy0922.shim@samsung.com > Subject: Re: [PATCH 2/2 v4] drm/exynos: added userptr feature. > = > > + =A0 =A0 =A0 npages =3D buf->size >> PAGE_SHIFT; > = > Why round down? usually we use round up. > = The size was already rounded up by exynos_drm_gem_userptr_ioctl so this is just used to get page count. > = > > + =A0 =A0 =A0 down_read(¤t->mm->mmap_sem); > > + > > + =A0 =A0 =A0 /* > > + =A0 =A0 =A0 =A0* Basically, all the pages from get_user_pages() can n= ot be not > only > > + =A0 =A0 =A0 =A0* migrated by CMA but also swapped out. > > + =A0 =A0 =A0 =A0* > > + =A0 =A0 =A0 =A0* The migration issue. > > + =A0 =A0 =A0 =A0* - Pages reserved by CMA for some device using DMA co= uld be > used by > > + =A0 =A0 =A0 =A0* kernel and if the device driver wants to use those p= ages > > + =A0 =A0 =A0 =A0* while being used by kernel then the pages are copied= into > > + =A0 =A0 =A0 =A0* other ones allocated to migrate them and then finall= y, > > + =A0 =A0 =A0 =A0* the device driver can use the pages for itself. > > + =A0 =A0 =A0 =A0* Thus, migrated, the pages being accessed by DMA coul= d be > changed > > + =A0 =A0 =A0 =A0* to other so this situation may incur that DMA access= es any > pages > > + =A0 =A0 =A0 =A0* it doesn't want. > > + =A0 =A0 =A0 =A0* > > + =A0 =A0 =A0 =A0* But the use of get_user_pages is safe from such magr= ation > issue > > + =A0 =A0 =A0 =A0* because all the pages from get_user_pages CAN NOT be= not only > > + =A0 =A0 =A0 =A0* migrated, but also swapped out. > > + =A0 =A0 =A0 =A0*/ > > + =A0 =A0 =A0 get_npages =3D get_user_pages(current, current->mm, userp= tr, > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 npages, write, 1, buf->pages, NULL); > = > Why force=3D1? It is almostly core-dump specific option. Why don't you > return I know that force indicates whether to force write access even if user mapping is readonly. so we just want to use pages from get_user_pages as read/write permission. > EFAULT when the page has write permission. IOW, Why your Xorg module > don't map memory w/ PROT_WRITE? No, Xorg can map memory w/ PROT_WRITE. Couldn't the Xorg map w/ PROT_WRITE if force =3D 1? plz, let me know if there is my missing point. Thanks, Inki Dae > = > = > > + =A0 =A0 =A0 up_read(¤t->mm->mmap_sem); > > + =A0 =A0 =A0 if (get_npages !=3D npages) > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_ERROR("failed to get user_pages.\n");