[PATCH] drm/amdgpu: Fix minmax error

James Zhu jamesz at amd.com
Thu Nov 24 22:04:05 UTC 2022


ThispatchisReviewed-by:JamesZhu<James.Zhu at amd.com>

On 2022-11-24 16:19, Luben Tuikov wrote:
> Fix minmax compilation error by using min_t()/max_t(), of the assignment type.
>
> Cc: James Zhu<James.Zhu at amd.com>
> Cc: Felix Kuehling<Felix.Kuehling at amd.com>
> Fixes: 58170a7a002ad6 ("drm/amdgpu: fix stall on CPU when allocate large system memory")
> Signed-off-by: Luben Tuikov<luben.tuikov at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
> index 8a2e5716d8dba2..d22d14b0ef0c84 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
> @@ -191,14 +191,18 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
>   	hmm_range->dev_private_owner = owner;
>   
>   	do {
> -		hmm_range->end = min(hmm_range->start + MAX_WALK_BYTE, end);
> +		hmm_range->end = min_t(typeof(hmm_range->end),
> +				       hmm_range->start + MAX_WALK_BYTE,
> +				       end);
>   
>   		pr_debug("hmm range: start = 0x%lx, end = 0x%lx",
>   			hmm_range->start, hmm_range->end);
>   
>   		/* Assuming 512MB takes maxmium 1 second to fault page address */
> -		timeout = max((hmm_range->end - hmm_range->start) >> 29, 1ULL) *
> -			HMM_RANGE_DEFAULT_TIMEOUT;
> +		timeout = max_t(typeof(timeout),
> +				(hmm_range->end - hmm_range->start) >> 29,
> +				1ULL);
> +		timeout *= HMM_RANGE_DEFAULT_TIMEOUT;
>   		timeout = jiffies + msecs_to_jiffies(timeout);
>   
>   retry:
>
> base-commit: d5e8f4912061ad2e577b4909556e1364e2c2018e
> prerequisite-patch-id: 6024d0c36cae3e4a995a8fcf787b91f511a37486
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20221124/de57f8ae/attachment.htm>


More information about the amd-gfx mailing list