From patchwork Mon Aug 31 22:19:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 44936 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7VMJk2l012179 for ; Mon, 31 Aug 2009 22:19:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750829AbZHaWTm (ORCPT ); Mon, 31 Aug 2009 18:19:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750929AbZHaWTm (ORCPT ); Mon, 31 Aug 2009 18:19:42 -0400 Received: from 124x34x33x190.ap124.ftth.ucom.ne.jp ([124.34.33.190]:57697 "EHLO master.linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750829AbZHaWTl (ORCPT ); Mon, 31 Aug 2009 18:19:41 -0400 Received: from localhost (unknown [127.0.0.1]) by master.linux-sh.org (Postfix) with ESMTP id 64B8A6375A; Mon, 31 Aug 2009 22:19:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at linux-sh.org Received: from master.linux-sh.org ([127.0.0.1]) by localhost (master.linux-sh.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qSwY+223YdD4; Tue, 1 Sep 2009 07:19:40 +0900 (JST) Received: from localhost (82-38-64-26.cable.ubr06.brad.blueyonder.co.uk [82.38.64.26]) by master.linux-sh.org (Postfix) with ESMTP id 930B663758; Tue, 1 Sep 2009 07:19:39 +0900 (JST) From: Matt Fleming To: Paul Mundt Cc: linux-sh@vger.kernel.org Subject: [PATCH] sh: Fix dcache flushing with 4-way write-through cache Date: Mon, 31 Aug 2009 23:19:31 +0100 Message-Id: <1251757171-17201-1-git-send-email-matt@console-pimps.org> X-Mailer: git-send-email 1.6.3.3 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org We can't use the same code to flush a 4-way dcache in both write-through and write-back mode. For write-through mode, use the same technique as is currently used for a 2-way cache and stop writing garbage to memory. Signed-off-by: Matt Fleming --- arch/sh/mm/cache-sh4.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c index 397c103..08678c5 100644 --- a/arch/sh/mm/cache-sh4.c +++ b/arch/sh/mm/cache-sh4.c @@ -673,6 +673,25 @@ static void __flush_dcache_segment_2way(unsigned long start, extent_per_way -= cpu_data->dcache.linesz; } } + +static void __flush_dcache_segment_4way(unsigned long start, + unsigned long extent_per_way) +{ + unsigned long array_addr, way_addr; + int i; + + array_addr = CACHE_OC_ADDRESS_ARRAY | + (start & cpu_data->dcache.entry_mask); + + while (extent_per_way) { + for (i = 0; i < 4; i++) { + way_addr = array_addr + cpu_data->dcache.way_incr * i; + ctrl_outl(0, way_addr); + } + array_addr += cpu_data->dcache.linesz; + extent_per_way -= cpu_data->dcache.linesz; + } +} #else static void __flush_dcache_segment_2way(unsigned long start, unsigned long extent_per_way) @@ -732,7 +751,6 @@ static void __flush_dcache_segment_2way(unsigned long start, a1 += linesz; } while (a0 < a0e); } -#endif static void __flush_dcache_segment_4way(unsigned long start, unsigned long extent_per_way) @@ -818,3 +836,4 @@ static void __flush_dcache_segment_4way(unsigned long start, a3 += linesz; } while (a0 < a0e); } +#endif /* CONFIG_CACHE_WRITETHROUGH */