public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
To: linux-sh@vger.kernel.org
Subject: About invalidate cache of SH4
Date: Tue, 08 Jan 2008 07:59:20 +0000	[thread overview]
Message-ID: <47832D9E.1010201@renesas.com> (raw)

Hi, Paul,

When start or size of __flush_invalidate_region() is not cache
alignment, enlarge the range to match it. However, the data is
lost if there are the data which should write-back in there.

For example, struct scsi_cmnd has sense_buffer[]. sense_buffer
is not cache alignment. When there is invalidated sense_buffer,
struct request *request of struct scsi_cmnd may be invalidated.
Connection of the USB memory sometimes fails and cannnot mount
USB-CDROM(oops occured) for this processing.

I made a patch, but this implementation may not be good...

Thanks,
Yoshihiro Shimoda

---
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 43d7ff6..cc1751d 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -164,15 +164,37 @@ void __flush_invalidate_region(void *start, int size)
 {
 	unsigned long v;
 	unsigned long begin, end;
+	int no_align = 0;

 	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
 	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
 		& ~(L1_CACHE_BYTES-1);
+
+	if ((unsigned long)start & (L1_CACHE_BYTES - 1) ||
+	    size & (L1_CACHE_BYTES - 1)) {
+		if (size <= (L1_CACHE_BYTES << 1)) {
+			__flush_purge_region(start, size);
+			return;
+		} else {
+			no_align = 1;
+			begin += L1_CACHE_BYTES;
+			end -= L1_CACHE_BYTES;
+		}
+	}
+
+	if (no_align)
+		__flush_purge_region((void *)(begin - L1_CACHE_BYTES),
+				     L1_CACHE_BYTES);
+
 	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
 		asm volatile("ocbi	%0"
 			     : /* no output */
 			     : "m" (__m(v)));
 	}
+
+	if (no_align)
+		__flush_purge_region((void *)(end + L1_CACHE_BYTES),
+				     L1_CACHE_BYTES);
 }

 /*

             reply	other threads:[~2008-01-08  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08  7:59 Yoshihiro Shimoda [this message]
2008-01-08  8:08 ` About invalidate cache of SH4 Paul Mundt

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=47832D9E.1010201@renesas.com \
    --to=shimoda.yoshihiro@renesas.com \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox