From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 for soc 3/4] arm: Add v7_invalidate_l1 to cache-v7.S
Date: Fri, 1 Feb 2013 14:31:36 +0000 [thread overview]
Message-ID: <20130201143136.GP23505@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20130201141914.GO23505@n2100.arm.linux.org.uk>
On Fri, Feb 01, 2013 at 02:19:14PM +0000, Russell King - ARM Linux wrote:
> On Fri, Feb 01, 2013 at 02:10:52PM +0000, Lorenzo Pieralisi wrote:
> > On Fri, Feb 01, 2013 at 12:54:17PM +0000, Russell King - ARM Linux wrote:
> > > On Fri, Feb 01, 2013 at 12:11:38PM +0000, Lorenzo Pieralisi wrote:
> > > > Well, on latest processors (A15, A7) caches are invalidated on reset unless
> > > > the chip is programmed to skip that on reset (ie L2 retained).
> > > >
> > > > But it makes sense, for sure it should not be called v7_invalidate_l1,
> > > > but invalidate_louis, and instead of forcing level 0 we should be
> > > > reading LoUIS and invalidate up to that level as we do in the clean and
> > > > invalidate function.
> > >
> > > No. Think about it. c7, c6, 2 _invalidates_ the cache. That means any
> > > data contained within the cache is discarded. Data is not written back.
> > >
> > > If you do this down to the LoUIS, that includes all cache levels in the
> > > inner sharable domain. The inner sharable domain includes the other CPUs
> > > in the system which may already be running (certainly the boot CPU will
> > > be running).
> >
> > On all v7 ARM systems I know of LoUIS correspond to L1 and using LoUIS is a
> > plaster that works for current systems (where by LoUIS I mean all cache
> > levels down to but not inclusive of, LoUIS).
>
> All that I'm saying is that suggesting that v7_invalidate_l1 should go
> down to LoUIS is wrong, in much the same way as _invalidating_ only the
> first level of cache.
>
> However, invalidating the first level of cache only is safer than
> invalidating down to LoUIS.
>
> The only path which needs this is the secondary CPU bringup path; that's
> the only path we have where some platforms give us a CPU which has only
> just come out of reset, and so the caches for that CPU may be in an
> unknown state. And it only happens to a small subset of platforms.
>
> Currently, that small subset of platforms only need the first level of
> cache invalidating. (Most platforms don't need this; most platforms
> this would be a waste of time - and people seem to care about hotplug
> times.)
>
> So, that's what we should do. And v7_invalidate_l1 is a perfectly
> reasonable name for a function to do that for the V7 architecture.
>
> As has been pointed out, there's several duplications of that. That's
> fine, let's move them into the v7 cache code. But... let's not change
> how they work and go through a pointless design exercise for
> invalidating more levels of cache when we know that no platform needs
> it.
>
> If/when we do end up with a platform which requires it, we can deal
> with it then. But let's not lead people down the route of thinking
> that LoUIS is suitable here when it isn't.
Just to further provide some insight into the reasoning:
Invalidating data out of a working cache risks data corruption; maybe
the data being invalidated is filesystem metadata which was about to
be cleaned and written back to storage. That risks filesystem
corruption.
Invalidating fewer levels than are actually required is different: we
may leave dirty cache lines behind which may be evicted, but there's
also the chance that the CPU will end up _reading_ from its
uninitialized caches and may crash before that happens.
So, the risks are:
1. invalidate more levels than are necessary and risk discarding data
which other CPUs are using, which may be important data.
2. invalidate less levels than are necessary and risk writing out
data from the CPU cache, which may or may not happen _before_ the
CPU crashes due to reading invalid data.
Out of those two, (2) sounds to me to be the safer approach.
Plus, I can't think of a reason why you'd want to put on a SMP system
more than one layer of CPU local caches... to do so would seem to me to
be an exercise in coherency complexity... So, I suspect that in the
real world, we will _never_ see any system which has more than one
layer of caches local to the CPU. But we may see a system with a
cache architecture similar to the one I drew in my email to Santosh.
next prev parent reply other threads:[~2013-02-01 14:31 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 17:05 [PATCHv2 for soc 0/4] Enabling socfpga on hardware dinguyen at altera.com
2013-01-31 17:05 ` [PATCHv2 for soc 1/4] arm: socfpga: Add new device tree source for actual socfpga HW dinguyen at altera.com
2013-02-01 3:46 ` Olof Johansson
2013-02-01 15:23 ` Dinh Nguyen
2013-01-31 17:05 ` [PATCHv2 for soc 2/4] arm: socfpga: Add entries to enable make dtbs socfpga dinguyen at altera.com
2013-01-31 17:05 ` [PATCHv2 for soc 3/4] arm: Add v7_invalidate_l1 to cache-v7.S dinguyen at altera.com
2013-01-31 18:11 ` Stephen Warren
2013-02-01 3:47 ` Olof Johansson
2013-02-01 11:29 ` Santosh Shilimkar
2013-02-01 11:32 ` Russell King - ARM Linux
2013-02-01 11:44 ` Santosh Shilimkar
2013-02-01 12:48 ` Russell King - ARM Linux
2013-02-01 13:04 ` Santosh Shilimkar
2013-02-01 13:20 ` Russell King - ARM Linux
2013-02-01 14:09 ` Santosh Shilimkar
2013-02-01 12:11 ` Lorenzo Pieralisi
2013-02-01 12:24 ` Santosh Shilimkar
2013-02-01 12:54 ` Russell King - ARM Linux
2013-02-01 14:10 ` Lorenzo Pieralisi
2013-02-01 14:19 ` Russell King - ARM Linux
2013-02-01 14:31 ` Russell King - ARM Linux [this message]
2013-02-01 14:43 ` Santosh Shilimkar
2013-02-01 14:49 ` Russell King - ARM Linux
2013-02-01 14:53 ` Santosh Shilimkar
2013-02-01 14:34 ` Lorenzo Pieralisi
2013-01-31 17:05 ` [PATCHv2 for soc 4/4] arm: socfpga: Add SMP support for actual socfpga harware dinguyen at altera.com
2013-02-01 3:50 ` Olof Johansson
2013-02-01 10:46 ` Pavel Machek
2013-02-01 15:27 ` Dinh Nguyen
2013-02-01 15:31 ` Russell King - ARM Linux
2013-02-01 16:39 ` Dinh Nguyen
2013-02-02 19:24 ` Pavel Machek
2013-02-02 21:37 ` Dinh Nguyen
2013-02-03 18:36 ` Pavel Machek
2013-02-04 16:12 ` Dinh Nguyen
2013-02-01 10:50 ` Pavel Machek
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=20130201143136.GP23505@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).