All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
@ 2019-06-05  6:44 Monk Liu
       [not found] ` <1559717076-25471-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Monk Liu @ 2019-06-05  6:44 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Monk Liu

need to clear bo glob and mem glob during their release
otherwise their member value would be wrongly used in the
next glob init stage and lead to wild pointer access problems:

1) kobj.state_initialized is 1
2) ttm_bo_glob.bo_count isn't cleared and referenced via it
   on member "swap_lru" would hit out of bound array accessing
   bug

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
 drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c7de667..6434eac 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
 		container_of(kobj, struct ttm_bo_global, kobj);
 
 	__free_page(glob->dummy_read_page);
+
+	memset(glob, 0, sizeof(*glob));
 }
 
 static void ttm_bo_global_release(void)
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 8617958..7128bbf 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
 	.store = &ttm_mem_global_store,
 };
 
+void ttm_mem_glob_kobj_release(struct kobject *kobj)
+{
+	struct ttm_mem_global *glob = container_of(kobj, struct ttm_mem_global, kobj);
+
+	memset(glob, 0, sizeof(*glob));
+}
+
 static struct kobj_type ttm_mem_glob_kobj_type = {
 	.sysfs_ops = &ttm_mem_global_ops,
 	.default_attrs = ttm_mem_global_attrs,
+	.release = ttm_mem_glob_kobj_release,
 };
 
 static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found] ` <1559717076-25471-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
@ 2019-06-05  7:29   ` Liu, Monk
       [not found]     ` <MN2PR12MB393308FE408E9E41EF0D615184160-rweVpJHSKTq/67K4VYF1uAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Liu, Monk @ 2019-06-05  7:29 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Koenig, Christian



-----Original Message-----
From: Monk Liu <Monk.Liu@amd.com> 
Sent: Wednesday, June 5, 2019 2:45 PM
To: amd-gfx@lists.freedesktop.org
Cc: Liu, Monk <Monk.Liu@amd.com>
Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:

1) kobj.state_initialized is 1
2) ttm_bo_glob.bo_count isn't cleared and referenced via it
   on member "swap_lru" would hit out of bound array accessing
   bug

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
 drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
 		container_of(kobj, struct ttm_bo_global, kobj);
 
 	__free_page(glob->dummy_read_page);
+
+	memset(glob, 0, sizeof(*glob));
 }
 
 static void ttm_bo_global_release(void) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 8617958..7128bbf 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
 	.store = &ttm_mem_global_store,
 };
 
+void ttm_mem_glob_kobj_release(struct kobject *kobj) {
+	struct ttm_mem_global *glob = container_of(kobj, struct 
+ttm_mem_global, kobj);
+
+	memset(glob, 0, sizeof(*glob));
+}
+
 static struct kobj_type ttm_mem_glob_kobj_type = {
 	.sysfs_ops = &ttm_mem_global_ops,
 	.default_attrs = ttm_mem_global_attrs,
+	.release = ttm_mem_glob_kobj_release,
 };
 
 static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
--
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found]     ` <MN2PR12MB393308FE408E9E41EF0D615184160-rweVpJHSKTq/67K4VYF1uAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2019-06-05 11:10       ` Koenig, Christian
       [not found]         ` <8dbf96e5-056f-b2bb-b0d3-9376b92b0140-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Koenig, Christian @ 2019-06-05 11:10 UTC (permalink / raw)
  To: Liu, Monk, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This should already be fixed by patch "drm/ttm: fix re-init of global 
structures".

Christian.

Am 05.06.19 um 09:29 schrieb Liu, Monk:
>
> -----Original Message-----
> From: Monk Liu <Monk.Liu@amd.com>
> Sent: Wednesday, June 5, 2019 2:45 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Liu, Monk <Monk.Liu@amd.com>
> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
>
> need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:
>
> 1) kobj.state_initialized is 1
> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>     on member "swap_lru" would hit out of bound array accessing
>     bug
>
> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
>   drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
>   2 files changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
>   		container_of(kobj, struct ttm_bo_global, kobj);
>   
>   	__free_page(glob->dummy_read_page);
> +
> +	memset(glob, 0, sizeof(*glob));
>   }
>   
>   static void ttm_bo_global_release(void) diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
> index 8617958..7128bbf 100644
> --- a/drivers/gpu/drm/ttm/ttm_memory.c
> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>   	.store = &ttm_mem_global_store,
>   };
>   
> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
> +	struct ttm_mem_global *glob = container_of(kobj, struct
> +ttm_mem_global, kobj);
> +
> +	memset(glob, 0, sizeof(*glob));
> +}
> +
>   static struct kobj_type ttm_mem_glob_kobj_type = {
>   	.sysfs_ops = &ttm_mem_global_ops,
>   	.default_attrs = ttm_mem_global_attrs,
> +	.release = ttm_mem_glob_kobj_release,
>   };
>   
>   static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
> --
> 2.7.4
>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found]         ` <8dbf96e5-056f-b2bb-b0d3-9376b92b0140-5C7GfCeVMHo@public.gmane.org>
@ 2019-06-05 14:44           ` Liu, Monk
       [not found]             ` <MN2PR12MB39334AC8143DDBC1AA7587E884160-rweVpJHSKTq/67K4VYF1uAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Liu, Monk @ 2019-06-05 14:44 UTC (permalink / raw)
  To: Koenig, Christian, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Strange, I get the latest "drm-next" branch and didn't see the change landed ....

/Monk

-----Original Message-----
From: Koenig, Christian 
Sent: Wednesday, June 5, 2019 7:11 PM
To: Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org
Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

This should already be fixed by patch "drm/ttm: fix re-init of global structures".

Christian.

Am 05.06.19 um 09:29 schrieb Liu, Monk:
>
> -----Original Message-----
> From: Monk Liu <Monk.Liu@amd.com>
> Sent: Wednesday, June 5, 2019 2:45 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Liu, Monk <Monk.Liu@amd.com>
> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload 
> issue
>
> need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:
>
> 1) kobj.state_initialized is 1
> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>     on member "swap_lru" would hit out of bound array accessing
>     bug
>
> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
>   drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
>   2 files changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c 
> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
>   		container_of(kobj, struct ttm_bo_global, kobj);
>   
>   	__free_page(glob->dummy_read_page);
> +
> +	memset(glob, 0, sizeof(*glob));
>   }
>   
>   static void ttm_bo_global_release(void) diff --git 
> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
> index 8617958..7128bbf 100644
> --- a/drivers/gpu/drm/ttm/ttm_memory.c
> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>   	.store = &ttm_mem_global_store,
>   };
>   
> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
> +	struct ttm_mem_global *glob = container_of(kobj, struct 
> +ttm_mem_global, kobj);
> +
> +	memset(glob, 0, sizeof(*glob));
> +}
> +
>   static struct kobj_type ttm_mem_glob_kobj_type = {
>   	.sysfs_ops = &ttm_mem_global_ops,
>   	.default_attrs = ttm_mem_global_attrs,
> +	.release = ttm_mem_glob_kobj_release,
>   };
>   
>   static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
> --
> 2.7.4
>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found]             ` <MN2PR12MB39334AC8143DDBC1AA7587E884160-rweVpJHSKTq/67K4VYF1uAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2019-06-05 18:10               ` Koenig, Christian
       [not found]                 ` <bb88e890-84c4-5405-85c6-59f02d5a7a61-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Koenig, Christian @ 2019-06-05 18:10 UTC (permalink / raw)
  To: Liu, Monk, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Mhm, looks like that somehow got dropped during rebase.

Going to dig up where that actually ended up tomorrow.

Christian.

Am 05.06.19 um 16:44 schrieb Liu, Monk:
> Strange, I get the latest "drm-next" branch and didn't see the change landed ....
>
> /Monk
>
> -----Original Message-----
> From: Koenig, Christian
> Sent: Wednesday, June 5, 2019 7:11 PM
> To: Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org
> Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
>
> This should already be fixed by patch "drm/ttm: fix re-init of global structures".
>
> Christian.
>
> Am 05.06.19 um 09:29 schrieb Liu, Monk:
>> -----Original Message-----
>> From: Monk Liu <Monk.Liu@amd.com>
>> Sent: Wednesday, June 5, 2019 2:45 PM
>> To: amd-gfx@lists.freedesktop.org
>> Cc: Liu, Monk <Monk.Liu@amd.com>
>> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload
>> issue
>>
>> need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:
>>
>> 1) kobj.state_initialized is 1
>> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>>      on member "swap_lru" would hit out of bound array accessing
>>      bug
>>
>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>> ---
>>    drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
>>    drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
>>    2 files changed, 10 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
>> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
>>    		container_of(kobj, struct ttm_bo_global, kobj);
>>    
>>    	__free_page(glob->dummy_read_page);
>> +
>> +	memset(glob, 0, sizeof(*glob));
>>    }
>>    
>>    static void ttm_bo_global_release(void) diff --git
>> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
>> index 8617958..7128bbf 100644
>> --- a/drivers/gpu/drm/ttm/ttm_memory.c
>> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
>> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>>    	.store = &ttm_mem_global_store,
>>    };
>>    
>> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
>> +	struct ttm_mem_global *glob = container_of(kobj, struct
>> +ttm_mem_global, kobj);
>> +
>> +	memset(glob, 0, sizeof(*glob));
>> +}
>> +
>>    static struct kobj_type ttm_mem_glob_kobj_type = {
>>    	.sysfs_ops = &ttm_mem_global_ops,
>>    	.default_attrs = ttm_mem_global_attrs,
>> +	.release = ttm_mem_glob_kobj_release,
>>    };
>>    
>>    static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
>> --
>> 2.7.4
>>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found]                 ` <bb88e890-84c4-5405-85c6-59f02d5a7a61-5C7GfCeVMHo@public.gmane.org>
@ 2019-06-06 14:00                   ` Christian König
       [not found]                     ` <1ef221b9-f29e-cbd2-488a-d5d0b349e45f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2019-06-06 14:00 UTC (permalink / raw)
  To: Koenig, Christian, Liu, Monk,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Alex Deucher

It is part of amd-staging-drm-next and has Alex Signed-of by tag.

So it should definitely be upstream, Alex any idea why that patch isn't 
in drm-next?

Christian.

Am 05.06.19 um 20:10 schrieb Koenig, Christian:
> Mhm, looks like that somehow got dropped during rebase.
>
> Going to dig up where that actually ended up tomorrow.
>
> Christian.
>
> Am 05.06.19 um 16:44 schrieb Liu, Monk:
>> Strange, I get the latest "drm-next" branch and didn't see the change landed ....
>>
>> /Monk
>>
>> -----Original Message-----
>> From: Koenig, Christian
>> Sent: Wednesday, June 5, 2019 7:11 PM
>> To: Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org
>> Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
>>
>> This should already be fixed by patch "drm/ttm: fix re-init of global structures".
>>
>> Christian.
>>
>> Am 05.06.19 um 09:29 schrieb Liu, Monk:
>>> -----Original Message-----
>>> From: Monk Liu <Monk.Liu@amd.com>
>>> Sent: Wednesday, June 5, 2019 2:45 PM
>>> To: amd-gfx@lists.freedesktop.org
>>> Cc: Liu, Monk <Monk.Liu@amd.com>
>>> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload
>>> issue
>>>
>>> need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:
>>>
>>> 1) kobj.state_initialized is 1
>>> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>>>       on member "swap_lru" would hit out of bound array accessing
>>>       bug
>>>
>>> Signed-off-by: Monk Liu <Monk.Liu@amd.com>
>>> ---
>>>     drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
>>>     drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
>>>     2 files changed, 10 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
>>> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>>> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
>>>     		container_of(kobj, struct ttm_bo_global, kobj);
>>>     
>>>     	__free_page(glob->dummy_read_page);
>>> +
>>> +	memset(glob, 0, sizeof(*glob));
>>>     }
>>>     
>>>     static void ttm_bo_global_release(void) diff --git
>>> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
>>> index 8617958..7128bbf 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_memory.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
>>> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>>>     	.store = &ttm_mem_global_store,
>>>     };
>>>     
>>> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
>>> +	struct ttm_mem_global *glob = container_of(kobj, struct
>>> +ttm_mem_global, kobj);
>>> +
>>> +	memset(glob, 0, sizeof(*glob));
>>> +}
>>> +
>>>     static struct kobj_type ttm_mem_glob_kobj_type = {
>>>     	.sysfs_ops = &ttm_mem_global_ops,
>>>     	.default_attrs = ttm_mem_global_attrs,
>>> +	.release = ttm_mem_glob_kobj_release,
>>>     };
>>>     
>>>     static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
>>> --
>>> 2.7.4
>>>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found]                     ` <1ef221b9-f29e-cbd2-488a-d5d0b349e45f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2019-06-06 15:15                       ` Deucher, Alexander
       [not found]                         ` <BN6PR12MB1809F73FCA1AC3CA8B91CD1AF7170-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Deucher, Alexander @ 2019-06-06 15:15 UTC (permalink / raw)
  To: Koenig, Christian, Liu, Monk, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 4318 bytes --]

It's upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bd4264112f93045704731850c5e4d85db981cd85
and in drm-next:
https://cgit.freedesktop.org/drm/drm/commit/?id=bd4264112f93045704731850c5e4d85db981cd85
and in amd-staging-drm-next:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-next&id=bd4264112f93045704731850c5e4d85db981cd85

Where are you seeing it missing?

Alex
________________________________
From: Christian K?nig <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Sent: Thursday, June 6, 2019 10:00 AM
To: Koenig, Christian; Liu, Monk; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Deucher, Alexander
Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

It is part of amd-staging-drm-next and has Alex Signed-of by tag.

So it should definitely be upstream, Alex any idea why that patch isn't
in drm-next?

Christian.

Am 05.06.19 um 20:10 schrieb Koenig, Christian:
> Mhm, looks like that somehow got dropped during rebase.
>
> Going to dig up where that actually ended up tomorrow.
>
> Christian.
>
> Am 05.06.19 um 16:44 schrieb Liu, Monk:
>> Strange, I get the latest "drm-next" branch and didn't see the change landed ....
>>
>> /Monk
>>
>> -----Original Message-----
>> From: Koenig, Christian
>> Sent: Wednesday, June 5, 2019 7:11 PM
>> To: Liu, Monk <Monk.Liu-5C7GfCeVMHo@public.gmane.org>; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
>> Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
>>
>> This should already be fixed by patch "drm/ttm: fix re-init of global structures".
>>
>> Christian.
>>
>> Am 05.06.19 um 09:29 schrieb Liu, Monk:
>>> -----Original Message-----
>>> From: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
>>> Sent: Wednesday, June 5, 2019 2:45 PM
>>> To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
>>> Cc: Liu, Monk <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
>>> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload
>>> issue
>>>
>>> need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:
>>>
>>> 1) kobj.state_initialized is 1
>>> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>>>       on member "swap_lru" would hit out of bound array accessing
>>>       bug
>>>
>>> Signed-off-by: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
>>> ---
>>>     drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
>>>     drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
>>>     2 files changed, 10 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
>>> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>>> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
>>>              container_of(kobj, struct ttm_bo_global, kobj);
>>>
>>>      __free_page(glob->dummy_read_page);
>>> +
>>> +   memset(glob, 0, sizeof(*glob));
>>>     }
>>>
>>>     static void ttm_bo_global_release(void) diff --git
>>> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
>>> index 8617958..7128bbf 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_memory.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
>>> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>>>      .store = &ttm_mem_global_store,
>>>     };
>>>
>>> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
>>> +   struct ttm_mem_global *glob = container_of(kobj, struct
>>> +ttm_mem_global, kobj);
>>> +
>>> +   memset(glob, 0, sizeof(*glob));
>>> +}
>>> +
>>>     static struct kobj_type ttm_mem_glob_kobj_type = {
>>>      .sysfs_ops = &ttm_mem_global_ops,
>>>      .default_attrs = ttm_mem_global_attrs,
>>> +   .release = ttm_mem_glob_kobj_release,
>>>     };
>>>
>>>     static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
>>> --
>>> 2.7.4
>>>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[-- Attachment #1.2: Type: text/html, Size: 8315 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
       [not found]                         ` <BN6PR12MB1809F73FCA1AC3CA8B91CD1AF7170-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2019-06-07 10:13                           ` Liu, Monk
  0 siblings, 0 replies; 8+ messages in thread
From: Liu, Monk @ 2019-06-07 10:13 UTC (permalink / raw)
  To: Deucher, Alexander, Koenig, Christian,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 5290 bytes --]

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 <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>; Liu, Monk <Monk.Liu@amd.com>; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

It's upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bd4264112f93045704731850c5e4d85db981cd85
and in drm-next:
https://cgit.freedesktop.org/drm/drm/commit/?id=bd4264112f93045704731850c5e4d85db981cd85
and in amd-staging-drm-next:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-next&id=bd4264112f93045704731850c5e4d85db981cd85

Where are you seeing it missing?

Alex
________________________________
From: Christian König <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>>
Sent: Thursday, June 6, 2019 10:00 AM
To: Koenig, Christian; Liu, Monk; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>; Deucher, Alexander
Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue

It is part of amd-staging-drm-next and has Alex Signed-of by tag.

So it should definitely be upstream, Alex any idea why that patch isn't
in drm-next?

Christian.

Am 05.06.19 um 20:10 schrieb Koenig, Christian:
> Mhm, looks like that somehow got dropped during rebase.
>
> Going to dig up where that actually ended up tomorrow.
>
> Christian.
>
> Am 05.06.19 um 16:44 schrieb Liu, Monk:
>> Strange, I get the latest "drm-next" branch and didn't see the change landed ....
>>
>> /Monk
>>
>> -----Original Message-----
>> From: Koenig, Christian
>> Sent: Wednesday, June 5, 2019 7:11 PM
>> To: Liu, Monk <Monk.Liu-5C7GfCeVMHo@public.gmane.org<mailto:Monk.Liu-5C7GfCeVMHo@public.gmane.org>>; amd-gfx@lists.freedesktop.org<mailto:amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
>> Subject: Re: FW: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue
>>
>> This should already be fixed by patch "drm/ttm: fix re-init of global structures".
>>
>> Christian.
>>
>> Am 05.06.19 um 09:29 schrieb Liu, Monk:
>>> -----Original Message-----
>>> From: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org<mailto:Monk.Liu-5C7GfCeVMHo@public.gmane.org>>
>>> Sent: Wednesday, June 5, 2019 2:45 PM
>>> To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
>>> Cc: Liu, Monk <Monk.Liu-5C7GfCeVMHo@public.gmane.org<mailto:Monk.Liu-5C7GfCeVMHo@public.gmane.org>>
>>> Subject: [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload
>>> issue
>>>
>>> need to clear bo glob and mem glob during their release otherwise their member value would be wrongly used in the next glob init stage and lead to wild pointer access problems:
>>>
>>> 1) kobj.state_initialized is 1
>>> 2) ttm_bo_glob.bo_count isn't cleared and referenced via it
>>>       on member "swap_lru" would hit out of bound array accessing
>>>       bug
>>>
>>> Signed-off-by: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org<mailto:Monk.Liu-5C7GfCeVMHo@public.gmane.org>>
>>> ---
>>>     drivers/gpu/drm/ttm/ttm_bo.c     | 2 ++
>>>     drivers/gpu/drm/ttm/ttm_memory.c | 8 ++++++++
>>>     2 files changed, 10 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
>>> b/drivers/gpu/drm/ttm/ttm_bo.c index c7de667..6434eac 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>>> @@ -1604,6 +1604,8 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
>>>              container_of(kobj, struct ttm_bo_global, kobj);
>>>
>>>      __free_page(glob->dummy_read_page);
>>> +
>>> +   memset(glob, 0, sizeof(*glob));
>>>     }
>>>
>>>     static void ttm_bo_global_release(void) diff --git
>>> a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
>>> index 8617958..7128bbf 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_memory.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_memory.c
>>> @@ -229,9 +229,17 @@ static const struct sysfs_ops ttm_mem_global_ops = {
>>>      .store = &ttm_mem_global_store,
>>>     };
>>>
>>> +void ttm_mem_glob_kobj_release(struct kobject *kobj) {
>>> +   struct ttm_mem_global *glob = container_of(kobj, struct
>>> +ttm_mem_global, kobj);
>>> +
>>> +   memset(glob, 0, sizeof(*glob));
>>> +}
>>> +
>>>     static struct kobj_type ttm_mem_glob_kobj_type = {
>>>      .sysfs_ops = &ttm_mem_global_ops,
>>>      .default_attrs = ttm_mem_global_attrs,
>>> +   .release = ttm_mem_glob_kobj_release,
>>>     };
>>>
>>>     static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
>>> --
>>> 2.7.4
>>>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[-- Attachment #1.2: Type: text/html, Size: 11433 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-07 10:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05  6:44 [PATCH] drm/ttm: fix ttm client driver (e.g. amdgpu) reload issue Monk Liu
     [not found] ` <1559717076-25471-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2019-06-05  7:29   ` FW: " Liu, Monk
     [not found]     ` <MN2PR12MB393308FE408E9E41EF0D615184160-rweVpJHSKTq/67K4VYF1uAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-06-05 11:10       ` Koenig, Christian
     [not found]         ` <8dbf96e5-056f-b2bb-b0d3-9376b92b0140-5C7GfCeVMHo@public.gmane.org>
2019-06-05 14:44           ` Liu, Monk
     [not found]             ` <MN2PR12MB39334AC8143DDBC1AA7587E884160-rweVpJHSKTq/67K4VYF1uAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-06-05 18:10               ` Koenig, Christian
     [not found]                 ` <bb88e890-84c4-5405-85c6-59f02d5a7a61-5C7GfCeVMHo@public.gmane.org>
2019-06-06 14:00                   ` Christian König
     [not found]                     ` <1ef221b9-f29e-cbd2-488a-d5d0b349e45f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-06 15:15                       ` Deucher, Alexander
     [not found]                         ` <BN6PR12MB1809F73FCA1AC3CA8B91CD1AF7170-/b2+HYfkarSEx6ez0IUAagdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-06-07 10:13                           ` Liu, Monk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.