From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E92DC83004 for ; Wed, 29 Apr 2020 19:38:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CF3C206D6 for ; Wed, 29 Apr 2020 19:38:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="NfXC63zz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbgD2Tiw (ORCPT ); Wed, 29 Apr 2020 15:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726775AbgD2Tiw (ORCPT ); Wed, 29 Apr 2020 15:38:52 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7351C035493 for ; Wed, 29 Apr 2020 12:38:51 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id s30so2984497qth.2 for ; Wed, 29 Apr 2020 12:38:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wSYESb9Z3lobUMcKhRgLVx/Jnc91KqPEgi7fezuq0cw=; b=NfXC63zzpf/8TqXiV12LVXGiDGkba+94lBawHeUu83K8kLO8LRDgkxz43bWbbguQFH aCgsfAqUHnw9A7jIE+4yQDpSBQ9ejSEwi62fbLyNgrZQF6E45SKOlcrZpp3ZA+x+T81t 05c9+uMkRiw5dJ58ysX0oVJvqft33g+XCuCp2l8cUvJI6iP1S8Vujxgbk5X6fDpsk2TX Vd6i5AIIK/Oyu4Q/ttB0qTWO+51Joo3U4fWF4Lkf2S6hLdFNWplzSuZgTs6i+e6rfv// X3HxIzTHtwQ7e5jBUgRqMi3T5DsoKatOu2U5HWkn6PujV760l328OCDPIQi8nYsNU/Lp pAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wSYESb9Z3lobUMcKhRgLVx/Jnc91KqPEgi7fezuq0cw=; b=a++S1N2wa1DLLcqby2Vzn33ip440VdhQ9nFEzeN5dsrW98Z/K8bmYNs2jmmoeoY7Fq 3MKRHEUEPqCcsDtyZVhLlyAUoapiI2XBboazzYvaBYN0RQka3TQmoAnDLtz3M7GCnM+f lyKpUkwB8IUlqoG89pfRFZNfCSFJ+taN5MGDye1dvpoJgHudxAm9d6viUInMrHW7H2PU kNVqJ+7llSGIGJwjz6TmyAoTrrAL9hLqpwGOsrxoFSRo4KB0eaLaLxhJVQlR05EgASZ7 R1Bo2s/dIL6W+TiLL3N8z8WqgpJZKHf449TWEyJNuaixpUFgq7bFn+tjaKFD0XfHSp9A 15IA== X-Gm-Message-State: AGi0PuYk+5fSkA5LvSTF8/67/YDqbaF2bzQUn6qr3SAUYtK5hlBeMAM2 LMC75jjF7+YpE2PBIqqHqT8O3A== X-Google-Smtp-Source: APiQypKXiOYH85US8Z7h6G2+cqWcYKpnBdMFUGM9XeOFtVhWzW/P0ELjxN2G8888g6EU3/+MJwFu8g== X-Received: by 2002:ac8:3a83:: with SMTP id x3mr24832605qte.44.1588189131135; Wed, 29 Apr 2020 12:38:51 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id m12sm92419qki.75.2020.04.29.12.38.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Apr 2020 12:38:50 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jTsXh-0005C7-Ba; Wed, 29 Apr 2020 16:38:49 -0300 Date: Wed, 29 Apr 2020 16:38:49 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: linux-mm@kvack.org, Ralph Campbell , Alex Deucher , amd-gfx@lists.freedesktop.org, Ben Skeggs , Christian =?utf-8?B?S8O2bmln?= , "David (ChunMing) Zhou" , dri-devel@lists.freedesktop.org, "Kuehling, Felix" , intel-gfx@lists.freedesktop.org, =?utf-8?B?SsOpcsO0bWU=?= Glisse , John Hubbard , linux-kernel@vger.kernel.org, Niranjana Vishwanathapura , nouveau@lists.freedesktop.org Subject: Re: [PATCH hmm 2/5] mm/hmm: make hmm_range_fault return 0 or -1 Message-ID: <20200429193849.GA3824@ziepe.ca> References: <0-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <2-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <20200422055229.GB22366@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200422055229.GB22366@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 22, 2020 at 07:52:29AM +0200, Christoph Hellwig wrote: > On Tue, Apr 21, 2020 at 09:21:43PM -0300, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > hmm_vma_walk->last is supposed to be updated after every write to the > > pfns, so that it can be returned by hmm_range_fault(). However, this is > > not done consistently. Fortunately nothing checks the return code of > > hmm_range_fault() for anything other than error. > > > > More importantly last must be set before returning -EBUSY as it is used to > > prevent reading an output pfn as an input flags when the loop restarts. > > > > For clarity and simplicity make hmm_range_fault() return 0 or -ERRNO. Only > > set last when returning -EBUSY. > > > > Signed-off-by: Jason Gunthorpe > > Documentation/vm/hmm.rst | 2 +- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- > > drivers/gpu/drm/nouveau/nouveau_svm.c | 6 +++--- > > include/linux/hmm.h | 2 +- > > mm/hmm.c | 25 +++++++++---------------- > > 5 files changed, 16 insertions(+), 23 deletions(-) > > > > diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst > > index 4e3e9362afeb10..9924f2caa0184c 100644 > > +++ b/Documentation/vm/hmm.rst > > @@ -161,7 +161,7 @@ device must complete the update before the driver callback returns. > > When the device driver wants to populate a range of virtual addresses, it can > > use:: > > > > - long hmm_range_fault(struct hmm_range *range); > > + int hmm_range_fault(struct hmm_range *range); > > > > It will trigger a page fault on missing or read-only entries if write access is > > requested (see below). Page faults use the generic mm page fault code path just > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > index 6309ff72bd7876..efc1329a019127 100644 > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > @@ -852,12 +852,12 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) > > down_read(&mm->mmap_sem); > > r = hmm_range_fault(range); > > up_read(&mm->mmap_sem); > > - if (unlikely(r <= 0)) { > > + if (unlikely(r)) { > > /* > > * FIXME: This timeout should encompass the retry from > > * mmu_interval_read_retry() as well. > > */ > > - if ((r == 0 || r == -EBUSY) && !time_after(jiffies, timeout)) > > + if ((r == -EBUSY) && !time_after(jiffies, timeout)) > > Please also kill the superflous inner braces here. > > > + * Return: 0 or -ERRNO with one of the following status codes: > > Maybe say something like: > > * Returns 0 on success or one of the following error codes: > > Otherwise this looks good: Got it, thanks Jason From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [PATCH hmm 2/5] mm/hmm: make hmm_range_fault return 0 or -1 Date: Wed, 29 Apr 2020 16:38:49 -0300 Message-ID: <20200429193849.GA3824@ziepe.ca> References: <0-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <2-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <20200422055229.GB22366@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20200422055229.GB22366-jcswGhMUV9g@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: nouveau-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "Nouveau" To: Christoph Hellwig Cc: "David (ChunMing) Zhou" , Ralph Campbell , dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Ben Skeggs , nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, Alex Deucher , "Kuehling, Felix" , Niranjana Vishwanathapura , intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, Christian =?utf-8?B?S8O2bmln?= List-Id: nouveau.vger.kernel.org On Wed, Apr 22, 2020 at 07:52:29AM +0200, Christoph Hellwig wrote: > On Tue, Apr 21, 2020 at 09:21:43PM -0300, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > hmm_vma_walk->last is supposed to be updated after every write to the > > pfns, so that it can be returned by hmm_range_fault(). However, this is > > not done consistently. Fortunately nothing checks the return code of > > hmm_range_fault() for anything other than error. > > > > More importantly last must be set before returning -EBUSY as it is used to > > prevent reading an output pfn as an input flags when the loop restarts. > > > > For clarity and simplicity make hmm_range_fault() return 0 or -ERRNO. Only > > set last when returning -EBUSY. > > > > Signed-off-by: Jason Gunthorpe > > Documentation/vm/hmm.rst | 2 +- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- > > drivers/gpu/drm/nouveau/nouveau_svm.c | 6 +++--- > > include/linux/hmm.h | 2 +- > > mm/hmm.c | 25 +++++++++---------------- > > 5 files changed, 16 insertions(+), 23 deletions(-) > > > > diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst > > index 4e3e9362afeb10..9924f2caa0184c 100644 > > +++ b/Documentation/vm/hmm.rst > > @@ -161,7 +161,7 @@ device must complete the update before the driver callback returns. > > When the device driver wants to populate a range of virtual addresses, it can > > use:: > > > > - long hmm_range_fault(struct hmm_range *range); > > + int hmm_range_fault(struct hmm_range *range); > > > > It will trigger a page fault on missing or read-only entries if write access is > > requested (see below). Page faults use the generic mm page fault code path just > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > index 6309ff72bd7876..efc1329a019127 100644 > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > @@ -852,12 +852,12 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) > > down_read(&mm->mmap_sem); > > r = hmm_range_fault(range); > > up_read(&mm->mmap_sem); > > - if (unlikely(r <= 0)) { > > + if (unlikely(r)) { > > /* > > * FIXME: This timeout should encompass the retry from > > * mmu_interval_read_retry() as well. > > */ > > - if ((r == 0 || r == -EBUSY) && !time_after(jiffies, timeout)) > > + if ((r == -EBUSY) && !time_after(jiffies, timeout)) > > Please also kill the superflous inner braces here. > > > + * Return: 0 or -ERRNO with one of the following status codes: > > Maybe say something like: > > * Returns 0 on success or one of the following error codes: > > Otherwise this looks good: Got it, thanks Jason From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05484C83001 for ; Thu, 30 Apr 2020 07:32:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD36420757 for ; Thu, 30 Apr 2020 07:32:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="NfXC63zz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD36420757 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 301176EB60; Thu, 30 Apr 2020 07:32:45 +0000 (UTC) Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id 158A56EB0C for ; Wed, 29 Apr 2020 19:38:52 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id i68so2957875qtb.5 for ; Wed, 29 Apr 2020 12:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wSYESb9Z3lobUMcKhRgLVx/Jnc91KqPEgi7fezuq0cw=; b=NfXC63zzpf/8TqXiV12LVXGiDGkba+94lBawHeUu83K8kLO8LRDgkxz43bWbbguQFH aCgsfAqUHnw9A7jIE+4yQDpSBQ9ejSEwi62fbLyNgrZQF6E45SKOlcrZpp3ZA+x+T81t 05c9+uMkRiw5dJ58ysX0oVJvqft33g+XCuCp2l8cUvJI6iP1S8Vujxgbk5X6fDpsk2TX Vd6i5AIIK/Oyu4Q/ttB0qTWO+51Joo3U4fWF4Lkf2S6hLdFNWplzSuZgTs6i+e6rfv// X3HxIzTHtwQ7e5jBUgRqMi3T5DsoKatOu2U5HWkn6PujV760l328OCDPIQi8nYsNU/Lp pAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wSYESb9Z3lobUMcKhRgLVx/Jnc91KqPEgi7fezuq0cw=; b=aLeG0Z/ClrM5xorX6QueTFA0+q/sRih8fBa2T2DUdWLlA1aBnRH5E1GBscrBpZm/pl ULVY894ULukjDxMyHMqStT4WTIfck0dm53Wtj+V8+gdTQxx7Tk2jtpg2cDwnyWi0v+ku rhOIaDvWDmsfrvSVb8w86liWb7gYrXehz9sAaRsm+bkUjUnhsDo1whDaTlMZfkxAErOZ PYPW4zj1SNR6HFejjHqzyppVI08a5zQPFvuNQ8NaR+f38RgWw/+on5h/1Ig+kOOCLxrx MPTCjdpboYXSRkfXAFHqTZPHeFs1EWWz/c55H5VO2A+J9xOfsoc9bD1QXBaSbvBXw1fH YvRw== X-Gm-Message-State: AGi0PuZjx0wQcsTk4HiT2T/1DINJtnUgRXxeV7cznMBKqpcrz+yK3AcJ +y9p/RZ2Za4TzIWvz8gzcV58bA== X-Google-Smtp-Source: APiQypKXiOYH85US8Z7h6G2+cqWcYKpnBdMFUGM9XeOFtVhWzW/P0ELjxN2G8888g6EU3/+MJwFu8g== X-Received: by 2002:ac8:3a83:: with SMTP id x3mr24832605qte.44.1588189131135; Wed, 29 Apr 2020 12:38:51 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id m12sm92419qki.75.2020.04.29.12.38.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Apr 2020 12:38:50 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jTsXh-0005C7-Ba; Wed, 29 Apr 2020 16:38:49 -0300 Date: Wed, 29 Apr 2020 16:38:49 -0300 From: Jason Gunthorpe To: Christoph Hellwig Subject: Re: [PATCH hmm 2/5] mm/hmm: make hmm_range_fault return 0 or -1 Message-ID: <20200429193849.GA3824@ziepe.ca> References: <0-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <2-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <20200422055229.GB22366@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200422055229.GB22366@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Thu, 30 Apr 2020 07:31:56 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ralph Campbell , John Hubbard , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-mm@kvack.org, =?utf-8?B?SsOpcsO0bWU=?= Glisse , Ben Skeggs , nouveau@lists.freedesktop.org, Alex Deucher , "Kuehling, Felix" , Niranjana Vishwanathapura , intel-gfx@lists.freedesktop.org, Christian =?utf-8?B?S8O2bmln?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Apr 22, 2020 at 07:52:29AM +0200, Christoph Hellwig wrote: > On Tue, Apr 21, 2020 at 09:21:43PM -0300, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > hmm_vma_walk->last is supposed to be updated after every write to the > > pfns, so that it can be returned by hmm_range_fault(). However, this is > > not done consistently. Fortunately nothing checks the return code of > > hmm_range_fault() for anything other than error. > > > > More importantly last must be set before returning -EBUSY as it is used to > > prevent reading an output pfn as an input flags when the loop restarts. > > > > For clarity and simplicity make hmm_range_fault() return 0 or -ERRNO. Only > > set last when returning -EBUSY. > > > > Signed-off-by: Jason Gunthorpe > > Documentation/vm/hmm.rst | 2 +- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- > > drivers/gpu/drm/nouveau/nouveau_svm.c | 6 +++--- > > include/linux/hmm.h | 2 +- > > mm/hmm.c | 25 +++++++++---------------- > > 5 files changed, 16 insertions(+), 23 deletions(-) > > > > diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst > > index 4e3e9362afeb10..9924f2caa0184c 100644 > > +++ b/Documentation/vm/hmm.rst > > @@ -161,7 +161,7 @@ device must complete the update before the driver callback returns. > > When the device driver wants to populate a range of virtual addresses, it can > > use:: > > > > - long hmm_range_fault(struct hmm_range *range); > > + int hmm_range_fault(struct hmm_range *range); > > > > It will trigger a page fault on missing or read-only entries if write access is > > requested (see below). Page faults use the generic mm page fault code path just > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > index 6309ff72bd7876..efc1329a019127 100644 > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > @@ -852,12 +852,12 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) > > down_read(&mm->mmap_sem); > > r = hmm_range_fault(range); > > up_read(&mm->mmap_sem); > > - if (unlikely(r <= 0)) { > > + if (unlikely(r)) { > > /* > > * FIXME: This timeout should encompass the retry from > > * mmu_interval_read_retry() as well. > > */ > > - if ((r == 0 || r == -EBUSY) && !time_after(jiffies, timeout)) > > + if ((r == -EBUSY) && !time_after(jiffies, timeout)) > > Please also kill the superflous inner braces here. > > > + * Return: 0 or -ERRNO with one of the following status codes: > > Maybe say something like: > > * Returns 0 on success or one of the following error codes: > > Otherwise this looks good: Got it, thanks Jason _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA527C83000 for ; Wed, 29 Apr 2020 19:41:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D262206D6 for ; Wed, 29 Apr 2020 19:41:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="NfXC63zz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D262206D6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=amd-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4273E6EB0B; Wed, 29 Apr 2020 19:41:27 +0000 (UTC) Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by gabe.freedesktop.org (Postfix) with ESMTPS id 256996EB0E for ; Wed, 29 Apr 2020 19:38:52 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id t20so2911033qtq.13 for ; Wed, 29 Apr 2020 12:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wSYESb9Z3lobUMcKhRgLVx/Jnc91KqPEgi7fezuq0cw=; b=NfXC63zzpf/8TqXiV12LVXGiDGkba+94lBawHeUu83K8kLO8LRDgkxz43bWbbguQFH aCgsfAqUHnw9A7jIE+4yQDpSBQ9ejSEwi62fbLyNgrZQF6E45SKOlcrZpp3ZA+x+T81t 05c9+uMkRiw5dJ58ysX0oVJvqft33g+XCuCp2l8cUvJI6iP1S8Vujxgbk5X6fDpsk2TX Vd6i5AIIK/Oyu4Q/ttB0qTWO+51Joo3U4fWF4Lkf2S6hLdFNWplzSuZgTs6i+e6rfv// X3HxIzTHtwQ7e5jBUgRqMi3T5DsoKatOu2U5HWkn6PujV760l328OCDPIQi8nYsNU/Lp pAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wSYESb9Z3lobUMcKhRgLVx/Jnc91KqPEgi7fezuq0cw=; b=C+GCdiFKVXqIkvjJIFJDOyvFRKrw+U+KHzZBTXsi/dFYN5C9e9ftlix4MFd+/Ibxxa dG/KzLD2tyP0mSH5L4mbqofO2F3uAwbbCoHHpBdNvQHJCwrZihunKAWSN9tVZjT09VNo CCfYsBL0NS9K3Tj26+wWnj+ZXTEnaSJ7B+yjgkLGkjchx0Sy+qWaN3Aj2fPIgp1/eG0Q AWyMiXEO2cbTSxc3ZAR6qwnktWoE2YjNT4xbjkQ/yP9ftpWZ9RJFo7exA2+sSt40aL6R OgAiKjb1dhUfFejjBxy5j7GObBGE+xJp192gN+1qXgSUDdufvYrdsQLm4FBADpS8TTKE cRhg== X-Gm-Message-State: AGi0Pua+1lgRuonnHX26Sx9UsPunhwKi3eEd7qpcymAwKWLbj2XmgPWI 9gSfxYlhFQ8XLDa7Ly6jh0m4Fw== X-Google-Smtp-Source: APiQypKXiOYH85US8Z7h6G2+cqWcYKpnBdMFUGM9XeOFtVhWzW/P0ELjxN2G8888g6EU3/+MJwFu8g== X-Received: by 2002:ac8:3a83:: with SMTP id x3mr24832605qte.44.1588189131135; Wed, 29 Apr 2020 12:38:51 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id m12sm92419qki.75.2020.04.29.12.38.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Apr 2020 12:38:50 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jTsXh-0005C7-Ba; Wed, 29 Apr 2020 16:38:49 -0300 Date: Wed, 29 Apr 2020 16:38:49 -0300 From: Jason Gunthorpe To: Christoph Hellwig Subject: Re: [PATCH hmm 2/5] mm/hmm: make hmm_range_fault return 0 or -1 Message-ID: <20200429193849.GA3824@ziepe.ca> References: <0-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <2-v1-4eb72686de3c+5062-hmm_no_flags_jgg@mellanox.com> <20200422055229.GB22366@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200422055229.GB22366@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Wed, 29 Apr 2020 19:41:26 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "David \(ChunMing\) Zhou" , Ralph Campbell , John Hubbard , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-mm@kvack.org, =?utf-8?B?SsOpcsO0bWU=?= Glisse , Ben Skeggs , nouveau@lists.freedesktop.org, Alex Deucher , "Kuehling, Felix" , Niranjana Vishwanathapura , intel-gfx@lists.freedesktop.org, Christian =?utf-8?B?S8O2bmln?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Wed, Apr 22, 2020 at 07:52:29AM +0200, Christoph Hellwig wrote: > On Tue, Apr 21, 2020 at 09:21:43PM -0300, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > hmm_vma_walk->last is supposed to be updated after every write to the > > pfns, so that it can be returned by hmm_range_fault(). However, this is > > not done consistently. Fortunately nothing checks the return code of > > hmm_range_fault() for anything other than error. > > > > More importantly last must be set before returning -EBUSY as it is used to > > prevent reading an output pfn as an input flags when the loop restarts. > > > > For clarity and simplicity make hmm_range_fault() return 0 or -ERRNO. Only > > set last when returning -EBUSY. > > > > Signed-off-by: Jason Gunthorpe > > Documentation/vm/hmm.rst | 2 +- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- > > drivers/gpu/drm/nouveau/nouveau_svm.c | 6 +++--- > > include/linux/hmm.h | 2 +- > > mm/hmm.c | 25 +++++++++---------------- > > 5 files changed, 16 insertions(+), 23 deletions(-) > > > > diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst > > index 4e3e9362afeb10..9924f2caa0184c 100644 > > +++ b/Documentation/vm/hmm.rst > > @@ -161,7 +161,7 @@ device must complete the update before the driver callback returns. > > When the device driver wants to populate a range of virtual addresses, it can > > use:: > > > > - long hmm_range_fault(struct hmm_range *range); > > + int hmm_range_fault(struct hmm_range *range); > > > > It will trigger a page fault on missing or read-only entries if write access is > > requested (see below). Page faults use the generic mm page fault code path just > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > index 6309ff72bd7876..efc1329a019127 100644 > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > > @@ -852,12 +852,12 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) > > down_read(&mm->mmap_sem); > > r = hmm_range_fault(range); > > up_read(&mm->mmap_sem); > > - if (unlikely(r <= 0)) { > > + if (unlikely(r)) { > > /* > > * FIXME: This timeout should encompass the retry from > > * mmu_interval_read_retry() as well. > > */ > > - if ((r == 0 || r == -EBUSY) && !time_after(jiffies, timeout)) > > + if ((r == -EBUSY) && !time_after(jiffies, timeout)) > > Please also kill the superflous inner braces here. > > > + * Return: 0 or -ERRNO with one of the following status codes: > > Maybe say something like: > > * Returns 0 on success or one of the following error codes: > > Otherwise this looks good: Got it, thanks Jason _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx