Received: by 10.223.176.5 with SMTP id f5csp1989342wra; Sun, 4 Feb 2018 17:33:49 -0800 (PST) X-Google-Smtp-Source: AH8x227or5LZ2iigdTUJoQVHn1GW4MKbDO6pTaqQyhtwRnOiH7KhtMOvk8AHo6O5kIXULguwRrT8 X-Received: by 10.101.66.193 with SMTP id l1mr36710878pgp.17.1517794429013; Sun, 04 Feb 2018 17:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517794428; cv=none; d=google.com; s=arc-20160816; b=p97vEYn1zX7q1Bf77lzEY19XQo7rrpvw8GzblneLTRRSlZywthje0koXvyUSduz433 Wvj+AaTTJSS7DWzQYEbyDwxYCnfJC0Ei5j+yftY7GcuZ4F5a0A0ZAmOyrJ1tU7NiZ0K8 3tFnTfrGCW/gTymqiiUxfPa5NEmWptDfarkXtgJRtZjYjMZV9yr8LGRC0hLpdYrDmUpe mbOAIogOiY4hX0opijYqn4K8OgRCre8JqjoEd58u7s4jeolRBfQcKj1VJ37PKBvqPoVk c35es4CYgKGZaTZyExsqPAxIbDw7nZYeeSfERcchTeox+gSv47jf3zEVb59nwhMtPxHO HJPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=xQwcuhLD1kAGwYY/lHCZbMyQ+FobW3CwpedjB8x5Y4s=; b=TrCuJWDE5pENeJzsdumVAYT/bC5N5mtYypcz5R4FmdAgGFPs51TkygML/mIWjInKnq pdObV9QPKy0JDvcinOzGrtqLgvwMMFgAaROp/bQyjKMBb26l7UkhKyM9FCeDLo+U0G3M fS+wMvle1pB8dU5p6nnZOVBiKmHqDdrL569VBoFSEPPIC9Sn7NwZtRwXQPQlOJp3Y4pN +uzIFQjbzp3CyhVpMrdZql8CH/thOcnYVTAUA0F4vs1xle3cTkwRHLqNha+uOQG53zH8 b2YAua7wECHT1LmFWt2EkWdNUIIgTSxdJIkoYuS8oO0RZXPV8aVRChEXP9SsaJQYBaXJ Ns7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si5982502pla.156.2018.02.04.17.33.34; Sun, 04 Feb 2018 17:33:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbeBEBcz (ORCPT + 99 others); Sun, 4 Feb 2018 20:32:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:43456 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752793AbeBEB3X (ORCPT ); Sun, 4 Feb 2018 20:29:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A094EAE1E; Mon, 5 Feb 2018 01:28:01 +0000 (UTC) From: Davidlohr Bueso To: akpm@linux-foundation.org, mingo@kernel.org Cc: peterz@infradead.org, ldufour@linux.vnet.ibm.com, jack@suse.cz, mhocko@kernel.org, kirill.shutemov@linux.intel.com, mawilcox@microsoft.com, mgorman@techsingularity.net, dave@stgolabs.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 52/64] arch/openrisc: use mm locking wrappers Date: Mon, 5 Feb 2018 02:27:42 +0100 Message-Id: <20180205012754.23615-53-dbueso@wotan.suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180205012754.23615-1-dbueso@wotan.suse.de> References: <20180205012754.23615-1-dbueso@wotan.suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davidlohr Bueso This becomes quite straightforward with the mmrange in place. Signed-off-by: Davidlohr Bueso --- arch/openrisc/kernel/dma.c | 6 ++++-- arch/openrisc/mm/fault.c | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c index a945f00011b4..9fee5388f647 100644 --- a/arch/openrisc/kernel/dma.c +++ b/arch/openrisc/kernel/dma.c @@ -87,6 +87,7 @@ or1k_dma_alloc(struct device *dev, size_t size, { unsigned long va; void *page; + DEFINE_RANGE_LOCK_FULL(mmrange); struct mm_walk walk = { .pte_entry = page_set_nocache, .mm = &init_mm @@ -106,7 +107,7 @@ or1k_dma_alloc(struct device *dev, size_t size, * We need to iterate through the pages, clearing the dcache for * them and setting the cache-inhibit bit. */ - if (walk_page_range(va, va + size, &walk)) { + if (walk_page_range(va, va + size, &walk, &mmrange)) { free_pages_exact(page, size); return NULL; } @@ -120,6 +121,7 @@ or1k_dma_free(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, unsigned long attrs) { unsigned long va = (unsigned long)vaddr; + DEFINE_RANGE_LOCK_FULL(mmrange); struct mm_walk walk = { .pte_entry = page_clear_nocache, .mm = &init_mm @@ -127,7 +129,7 @@ or1k_dma_free(struct device *dev, size_t size, void *vaddr, if ((attrs & DMA_ATTR_NON_CONSISTENT) == 0) { /* walk_page_range shouldn't be able to fail here */ - WARN_ON(walk_page_range(va, va + size, &walk)); + WARN_ON(walk_page_range(va, va + size, &walk, &mmrange)); } free_pages_exact(vaddr, size); diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c index 75ddb1e8e7e7..81f6d509bf64 100644 --- a/arch/openrisc/mm/fault.c +++ b/arch/openrisc/mm/fault.c @@ -109,7 +109,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, goto no_context; retry: - down_read(&mm->mmap_sem); + mm_read_lock(mm, &mmrange); vma = find_vma(mm, address); if (!vma) @@ -198,7 +198,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, } } - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); return; /* @@ -207,7 +207,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, */ bad_area: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); bad_area_nosemaphore: @@ -270,14 +270,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, __asm__ __volatile__("l.nop 42"); __asm__ __volatile__("l.nop 1"); - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); if (!user_mode(regs)) goto no_context; pagefault_out_of_memory(); return; do_sigbus: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); /* * Send a sigbus, regardless of whether we were in kernel -- 2.13.6