From: Ralf Baechle <ralf@linux-mips.org>
To: Kevin Cernekee <cernekee@gmail.com>
Cc: linux-mips@linux-mips.org
Subject: Re: [PATCH 7/9] MIPS: BMIPS: Introduce bmips.h
Date: Tue, 8 Nov 2011 15:03:33 +0000 [thread overview]
Message-ID: <20111108150333.GA1491@linux-mips.org> (raw)
In-Reply-To: <1c70a0e0f9e1a3967b60c4c2d1ec99bd@localhost>
On Sat, Nov 05, 2011 at 02:21:16PM -0700, Kevin Cernekee wrote:
> +static inline unsigned long bmips_read_zscm_reg(unsigned int offset)
> +{
> + unsigned long ret;
> +
> + cache_op(Index_Load_Tag_S, ZSCM_REG_BASE + offset);
> +
> + __asm__ __volatile__(
> + ".set push\n"
> + ".set noreorder\n"
> + "sync\n"
> + "ssnop\n"
> + "ssnop\n"
> + "ssnop\n"
> + "ssnop\n"
> + "ssnop\n"
> + "ssnop\n"
> + "ssnop\n"
> + "mfc0 %0, $28, 3\n"
> + "ssnop\n"
> + ".set pop\n"
> + : "=&r" (ret) : : "memory");
Is it critical that the C compiler or assembler can't reorder anything to
in between the cache_op and the inline asm statement? If so, I'd
recommend to put the cache instruction into the asm as well.
> +static inline void bmips_write_zscm_reg(unsigned int offset, unsigned long data)
> +{
> + __write_32bit_c0_register($28, 3, data);
> + back_to_back_c0_hazard();
> + cache_op(Index_Store_Tag_S, ZSCM_REG_BASE + offset);
> + back_to_back_c0_hazard();
back_to_back_c0_hazard() is meant as the hazard barrier between a write
followed immediately by a read from the same cp0 register:
mtc0 $reg1, $12
mfc0 $reg2, $12
On various MIPS processors this instruction sequence would result in
undefined operation such as the mfc0 instruction reading the value of
$12 before the mtc0 or even next week's lucky lottery numbers..
I think we don't really have a type of hazard barrier defined in hazard.h
and this seems a rather special purpose use so I suggest you just open
code whatever needs to be done.
Ralf
next prev parent reply other threads:[~2011-11-08 15:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-05 21:21 [PATCH RESEND 1/9] MIPS: Add local_flush_tlb_all_mm to clear all mm contexts on calling cpu Kevin Cernekee
2011-11-05 21:21 ` [PATCH 2/9] MIPS: BMIPS: Fix up Kconfig settings Kevin Cernekee
2011-11-05 21:21 ` [PATCH 3/9] MIPS: BMIPS: Add XKS01 feature flag to Kconfig Kevin Cernekee
2011-11-08 15:49 ` Ralf Baechle
2011-11-05 21:21 ` [PATCH 4/9] MIPS: Clean up whitespace warning in hazards.h Kevin Cernekee
2011-11-05 21:21 ` [PATCH 5/9] MIPS: BMIPS: Add CFLAGS, Makefile entries for BMIPS Kevin Cernekee
2011-11-05 21:21 ` [PATCH 6/9] MIPS: BMIPS: Add set/clear CP0 macros for BMIPS operations Kevin Cernekee
2011-11-05 21:21 ` [PATCH 7/9] MIPS: BMIPS: Introduce bmips.h Kevin Cernekee
2011-11-08 15:03 ` Ralf Baechle [this message]
2011-11-05 21:21 ` [PATCH 8/9] MIPS: Add board_* hooks for ebase and NMI Kevin Cernekee
2011-11-08 15:23 ` Ralf Baechle
2011-11-05 21:21 ` [PATCH 9/9] MIPS: BMIPS: Add SMP support code for BMIPS43xx/BMIPS5000 Kevin Cernekee
2011-11-08 15:56 ` Ralf Baechle
2011-11-08 16:47 ` [PATCH RESEND 1/9] MIPS: Add local_flush_tlb_all_mm to clear all mm contexts on calling cpu Ralf Baechle
2011-11-08 19:40 ` Kevin Cernekee
2011-11-09 5:33 ` Kevin Cernekee
2011-11-09 13:11 ` Ralf Baechle
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=20111108150333.GA1491@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=cernekee@gmail.com \
--cc=linux-mips@linux-mips.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