Re: [PATCH 10/24] drm/amd/display: Rework CRTC color management

2019-06-07 Thread Michel Dänzer
On 2019-06-06 10:54 p.m., Bhawanpreet Lakha wrote: > From: Nicholas Kazlauskas > > [Why] > To prepare for the upcoming DRM plane color management properties > we need to correct a lot of wrong behavior and assumptions made for > CRTC color management. > > The documentation added by this commit

Re: [PATCH v2 hmm 07/11] mm/hmm: Use lockdep instead of comments

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > So we can check locking at runtime. > > Signed-off-by: Jason Gunthorpe > Reviewed-by: Jérôme Glisse > --- > v2 > - Fix missing & in lockdeps (Jason) > --- > mm/hmm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2

Re: [PATCH v2 hmm 09/11] mm/hmm: Poison hmm_range during unregister

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > Trying to misuse a range outside its lifetime is a kernel bug. Use WARN_ON > and poison bytes to detect this condition. > > Signed-off-by: Jason Gunthorpe > Reviewed-by: Jérôme Glisse > --- > v2 > - Keep range start/end

Re: [PATCH v2 hmm 10/11] mm/hmm: Do not use list*_rcu() for hmm->ranges

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > This list is always read and written while holding hmm->lock so there is > no need for the confusing _rcu annotations. > > Signed-off-by: Jason Gunthorpe > Reviewed-by: Jérôme Glisse > --- > mm/hmm.c | 4 ++-- > 1 file

Re: [PATCH v2 hmm 04/11] mm/hmm: Simplify hmm_get_or_create and make it reliable

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > As coded this function can false-fail in various racy situations. Make it > reliable by running only under the write side of the mmap_sem and avoiding > the false-failing compare/exchange pattern. > > Also make the locking

Re: [PATCH v2 hmm 06/11] mm/hmm: Hold on to the mmget for the lifetime of the range

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > Range functions like hmm_range_snapshot() and hmm_range_fault() call > find_vma, which requires hodling the mmget() and the mmap_sem for the mm. > > Make this simpler for the callers by holding the mmget() inside the range >

Re: [PATCH v2 hmm 05/11] mm/hmm: Remove duplicate condition test before wait_event_timeout

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > The wait_event_timeout macro already tests the condition as its first > action, so there is no reason to open code another version of this, all > that does is skip the might_sleep() debugging in common cases, which is > not

Re: [PATCH v2 hmm 11/11] mm/hmm: Remove confusing comment and logic from hmm_release

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > hmm_release() is called exactly once per hmm. ops->release() cannot > accidentally trigger any action that would recurse back onto > hmm->mirrors_sem. > > This fixes a use after-free race of the form: > >CPU0

Re: [PATCH v2 hmm 08/11] mm/hmm: Remove racy protection against double-unregistration

2019-06-07 Thread John Hubbard
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > No other register/unregister kernel API attempts to provide this kind of > protection as it is inherently racy, so just drop it. > > Callers should provide their own protection, it appears nouveau already > does, but just in

Re: [PATCH 10/24] drm/amd/display: Rework CRTC color management

2019-06-07 Thread Kazlauskas, Nicholas
On 6/7/19 3:58 AM, Michel Dänzer wrote: > On 2019-06-06 10:54 p.m., Bhawanpreet Lakha wrote: >> From: Nicholas Kazlauskas >> >> [Why] >> To prepare for the upcoming DRM plane color management properties >> we need to correct a lot of wrong behavior and assumptions made for >> CRTC color

RE: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

2019-06-07 Thread Liu, Monk
Oh I know why, My fix is to modify kobj_type's member "release" while upstream is doing the different way, but both of the way shall fix the issue Thanks /Monk From: Deucher, Alexander Sent: Thursday, June 6, 2019 11:16 PM To: Koenig, Christian ; Liu, Monk ; amd-gfx@lists.freedesktop.org

Re: [PATCH v2 hmm 08/11] mm/hmm: Remove racy protection against double-unregistration

2019-06-07 Thread Jason Gunthorpe
On Thu, Jun 06, 2019 at 08:29:10PM -0700, John Hubbard wrote: > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > No other register/unregister kernel API attempts to provide this kind of > > protection as it is inherently racy, so just drop it. > > > > Callers should

Re: [PATCH] drm/amd/display: Use current connector state if NULL when checking bpc

2019-06-07 Thread Harry Wentland
On 2019-06-05 12:33 p.m., Nicholas Kazlauskas wrote: > [Why] > The old logic for checking which output depth to use relied on using > the current connector state rather than the new proposed state. This > was a problem when performing atomic commits since we weren't verifying > it against the

Re: [PATCH v2 hmm 03/11] mm/hmm: Hold a mmgrab from hmm to mm

2019-06-07 Thread Jason Gunthorpe
On Thu, Jun 06, 2019 at 07:44:58PM -0700, John Hubbard wrote: > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > So long a a struct hmm pointer exists, so should the struct mm it is > > linked too. Hold the mmgrab() as soon as a hmm is created, and mmdrop() it > >

Re: [PATCH v2 hmm 05/11] mm/hmm: Remove duplicate condition test before wait_event_timeout

2019-06-07 Thread Jason Gunthorpe
On Thu, Jun 06, 2019 at 08:06:52PM -0700, John Hubbard wrote: > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > The wait_event_timeout macro already tests the condition as its first > > action, so there is no reason to open code another version of this, all > > that

[PATCH v3 hmm 05/11] mm/hmm: Remove duplicate condition test before wait_event_timeout

2019-06-07 Thread Jason Gunthorpe
The wait_event_timeout macro already tests the condition as its first action, so there is no reason to open code another version of this, all that does is skip the might_sleep() debugging in common cases, which is not helpful. Further, based on prior patches, we can now simplify the required

Re: [PATCH v2 hmm 01/11] mm/hmm: fix use after free with struct hmm in the mmu notifiers

2019-06-07 Thread Jason Gunthorpe
On Fri, Jun 07, 2019 at 09:34:32AM -0300, Jason Gunthorpe wrote: > CH also pointed out a more elegant solution, which is to get the write > side of the mmap_sem during hmm_mirror_unregister - no notifier > callback can be running in this case. Then we delete the kref, srcu > and so forth. Oops,

Re: [PATCH v2 hmm 01/11] mm/hmm: fix use after free with struct hmm in the mmu notifiers

2019-06-07 Thread Jason Gunthorpe
On Thu, Jun 06, 2019 at 07:29:08PM -0700, John Hubbard wrote: > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > ... > > diff --git a/mm/hmm.c b/mm/hmm.c > > index 8e7403f081f44a..547002f56a163d 100644 > > +++ b/mm/hmm.c > ... > > @@ -125,7 +130,7 @@ static void

Re: [PATCH v2 hmm 11/11] mm/hmm: Remove confusing comment and logic from hmm_release

2019-06-07 Thread Jason Gunthorpe
On Thu, Jun 06, 2019 at 08:47:28PM -0700, John Hubbard wrote: > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > hmm_release() is called exactly once per hmm. ops->release() cannot > > accidentally trigger any action that would recurse back onto > > hmm->mirrors_sem.

Re: [PATCH 10/24] drm/amd/display: Rework CRTC color management

2019-06-07 Thread Michel Dänzer
On 2019-06-07 2:26 p.m., Kazlauskas, Nicholas wrote: > On 6/7/19 3:58 AM, Michel Dänzer wrote: >> On 2019-06-06 10:54 p.m., Bhawanpreet Lakha wrote: >>> From: Nicholas Kazlauskas >>> >>> [Why] >>> To prepare for the upcoming DRM plane color management properties >>> we need to correct a lot of

Re: [PATCH v2 hmm 09/11] mm/hmm: Poison hmm_range during unregister

2019-06-07 Thread Jason Gunthorpe
On Thu, Jun 06, 2019 at 08:37:42PM -0700, John Hubbard wrote: > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > Trying to misuse a range outside its lifetime is a kernel bug. Use WARN_ON > > and poison bytes to detect this condition. > > > > Signed-off-by: Jason

Re: [PATCH] drm/amd/display: Enable fast plane updates when state->allow_modeset = true

2019-06-07 Thread Francis, David
Patch is Reviewed-by: David Francis From: amd-gfx on behalf of Nicholas Kazlauskas Sent: June 7, 2019 11:16:55 AM To: amd-gfx@lists.freedesktop.org Cc: Francis, David; Wentland, Harry; Kazlauskas, Nicholas Subject: [PATCH] drm/amd/display: Enable fast plane

Re: [PATCH 10/24] drm/amd/display: Rework CRTC color management

2019-06-07 Thread Kazlauskas, Nicholas
On 6/7/19 11:51 AM, Michel Dänzer wrote: > On 2019-06-07 2:26 p.m., Kazlauskas, Nicholas wrote: >> On 6/7/19 3:58 AM, Michel Dänzer wrote: >>> On 2019-06-06 10:54 p.m., Bhawanpreet Lakha wrote: From: Nicholas Kazlauskas [Why] To prepare for the upcoming DRM plane color

[PATCH] drm/amdgpu: Add GDS clearing workaround in later init for gfx9

2019-06-07 Thread Zhu, James
Since Hardware bug, GDS exist ECC error after cold boot up, adding GDS clearing workaround in later init for gfx9. Signed-off-by: James Zhu --- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 48 +++ 1 file changed, 48 insertions(+) diff --git

[PATCH] drm/amd/display: Enable fast plane updates when state->allow_modeset = true

2019-06-07 Thread Nicholas Kazlauskas
[Why] Whenever the a modeset is allowed (but not neccessarily required) we currently recreate all the planes in the state. Most IGT tests and legacy IOCTLs create atomic commits with this flag set, so the pipes are often unnecessarily reprogrammed. Poor performance and stuttering can occur when

Re: [PATCH] drm/amdgpu: Add GDS clearing workaround in later init for gfx9

2019-06-07 Thread James Zhu
On 2019-06-07 3:12 p.m., Zhu, James wrote: > On 2019-06-07 2:16 p.m., Alex Deucher wrote: >> On Fri, Jun 7, 2019 at 12:38 PM Zhu, James wrote: >>> Since Hardware bug, GDS exist ECC error after cold boot up, >>> adding GDS clearing workaround in later init for gfx9. >>> >>> Signed-off-by: James

Re: [PATCH] drm/amdgpu: Add GDS clearing workaround in later init for gfx9

2019-06-07 Thread Alex Deucher
On Fri, Jun 7, 2019 at 12:38 PM Zhu, James wrote: > > Since Hardware bug, GDS exist ECC error after cold boot up, > adding GDS clearing workaround in later init for gfx9. > > Signed-off-by: James Zhu > --- > drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 48 > +++ > 1

Re: [PATCH v2 hmm 02/11] mm/hmm: Use hmm_mirror not mm as an argument for hmm_range_register

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe Ralph observes that hmm_range_register() can only be called by a driver while a mirror is registered. Make this clear in the API by passing in the mirror structure as a parameter. This also simplifies understanding the lifetime

Re: [PATCH v2 hmm 03/11] mm/hmm: Hold a mmgrab from hmm to mm

2019-06-07 Thread Jason Gunthorpe
On Fri, Jun 07, 2019 at 11:41:20AM -0700, Ralph Campbell wrote: > > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > So long a a struct hmm pointer exists, so should the struct mm it is > > s/a a/as a/ Got it, thanks Jason

Re: [PATCH v2 hmm 03/11] mm/hmm: Hold a mmgrab from hmm to mm

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe So long a a struct hmm pointer exists, so should the struct mm it is s/a a/as a/ linked too. Hold the mmgrab() as soon as a hmm is created, and mmdrop() it once the hmm refcount goes to zero. Since mmdrop() (ie a 0 kref on

Re: [PATCH] drm/amdgpu: Add GDS clearing workaround in later init for gfx9

2019-06-07 Thread Shamis, Leonid
James, Do you set GDS_VMID0_BASE to 0?.. I don't see it in your patch. Regards, Leonid On 2019-06-07, 15:42, "Zhu, James" wrote: On 2019-06-07 3:12 p.m., Zhu, James wrote: > On 2019-06-07 2:16 p.m., Alex Deucher wrote: >> On Fri, Jun 7, 2019 at 12:38 PM Zhu, James wrote:

[PATCH v2 12/11] mm/hmm: Fix error flows in hmm_invalidate_range_start

2019-06-07 Thread Jason Gunthorpe
If the trylock on the hmm->mirrors_sem fails the function will return without decrementing the notifiers that were previously incremented. Since the caller will not call invalidate_range_end() on EAGAIN this will result in notifiers becoming permanently incremented and deadlock. If the

Re: [PATCH v2 hmm 01/11] mm/hmm: fix use after free with struct hmm in the mmu notifiers

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe mmu_notifier_unregister_no_release() is not a fence and the mmu_notifier system will continue to reference hmm->mn until the srcu grace period expires. Resulting in use after free races like this: CPU0

Re: [PATCH v2 hmm 05/11] mm/hmm: Remove duplicate condition test before wait_event_timeout

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe The wait_event_timeout macro already tests the condition as its first action, so there is no reason to open code another version of this, all that does is skip the might_sleep() debugging in common cases, which is not helpful.

Re: [PATCH v2 hmm 04/11] mm/hmm: Simplify hmm_get_or_create and make it reliable

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe As coded this function can false-fail in various racy situations. Make it reliable by running only under the write side of the mmap_sem and avoiding the false-failing compare/exchange pattern. Also make the locking very easy to

Re: [PATCH] drm/amdgpu: Add GDS clearing workaround in later init for gfx9

2019-06-07 Thread James Zhu
On 2019-06-07 2:16 p.m., Alex Deucher wrote: > On Fri, Jun 7, 2019 at 12:38 PM Zhu, James wrote: >> Since Hardware bug, GDS exist ECC error after cold boot up, >> adding GDS clearing workaround in later init for gfx9. >> >> Signed-off-by: James Zhu >> --- >>

Re: [PATCH v2 hmm 05/11] mm/hmm: Remove duplicate condition test before wait_event_timeout

2019-06-07 Thread Ralph Campbell
On 6/7/19 12:13 PM, Jason Gunthorpe wrote: On Fri, Jun 07, 2019 at 12:01:45PM -0700, Ralph Campbell wrote: On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe The wait_event_timeout macro already tests the condition as its first action, so there is no reason to open code

Re: [PATCH v2 hmm 07/11] mm/hmm: Use lockdep instead of comments

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe So we can check locking at runtime. Signed-off-by: Jason Gunthorpe Reviewed-by: Jérôme Glisse Reviewed-by: Ralph Campbell --- v2 - Fix missing & in lockdeps (Jason) --- mm/hmm.c | 4 ++-- 1 file changed, 2

Re: [PATCH v2 hmm 08/11] mm/hmm: Remove racy protection against double-unregistration

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe No other register/unregister kernel API attempts to provide this kind of protection as it is inherently racy, so just drop it. Callers should provide their own protection, it appears nouveau already does, but just in case drop

Re: [PATCH v2 hmm 05/11] mm/hmm: Remove duplicate condition test before wait_event_timeout

2019-06-07 Thread Jason Gunthorpe
On Fri, Jun 07, 2019 at 12:01:45PM -0700, Ralph Campbell wrote: > > On 6/6/19 11:44 AM, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > The wait_event_timeout macro already tests the condition as its first > > action, so there is no reason to open code another version of this, all > >

Re: [PATCH v2 hmm 06/11] mm/hmm: Hold on to the mmget for the lifetime of the range

2019-06-07 Thread Ralph Campbell
On 6/6/19 11:44 AM, Jason Gunthorpe wrote: From: Jason Gunthorpe Range functions like hmm_range_snapshot() and hmm_range_fault() call find_vma, which requires hodling the mmget() and the mmap_sem for the mm. Make this simpler for the callers by holding the mmget() inside the range for the

Re: [PATCH v16 16/16] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:18PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > This patch adds a simple test, that

Re: [PATCH v16 09/16] fs, arm64: untag user pointers in fs/userfaultfd.c

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:11PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > userfaultfd code use provided user

Re: [PATCH v16 08/16] fs, arm64: untag user pointers in copy_mount_options

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:10PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > In copy_mount_options a user address is

Re: [PATCH v16 02/16] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:04PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > copy_from_user (and a few other similar

Re: [PATCH v16 05/16] arm64: untag user pointers passed to memory syscalls

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:07PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > This patch allows tagged pointers to be

Re: [PATCH v16 13/16] media/v4l2-core, arm64: untag user pointers in videobuf_dma_contig_user_get

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:15PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > videobuf_dma_contig_user_get() uses

Re: [PATCH v16 14/16] tee, arm64: untag user pointers in tee_shm_register

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:16PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > >

Re: [PATCH v16 03/16] lib, arm64: untag user pointers in strn*_user

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:05PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > strncpy_from_user and strnlen_user

Re: [PATCH v16 04/16] mm: untag user pointers in do_pages_move

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:06PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > do_pages_move() is used in the

Re: [PATCH v16 07/16] mm, arm64: untag user pointers in get_vaddr_frames

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:09PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > get_vaddr_frames uses provided user

Re: [PATCH v16 06/16] mm, arm64: untag user pointers in mm/gup.c

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:08PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > mm/gup.c provides a kernel interface

Re: [PATCH v16 15/16] vfio/type1, arm64: untag user pointers in vaddr_get_pfn

2019-06-07 Thread Kees Cook
On Mon, Jun 03, 2019 at 06:55:17PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow to > pass tagged user pointers (with the top byte set to something else other > than 0x00) as syscall arguments. > > vaddr_get_pfn() uses provided user