Linux-sh Archive on lore.kernel.org
 help / color / Atom feed
From: 斉藤英夫@電産 <saito@densan.co.jp>
To: linux-sh@vger.kernel.org
Subject: cache coherency problem on CF
Date: Fri, 18 Jun 2010 02:06:29 +0000
Message-ID: <20100618.110629.68564635.saito@densan.co.jp> (raw)

Hi Paul,

When I use linux-2.6.34 on our board with SH7780, an IDE device for CF does not work.

It seems that this problem is caused by using PIO, because when a command is loaded from filesystem on the CF device, the data is read to i-cache from main memory without copying back to main memory from d-cache.

I think that the following code on arch/sh/mm/cache-sh7705.c is also useful for SH4.

/*
 * This is called when a page-cache page is about to be mapped into a
 * user process' address space.  It offers an opportunity for a
 * port to ensure d-cache/i-cache coherency if necessary.
 *
 * Not entirely sure why this is necessary on SH3 with 32K cache but
 * without it we get occasional "Memory fault" when loading a program.
 */
static void sh7705_flush_icache_page(void *page)
{
        __flush_purge_region(page_address(page), PAGE_SIZE);
}

For example, following change solves this problem likewise.

--- arch/sh/mm/cache-sh4.c.org	2010-05-17 06:17:36.000000000 +0900
+++ arch/sh/mm/cache-sh4.c	2010-06-17 19:00:55.000000000 +0900
@@ -364,16 +364,21 @@ static void __flush_cache_one(unsigned l
 			a += 64;
 			p += 64;
 		} while (a < ea);
 
 		base_addr += way_incr;
 	} while (--way_count != 0);
 }
 
+static void sh4_flush_icache_page(void *page)
+{
+	 __flush_purge_region(page_address(page), PAGE_SIZE);
+}
+
 extern void __weak sh4__flush_region_init(void);
 
 /*
  * SH-4 has virtually indexed and physically tagged cache.
  */
 void __init sh4_cache_init(void)
 {
 	printk("PVR=%08x CVR=%08x PRR=%08x\n",
@@ -383,11 +388,12 @@ void __init sh4_cache_init(void)
 
 	local_flush_icache_range	= sh4_flush_icache_range;
 	local_flush_dcache_page		= sh4_flush_dcache_page;
 	local_flush_cache_all		= sh4_flush_cache_all;
 	local_flush_cache_mm		= sh4_flush_cache_mm;
 	local_flush_cache_dup_mm	= sh4_flush_cache_mm;
 	local_flush_cache_page		= sh4_flush_cache_page;
 	local_flush_cache_range		= sh4_flush_cache_range;
+	local_flush_icache_page		= sh4_flush_icache_page;
 
 	sh4__flush_region_init();
 }

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100618.110629.68564635.saito@densan.co.jp \
    --to=saito@densan.co.jp \
    --cc=linux-sh@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-sh Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sh/0 linux-sh/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sh linux-sh/ https://lore.kernel.org/linux-sh \
		linux-sh@vger.kernel.org
	public-inbox-index linux-sh

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sh


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git