Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp926893imj; Sat, 9 Feb 2019 10:59:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IavQTELgmGHhX+BU2VBGEFZ4ZUmHPDBz1sezULXVew6NcjE+6Ix+HTJKIgTmTrKyEYDyYF/ X-Received: by 2002:a17:902:2468:: with SMTP id m37mr29594551plg.314.1549738772229; Sat, 09 Feb 2019 10:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549738772; cv=none; d=google.com; s=arc-20160816; b=rPwYQD7U7S1ctuiQDDCCeLTf6FB7vm/97mchBGgKt2KhelGdJ9ynDph8/s4D+YpBD0 CCEvpmhUDgusMeGoS7SgToe7I9kUolapN2vQ92yhphdwiC1c96EtRz5w7b168zydsRt2 aQ56aSD7l20f/hRPdlAdoHvP+SBk2vmI42wGeInwItdbvm/NjIABQV/ONr3W5Sp5gyMy NgyAI2OycbIjKHxyTYoF7k+FLukx5Aop0YtkcFoaWmnDTn/QuaIAKC/vGFCY61aFExJl Hglu9w7ZtxadzCxHwDKYmXZk5CLBLhMDlOFZT1hA12As20q7ifl+ihJ3pUVluJIX4LCt WnRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=epgYl3qywSkSCgPxhKqPhIXlLZgL4+vOAbTqgOYagKA=; b=apIRLHyqez23UWrRWgRSnAvFJDbLIksAN1RXIxfl1XX/7e23/ObcA2zT6zVTlA/9BL bKwZfUqF9QGvT4VZyYcFW7zqaLb0FMo2KTXWT/d96K8DpEGjcshGzuAT4cBsXNc3sf3N tA43+NiwQgjkpyJbrNE15UtIy0WdPZja12L4X5N1kJdPsz6NLjHfYQpVGswKgMj4GozR pOK47Sc7Km1QWpreCAn1ZxGKdjbjk/owQMJPQBzS4SYKkEV9/AACpXQZOnY9ivAHlggv hoxHCWd0DMDiHav3m4ro47zLNpDqVTfls7gx+EPVt7OLJZ1U1OdN5Q7KEw2YUvoiKAaz y+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UHBO6l4g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d133si4505975pfd.163.2019.02.09.10.59.16; Sat, 09 Feb 2019 10:59:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UHBO6l4g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbfBIS5R (ORCPT + 99 others); Sat, 9 Feb 2019 13:57:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:60406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727389AbfBISrr (ORCPT ); Sat, 9 Feb 2019 13:47:47 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A2AA2192B; Sat, 9 Feb 2019 18:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549738067; bh=59Vga8ht6ffSRgDIcUkB1REx/orLYMgBGQiMPWO+ESU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UHBO6l4gYncxDLRgbWYXGCn/WHqFJ6GoIHpYz86hJNW5vJpkK323sG7s5gcF0yKMd S3m3SwtFeeKfZ0Kg8ObbzcW5lKvYBo8p6zbf0wpC+p4yMhvryrKefUA81gQPQjiTF+ yMoCjoqDQw9hfQkP/zHl766G8lsEa9AILaY0VXJY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Guo Ren , Lu Baoquan , Sasha Levin Subject: [PATCH AUTOSEL 4.20 11/42] csky: fixup CACHEV1 store instruction fast retire Date: Sat, 9 Feb 2019 13:47:03 -0500 Message-Id: <20190209184734.125935-11-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190209184734.125935-1-sashal@kernel.org> References: <20190209184734.125935-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren [ Upstream commit 96354ad79e2e59f9d620669c8e1ac2452440c260 ] For I/O access, 810/807 store instruction fast retire will cause wrong primitive. For example: stw (clear interrupt source) stw (unmask interrupt controller) enable interrupt stw is fast retire instruction. When PC is run at enable interrupt stage, the clear interrupt source hasn't finished. It will cause another wrong irq-enter. So use mb() to prevent above. Signed-off-by: Guo Ren Cc: Lu Baoquan Signed-off-by: Sasha Levin --- arch/csky/include/asm/io.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h index ecae6b358f95..c1dfa9c10e36 100644 --- a/arch/csky/include/asm/io.h +++ b/arch/csky/include/asm/io.h @@ -15,6 +15,31 @@ extern void iounmap(void *addr); extern int remap_area_pages(unsigned long address, phys_addr_t phys_addr, size_t size, unsigned long flags); +/* + * I/O memory access primitives. Reads are ordered relative to any + * following Normal memory access. Writes are ordered relative to any prior + * Normal memory access. + * + * For CACHEV1 (807, 810), store instruction could fast retire, so we need + * another mb() to prevent st fast retire. + * + * For CACHEV2 (860), store instruction with PAGE_ATTR_NO_BUFFERABLE won't + * fast retire. + */ +#define readb(c) ({ u8 __v = readb_relaxed(c); rmb(); __v; }) +#define readw(c) ({ u16 __v = readw_relaxed(c); rmb(); __v; }) +#define readl(c) ({ u32 __v = readl_relaxed(c); rmb(); __v; }) + +#ifdef CONFIG_CPU_HAS_CACHEV2 +#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); }) +#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); }) +#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); }) +#else +#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); mb(); }) +#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); mb(); }) +#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); }) +#endif + #define ioremap_nocache(phy, sz) ioremap(phy, sz) #define ioremap_wc ioremap_nocache #define ioremap_wt ioremap_nocache -- 2.19.1