From patchwork Sun Nov 4 13:54:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150114 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1539330ljp; Sun, 4 Nov 2018 05:54:45 -0800 (PST) X-Google-Smtp-Source: AJdET5f4JQp1CB1CFf4tYEFXpR1wta9lYF3qCkX4d8Bod4K062iA6cZpaGlC6MEWQ1Pzl2mY1k4O X-Received: by 2002:a62:a218:: with SMTP id m24-v6mr18150241pff.99.1541339685463; Sun, 04 Nov 2018 05:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541339685; cv=none; d=google.com; s=arc-20160816; b=YTVV1js8cbko2jWVV/Hhlzsiy6FeMZkBa4EX2u0I+SUzzc7Eu4Qqi70nAkEeAV8d97 iMpnGTLVFe6NFq5owuKPvBJtgcA/7RACQNVxO9hZXuJgqVBcyYH5Hfs3UXMAInAelzz5 cyfsdN1N0gkMNF9NsljgQhSVEdxh8M0aRQnAdW+l2oCv24HDzaSyV1RQcCGYaPtcT/CX jnKWpXr3RHYCEQg36+6wtiKeUvflXwJLcFZBWG4v5aLL77jKRSBLa+pII02GPV1F4gAE QZAMyZ/WcSOPibaMWnbSJ1hYvSM2uB7ZOZCUYQByU7NM0TwwjxjqkBzBZMawLiU3SuAs C3nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Sq5rfCyn7A2KMlYCVg2cvY3w/SN7sW8DRK/TlyWqFZU=; b=AHZlwMlRuo8DNowvNMi4jUCBMVTECxyhzxPa+I3KR30Cju+EwWTlpA6Cj3q4uXjj1P LNXlSG8xCcNb6exYJPvjcjivDBMkOIGpXafGfwefjJuMr7sM1XDjKDuV+XRiu5no+dWd 8/AUtu4aGa6C4WC6jR6RVWJzpDLyGaAT8fYDTKWGuLvZhePbCx3DMjZDkhlwYC6Ibgdu CL8IG748QSwoKIBVYGa9hLkno+elqFiXxICo/4YDHd0G0aCTAuKVafD1vzWQEL6/7qau xdA8mUTkVz7Yr34ANGjIi5Mr9Vzh2vg4tuixxYK+nANUyxXV/FrvjrC5CdqGttvHo7Wh bRzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SOcK6Psz; 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 w11-v6si10540193ply.404.2018.11.04.05.54.45; Sun, 04 Nov 2018 05:54:45 -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=SOcK6Psz; 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 S1731887AbeKDXJq (ORCPT + 32 others); Sun, 4 Nov 2018 18:09:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:49808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731865AbeKDXJp (ORCPT ); Sun, 4 Nov 2018 18:09:45 -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 5C2FC20868; Sun, 4 Nov 2018 13:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339680; bh=gwES/wZ5EYJIUi01ywDLdJLbWcmmptvDCNXAf1R/ruA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOcK6PszbNMczVHU704CeR9a3cTE7GDdcuNKogvVP4xGpvQJi5iHT73yUHD1+Aczm hlRh5Zc/j5GlhUL9xV7zzuRTP9DajuCvJ4cYUBc4NiYdbeAbbkJQvIr6a3PpekmX0Q HFMyw1Q6P3PoLEAwWt9dqJC/sHzaG455+e0JCJYE= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomi Valkeinen , Peter Ujfalusi , Sasha Levin Subject: [PATCH AUTOSEL 3.18 06/13] drm/omap: fix memory barrier bug in DMM driver Date: Sun, 4 Nov 2018 08:54:26 -0500 Message-Id: <20181104135433.88734-6-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135433.88734-1-sashal@kernel.org> References: <20181104135433.88734-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomi Valkeinen [ Upstream commit 538f66ba204944470a653a4cccc5f8befdf97c22 ] A DMM timeout "timed out waiting for done" has been observed on DRA7 devices. The timeout happens rarely, and only when the system is under heavy load. Debugging showed that the timeout can be made to happen much more frequently by optimizing the DMM driver, so that there's almost no code between writing the last DMM descriptors to RAM, and writing to DMM register which starts the DMM transaction. The current theory is that a wmb() does not properly ensure that the data written to RAM is observable by all the components in the system. This DMM timeout has caused interesting (and rare) bugs as the error handling was not functioning properly (the error handling has been fixed in previous commits): * If a DMM timeout happened when a GEM buffer was being pinned for display on the screen, a timeout error would be shown, but the driver would continue programming DSS HW with broken buffer, leading to SYNCLOST floods and possible crashes. * If a DMM timeout happened when other user (say, video decoder) was pinning a GEM buffer, a timeout would be shown but if the user handled the error properly, no other issues followed. * If a DMM timeout happened when a GEM buffer was being released, the driver does not even notice the error, leading to crashes or hang later. This patch adds wmb() and readl() calls after the last bit is written to RAM, which should ensure that the execution proceeds only after the data is actually in RAM, and thus observable by DMM. The read-back should not be needed. Further study is required to understand if DMM is somehow special case and read-back is ok, or if DRA7's memory barriers do not work correctly. Signed-off-by: Tomi Valkeinen Signed-off-by: Peter Ujfalusi Signed-off-by: Sasha Levin --- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index eb5b0f1d2a10..91be4e23a90f 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -256,6 +256,17 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait) } txn->last_pat->next_pa = 0; + /* ensure that the written descriptors are visible to DMM */ + wmb(); + + /* + * NOTE: the wmb() above should be enough, but there seems to be a bug + * in OMAP's memory barrier implementation, which in some rare cases may + * cause the writes not to be observable after wmb(). + */ + + /* read back to ensure the data is in RAM */ + readl(&txn->last_pat->next_pa); /* write to PAT_DESCR to clear out any pending transaction */ writel(0x0, dmm->base + reg[PAT_DESCR][engine->id]);