<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This<span style=" color:#c0c0c0;"> </span>patch<span style=" color:#c0c0c0;"> </span>is<span style=" color:#c0c0c0;"> </span>Reviewed-by:<span style=" color:#c0c0c0;"> </span>James<span style=" color:#c0c0c0;"> </span>Zhu<span style=" color:#c0c0c0;"> </span><a class="moz-txt-link-rfc2396E" href="mailto:James.Zhu@amd.com"><James.Zhu@amd.com></a></pre>
    <p><style type="text/css">p, li { white-space: pre-wrap; }</style></p>
    <div class="moz-cite-prefix">On 2022-11-24 16:19, Luben Tuikov
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20221124211956.264282-1-luben.tuikov@amd.com">
      <pre class="moz-quote-pre" wrap="">Fix minmax compilation error by using min_t()/max_t(), of the assignment type.

Cc: James Zhu <a class="moz-txt-link-rfc2396E" href="mailto:James.Zhu@amd.com"><James.Zhu@amd.com></a>
Cc: Felix Kuehling <a class="moz-txt-link-rfc2396E" href="mailto:Felix.Kuehling@amd.com"><Felix.Kuehling@amd.com></a>
Fixes: 58170a7a002ad6 ("drm/amdgpu: fix stall on CPU when allocate large system memory")
Signed-off-by: Luben Tuikov <a class="moz-txt-link-rfc2396E" href="mailto:luben.tuikov@amd.com"><luben.tuikov@amd.com></a>
---
 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
</pre>
    </blockquote>
  </body>
</html>