From patchwork Tue Jan 6 20:22:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 16847 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id D7531DE6AA for ; Wed, 7 Jan 2009 07:21:07 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754719AbZAFUVG (ORCPT ); Tue, 6 Jan 2009 15:21:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754766AbZAFUVG (ORCPT ); Tue, 6 Jan 2009 15:21:06 -0500 Received: from pfepa.post.tele.dk ([195.41.46.235]:56888 "EHLO pfepa.post.tele.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754719AbZAFUVE (ORCPT ); Tue, 6 Jan 2009 15:21:04 -0500 Received: from ravnborg.org (x1-6-00-1e-2a-84-ae-3e.k225.webspeed.dk [80.163.61.94]) by pfepa.post.tele.dk (Postfix) with ESMTP id C5D48A5004D; Tue, 6 Jan 2009 21:21:01 +0100 (CET) Received: by ravnborg.org (Postfix, from userid 500) id 0E428580D0; Tue, 6 Jan 2009 21:22:45 +0100 (CET) Date: Tue, 6 Jan 2009 21:22:45 +0100 From: Sam Ravnborg To: "David S. Miller" , sparclinux , Steven Rostedt Subject: [PATCH] sparc64: refactor code in init_64.c Message-ID: <20090106202245.GB17714@uranus.ravnborg.org> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org The sparc64 allmodconfig build broke due to enabling of the branch_tracer that does some very clever things with all if conditions. This caused my gcc 3.4.5 to be so confused that it emitted two warnings: arch/sparc/mm/init_64.c: In function `update_mmu_cache': arch/sparc/mm/init_64.c:271: warning: 'pg_flags' might be used uninitialized in this function arch/sparc/mm/init_64.c:272: warning: 'page' might be used uninitialized in this function And with -Werror this broke the build. Refactor code so it: 1) becomes more readable 2) no longer emit a warning with the branch_tracer enabled The refactoring uses a small helper function (flush_dcache()). Signed-off-by: Sam Ravnborg Cc: Steven Rostedt --- The diff is not readable so you need to apply it to see the end result. Please review extra carefully to check that the transformation of: (page = pfn_to_page(pfn), page_mapping(page)) is correct. Thanks, Sam -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index c04b111..6afb1a1 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -259,21 +259,16 @@ static inline void tsb_insert(struct tsb *ent, unsigned long tag, unsigned long unsigned long _PAGE_ALL_SZ_BITS __read_mostly; unsigned long _PAGE_SZBITS __read_mostly; -void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte) +static void flush_dcache(unsigned long pfn) { - struct mm_struct *mm; - struct tsb *tsb; - unsigned long tag, flags; - unsigned long tsb_index, tsb_hash_shift; + struct page *page; - if (tlb_type != hypervisor) { - unsigned long pfn = pte_pfn(pte); + page = pfn_to_page(pfn); + if (page && page_mapping(page)) { unsigned long pg_flags; - struct page *page; - if (pfn_valid(pfn) && - (page = pfn_to_page(pfn), page_mapping(page)) && - ((pg_flags = page->flags) & (1UL << PG_dcache_dirty))) { + pg_flags = page->flags; + if (pg_flags & (1UL << PG_dcache_dirty)) { int cpu = ((pg_flags >> PG_dcache_cpu_shift) & PG_dcache_cpu_mask); int this_cpu = get_cpu(); @@ -291,6 +286,21 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t p put_cpu(); } } +} + +void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte) +{ + struct mm_struct *mm; + struct tsb *tsb; + unsigned long tag, flags; + unsigned long tsb_index, tsb_hash_shift; + + if (tlb_type != hypervisor) { + unsigned long pfn = pte_pfn(pte); + + if (pfn_valid(pfn)) + flush_dcache(pfn); + } mm = vma->vm_mm;