From patchwork Wed Jul 3 22:02:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11030531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4E34138D for ; Wed, 3 Jul 2019 22:02:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5F7D289B8 for ; Wed, 3 Jul 2019 22:02:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9F3C289CE; Wed, 3 Jul 2019 22:02:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17243289B8 for ; Wed, 3 Jul 2019 22:02:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E7B18E0025; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 797F98E0027; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48BF48E0025; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id EDC528E0025 for ; Wed, 3 Jul 2019 18:02:20 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id a5so2068348pla.3 for ; Wed, 03 Jul 2019 15:02:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NS2VTlTL88GXGtGIYTIdIxcDk6oTfWlSKFcdult1b6c=; b=i5ZZ5ZIpejJYY1qeAvLMZ71D0TRKb4ohR7xev+ioMWDqzGS29/0mAt4XMNv1Gq34pX 6aAzUfQ7bK8aHNQ9FvgD6UdsCeM35l8Fv+1jQTNP1QPqMgW1aVn4tz63huNnpuJ64yLc rcN1s/VbiMmbmFA3k0MaQ3aPyTRV0d6+4fpSSyPUtrBC1K1Vf+F8Hy74FwIifssvYuma Sx6WOpeSgLRrvtB7VbPIrbeTjrhE9HJTHcAljgWJt74wEZF8M/9ZDBJW5Tspq+G+42wN kBXUe+bEXkAujEyetQhqFy76Iq+qWgeyPOu25iGBJpAJ758kZ8KOpVOOYNXjMZgtdTP0 MmUw== X-Gm-Message-State: APjAAAXkeCoyx5REqdayy565hqc9d+bWHPv+plKxOcSGPT9t6JfBGB1R 0VoMNmn3IEaIb8bFQVdSZ/wYgxEqidCbRzNzgq8YIcyVdYzMoyZ5SByFeoWFLwsM1Sbm9nXjm1T 5VnTxnAHJCXBqNb3uvcoU7ySccSIx+n8kkzyq42+TyWw0Q9yUuYR/LRPYDq+M7dE= X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr15551218pjb.115.1562191340612; Wed, 03 Jul 2019 15:02:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8jEYC1a1LueUKwEEGMZHVuN4jPAJ6z6Emmhl1aBMOFvKJsNbV8S/qpQknWxTRjB3neOVE X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr15551118pjb.115.1562191339442; Wed, 03 Jul 2019 15:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562191339; cv=none; d=google.com; s=arc-20160816; b=mH80nLOUxOb73gUcPwnuFXMTzlW04H4Kvmb/znWU7XXZ0P/mwFOT3hRRQxgNF90REJ xuhf05vzecTFr89lcl1APdaHxUeMZNlRbcDEJt0sf6fAmi6Kx1tO/yDdXYuskS5tArn9 dCBZxOfPfJdVNHubCYB8npXrMmV7ANacjHuI4UoJ+XuWrWW1ZtxsZFDvALaIhiRwZCJp ulrZ+FJT7ujmhnjUv4+r6wFpbOZHek9bz0S5prW7fRhSNnzN/B8cLF80ZaefgSZbdqYh KldU5T1GJt447eZKB8nbN5pa3lIDweEcP2BnWqeCe7qRJeuaTAUCuPJc41jmhc63t1fY rpVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=NS2VTlTL88GXGtGIYTIdIxcDk6oTfWlSKFcdult1b6c=; b=pcwgzmIZUFx6l9xmRT9X7mUHvKILjX40s8Me+SqfrkFuaxn+LjTaFj2G72wBNZvzkC UNWA/Aj9MhTRm58kPwro6yeUVNeOzJ1UA/mZprwfc56E2xehaHR7So51oQUql4d68nmw +vrYJDel9pFh/HT7IKX28bnb4gDgPbjA7lEq6MiqWOxvsCax3Z6ri9DopVjXiBS9LkTv vdcpo6mG3Yptx/2kpnUWhW4Dq+WZvHG70G48fx+Ov2RfF+qzBUgPDOaTZ3DXe/He3k94 6AfgK6aMsJqkaN6Rdm/GQGTMMDZQDTPnehA3Mifv5kxqHAp/7yB6p8UDTrbcOte8cRz8 XmNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=UdUPRM97; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id x63si3384334pgd.224.2019.07.03.15.02.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 15:02:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=UdUPRM97; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NS2VTlTL88GXGtGIYTIdIxcDk6oTfWlSKFcdult1b6c=; b=UdUPRM9702sfvLifCc8pPMC2aw LKUsn7kyOwVNfN6MlrKBQNCi3nL1x8SmpXj43Q3xEMu+cfuC1MdIb1fHyxiZlXTDu6PCk1+p7niBV FZ4+8Xio8+nJ67X+uBfr7pTHgYLPuNjdCCO9+K0R9zqULuTbibDw/B77irgHa+EZfA77+WmQv5ySC y8D4s0hg1LlbsNh7JmvGGCBqtoHIRkMxn1/F2W/r0h7nD9QHSYIsKtQLm6F8yk4X9R3DdzINGvsSO F3c/PXuwTOr4ghT6Wy+P1265stXrlBzmxchknyosBXC9J8PZzgsJzPZlCsyGNOEAFf57nQ6sHdKzN H+pV8yAg==; Received: from rap-us.hgst.com ([199.255.44.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hinKR-0004EQ-QL; Wed, 03 Jul 2019 22:02:15 +0000 From: Christoph Hellwig To: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Felix Kuehling Subject: [PATCH 1/6] mm: always return EBUSY for invalid ranges in hmm_range_{fault,snapshot} Date: Wed, 3 Jul 2019 15:02:09 -0700 Message-Id: <20190703220214.28319-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703220214.28319-1-hch@lst.de> References: <20190703220214.28319-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We should not have two different error codes for the same condition. In addition this really complicates the code due to the special handling of EAGAIN that drops the mmap_sem due to the FAULT_FLAG_ALLOW_RETRY logic in the core vm. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell Reviewed-by: Felix Kuehling --- Documentation/vm/hmm.rst | 2 +- mm/hmm.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst index 7d90964abbb0..710ce1c701bf 100644 --- a/Documentation/vm/hmm.rst +++ b/Documentation/vm/hmm.rst @@ -237,7 +237,7 @@ The usage pattern is:: ret = hmm_range_snapshot(&range); if (ret) { up_read(&mm->mmap_sem); - if (ret == -EAGAIN) { + if (ret == -EBUSY) { /* * No need to check hmm_range_wait_until_valid() return value * on retry we will get proper error with hmm_range_snapshot() diff --git a/mm/hmm.c b/mm/hmm.c index d48b9283725a..1d57c39c1d8b 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -946,7 +946,7 @@ EXPORT_SYMBOL(hmm_range_unregister); * @range: range * Return: -EINVAL if invalid argument, -ENOMEM out of memory, -EPERM invalid * permission (for instance asking for write and range is read only), - * -EAGAIN if you need to retry, -EFAULT invalid (ie either no valid + * -EBUSY if you need to retry, -EFAULT invalid (ie either no valid * vma or it is illegal to access that range), number of valid pages * in range->pfns[] (from range start address). * @@ -967,7 +967,7 @@ long hmm_range_snapshot(struct hmm_range *range) do { /* If range is no longer valid force retry. */ if (!range->valid) - return -EAGAIN; + return -EBUSY; vma = find_vma(hmm->mm, start); if (vma == NULL || (vma->vm_flags & device_vma)) @@ -1062,10 +1062,8 @@ long hmm_range_fault(struct hmm_range *range, bool block) do { /* If range is no longer valid force retry. */ - if (!range->valid) { - up_read(&hmm->mm->mmap_sem); - return -EAGAIN; - } + if (!range->valid) + return -EBUSY; vma = find_vma(hmm->mm, start); if (vma == NULL || (vma->vm_flags & device_vma)) From patchwork Wed Jul 3 22:02:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11030537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B4F314C0 for ; Wed, 3 Jul 2019 22:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F047D289BE for ; Wed, 3 Jul 2019 22:02:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44E028A02; Wed, 3 Jul 2019 22:02:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EC6E289BE for ; Wed, 3 Jul 2019 22:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C3B08E0027; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1F5F88E0028; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 046198E0021; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id AEB048E0027 for ; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id u21so2280229pfn.15 for ; Wed, 03 Jul 2019 15:02:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/hemVxgPEOdbiVtqmrJ7Pu3HACPpqgUeF/rrQJ8zMho=; b=YjkjgEneX+ynAfz12jz6RZe8sSFH8UMAd4NXYa7VixUgKt1WJDmSgq+UxYtrlhR8EV DadQv7qwV3NpHQH6aitgLE0QLq+zyIoPIoscbGEhbPvRe91IjTTpTN02qmkY8taf0D9c JevznMLVjrihgj4mI3QeSr6xzQ+39RnQA1qDFiQyIbJz9SbocItWpXQBEpjhGdoN/u5t lUySS2jyZ6og7b8MxzZj6EPVlw2KyhhhKYCv6I56WZRgPM12GbeNqwk+hR4WtMDMvqeQ DrDUE0qh38XhQwHv+OD7ir8iLB5XxFdbJNKqCko8AeE8bSYr3F/3kigcfi2IN42Q9H5Y 3o1Q== X-Gm-Message-State: APjAAAXX70n8IUrkLkbrMoGVRlJTc3hLjQBDTkt4uFjpYdVwtotyyBAw pJ/AuhCKi0yMw8tgs5zT7Bbt1nvAlxVeY2Yo76pkVQV3d2axotxFYSSc2T1POMxhcJVG+KPoZzN ze4eZXXvWNI803ciMCAgQRVLOmPe9Xrq7yt1FQfzbIms1b0TREBLHCyY85jaQNSg= X-Received: by 2002:a63:3046:: with SMTP id w67mr8384242pgw.37.1562191341285; Wed, 03 Jul 2019 15:02:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4PpdS6QoQMty5PL09VSUK/dwAqvxA0lfe69kf8RnAzQn5WFwLZJrHGMTRzGRTNjIsbSeW X-Received: by 2002:a63:3046:: with SMTP id w67mr8384104pgw.37.1562191339441; Wed, 03 Jul 2019 15:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562191339; cv=none; d=google.com; s=arc-20160816; b=i/V9zxVD4lPhVwbpGTh97gfKzJk6bGODz6hyuSsN3mw44fh3YgyrpsZKE0fD8eJfna Leve3xmX9yTCocBKo4FQrXMQN41bQyWN5YRcuNqbmKyvOv1W7bs6EcntvwElgFv8rE0T pMe2+fWWyus4zreIJvI9zwkOpy3Q1KQ1FauiEVa7tcX5kr15g1Zp0Sr43YwWPRCkK9fa DJxgYMJ+AGFKd7HGf336ITKtF8m3fNpvCbCYyplIC5/Yb7/sEUqDzOLjzZo3ZBrmGrSz ihg3VohnRxT9qRLSrvu98mohhXg8oKDOBFqbEJjO1Bgv/sw4DQhuBx9SA4cmRguYSueG Rw+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=/hemVxgPEOdbiVtqmrJ7Pu3HACPpqgUeF/rrQJ8zMho=; b=lTAnX3CFbxsxjmm40L1Ri7zrkeS/CdUjkSoxYkjMKXRqXOL/ijD2SKXmryUzZBQ/oh uSyqnanCzwUCFhqUZKrOPa3mEVoDvSAA9lSi5oarbHuOo/jtfFlSXQw1ZnF2S5UZiAgO +Bn7ZD3JhBQ7KpdzyO6Jya/D49ciMUdjNXZJCmPXvORfI8Htr0LGOGMeruK7VjNhNs4S zltzEOW5tnFTjYcZu/pweoSN8N+SNPONrfEjaQN3ernEMyWh2V+BfLaS6vCnMSsKqyju 4nGhLMBBJZ8DzlY0YDFhYPwwVVtGUuMbtYc6zSXC5Fhf7MwvS9BRxTTLgQ5KF2H35u/D GU0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Kkz67VFi; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id u192si3494941pgb.77.2019.07.03.15.02.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 15:02:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Kkz67VFi; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/hemVxgPEOdbiVtqmrJ7Pu3HACPpqgUeF/rrQJ8zMho=; b=Kkz67VFiEYQBRKNbXzQ6Ojm7Ri OcwpoDV/CsFrwaqGuhBbSPNg3mkKTGK3IBm4+RL/EUwlT0NR3dRRgi/wPRUKHT9sxRXcnmpRyRMwf m6MHJce1FU7Shn767N08Sk0B9F/mSAOHWhU6/7GIcuZm/DWc1kgge97CFqvxLueX1nexjJfh2RFvu Gs6UiDeiyfwXE/5jyQ+mVDkX0Cgeidpr53Uwx7wASNMlwTwo61RQBiZYib9OefWnsuFa4yw4ZR+dS jGCf81A/6pWNFN7na5WjJOH3ajeY3WvYZLe26FCPeDdEc0pyG2G39NSjTPRsO5OI7H1G9xOMn0fIR 3b9pwbVA==; Received: from rap-us.hgst.com ([199.255.44.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hinKS-0004EV-0U; Wed, 03 Jul 2019 22:02:16 +0000 From: Christoph Hellwig To: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] mm: move hmm_vma_range_done and hmm_vma_fault to nouveau Date: Wed, 3 Jul 2019 15:02:10 -0700 Message-Id: <20190703220214.28319-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703220214.28319-1-hch@lst.de> References: <20190703220214.28319-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP These two functions are marked as a legacy APIs to get rid of, but seem to suit the current nouveau flow. Move it to the only user in preparation for fixing a locking bug involving caller and callee. All comments referring to the old API have been removed as this now is a driver private helper. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_svm.c | 52 +++++++++++++++++++++- include/linux/hmm.h | 63 --------------------------- 2 files changed, 50 insertions(+), 65 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 8c92374afcf2..033a9241a14a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -36,6 +36,13 @@ #include #include +/* + * When waiting for mmu notifiers we need some kind of time out otherwise we + * could potentialy wait for ever, 1000ms ie 1s sounds like a long time to + * wait already. + */ +#define NOUVEAU_RANGE_FAULT_TIMEOUT 1000 + struct nouveau_svm { struct nouveau_drm *drm; struct mutex mutex; @@ -475,6 +482,47 @@ nouveau_svm_fault_cache(struct nouveau_svm *svm, fault->inst, fault->addr, fault->access); } +static inline bool nouveau_range_done(struct hmm_range *range) +{ + bool ret = hmm_range_valid(range); + + hmm_range_unregister(range); + return ret; +} + +static int +nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range, + bool block) +{ + long ret; + + range->default_flags = 0; + range->pfn_flags_mask = -1UL; + + ret = hmm_range_register(range, mirror, + range->start, range->end, + PAGE_SHIFT); + if (ret) + return (int)ret; + + if (!hmm_range_wait_until_valid(range, NOUVEAU_RANGE_FAULT_TIMEOUT)) { + up_read(&range->vma->vm_mm->mmap_sem); + return -EAGAIN; + } + + ret = hmm_range_fault(range, block); + if (ret <= 0) { + if (ret == -EBUSY || !ret) { + up_read(&range->vma->vm_mm->mmap_sem); + ret = -EBUSY; + } else if (ret == -EAGAIN) + ret = -EBUSY; + hmm_range_unregister(range); + return ret; + } + return 0; +} + static int nouveau_svm_fault(struct nvif_notify *notify) { @@ -649,10 +697,10 @@ nouveau_svm_fault(struct nvif_notify *notify) range.values = nouveau_svm_pfn_values; range.pfn_shift = NVIF_VMM_PFNMAP_V0_ADDR_SHIFT; again: - ret = hmm_vma_fault(&svmm->mirror, &range, true); + ret = nouveau_range_fault(&svmm->mirror, &range, true); if (ret == 0) { mutex_lock(&svmm->mutex); - if (!hmm_vma_range_done(&range)) { + if (!nouveau_range_done(&range)) { mutex_unlock(&svmm->mutex); goto again; } diff --git a/include/linux/hmm.h b/include/linux/hmm.h index b8a08b2a10ca..fa43a9f53833 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -475,69 +475,6 @@ long hmm_range_dma_unmap(struct hmm_range *range, dma_addr_t *daddrs, bool dirty); -/* - * HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range - * - * When waiting for mmu notifiers we need some kind of time out otherwise we - * could potentialy wait for ever, 1000ms ie 1s sounds like a long time to - * wait already. - */ -#define HMM_RANGE_DEFAULT_TIMEOUT 1000 - -/* This is a temporary helper to avoid merge conflict between trees. */ -static inline bool hmm_vma_range_done(struct hmm_range *range) -{ - bool ret = hmm_range_valid(range); - - hmm_range_unregister(range); - return ret; -} - -/* This is a temporary helper to avoid merge conflict between trees. */ -static inline int hmm_vma_fault(struct hmm_mirror *mirror, - struct hmm_range *range, bool block) -{ - long ret; - - /* - * With the old API the driver must set each individual entries with - * the requested flags (valid, write, ...). So here we set the mask to - * keep intact the entries provided by the driver and zero out the - * default_flags. - */ - range->default_flags = 0; - range->pfn_flags_mask = -1UL; - - ret = hmm_range_register(range, mirror, - range->start, range->end, - PAGE_SHIFT); - if (ret) - return (int)ret; - - if (!hmm_range_wait_until_valid(range, HMM_RANGE_DEFAULT_TIMEOUT)) { - /* - * The mmap_sem was taken by driver we release it here and - * returns -EAGAIN which correspond to mmap_sem have been - * drop in the old API. - */ - up_read(&range->vma->vm_mm->mmap_sem); - return -EAGAIN; - } - - ret = hmm_range_fault(range, block); - if (ret <= 0) { - if (ret == -EBUSY || !ret) { - /* Same as above, drop mmap_sem to match old API. */ - up_read(&range->vma->vm_mm->mmap_sem); - ret = -EBUSY; - } else if (ret == -EAGAIN) - ret = -EBUSY; - hmm_range_unregister(range); - return ret; - } - return 0; -} - /* Below are for HMM internal use only! Not to be used by device driver! */ static inline void hmm_mm_init(struct mm_struct *mm) { From patchwork Wed Jul 3 22:02:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11030533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40301138D for ; Wed, 3 Jul 2019 22:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31681289B8 for ; Wed, 3 Jul 2019 22:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25631289CE; Wed, 3 Jul 2019 22:02:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEF79289B8 for ; Wed, 3 Jul 2019 22:02:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAA118E0024; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E7C98E0028; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 611DD8E0024; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id EC9BE8E0024 for ; Wed, 3 Jul 2019 18:02:20 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id y9so2057895plp.12 for ; Wed, 03 Jul 2019 15:02:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aR5JFpbAtZwK/e60Yd9Huxe2JebEBXUD/VqFe6j363c=; b=XZFa12Hx53ulJQdXoL0wPB0WxbhFHdy47XM/nSVbVeR+dmgzi718oixu4ea6DcVGi4 zw6VA/ECnoRPGfUGG1EmmtVJDcnr8lCY/zEKYouMHy0TCGeFk991EEq2N4vOpg62Yr79 0p7+7HJ5+WnGskaYUUiGGYlBfVJJ27v/bR24i7Qy7arE4sjjBZiopJosRUYpHPMoDq55 o9gZuhJiptR5rxcaroUQkbRBh3OBZkA5IKFfKrpyyChEaZAGhAl3ZiCFf/rGvAV4uMIc gwwLVIeRhHV7y11Yt5IuxrzoUXKqu4nGBh0Lt0X9kckW+X/Qpd/nF9xkwmuZ6IfQCwfq j2xg== X-Gm-Message-State: APjAAAVadZqyjxro2vamha98LmAYNDid3HpvxUn9yIjBBHKT2/eWXpxj URaw843IS3Z3e4z8hGMtsHYZRVkSUTybxUyQBhdx6c/TI4CWNROGjGa/Yh2EoTsae72spquaAeP NHj7A01mX75yTj0xhrfPGwVbzK00fgj58Tf7gbrzmbRnofH35YfAtUb/yvWoKbW4= X-Received: by 2002:a17:90a:3210:: with SMTP id k16mr14845573pjb.13.1562191340581; Wed, 03 Jul 2019 15:02:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjDAIjSlRPyV7WLErP4aHx1Y+tUi4eXw4ts1XlTlmu2LZoboXApLh/BB4/dUgyTX3CBzx5 X-Received: by 2002:a17:90a:3210:: with SMTP id k16mr14845487pjb.13.1562191339440; Wed, 03 Jul 2019 15:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562191339; cv=none; d=google.com; s=arc-20160816; b=SfKYfY+4U/Hg7Gy8XHw/YF0oQXhkVeEtbbUKQR6AXeF61+3CrL6sX16kdRry3lLOvD Ml69efVJfWo5qfWPxLAu2pH4uQ8YkUo6l7ySB3CqGXuGZjqLc9cjNqNZBqpHhEKLfljg YGn4OJsmM0dlZp6rjZYlOQ5n9EDSDUPAIKtngAbekBRt+5mVSp1IzD3cNACDCoP/80HG voM7sXtXwE1PCsz3eAy8IhaMG81/qisVdxIalDtw5jDnhym9YXTQL2vg8Sr3vzh1Ly3P p85SUS/GGzQfyDMtYa6yD7UnADTrOUMBOKO++rlIo1b0jSDvx4yiOdzbAXyLWhGlhQp/ CF2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=aR5JFpbAtZwK/e60Yd9Huxe2JebEBXUD/VqFe6j363c=; b=FJhrlBuKhuHaxcN3HXkBK22y2axUD5zPQ9K2TuI55mOml9RTLjjZdmInWJ9YN3buyX iFw3dvvlNJKDIGbZ/WM0gL1kje32GOYhzVq/Fqm8k9KVvFj7jvMOnJggW3mtFADxGMpv zARgwSDFdP34xSAqkRRsy49z6MONzFrmIS5/dVL/1PP4ie5fVMSYBZOkldQbyKtVJJX9 MQg4GRvSWXXRXef0j+kkA7cpbDsi4rVmcFw4ESMevTp5bYygBom0udkZ1jjjhQpgdsLH 2Tu3SpV1Mlc5XnFbkWlnIQNFai3y5eidjYJnB8Hw3MO80/00cHk4mqxSL/RlMAXtvHEu KWPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=OpDvh8ug; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id s24si3376848pga.515.2019.07.03.15.02.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 15:02:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=OpDvh8ug; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=aR5JFpbAtZwK/e60Yd9Huxe2JebEBXUD/VqFe6j363c=; b=OpDvh8ugx9CCqIn6z/3y1udmC9 KVHOJ4bsImzFgtZfExFnufvlaVFq0giHc/vuAIxKY0IiLV8hawN4olAqJfcL1gDdEfW57uyU5nj5l x3GGSB43dDPINYm/NEWoe96PFuvG+2P/z1Fr7axSCD8q98G6fn0/H5jngAe4xoO/Hqe9fnlPDrQYK maGsjZPeEo6lxfX+g7EBD2wrEI05R7gGH9G0i/0CFtnM1uTTiOFnW1vZT+aE3Q3gNb/qwMOnPVVa+ tpRen6TJqloiQxgbHEfAFv64GJOvH3Z05gcv5LDRyQ7BCWPwdBTu1oVT9mXca+ZqiZNiHRN1JiAaF aEarK4YQ==; Received: from rap-us.hgst.com ([199.255.44.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hinKS-0004Ec-6y; Wed, 03 Jul 2019 22:02:16 +0000 From: Christoph Hellwig To: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] nouveau: remove the block parameter to nouveau_range_fault Date: Wed, 3 Jul 2019 15:02:11 -0700 Message-Id: <20190703220214.28319-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703220214.28319-1-hch@lst.de> References: <20190703220214.28319-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The parameter is always false, so remove it as well as the -EAGAIN handling that can only happen for the non-blocking case. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_svm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 033a9241a14a..9a9f71e4be29 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -491,8 +491,7 @@ static inline bool nouveau_range_done(struct hmm_range *range) } static int -nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range, - bool block) +nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range) { long ret; @@ -510,7 +509,7 @@ nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range, return -EAGAIN; } - ret = hmm_range_fault(range, block); + ret = hmm_range_fault(range, true); if (ret <= 0) { if (ret == -EBUSY || !ret) { up_read(&range->vma->vm_mm->mmap_sem); @@ -697,7 +696,7 @@ nouveau_svm_fault(struct nvif_notify *notify) range.values = nouveau_svm_pfn_values; range.pfn_shift = NVIF_VMM_PFNMAP_V0_ADDR_SHIFT; again: - ret = nouveau_range_fault(&svmm->mirror, &range, true); + ret = nouveau_range_fault(&svmm->mirror, &range); if (ret == 0) { mutex_lock(&svmm->mutex); if (!nouveau_range_done(&range)) { From patchwork Wed Jul 3 22:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11030539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 986C3138D for ; Wed, 3 Jul 2019 22:02:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B4D289BE for ; Wed, 3 Jul 2019 22:02:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DBD228A02; Wed, 3 Jul 2019 22:02:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09056289BE for ; Wed, 3 Jul 2019 22:02:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACD9C8E0028; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A56EC8E0021; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D1C08E0028; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 339638E0021 for ; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id x10so2271463pfa.23 for ; Wed, 03 Jul 2019 15:02:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TH7ilSpN+2j82AKqVSfBr/e3/+W2L5xJvYOO3yTY4Is=; b=lq1EQD1R+kqBXveL7zE+M6ml+G5QhPN4ZAdhqL+HRwJt4izxMXCWP2QSZ0qunCMIl1 dtsvmBKlrj4rQ5HP5CvKmBukaKGbLbVRQ9rWKsgZflUH5hHK5RdngAOI4b1FUvN/thJQ p3qYsT1EDtM9p1bhFCCgBnEeme1XcLmFlRRP8hySTY44d5yVpNLQuKms8YquVE4u4wUa LfDe4uKkhkOa6NmhzG6MNBA2rx4tNsbGB/rU/xGncQ6TGJ78zSqwSVu4gMIW2UDiiPU/ vbs2wRO5FR7YFB1KEz14tF4V5z0CR45ntTISTgR7ZNOPvALwnADuUipdL4DXzYAIpbJ5 GpoQ== X-Gm-Message-State: APjAAAXc+FmTNGrndjLZWVziYCAUvUA/v/Sq+zYaORjbjSjyspaK1P8f bCMVEipwoxwZ/oA0vtz0LxNtEKdxlcj34IdwV2b/pNMkRdUJpFsQqMM7uBNGaWl4bIDjdTIaVeT z19mrarX0W4EE2ydnCpMj8Im1fO5CaAAT7ix63wGXt6DtiE9j7Abe6taFtKviZeA= X-Received: by 2002:a65:5b4b:: with SMTP id y11mr38563815pgr.244.1562191341752; Wed, 03 Jul 2019 15:02:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKhvZlf7+sQa7s5LDZzgWkSGbPWK8dh3W0+a7S7lw20Z59rl40tOtzFAgJp2052ZqdVmv/ X-Received: by 2002:a65:5b4b:: with SMTP id y11mr38563766pgr.244.1562191340899; Wed, 03 Jul 2019 15:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562191340; cv=none; d=google.com; s=arc-20160816; b=tAkWOrnizNGJipP3FCe/t6mtTArO7Kan0za/ES7YsQJ1f18YAyqNhB9NLrejJSc4Qu PeMzkyBhTKTfdbctGrtAQ5lJi4u7nJVSLAYieUWk43B0jf6v9txK+ePvsz8EqdiXtbPx 9hKd14UyHau8/4c7hcLCNx59K29VmXTX2TXPsg3zLeWuICivpB7oWXa30+QemTybBnD9 6m6LUcSkiCPADGD6z/b6ATpYiGEmMGJECmvCqiEM8a2xbSFUxuYl3ZCoT13DjyXYjnhj PpfoNMlK0ViYH8kZPruhQSN9TryMKwpOdR852lzzm/awckPGJ+EdFxCdXfZQStISkLCl vr9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=TH7ilSpN+2j82AKqVSfBr/e3/+W2L5xJvYOO3yTY4Is=; b=I+JJ1NMXJMP1n50ui5ugUe6SiKl4hHY66pHatmTWytI7Ty4DiAgemBWk0HHm1By5zf +C4aLFdJc+atetWB+ahbiwKxSgr9qlb9nsCbFO3JxqgUXtgAkYHZCCLsfAzOT/TJ88Pr foclHR6Gx9De9kUmrYxXmb4ds+gReR/QIBcAfIkJaEFHYVa3/DEJ1d3+wYZscNb7W+FG PxxQqzGewPYzdindSXH1SEP31MqeP8mmWoI0UKuwGb36+n1NhB3sZRYU91KaH6aNLy8w PnfG65mBeo2dQni/o6wulFeHOLQ5SwD41m0SwkvKiK16pPJ6KQiGCiD3Ydv51uA3cO25 K1wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QkYiGjbM; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id h61si3286360plb.256.2019.07.03.15.02.20 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 15:02:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QkYiGjbM; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TH7ilSpN+2j82AKqVSfBr/e3/+W2L5xJvYOO3yTY4Is=; b=QkYiGjbMBjTGLVROOh+GRbmRJb MyoPGFJE+6teMNn9c5SEVHNaLJh/dDNSFYCEY+IvBJKEGW9ohDBcsp6CVPN0VrZ0J7fDngCYsPSv4 CTcFISy34r27v4v0H03+M4tT46hjxR7FS9ebz/zaYpADue3mFBLXKkQiySiYo0OXMfYuIEZSyIeYM BCuxayLeVqoTiSZtVLEC80SQUqJFqA/SAdaH6UO6w3Q1gsl//cwPUe6JlfqruSzJ+jjOQ7dz9kSgZ fn9KEBBzwR+rePovn050pvLCHNfewpmtkFC8H0ZPqp/ZOMDz4QtUvPdjcKRyVJo7D+Wq8Gx7oUV5c ydw5RV1w==; Received: from rap-us.hgst.com ([199.255.44.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hinKS-0004Eh-Da; Wed, 03 Jul 2019 22:02:16 +0000 From: Christoph Hellwig To: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] nouveau: unlock mmap_sem on all errors from nouveau_range_fault Date: Wed, 3 Jul 2019 15:02:12 -0700 Message-Id: <20190703220214.28319-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703220214.28319-1-hch@lst.de> References: <20190703220214.28319-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Currently nouveau_svm_fault expects nouveau_range_fault to never unlock mmap_sem, but the latter unlocks it for a random selection of error codes. Fix this up by always unlocking mmap_sem for non-zero return values in nouveau_range_fault, and only unlocking it in the caller for successful returns. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_svm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 9a9f71e4be29..d97d862e8b7d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -501,8 +501,10 @@ nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range) ret = hmm_range_register(range, mirror, range->start, range->end, PAGE_SHIFT); - if (ret) + if (ret) { + up_read(&range->vma->vm_mm->mmap_sem); return (int)ret; + } if (!hmm_range_wait_until_valid(range, NOUVEAU_RANGE_FAULT_TIMEOUT)) { up_read(&range->vma->vm_mm->mmap_sem); @@ -511,11 +513,9 @@ nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range) ret = hmm_range_fault(range, true); if (ret <= 0) { - if (ret == -EBUSY || !ret) { - up_read(&range->vma->vm_mm->mmap_sem); - ret = -EBUSY; - } else if (ret == -EAGAIN) + if (ret == 0) ret = -EBUSY; + up_read(&range->vma->vm_mm->mmap_sem); hmm_range_unregister(range); return ret; } @@ -713,8 +713,8 @@ nouveau_svm_fault(struct nvif_notify *notify) NULL); svmm->vmm->vmm.object.client->super = false; mutex_unlock(&svmm->mutex); + up_read(&svmm->mm->mmap_sem); } - up_read(&svmm->mm->mmap_sem); /* Cancel any faults in the window whose pages didn't manage * to keep their valid bit, or stay writeable when required. From patchwork Wed Jul 3 22:02:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11030535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8579014C0 for ; Wed, 3 Jul 2019 22:02:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77AC9289B8 for ; Wed, 3 Jul 2019 22:02:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B86928A11; Wed, 3 Jul 2019 22:02:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DA88289B8 for ; Wed, 3 Jul 2019 22:02:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F8A48E0029; Wed, 3 Jul 2019 18:02:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 108CE8E0027; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D43F18E0029; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 6AD888E0021 for ; Wed, 3 Jul 2019 18:02:21 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id o16so2343128pgk.18 for ; Wed, 03 Jul 2019 15:02:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DUoOwqjnTji0F9t1TBg521OpvLvqwX3Vlrvz0Ntypso=; b=C01Tw5L1EGmiomRPoxEMqnZkIkKqlLQsY2e+z/M7xclpaq57fjXTBpNIoM2fCVUW2n MwVaktymaEk6FgFyX7CoF2tAA7ZR9LZdQgR3ssW9craVfX/OOMVLExGhATj21k71EnPH VOEbZ7WyD9Fk/TmBte0cuS242PmBRgtonJrGf0UZl76yFBm6mVuMROjRfuNi5mDpoGe4 2FvXWiUU2v7X1IDFtjkciLDGln2nBz2cCRaA8YE1IomuVL3dBINyFAl9UpbQ4vQuzu0d EYA/v89iqIGRpu/Kj78ef2ua/hLb4D7tEJg6jPOyXYS0spBDr+h/6TBtTC1KFIMoZsRA JWlg== X-Gm-Message-State: APjAAAWdhsJkRkW8aEh5dkJtOsqXxbZRuHI4fwq/i4jgntjMPjtP4ZRy t4M69PupB1IYPHXatTNV9KCVB408WWShZk9DD9U+FIJFLU8gpLSsr+/zA+iQS579U0TO/bTWUYp svTsA/zeI6WeTA12JFimeRbIWKfwuXuPWMmLIxE/T9d7cXNU5Mr5n7CKi80AsYJ0= X-Received: by 2002:a63:1b5c:: with SMTP id b28mr8663501pgm.101.1562191341016; Wed, 03 Jul 2019 15:02:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMknNJ9nP9uwIDlhXkYUnLfhH55upTS5TygGODhHDqfz3Ll+nm7filoJgVVSxY7mJdohEi X-Received: by 2002:a63:1b5c:: with SMTP id b28mr8663414pgm.101.1562191339916; Wed, 03 Jul 2019 15:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562191339; cv=none; d=google.com; s=arc-20160816; b=R7bcqjM0RvTFg3RtGVOqC/PQnEegBcGSkQ5M86nZIaD7Oh8jUdVUjm1tiboRilOYFf ROqyQMH/JThZY71gCbJ9LH2CCXbGDn1jD/AujYR3gb9r7ez4y1gdRHhfx2ia9jrbi7E2 I/N4FXNMDZzfJA6swxQGvEQ9c99W275BB+uAdpALeLJcIB5QLhpHzMThR6gd5SiOcWpM DJLA4QzitGtODMP5mELiQs8Pmvq6/D2wgO9QeRO+GJ1DagCKFA2pJKZ0uzY/DTFGFqBa 9XQ9065BSszW+GaVztO5XIKKSM8Mfu4WyovOiaB7ELB0iP3TLTOo0tcnLZpT/A35h1Sy kMLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=DUoOwqjnTji0F9t1TBg521OpvLvqwX3Vlrvz0Ntypso=; b=mvbYPiMthl96Jkx7xqkS+rfabjTBJtai6pKXe1nLxewDLHbm+OUSwfgNJSGRJFOkRk RhUJ9WTu9EfppFKOl0shwavEZQywUNhcBXSmEyd8M5SNeE/sK43Kxlp4ZKRejHYdVbiI k9H4IxmnBM8G1nB2xLw5YTF7sgykAksqREHL6HHmX3iWTXenbEMEebkOuT+KlN1+Pfse Es1vShF0WDl16UQFrj/6vZ8fxuPERPslfn20f8uFxN7lv8LA/JlCoc/QvELu2kX7y1+t m/ouSAB6DcJ1fWT4u2aiVNttFFzOIzN9WKd6SdrhGgS6FPk9CK1tn1GLlxBvb0Y92K/i 871Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=efDzZwBe; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id u38si3370371pgn.79.2019.07.03.15.02.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 15:02:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=efDzZwBe; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DUoOwqjnTji0F9t1TBg521OpvLvqwX3Vlrvz0Ntypso=; b=efDzZwBeFkuXGAumAQiTxGRxkt 7D+YalkdI4VpAhWfDiCr5acuRvXk3B2P6XcIKBXGzEPBierDhh0ydQYTRtK5O3oYNgb0CXsCluMgO z+4eQkFrCU1ogAFWQxXUO2itnHdgd5PstKF1fjC/mYhkALtlWktGH2LwfMkR3X+J+Iw2eeduXoBiZ TEUf3el0yJeHxkqoV3zcOygMbjfNtIkcYb7c/dNlmPWjVJG+bE00JuSW1bMeOcQZS+bZRWiWATVGf UdIM1NJZPbkyv3mt3mrXrTmNhpRloE/IABs8wxj3gLRGIvAGR1uw8u+PcvwC2w+8wtER9Birgc/wh KZgk5nNw==; Received: from rap-us.hgst.com ([199.255.44.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hinKS-0004Ek-JE; Wed, 03 Jul 2019 22:02:16 +0000 From: Christoph Hellwig To: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] nouveau: return -EBUSY when hmm_range_wait_until_valid fails Date: Wed, 3 Jul 2019 15:02:13 -0700 Message-Id: <20190703220214.28319-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703220214.28319-1-hch@lst.de> References: <20190703220214.28319-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP -EAGAIN has a magic meaning for non-blocking faults, so don't overload it. Given that the caller doesn't check for specific error codes this change is purely cosmetic. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index d97d862e8b7d..26853f59b0f4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -508,7 +508,7 @@ nouveau_range_fault(struct hmm_mirror *mirror, struct hmm_range *range) if (!hmm_range_wait_until_valid(range, NOUVEAU_RANGE_FAULT_TIMEOUT)) { up_read(&range->vma->vm_mm->mmap_sem); - return -EAGAIN; + return -EBUSY; } ret = hmm_range_fault(range, true); From patchwork Wed Jul 3 22:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11030541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D390914C0 for ; Wed, 3 Jul 2019 22:02:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4C79289BE for ; Wed, 3 Jul 2019 22:02:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B92EC28A02; Wed, 3 Jul 2019 22:02:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FADF289BE for ; Wed, 3 Jul 2019 22:02:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E02E58E002A; Wed, 3 Jul 2019 18:02:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D655C8E0021; Wed, 3 Jul 2019 18:02:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6B18E002A; Wed, 3 Jul 2019 18:02:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 75BC78E0021 for ; Wed, 3 Jul 2019 18:02:27 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id q14so2289970pff.8 for ; Wed, 03 Jul 2019 15:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GmIbzmtd8tOzuQLg/EqjNzFkCAF84w76eG2p5TWzhiU=; b=UONYVAJlHaAAHsQe8ebkKnBuvLhF7uHcQdZSouY6VWiGuCZp7DsQDPPBtNnyXvTt51 wtCmG20lex1VH+9t4jeOOYbwgx2h/H4jHvSCvoPBWrY3JKibypJM8vbq4ivSPpn+YdYm n0Mb1Ql/ShP9MpZBgmpwhy7O9A5ktAHAwFF0+pbSpOCShfnmx8XbsKs65I19pFp0qAUJ ZzGfZYlQ0Eq1QJEHuYIa2JjZKdWYFwP0Y7GIoqH9gYKh2Pc8kauwP/N0KBTLw4oorutj G4xkcxYbLzPxAHVw+NKRmt8XXr01gANF4X+i4BrgoKLLHuF9R0FV85/nMGyYsG0vlWEJ KJ5A== X-Gm-Message-State: APjAAAVBJwEcGsuBRSE5xQS0D2/CR9ufNDYIXXNIwHqtY6Y/H6ZBFltI 6digvjzZyXKEy/uAzyHSxPfEOK1DS1KsPzEf32Shuv2MAJIM9ZkrJ8li+2fb1EaQ6ROyEnnzM/8 x3+fV4jrQcb0PFVgc57fAjHXV5+g4rwE+dRd8SYe5eqPTZ4AhdLCHH5+Iy+RiPu8= X-Received: by 2002:a17:90a:7d04:: with SMTP id g4mr15523698pjl.41.1562191346696; Wed, 03 Jul 2019 15:02:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh5F8dQnlqos1N1PT5AQ7oHRQZT0ns5THkbTPBE/hvFz1cq+z0Nu8B+Pkt2JBVW4qFLdy9 X-Received: by 2002:a17:90a:7d04:: with SMTP id g4mr15523614pjl.41.1562191345505; Wed, 03 Jul 2019 15:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562191345; cv=none; d=google.com; s=arc-20160816; b=ee4GKI5lfi7610K6hUqGkf4ck4eUzUoIhLBNxPUyo+UO+bTJ39BO1q7BWzyBHkTc03 p5mndZP11Tnm666Ifyc96uqqbeEIJglmV9+goaZ7L1emb7A6La7Zo+jyV3zzFNz5gVOa vZdMWCHwNluEc1K6t4FuYrFSN9+2H/YoY7KiHGKdSJpC+bfyogprldAnWptxgmlsLlKO sFjtoS4r0psGHwnQNdI/nlNnlFjM6t3ZcJnjFHR/RyPEU0ZspA4370x49VolJwi4+suw kB57dr49/5wYl07tE2YeFR/TG+rLhLANeYgUNwrOr3GsTbpZFnoNW8GopmX5XgyUfFQw dMQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=GmIbzmtd8tOzuQLg/EqjNzFkCAF84w76eG2p5TWzhiU=; b=DsJeySR+Q45ioCdKMQNsy41KPgqyV/lvwp/exFiVJyLYU8Yww3LZCR4ihlAur3Riq5 18sxGxMJgACHD6CcGFnWELjg0Ut2oDGyNzqWxvAWvV/erhOc+ZJOHoJW6R4lEspcxjqc sHulgkk2CaQqab412Yqtjc7rvoI2kQLqcmzVNsZzUI7AmBrzcCCfqy50hdq3Lo4Q7MK4 xZDGhLY6rDdah/xT2RZD+CrgerNUz7HdQWQ7TaQAVcNXtvIVfdVYt6I2WYAMmW2Uk1EK qqnpIJ9esm6H+MxYiY622kXUonrIvMxXNqv3/XQ9TsTdi+cCaIpqnRlQy/iLO/EBI7z0 Zs5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=rntZ06uU; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id w18si3754812pgi.37.2019.07.03.15.02.25 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 15:02:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=rntZ06uU; spf=pass (google.com: best guess record for domain of batv+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+f19a2f3755a5a2fb7ec3+5792+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GmIbzmtd8tOzuQLg/EqjNzFkCAF84w76eG2p5TWzhiU=; b=rntZ06uUlfg/5V+8FahH4VKRve 0MTWu0xf0b1aqm0wYAYPxxooNt2SSuQ4vvjpnEEOS5h9gKLJ3rgNyZ5EJcPK3FjtJHY4t0WVemkdA y3sGrURy8SD/wfZyHPlvdc4Y0rB7DCzAbOMjatokw8rBtMyajtZFa8eUdnBzSIFtpGf0TICahDuUb Ua5BOTAsjHhBLjVqtdRVsqi5KqQR1r9mDEVMh70w7Ycs+P/S+rHEY+JhB3PREIVP/hBdt+xg9WWli 52ZJ6E8O3cpcXHKds0bFgglaJbptoQ5a1RVSGE8FFl75HsRneFOQTkbkPoPjNF808QquF6LjNNhKV Rj9RIUZw==; Received: from rap-us.hgst.com ([199.255.44.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hinKS-0004Er-Pp; Wed, 03 Jul 2019 22:02:16 +0000 From: Christoph Hellwig To: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] mm: remove the legacy hmm_pfn_* APIs Date: Wed, 3 Jul 2019 15:02:14 -0700 Message-Id: <20190703220214.28319-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703220214.28319-1-hch@lst.de> References: <20190703220214.28319-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Switch the one remaining user in nouveau over to its replacement, and remove all the wrappers. Signed-off-by: Christoph Hellwig Reviewed-by: Ralph Campbell Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- include/linux/hmm.h | 34 -------------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index 42c026010938..b9ced2e61667 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -844,7 +844,7 @@ nouveau_dmem_convert_pfn(struct nouveau_drm *drm, struct page *page; uint64_t addr; - page = hmm_pfn_to_page(range, range->pfns[i]); + page = hmm_device_entry_to_page(range, range->pfns[i]); if (page == NULL) continue; diff --git a/include/linux/hmm.h b/include/linux/hmm.h index fa43a9f53833..bf641bbecc7e 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -290,40 +290,6 @@ static inline uint64_t hmm_device_entry_from_pfn(const struct hmm_range *range, range->flags[HMM_PFN_VALID]; } -/* - * Old API: - * hmm_pfn_to_page() - * hmm_pfn_to_pfn() - * hmm_pfn_from_page() - * hmm_pfn_from_pfn() - * - * This are the OLD API please use new API, it is here to avoid cross-tree - * merge painfullness ie we convert things to new API in stages. - */ -static inline struct page *hmm_pfn_to_page(const struct hmm_range *range, - uint64_t pfn) -{ - return hmm_device_entry_to_page(range, pfn); -} - -static inline unsigned long hmm_pfn_to_pfn(const struct hmm_range *range, - uint64_t pfn) -{ - return hmm_device_entry_to_pfn(range, pfn); -} - -static inline uint64_t hmm_pfn_from_page(const struct hmm_range *range, - struct page *page) -{ - return hmm_device_entry_from_page(range, page); -} - -static inline uint64_t hmm_pfn_from_pfn(const struct hmm_range *range, - unsigned long pfn) -{ - return hmm_device_entry_from_pfn(range, pfn); -} - /* * Mirroring: how to synchronize device page table with CPU page table. *