Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1593729imd; Sun, 4 Nov 2018 06:01:22 -0800 (PST) X-Google-Smtp-Source: AJdET5d47DCYL45BD6oB2gONrXHg473ObH6P0wRYy1CybUBBN9HZbxLpdP13pCrT6OgK3k7tfAHS X-Received: by 2002:a62:68c3:: with SMTP id d186-v6mr19241216pfc.195.1541340082892; Sun, 04 Nov 2018 06:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340082; cv=none; d=google.com; s=arc-20160816; b=02FLxL7G2iQQYeIhzoZDvCGskIGsXLuWPqewmlXRq7nKk7vLeeaFSeOaveaHWueUG4 C6WlrH+DapZD8/YrmG9TRxlhO/19TGu80/epaqoQ4a4vhL3tDRZLfxNTZwBkzXNJnRGp 881kVxoltwrGDu30or8n7XYT5ZftCXLrcftQqFadpBmzLKfRZg53rOViM173ovj3Of8D LOuzKNWqXnuTn9P+YOf77By9SUACODkky1Ez0YSl/pu1cZ61bhAgt3AnXXoPlIQIEtjW AiZCqOZ5Uf6dup+nEcQNnubvc3XHyb/7P7ZcoQZsihujj2Hmxt+kF8OTMuTXZ7ancPfq YmZQ== 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=lkbZMfD9Nv8TDi2C6BP0wmJkMT83YATED7jnjq3Vliw=; b=iFNZOH/bs5bPWQdQE3Nh83caQkj3KeTDCHJDRsFWwcFVSGxuUSkdrwvjrSIMlLpH6C 18OmnUFjrquXg0wbvqsbluUPTKuQPB7V8VxdM/7meVGlQYzg1eK4W9Nb39sHPRyQhL9h g8ehshLuuPak/7cCtOMd/HZJBj+pHlDJkizlsBLORHlbsrPlFEeEhE4REaCBOl7/TfYA n9ufdNkI8UGGYxvT6yYcBnwz7OPA+V/85bvo0zle+lyQpEkjdKYdtce4PhVQ3Dt9m9T3 ydlUuulVxejAD2rpQGuxFVVBm1OYJHFHYhbnJ5Thcw+BQERfsu4esetDEeu1Ms2UvpEE HJSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hM1OvUU9; 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 w19-v6si40197344pgl.278.2018.11.04.06.01.08; Sun, 04 Nov 2018 06:01:22 -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=hM1OvUU9; 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 S1731287AbeKDXIq (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:47762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731227AbeKDXIo (ORCPT ); Sun, 4 Nov 2018 18:08:44 -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 A60292086C; Sun, 4 Nov 2018 13:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339620; bh=A6/X4YppExsa6bwHtOV0hd2CFF2T1ib/JdwbcAAfrFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hM1OvUU95uSW1kpyYURjJdERNxOWIwgWla/AR6RpIdHmEYBtgkVUc75Fnegan3JZt +Tdikilfq+7vO+9U4GK7A+SuLhIoMDP1pfzbZ8RsK5N8pynArtDeiVC569Wjk7ehMT CVOzNh1ZQAepmmoEDuu0gEqNwZ/i/WUhTPVosCW0= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomi Valkeinen , Peter Ujfalusi , Sasha Levin Subject: [PATCH AUTOSEL 4.14 14/30] drm/omap: fix memory barrier bug in DMM driver Date: Sun, 4 Nov 2018 08:53:09 -0500 Message-Id: <20181104135325.88524-14-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-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(+) diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index df05fe53c399..32901c6fe3df 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -273,6 +273,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 */ dmm_write(dmm, 0x0, reg[PAT_DESCR][engine->id]); -- 2.17.1