Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-12 Thread Andrey Grodzovsky
Ping Andrey On 2/10/21 5:01 PM, Andrey Grodzovsky wrote: On 2/9/21 10:40 AM, Christian König wrote: Am 09.02.21 um 15:30 schrieb Andrey Grodzovsky: [SNIP] Question - Why can't we just set those PTEs to point to system memory (another RO dummy page) filled with 1s ? Then writes are not d

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-10 Thread Andrey Grodzovsky
On 2/9/21 10:40 AM, Christian König wrote: Am 09.02.21 um 15:30 schrieb Andrey Grodzovsky: [SNIP] Question - Why can't we just set those PTEs to point to system memory (another RO dummy page) filled with 1s ? Then writes are not discarded. E.g. the 1s would change to something else. Chris

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-09 Thread Christian König
Am 09.02.21 um 15:30 schrieb Andrey Grodzovsky: [SNIP] Question - Why can't we just set those PTEs to point to system memory (another RO dummy page) filled with 1s ? Then writes are not discarded. E.g. the 1s would change to something else. Christian. I see but, what about marking the

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-09 Thread Andrey Grodzovsky
On 2/9/21 2:58 AM, Christian König wrote: Am 08.02.21 um 23:15 schrieb Andrey Grodzovsky: On 2/8/21 11:23 AM, Daniel Vetter wrote: On Mon, Feb 8, 2021 at 3:00 PM Christian König wrote: Am 08.02.21 um 11:11 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 11:03:15AM +0100, Christian König wr

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-09 Thread Daniel Vetter
On Tue, Feb 09, 2021 at 09:27:03AM +0100, Christian König wrote: > > > Am 08.02.21 um 23:09 schrieb Andrey Grodzovsky: > > > > > > On 2/8/21 4:37 AM, Christian König wrote: > > > Am 07.02.21 um 22:50 schrieb Daniel Vetter: > > > > [SNIP] > > > > > Clarification - as far as I know there are no p

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-09 Thread Christian König
Am 08.02.21 um 23:09 schrieb Andrey Grodzovsky: On 2/8/21 4:37 AM, Christian König wrote: Am 07.02.21 um 22:50 schrieb Daniel Vetter: [SNIP] Clarification - as far as I know there are no page fault handlers for kernel mappings. And we are talking about kernel mappings here, right ?  If th

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-09 Thread Christian König
Am 08.02.21 um 23:15 schrieb Andrey Grodzovsky: On 2/8/21 11:23 AM, Daniel Vetter wrote: On Mon, Feb 8, 2021 at 3:00 PM Christian König wrote: Am 08.02.21 um 11:11 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 11:03:15AM +0100, Christian König wrote: Am 08.02.21 um 10:48 schrieb Daniel Ve

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Andrey Grodzovsky
On 2/8/21 11:23 AM, Daniel Vetter wrote: On Mon, Feb 8, 2021 at 3:00 PM Christian König wrote: Am 08.02.21 um 11:11 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 11:03:15AM +0100, Christian König wrote: Am 08.02.21 um 10:48 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 10:37:19AM +0100, C

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Andrey Grodzovsky
On 2/8/21 4:37 AM, Christian König wrote: Am 07.02.21 um 22:50 schrieb Daniel Vetter: [SNIP] Clarification - as far as I know there are no page fault handlers for kernel mappings. And we are talking about kernel mappings here, right ?  If there were I could solve all those issues the same as I

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Daniel Vetter
On Mon, Feb 8, 2021 at 3:00 PM Christian König wrote: > > Am 08.02.21 um 11:11 schrieb Daniel Vetter: > > On Mon, Feb 08, 2021 at 11:03:15AM +0100, Christian König wrote: > >> Am 08.02.21 um 10:48 schrieb Daniel Vetter: > >>> On Mon, Feb 08, 2021 at 10:37:19AM +0100, Christian König wrote: >

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Christian König
Am 08.02.21 um 11:11 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 11:03:15AM +0100, Christian König wrote: Am 08.02.21 um 10:48 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 10:37:19AM +0100, Christian König wrote: Am 07.02.21 um 22:50 schrieb Daniel Vetter: [SNIP] Clarification - as far

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Daniel Vetter
On Mon, Feb 08, 2021 at 11:03:15AM +0100, Christian König wrote: > Am 08.02.21 um 10:48 schrieb Daniel Vetter: > > On Mon, Feb 08, 2021 at 10:37:19AM +0100, Christian König wrote: > > > Am 07.02.21 um 22:50 schrieb Daniel Vetter: > > > > [SNIP] > > > > > Clarification - as far as I know there are n

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Christian König
Am 08.02.21 um 10:48 schrieb Daniel Vetter: On Mon, Feb 08, 2021 at 10:37:19AM +0100, Christian König wrote: Am 07.02.21 um 22:50 schrieb Daniel Vetter: [SNIP] Clarification - as far as I know there are no page fault handlers for kernel mappings. And we are talking about kernel mappings here,

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Daniel Vetter
On Mon, Feb 08, 2021 at 10:37:19AM +0100, Christian König wrote: > Am 07.02.21 um 22:50 schrieb Daniel Vetter: > > [SNIP] > > > Clarification - as far as I know there are no page fault handlers for > > > kernel > > > mappings. And we are talking about kernel mappings here, right ? If > > > there

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-08 Thread Christian König
Am 07.02.21 um 22:50 schrieb Daniel Vetter: [SNIP] Clarification - as far as I know there are no page fault handlers for kernel mappings. And we are talking about kernel mappings here, right ? If there were I could solve all those issues the same as I do for user mappings, by invalidating all e

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-07 Thread Daniel Vetter
On Sun, Feb 7, 2021 at 10:28 PM Andrey Grodzovsky wrote: > > > > On 2/5/21 5:10 PM, Daniel Vetter wrote: > > On Fri, Feb 5, 2021 at 5:22 PM Andrey Grodzovsky > > wrote: > >> > >> Daniel, ping. Also, please refer to the other thread with Bjorn from > >> pci-dev > >> on the same topic I added you

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-07 Thread Andrey Grodzovsky
On 2/5/21 5:10 PM, Daniel Vetter wrote: On Fri, Feb 5, 2021 at 5:22 PM Andrey Grodzovsky wrote: Daniel, ping. Also, please refer to the other thread with Bjorn from pci-dev on the same topic I added you to. Summarizing my take over there for here plus maybe some more clarification. There's

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-06 Thread Daniel Vetter
On Sat, Feb 6, 2021 at 12:09 AM Andrey Grodzovsky wrote: > > > > On 2/5/21 5:10 PM, Daniel Vetter wrote: > > On Fri, Feb 5, 2021 at 5:22 PM Andrey Grodzovsky > > wrote: > >> > >> Daniel, ping. Also, please refer to the other thread with Bjorn from > >> pci-dev > >> on the same topic I added you

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-05 Thread Andrey Grodzovsky
On 2/5/21 5:10 PM, Daniel Vetter wrote: On Fri, Feb 5, 2021 at 5:22 PM Andrey Grodzovsky wrote: Daniel, ping. Also, please refer to the other thread with Bjorn from pci-dev on the same topic I added you to. Summarizing my take over there for here plus maybe some more clarification. There's

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-05 Thread Daniel Vetter
On Fri, Feb 5, 2021 at 5:22 PM Andrey Grodzovsky wrote: > > Daniel, ping. Also, please refer to the other thread with Bjorn from pci-dev > on the same topic I added you to. Summarizing my take over there for here plus maybe some more clarification. There's two problems: - You must guarantee that

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-02-05 Thread Andrey Grodzovsky
Daniel, ping. Also, please refer to the other thread with Bjorn from pci-dev on the same topic I added you to. Andrey On 1/29/21 2:25 PM, Christian König wrote: Am 29.01.21 um 18:35 schrieb Andrey Grodzovsky: On 1/29/21 10:16 AM, Christian König wrote: Am 28.01.21 um 18:23 schrieb Andrey Gro

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-29 Thread Christian König
Am 29.01.21 um 18:35 schrieb Andrey Grodzovsky: On 1/29/21 10:16 AM, Christian König wrote: Am 28.01.21 um 18:23 schrieb Andrey Grodzovsky: On 1/19/21 1:59 PM, Christian König wrote: Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: [SNIP] So say wri

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-29 Thread Andrey Grodzovsky
On 1/29/21 10:16 AM, Christian König wrote: Am 28.01.21 um 18:23 schrieb Andrey Grodzovsky: On 1/19/21 1:59 PM, Christian König wrote: Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: [SNIP] So say writing in a loop to some harmless scratch register

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-29 Thread Christian König
Am 28.01.21 um 18:23 schrieb Andrey Grodzovsky: On 1/19/21 1:59 PM, Christian König wrote: Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: [SNIP] So say writing in a loop to some harmless scratch register for many times both for plugged and unplugge

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-28 Thread Andrey Grodzovsky
On 1/19/21 1:59 PM, Christian König wrote: Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: On Tue, Jan 19, 2021 at 4:35 PM Andrey Grodzovsky wrote: There is really no other way according to this article https://nam11.safelinks.protection.outlook.com/

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-20 Thread Andrey Grodzovsky
On 1/19/21 2:16 PM, Andrey Grodzovsky wrote: On 1/19/21 1:59 PM, Christian König wrote: Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: On Tue, Jan 19, 2021 at 4:35 PM Andrey Grodzovsky wrote: There is really no other way according to this article

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Andrey Grodzovsky
On 1/19/21 1:59 PM, Christian König wrote: Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: On Tue, Jan 19, 2021 at 4:35 PM Andrey Grodzovsky wrote: There is really no other way according to this article https://nam11.safelinks.protection.outlook.com/

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Christian König
Am 19.01.21 um 19:22 schrieb Andrey Grodzovsky: On 1/19/21 1:05 PM, Daniel Vetter wrote: On Tue, Jan 19, 2021 at 4:35 PM Andrey Grodzovsky wrote: There is really no other way according to this article https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flwn.net%2FArticles%2F76788

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Andrey Grodzovsky
On 1/19/21 1:05 PM, Daniel Vetter wrote: On Tue, Jan 19, 2021 at 4:35 PM Andrey Grodzovsky wrote: There is really no other way according to this article https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flwn.net%2FArticles%2F767885%2F&data=04%7C01%7CAndrey.Grodzovsky%40amd.com%7

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Daniel Vetter
On Tue, Jan 19, 2021 at 4:35 PM Andrey Grodzovsky wrote: > > There is really no other way according to this article > https://lwn.net/Articles/767885/ > > "A perfect solution seems nearly impossible though; we cannot acquire a mutex > on > the user > to prevent them from yanking a device and we c

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Christian König
The is also the possibility to have the drm_dev_enter/exit much more high level. E.g. we should it have anyway on every IOCTL and what remains are work items, scheduler threads and interrupts. Christian. Am 19.01.21 um 16:35 schrieb Andrey Grodzovsky: There is really no other way according t

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Andrey Grodzovsky
There is really no other way according to this article https://lwn.net/Articles/767885/ "A perfect solution seems nearly impossible though; we cannot acquire a mutex on the user to prevent them from yanking a device and we cannot check for a presence change after every device access for perfo

Re: [PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-19 Thread Christian König
Am 18.01.21 um 22:01 schrieb Andrey Grodzovsky: This should prevent writing to memory or IO ranges possibly already allocated for other uses after our device is removed. Wow, that adds quite some overhead to every register access. I'm not sure we can do this. Christian. Signed-off-by: And

[PATCH v4 11/14] drm/amdgpu: Guard against write accesses after device removal

2021-01-18 Thread Andrey Grodzovsky
This should prevent writing to memory or IO ranges possibly already allocated for other uses after our device is removed. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 57 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c| 9 drivers/g