Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2721357imj; Mon, 11 Feb 2019 07:30:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ4APxPRldl3sJ4n3E0gkTNzwXXuxLXBpGcexDMX+uZ92YJCHECdrAL83ibGhxs94u+L1c6 X-Received: by 2002:aa7:819a:: with SMTP id g26mr28575912pfi.187.1549899010284; Mon, 11 Feb 2019 07:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899010; cv=none; d=google.com; s=arc-20160816; b=HXh430o2UCIbMSRQIzX2tZ7woOk9AK4NIxsjqKIX3SLKDoQxePJgCr9g8jyJUEmgS2 MG6DAscy0lWi700fohng3rTFHy//2Lg6lmpB1DF3wCvbeDQI7dlwiRp6R8kNdZN+C7J6 Rf1j2UUf1ZZl9tAybqRiU6G5A8ykaJOthLkboQYgwfUKs5J/fxbo47iImCmSCspuORT9 i8TC5dAe5L0OBsyWaHztt9llYnYfsaYhEcg3T9NZub2zNtsHrE4+Utv6fwkgZDR70PY1 Mb/6R6aaVSy6KaLDXqrdn3dTV7rib6Mgty6iHC6mfDwsPl/6nZ41LDwoygyUSUwrQ00i fQvA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vDQUy+cSVW1zg3n7UYz6q+KEMqSKZjdRguQkE5RHgN4=; b=worVLY6hcP+aKETlmmUUUNjWhfv97Sqr9OerEACZUSW6zZElr7RtHqJY9iMz/yRE97 58rABONBdDhXzVqNlax66C/V4P/jz1CSdYwik3Lyoi1tl725YFnsaR3VOs17ouTGzdq8 roY1uN4XCvDFmp08eUe+LtZdrTL+bfWOnCp0HNKPglz1X0pdySNvDVqfDhghEMVbFwi9 DW9MjdQVJZYzNoNuuLr9ZLg+SZDdaYJuEDWxRW/zhbbPE6yTaqvpDhsujnXoYtX9tCLt OidXWDQ6SUN3HK6NZ1634h8qywJdx00VIsuW1gWYKv+dwZGdSOg9CkNWfokTJk2uyMoP OSVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UA6jqDLA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si545965pgr.384.2019.02.11.07.29.52; Mon, 11 Feb 2019 07:30:10 -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=UA6jqDLA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732061AbfBKP3K (ORCPT + 99 others); Mon, 11 Feb 2019 10:29:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:45470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389432AbfBKO5z (ORCPT ); Mon, 11 Feb 2019 09:57:55 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A9D9222A8; Mon, 11 Feb 2019 14:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897075; bh=5tA/6eRripWo2fhI498TkLgxAn28UlvrGcLs4vyKt7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UA6jqDLABjf/G4rtFAH7uy8cHUihEtN4/HvuOoHBNO0uPRsgipFQPB0q/oItXpw0v LMI4Tx2Ua89sgB2nwTwCJjPC4REVToW2tItJQBigMUHgHnDAWjrtT5wNThZvRTKNRJ aG9oLDTbRpjbNYweVM8Vh6I4rDCa/n1zVPcqBcFg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Will Deacon , Sasha Levin Subject: [PATCH 4.14 081/205] iommu/arm-smmu-v3: Use explicit mb() when moving cons pointer Date: Mon, 11 Feb 2019 15:17:59 +0100 Message-Id: <20190211141833.995228441@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit a868e8530441286342f90c1fd9c5f24de3aa2880 ] After removing an entry from a queue (e.g. reading an event in arm_smmu_evtq_thread()) it is necessary to advance the MMIO consumer pointer to free the queue slot back to the SMMU. A memory barrier is required here so that all reads targetting the queue entry have completed before the consumer pointer is updated. The implementation of queue_inc_cons() relies on a writel() to complete the previous reads, but this is incorrect because writel() is only guaranteed to complete prior writes. This patch replaces the call to writel() with an mb(); writel_relaxed() sequence, which gives us the read->write ordering which we require. Cc: Robin Murphy Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/iommu/arm-smmu-v3.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 26e99c03390f..09eb258a9a7d 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -730,7 +730,13 @@ static void queue_inc_cons(struct arm_smmu_queue *q) u32 cons = (Q_WRP(q, q->cons) | Q_IDX(q, q->cons)) + 1; q->cons = Q_OVF(q, q->cons) | Q_WRP(q, cons) | Q_IDX(q, cons); - writel(q->cons, q->cons_reg); + + /* + * Ensure that all CPU accesses (reads and writes) to the queue + * are complete before we update the cons pointer. + */ + mb(); + writel_relaxed(q->cons, q->cons_reg); } static int queue_sync_prod(struct arm_smmu_queue *q) -- 2.19.1