All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: 赵军奎 <bernard@vivo.com>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	"David (ChunMing) Zhou" <David1.Zhou@amd.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Tom St Denis <tom.stdenis@amd.com>,
	Ori Messinger <Ori.Messinger@amd.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, opensource.kernel@vivo.com
Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed
Date: Tue, 21 Apr 2020 15:02:27 +0200	[thread overview]
Message-ID: <5c1510e2-9007-50b8-9be9-b8a00f943c9b@amd.com> (raw)
In-Reply-To: <AIEABQDACBGx7eaGVybumqrT.3.1587470983521.Hmail.bernard@vivo.com>

Am 21.04.20 um 14:09 schrieb 赵军奎:
> From: "Christian König" <christian.koenig@amd.com>
> Date: 2020-04-21 19:22:49
> To:  Bernard Zhao <bernard@vivo.com>,Alex Deucher <alexander.deucher@amd.com>,"David (ChunMing) Zhou" <David1.Zhou@amd.com>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,Tom St Denis <tom.stdenis@amd.com>,Ori Messinger <Ori.Messinger@amd.com>,Sam Ravnborg <sam@ravnborg.org>,amd-gfx@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org
> Cc:  opensource.kernel@vivo.com
> Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed>Am 21.04.20 um 13:17 schrieb Bernard Zhao:
>>> VRAM manager and DRM MM when init failed, there is no operaction
>>> to free kzalloc memory & remove device file.
>>> This will lead to memleak & cause stability issue.
>> NAK, failure to create sysfs nodes are not critical.
>>
>> Christian.
>>
> OK, get it.
> By the way, should i modify this patch to just handle <kfree(mgr)> in error branch, or that it is also unnecessary?

What you can do is to drop the "return ret" if anything with the sysfs 
nodes goes wrong and instead print the error code.

It's really annoying that loading, unloading and loading the driver 
again sometimes fails because we have a bug in the sysfs files cleanup.

We certainly should fix those bugs as well, but they are just not 
critical for correct driver functionality.

Regards,
Christian.

>
> Regards,
> Bernard
>
>>> Signed-off-by: Bernard Zhao <bernard@vivo.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 24 ++++++++++++++++----
>>>    1 file changed, 19 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> index 82a3299e53c0..4c5fb153e6b4 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> @@ -175,30 +175,44 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_total\n");
>>> -		return ret;
>>> +		goto VRAM_TOTAL_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
>>> -		return ret;
>>> +		goto VIS_VRAM_TOTA_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_used\n");
>>> -		return ret;
>>> +		goto VRAM_USED_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
>>> -		return ret;
>>> +		goto VIS_VRAM_USED_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
>>> -		return ret;
>>> +		goto VRAM_VERDOR_FAIL;
>>>    	}
>>>    
>>>    	return 0;
>>> +
>>> +VRAM_VERDOR_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>> +VIS_VRAM_USED_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
>>> +RVAM_USED_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>> +VIS_VRAM_TOTA_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
>>> +VRAM_TOTAL_FAIL:
>>> +	kfree(mgr);
>>> +	man->priv = NULL;
>>> +
>>> +	return ret;
>>>    }
>>>    
>>>    /**
>


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: 赵军奎 <bernard@vivo.com>
Cc: Tom St Denis <tom.stdenis@amd.com>,
	Ori Messinger <Ori.Messinger@amd.com>,
	opensource.kernel@vivo.com, David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org,
	Alex Deucher <alexander.deucher@amd.com>,
	Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed
Date: Tue, 21 Apr 2020 15:02:27 +0200	[thread overview]
Message-ID: <5c1510e2-9007-50b8-9be9-b8a00f943c9b@amd.com> (raw)
In-Reply-To: <AIEABQDACBGx7eaGVybumqrT.3.1587470983521.Hmail.bernard@vivo.com>

Am 21.04.20 um 14:09 schrieb 赵军奎:
> From: "Christian König" <christian.koenig@amd.com>
> Date: 2020-04-21 19:22:49
> To:  Bernard Zhao <bernard@vivo.com>,Alex Deucher <alexander.deucher@amd.com>,"David (ChunMing) Zhou" <David1.Zhou@amd.com>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,Tom St Denis <tom.stdenis@amd.com>,Ori Messinger <Ori.Messinger@amd.com>,Sam Ravnborg <sam@ravnborg.org>,amd-gfx@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org
> Cc:  opensource.kernel@vivo.com
> Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed>Am 21.04.20 um 13:17 schrieb Bernard Zhao:
>>> VRAM manager and DRM MM when init failed, there is no operaction
>>> to free kzalloc memory & remove device file.
>>> This will lead to memleak & cause stability issue.
>> NAK, failure to create sysfs nodes are not critical.
>>
>> Christian.
>>
> OK, get it.
> By the way, should i modify this patch to just handle <kfree(mgr)> in error branch, or that it is also unnecessary?

What you can do is to drop the "return ret" if anything with the sysfs 
nodes goes wrong and instead print the error code.

It's really annoying that loading, unloading and loading the driver 
again sometimes fails because we have a bug in the sysfs files cleanup.

We certainly should fix those bugs as well, but they are just not 
critical for correct driver functionality.

Regards,
Christian.

>
> Regards,
> Bernard
>
>>> Signed-off-by: Bernard Zhao <bernard@vivo.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 24 ++++++++++++++++----
>>>    1 file changed, 19 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> index 82a3299e53c0..4c5fb153e6b4 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> @@ -175,30 +175,44 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_total\n");
>>> -		return ret;
>>> +		goto VRAM_TOTAL_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
>>> -		return ret;
>>> +		goto VIS_VRAM_TOTA_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_used\n");
>>> -		return ret;
>>> +		goto VRAM_USED_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
>>> -		return ret;
>>> +		goto VIS_VRAM_USED_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
>>> -		return ret;
>>> +		goto VRAM_VERDOR_FAIL;
>>>    	}
>>>    
>>>    	return 0;
>>> +
>>> +VRAM_VERDOR_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>> +VIS_VRAM_USED_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
>>> +RVAM_USED_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>> +VIS_VRAM_TOTA_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
>>> +VRAM_TOTAL_FAIL:
>>> +	kfree(mgr);
>>> +	man->priv = NULL;
>>> +
>>> +	return ret;
>>>    }
>>>    
>>>    /**
>

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

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: 赵军奎 <bernard@vivo.com>
Cc: Tom St Denis <tom.stdenis@amd.com>,
	"David \(ChunMing\) Zhou" <David1.Zhou@amd.com>,
	Ori Messinger <Ori.Messinger@amd.com>,
	opensource.kernel@vivo.com, David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>,
	Alex Deucher <alexander.deucher@amd.com>,
	Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed
Date: Tue, 21 Apr 2020 15:02:27 +0200	[thread overview]
Message-ID: <5c1510e2-9007-50b8-9be9-b8a00f943c9b@amd.com> (raw)
In-Reply-To: <AIEABQDACBGx7eaGVybumqrT.3.1587470983521.Hmail.bernard@vivo.com>

Am 21.04.20 um 14:09 schrieb 赵军奎:
> From: "Christian König" <christian.koenig@amd.com>
> Date: 2020-04-21 19:22:49
> To:  Bernard Zhao <bernard@vivo.com>,Alex Deucher <alexander.deucher@amd.com>,"David (ChunMing) Zhou" <David1.Zhou@amd.com>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,Tom St Denis <tom.stdenis@amd.com>,Ori Messinger <Ori.Messinger@amd.com>,Sam Ravnborg <sam@ravnborg.org>,amd-gfx@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org
> Cc:  opensource.kernel@vivo.com
> Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed>Am 21.04.20 um 13:17 schrieb Bernard Zhao:
>>> VRAM manager and DRM MM when init failed, there is no operaction
>>> to free kzalloc memory & remove device file.
>>> This will lead to memleak & cause stability issue.
>> NAK, failure to create sysfs nodes are not critical.
>>
>> Christian.
>>
> OK, get it.
> By the way, should i modify this patch to just handle <kfree(mgr)> in error branch, or that it is also unnecessary?

What you can do is to drop the "return ret" if anything with the sysfs 
nodes goes wrong and instead print the error code.

It's really annoying that loading, unloading and loading the driver 
again sometimes fails because we have a bug in the sysfs files cleanup.

We certainly should fix those bugs as well, but they are just not 
critical for correct driver functionality.

Regards,
Christian.

>
> Regards,
> Bernard
>
>>> Signed-off-by: Bernard Zhao <bernard@vivo.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 24 ++++++++++++++++----
>>>    1 file changed, 19 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> index 82a3299e53c0..4c5fb153e6b4 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>>> @@ -175,30 +175,44 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_total\n");
>>> -		return ret;
>>> +		goto VRAM_TOTAL_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
>>> -		return ret;
>>> +		goto VIS_VRAM_TOTA_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_used\n");
>>> -		return ret;
>>> +		goto VRAM_USED_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
>>> -		return ret;
>>> +		goto VIS_VRAM_USED_FAIL;
>>>    	}
>>>    	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
>>>    	if (ret) {
>>>    		DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
>>> -		return ret;
>>> +		goto VRAM_VERDOR_FAIL;
>>>    	}
>>>    
>>>    	return 0;
>>> +
>>> +VRAM_VERDOR_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>> +VIS_VRAM_USED_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
>>> +RVAM_USED_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>> +VIS_VRAM_TOTA_FAIL:
>>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
>>> +VRAM_TOTAL_FAIL:
>>> +	kfree(mgr);
>>> +	man->priv = NULL;
>>> +
>>> +	return ret;
>>>    }
>>>    
>>>    /**
>

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

  reply	other threads:[~2020-04-21 13:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 11:17 [PATCH] amdgpu: fixes memleak issue when init failed Bernard Zhao
2020-04-21 11:17 ` Bernard Zhao
2020-04-21 11:17 ` Bernard Zhao
2020-04-21 11:22 ` Christian König
2020-04-21 11:22   ` Christian König
2020-04-21 11:22   ` Christian König
2020-04-21 12:09   ` 赵军奎
2020-04-21 12:09     ` 赵军奎
2020-04-21 12:09     ` 赵军奎
2020-04-21 13:02     ` Christian König [this message]
2020-04-21 13:02       ` Christian König
2020-04-21 13:02       ` Christian König
2020-04-21 13:39       ` 赵军奎
2020-04-21 13:39         ` 赵军奎
2020-04-21 13:39         ` 赵军奎
2020-04-21 14:53         ` Christian König
2020-04-21 14:53           ` Christian König
2020-04-21 14:53           ` Christian König
2020-04-22  0:56           ` 赵军奎
2020-04-22  0:56             ` 赵军奎
2020-04-22  0:56             ` 赵军奎
2020-04-22  7:27             ` Christian König
2020-04-22  7:27               ` Christian König
2020-04-22  7:27               ` Christian König
2020-04-22 15:51 ` Ruhl, Michael J
2020-04-22 15:51   ` Ruhl, Michael J
2020-04-22 15:51   ` Ruhl, Michael J
2020-04-22 18:28   ` Christian König
2020-04-22 18:28     ` Christian König
2020-04-22 18:28     ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c1510e2-9007-50b8-9be9-b8a00f943c9b@amd.com \
    --to=christian.koenig@amd.com \
    --cc=David1.Zhou@amd.com \
    --cc=Ori.Messinger@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bernard@vivo.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=sam@ravnborg.org \
    --cc=tom.stdenis@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.