Received: from eggs.gnu.org ([2001:4830:134:3::10]:60327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFoeq-0003LR-5Q for qemu-devel@nongnu.org; Wed, 22 Jun 2016 16:21:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFoek-0003FT-Vy for qemu-devel@nongnu.org; Wed, 22 Jun 2016 16:21:55 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFoek-0003FN-RH for qemu-devel@nongnu.org; Wed, 22 Jun 2016 16:21:50 -0400 Received: by mail-qk0-x243.google.com with SMTP id a186so12236444qkf.0 for ; Wed, 22 Jun 2016 13:21:50 -0700 (PDT) Sender: Richard Henderson References: <20160618040343.19517-1-bobby.prani@gmail.com> <20160618040343.19517-8-bobby.prani@gmail.com> <576AEBFE.2060803@gmail.com> From: Richard Henderson Message-ID: Date: Wed, 22 Jun 2016 13:21:47 -0700 MIME-Version: 1.0 In-Reply-To: <576AEBFE.2060803@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC v3 PATCH 07/14] tcg/ppc: Add support for fence List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov , Pranith Kumar , "Vassili Karpov (malc)" , "open list:All patches CC here" Cc: alex.bennee@linaro.org On 06/22/2016 12:50 PM, Sergey Fedorov wrote: > On 18/06/16 07:03, Pranith Kumar wrote: >> Signed-off-by: Richard Henderson >> Signed-off-by: Pranith Kumar >> --- >> tcg/ppc/tcg-target.inc.c | 24 ++++++++++++++++++++++++ >> 1 file changed, 24 insertions(+) >> >> diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c >> index da10052..766848e 100644 >> --- a/tcg/ppc/tcg-target.inc.c >> +++ b/tcg/ppc/tcg-target.inc.c >> @@ -469,6 +469,10 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, >> #define STHX XO31(407) >> #define STWX XO31(151) >> >> +#define EIEIO XO31(854) >> +#define HWSYNC XO31(598) >> +#define LWSYNC (HWSYNC | (1u << 21)) >> + >> #define SPR(a, b) ((((a)<<5)|(b))<<11) >> #define LR SPR(8, 0) >> #define CTR SPR(9, 0) >> @@ -1237,6 +1241,21 @@ static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args, >> tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, arg_label(args[5])); >> } >> >> +static void tcg_out_mb(TCGContext *s, TCGArg a0) >> +{ >> + switch (a0 & TCG_MO_ALL) { >> + case TCG_MO_LD_LD: >> + tcg_out32(s, LWSYNC); > > lwsync can be used for all cases except store-load which requires > hwsync. eieio is for synchronizing memory-mapped IO which is not used by > TCG at all. Have a look through linux/arch/powerpc/include/asm/barrier.h wherein we find # The eieio instruction is a barrier providing an ordering ... # for (a) cacheable stores .... # However, on CPUs that don't support lwsync, lwsync actually maps to a # heavy-weight sync, so smp_wmb() can be a lighter-weight eieio. And elsewhere, #if defined(__powerpc64__) || defined(CONFIG_PPC_E500MC) #define __SUBARCH_HAS_LWSYNC #endif Which suggests that ppc64 should use lwsync and ppc32 should use eieio for ST_ST. r~