lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 10 May 2022 17:23:37 +0200
From:   Christian König <christian.koenig@....com>
To:     "Limonciello, Mario" <Mario.Limonciello@....com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc:     "stable@...r.kernel.org" <stable@...r.kernel.org>,
        Nirmoy Das <nirmoy.das@....com>,
        "Deucher, Alexander" <Alexander.Deucher@....com>
Subject: Re: [PATCH 5.15 082/135] drm/amdgpu: unify BO evicting method in
 amdgpu_ttm

Am 10.05.22 um 17:17 schrieb Limonciello, Mario:
> [AMD Official Use Only - General]
>
>
>
>> -----Original Message-----
>> From: Koenig, Christian <Christian.Koenig@....com>
>> Sent: Tuesday, May 10, 2022 10:15
>> To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>; linux-
>> kernel@...r.kernel.org
>> Cc: stable@...r.kernel.org; Nirmoy Das <nirmoy.das@....com>; Deucher,
>> Alexander <Alexander.Deucher@....com>; Limonciello, Mario
>> <Mario.Limonciello@....com>
>> Subject: Re: [PATCH 5.15 082/135] drm/amdgpu: unify BO evicting method in
>> amdgpu_ttm
>>
>> Hi Greg,
>>
>> sorry only noticing this now. Why is that patch backported?
>>
>> I mean it probably doesn't hurt, but that is just a code cleanup without
>> much function difference and not a bug fix.
> Christian,
>
> It was for supporting a backport of some other fixes.
> See:
> https://lore.kernel.org/stable/BL1PR12MB5157776D00DAA747EF550CF1E2C69@BL1PR12MB5157.namprd12.prod.outlook.com/
>
> Technically it could have been a hand modified e53d9665ab00 but distros are
> doing it as a straight backport already so my thought was it's better to align what they're doing.

Ah! That makes more sense now, yes feel free to go ahead with that.

It's just that the backmerge notice of this patch alone ended up in my 
inbox and that didn't made to much sense.

Thanks,
Christian.

>
>> Regards,
>> Christian.
>>
>> Am 10.05.22 um 15:07 schrieb Greg Kroah-Hartman:
>>> From: Nirmoy Das <nirmoy.das@....com>
>>>
>>> commit 58144d283712c9e80e528e001af6ac5aeee71af2 upstream.
>>>
>>> Unify BO evicting functionality for possible memory
>>> types in amdgpu_ttm.c.
>>>
>>> Signed-off-by: Nirmoy Das <nirmoy.das@....com>
>>> Reviewed-by: Christian König <christian.koenig@....com>
>>> Signed-off-by: Alex Deucher <alexander.deucher@....com>
>>> Cc: "Limonciello, Mario" <Mario.Limonciello@....com>
>>> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c |    8 ++-----
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  |   30
>> ++++++++++++++++++++++------
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  |   23 ---------------------
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |    1
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     |   30
>> ++++++++++++++++++++++++++++
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |    1
>>>    6 files changed, 58 insertions(+), 35 deletions(-)
>>>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
>>> @@ -1176,7 +1176,7 @@ static int amdgpu_debugfs_evict_vram(voi
>>>    		return r;
>>>    	}
>>>
>>> -	*val = amdgpu_bo_evict_vram(adev);
>>> +	*val = amdgpu_ttm_evict_resources(adev, TTM_PL_VRAM);
>>>
>>>    	pm_runtime_mark_last_busy(dev->dev);
>>>    	pm_runtime_put_autosuspend(dev->dev);
>>> @@ -1189,17 +1189,15 @@ static int amdgpu_debugfs_evict_gtt(void
>>>    {
>>>    	struct amdgpu_device *adev = (struct amdgpu_device *)data;
>>>    	struct drm_device *dev = adev_to_drm(adev);
>>> -	struct ttm_resource_manager *man;
>>>    	int r;
>>>
>>>    	r = pm_runtime_get_sync(dev->dev);
>>>    	if (r < 0) {
>>> -		pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
>>> +		pm_runtime_put_autosuspend(dev->dev);
>>>    		return r;
>>>    	}
>>>
>>> -	man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
>>> -	*val = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
>>> +	*val = amdgpu_ttm_evict_resources(adev, TTM_PL_TT);
>>>
>>>    	pm_runtime_mark_last_busy(dev->dev);
>>>    	pm_runtime_put_autosuspend(dev->dev);
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>>> @@ -3928,6 +3928,25 @@ void amdgpu_device_fini_sw(struct amdgpu
>>>
>>>    }
>>>
>>> +/**
>>> + * amdgpu_device_evict_resources - evict device resources
>>> + * @adev: amdgpu device object
>>> + *
>>> + * Evicts all ttm device resources(vram BOs, gart table) from the lru list
>>> + * of the vram memory type. Mainly used for evicting device resources
>>> + * at suspend time.
>>> + *
>>> + */
>>> +static void amdgpu_device_evict_resources(struct amdgpu_device
>> *adev)
>>> +{
>>> +	/* No need to evict vram on APUs for suspend to ram */
>>> +	if (adev->in_s3 && (adev->flags & AMD_IS_APU))
>>> +		return;
>>> +
>>> +	if (amdgpu_ttm_evict_resources(adev, TTM_PL_VRAM))
>>> +		DRM_WARN("evicting device resources failed\n");
>>> +
>>> +}
>>>
>>>    /*
>>>     * Suspend & resume.
>>> @@ -3968,17 +3987,16 @@ int amdgpu_device_suspend(struct drm_dev
>>>    	if (!adev->in_s0ix)
>>>    		amdgpu_amdkfd_suspend(adev, adev->in_runpm);
>>>
>>> -	/* evict vram memory */
>>> -	amdgpu_bo_evict_vram(adev);
>>> +	/* First evict vram memory */
>>> +	amdgpu_device_evict_resources(adev);
>>>
>>>    	amdgpu_fence_driver_hw_fini(adev);
>>>
>>>    	amdgpu_device_ip_suspend_phase2(adev);
>>> -	/* evict remaining vram memory
>>> -	 * This second call to evict vram is to evict the gart page table
>>> -	 * using the CPU.
>>> +	/* This second call to evict device resources is to evict
>>> +	 * the gart page table using the CPU.
>>>    	 */
>>> -	amdgpu_bo_evict_vram(adev);
>>> +	amdgpu_device_evict_resources(adev);
>>>
>>>    	return 0;
>>>    }
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> @@ -1038,29 +1038,6 @@ void amdgpu_bo_unpin(struct amdgpu_bo *b
>>>    	}
>>>    }
>>>
>>> -/**
>>> - * amdgpu_bo_evict_vram - evict VRAM buffers
>>> - * @adev: amdgpu device object
>>> - *
>>> - * Evicts all VRAM buffers on the lru list of the memory type.
>>> - * Mainly used for evicting vram at suspend time.
>>> - *
>>> - * Returns:
>>> - * 0 for success or a negative error code on failure.
>>> - */
>>> -int amdgpu_bo_evict_vram(struct amdgpu_device *adev)
>>> -{
>>> -	struct ttm_resource_manager *man;
>>> -
>>> -	if (adev->in_s3 && (adev->flags & AMD_IS_APU)) {
>>> -		/* No need to evict vram on APUs for suspend to ram */
>>> -		return 0;
>>> -	}
>>> -
>>> -	man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
>>> -	return ttm_resource_manager_evict_all(&adev->mman.bdev, man);
>>> -}
>>> -
>>>    static const char *amdgpu_vram_names[] = {
>>>    	"UNKNOWN",
>>>    	"GDDR1",
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
>>> @@ -304,7 +304,6 @@ int amdgpu_bo_pin(struct amdgpu_bo *bo,
>>>    int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
>>>    			     u64 min_offset, u64 max_offset);
>>>    void amdgpu_bo_unpin(struct amdgpu_bo *bo);
>>> -int amdgpu_bo_evict_vram(struct amdgpu_device *adev);
>>>    int amdgpu_bo_init(struct amdgpu_device *adev);
>>>    void amdgpu_bo_fini(struct amdgpu_device *adev);
>>>    int amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags);
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>>> @@ -2036,6 +2036,36 @@ error_free:
>>>    	return r;
>>>    }
>>>
>>> +/**
>>> + * amdgpu_ttm_evict_resources - evict memory buffers
>>> + * @adev: amdgpu device object
>>> + * @mem_type: evicted BO's memory type
>>> + *
>>> + * Evicts all @mem_type buffers on the lru list of the memory type.
>>> + *
>>> + * Returns:
>>> + * 0 for success or a negative error code on failure.
>>> + */
>>> +int amdgpu_ttm_evict_resources(struct amdgpu_device *adev, int
>> mem_type)
>>> +{
>>> +	struct ttm_resource_manager *man;
>>> +
>>> +	switch (mem_type) {
>>> +	case TTM_PL_VRAM:
>>> +	case TTM_PL_TT:
>>> +	case AMDGPU_PL_GWS:
>>> +	case AMDGPU_PL_GDS:
>>> +	case AMDGPU_PL_OA:
>>> +		man = ttm_manager_type(&adev->mman.bdev,
>> mem_type);
>>> +		break;
>>> +	default:
>>> +		DRM_ERROR("Trying to evict invalid memory type\n");
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	return ttm_resource_manager_evict_all(&adev->mman.bdev, man);
>>> +}
>>> +
>>>    #if defined(CONFIG_DEBUG_FS)
>>>
>>>    static int amdgpu_mm_vram_table_show(struct seq_file *m, void
>> *unused)
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
>>> @@ -190,6 +190,7 @@ bool amdgpu_ttm_tt_is_readonly(struct tt
>>>    uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct
>> ttm_resource *mem);
>>>    uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct
>> ttm_tt *ttm,
>>>    				 struct ttm_resource *mem);
>>> +int amdgpu_ttm_evict_resources(struct amdgpu_device *adev, int
>> mem_type);
>>>    void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
>>>
>>>
>>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ