Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp425461imm; Tue, 3 Jul 2018 22:54:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/3YtkghACg9VVcYnU98UUSKcZw2LXujd46k3R/UannzBmm+IkERBrtPuq1nmQrJ474Xof X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr702849plg.135.1530683659691; Tue, 03 Jul 2018 22:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530683659; cv=none; d=google.com; s=arc-20160816; b=Rn3zv/ADXIg3B9D3qZlwAkfElpD7QCN5BFGaCMUXFuQLzIvGoDrQZI4b9VldDkquwT 8Qo29zP1M3wtgmp18mj8hu0pO7i+veTmAywI/+xD2Xm9mfP8Q3m4MMCvkAD2LhIFDLOJ CeDumq4tGLC+AvzdDhC5hrrTebRtDrUTBl3TU0Wp3J9OvxOW/7gcsa0ieHRLk17gZNih 6jz0rXFgVNfPBoCB8EjOUs5UW4LFPcVMVselrpi1NV4Q4oM/V9aWhozbZoUwCp3SWrsM nt/SVMJ7GFYGd35RZdrg0z8coUvsJxsbiacQ6ihDHzPjhW571HbfEMO63snxH4qh+4wC ak5Q== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ArxOyo6y2ooTiTS+NhWk/y+UgObtaihypFiwhUx48FM=; b=GVrVDXjXe6lw4BD0rkEyC0tNBTs2oEUudKT+J4Qo0IRO4pxlBl5fDl98LqIQb77tzI jj4SKmjHOV/oR8Wb0SWD1XjVF4m/S87zkdj6zfxyGqV//pUSiWvP0XmtqCM5e3G/f76X 89611DQ8uPMw9YPwyxwaGrHOh5gJc2HcdGqxLoV35H6r88MkdKB/aljc90ui+CWnzMoW 9Xk2HDwu3S8oQh76SqnPbn7QJ4x0X0gqJVz4Ks1lhGlReEHsx8eQuLxodztnKz6lqW/u 6yO0ZEwpay0YPmOaojhm4dtZIZOXbTep/B5a1fN+Zumlp7rMQb/KgkLOcnsRXQoTlrT5 1LxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OBppGlvW; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si2754451pla.288.2018.07.03.22.53.51; Tue, 03 Jul 2018 22:54:19 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OBppGlvW; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933370AbeGDFwp (ORCPT + 99 others); Wed, 4 Jul 2018 01:52:45 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38018 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbeGDFwj (ORCPT ); Wed, 4 Jul 2018 01:52:39 -0400 Received: by mail-pf0-f196.google.com with SMTP id j17-v6so2123681pfn.5 for ; Tue, 03 Jul 2018 22:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ArxOyo6y2ooTiTS+NhWk/y+UgObtaihypFiwhUx48FM=; b=OBppGlvWnlKOYZqvrZNfyZG/zRm7SjkLgxGyj0S7KTUueROqU8YRvduHD45sWNO8wa 3CAAqqLXQsN2LStudxb2yPtQWdksS4hI32YbP5RU2tBX0wUQiJj2n/XFaV/rrZrpbmKZ c2jiD4VAdBt6423xyk6lRyOurSDr3m0kW+uTMU0dTHx4Osz2y5izg1lqdw5d+DboUjqV mJnED3qjwv5Bqe0jptDOvskOG1fw81H3bBDwF7mMnVpOn9UxPSQjkt5MeK6Aut8YTD5L Ykw6PG1mHfpRR/0WUxz94EWb211nqBOM/ChspsCIhoN9ib96ToQT2+R9Xj6yju0gd2f5 Hd7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ArxOyo6y2ooTiTS+NhWk/y+UgObtaihypFiwhUx48FM=; b=tFjOjgWdrka9vBNcyqZV/85BVg8UU0DINQoHDjQDZN19wD6ORa19NbrBKPsrnK80Uf Ac6br/4X2eCUpDPGXqzkIT9NyDZOBE2KkzcGijU9l+8cyS7TzzWVNAjDZqkscjXbrDsR jc2yrOzvXr6LaZS0HdgWdbOzSgDK91vdRbdZ3UH+YMJy2fs72++TF3mxk7UJEP7Kqjbo A6M1m59/UMtYAuShHq0Wf1npYVYabFb1yHpneRg+808uDa2oZNBadvFU7WNmmYN1XNLG uCY8arMH6JnIQzINck0kNywUnhjDwNsVvGpRumoLBmtTyHDyia4VzTVVhiZAeOJgqSfz wPlw== X-Gm-Message-State: APt69E269cklevuCopk67ftzN3Y8HqrkCW2YHdy/LNL6W1UwM4GFCbMI v2JSD4ueQHXttJnFNMat9DY= X-Received: by 2002:a65:5106:: with SMTP id f6-v6mr641221pgq.72.1530683558933; Tue, 03 Jul 2018 22:52:38 -0700 (PDT) Received: from app09.andestech.com ([118.163.51.199]) by smtp.gmail.com with ESMTPSA id b22-v6sm4257226pfi.144.2018.07.03.22.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 22:52:38 -0700 (PDT) From: Greentime Hu X-Google-Original-From: Greentime Hu To: greentime@andestech.com, linux-kernel@vger.kernel.org, ren_guo@c-sky.com Cc: green.hu@gmail.com Subject: [PATCH v2 3/3] nds32: To simplify the implementation of update_mmu_cache() Date: Wed, 4 Jul 2018 13:52:10 +0800 Message-Id: X-Mailer: git-send-email 2.16.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The checking code is done in kmap_atomic() so that we don't need to check it in update_mmu_cache() again. There is no need to implement it for cache aliasing or cache non-aliasing versions. We can just implement one version for both. Signed-off-by: Greentime Hu --- arch/nds32/mm/cacheflush.c | 47 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/arch/nds32/mm/cacheflush.c b/arch/nds32/mm/cacheflush.c index 7fcaa4e6be78..254703653b6f 100644 --- a/arch/nds32/mm/cacheflush.c +++ b/arch/nds32/mm/cacheflush.c @@ -45,7 +45,7 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, flush_icache_range(kaddr, kaddr + len); kunmap_atomic((void *)kaddr); } -#ifndef CONFIG_CPU_CACHE_ALIASING + void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t * pte) { @@ -67,19 +67,15 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, if ((test_and_clear_bit(PG_dcache_dirty, &page->flags)) || (vma->vm_flags & VM_EXEC)) { - - if (!PageHighMem(page)) { - cpu_cache_wbinval_page((unsigned long) - page_address(page), - vma->vm_flags & VM_EXEC); - } else { - unsigned long kaddr = (unsigned long)kmap_atomic(page); - cpu_cache_wbinval_page(kaddr, vma->vm_flags & VM_EXEC); - kunmap_atomic((void *)kaddr); - } + unsigned long kaddr; + local_irq_save(flags); + kaddr = (unsigned long)kmap_atomic(page); + cpu_cache_wbinval_page(kaddr, vma->vm_flags & VM_EXEC); + kunmap_atomic((void *)kaddr); + local_irq_restore(flags); } } -#else +#ifdef CONFIG_CPU_CACHE_ALIASING extern pte_t va_present(struct mm_struct *mm, unsigned long addr); static inline unsigned long aliasing(unsigned long addr, unsigned long page) @@ -349,31 +345,4 @@ void invalidate_kernel_vmap_range(void *addr, int size) local_irq_restore(flags); } EXPORT_SYMBOL(invalidate_kernel_vmap_range); - -void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, - pte_t * pte) -{ - struct page *page; - unsigned long flags; - unsigned long pfn = pte_pfn(*pte); - - if (!pfn_valid(pfn)) - return; - - if (vma->vm_mm == current->active_mm) { - local_irq_save(flags); - __nds32__mtsr_dsb(addr, NDS32_SR_TLB_VPN); - __nds32__tlbop_rwr(*pte); - __nds32__isb(); - local_irq_restore(flags); - } - - page = pfn_to_page(pfn); - if (test_and_clear_bit(PG_dcache_dirty, &page->flags) || - (vma->vm_flags & VM_EXEC)) { - local_irq_save(flags); - cpu_dcache_wbinval_page((unsigned long)page_address(page)); - local_irq_restore(flags); - } -} #endif -- 2.16.2