From patchwork Sun Nov 4 13:54:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150112 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1539131ljp; Sun, 4 Nov 2018 05:54:29 -0800 (PST) X-Google-Smtp-Source: AJdET5fRFU0dKzdHXW81r1Z9pT0E+suzqOeSZFPIn9LR5fd+U0OhhaHYk21bz8YVetdzzqUCPvVd X-Received: by 2002:a62:1095:: with SMTP id 21-v6mr18339806pfq.227.1541339669297; Sun, 04 Nov 2018 05:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541339669; cv=none; d=google.com; s=arc-20160816; b=d4POPAMj9z7q2q6fE/7P3kZQ9eZXcS0SZAT6vDd+c3gAnT0XFb7yBqR3gBK9ND1hhq DpLimkpC8MfUI3KfvAERIf91uktYmvZThuHwfAhKR2SHQYqdDV+QGJ1M7kSAeheYRUA4 eLP2oep0v+7/aWTMh6d3ZtLFMmiJRmlYAedKwQhKF0xoQxPE0OLk9/NeLqW26G/yht/+ klM9ZqZ5qKxBAVhJ0doZdlJP06ri0hBiHnpciOsL4hY0TkPSi7vQ5qbPku603gyHDZRc CLnkC6RHdBqQiCpVnWfCvZCma9ExZXLpNce2W1kRQPlCwgsBzvSgIUtRmmf2aGXVxmfk +9xw== 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=eoJnBMKMB6/oje+4jRmJVsKEg/stGAjS1UQb7P/7JIE=; b=o3NHTVdSYvc1nCsqWCW2QVHoM5qc5kCyj3YRbTp9csk9C4XeSWTyVUUR/NZ6d5uZSn P0jRakCHuvieOgl1i7D+XFCAaClzPpQhZk82yZMJWsMQUCeaS+buAbtC4CC7wmALgj1o //4NmjP8xaRQ0TDq//mnMFJ+YBAo/rJS6HvIeUn1QfRhfW6Kiobwx5kROLhxoDEXBr+R EO4VELbUodHNi1U3xhtFFycWWc3aZ0hinL3EZa/AyxujGnBakdKaSGRZY4noM0F78tHd JhZb7dns00bEba5KGpD6kFwsciUhM9jORsm5aWXGj+XSkIAzWxJr0Nur77hJC3E8hVC0 v45A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2riGgjUK; 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 t191si17907816pgd.579.2018.11.04.05.54.29; Sun, 04 Nov 2018 05:54:29 -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=2riGgjUK; 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 S1731732AbeKDXJa (ORCPT + 32 others); Sun, 4 Nov 2018 18:09:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:49272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731705AbeKDXJ3 (ORCPT ); Sun, 4 Nov 2018 18:09:29 -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 6FF962085B; Sun, 4 Nov 2018 13:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339665; bh=TVzMlEvPILMXvNaJYMZtyJvnN3v3GRYDyIE6coxw7/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2riGgjUKkDrtVekiJtoyfGJ0V8JCi7WuaolUYne6VIcODd5V8i5MDvHr4BEHMbmH1 1ePbBauFzyOh00kIKgHaRpk9m+sdhD4JjZsX9nHjws+suIJy1SX073HZJKbCmqZZyH V22Lrtqswx1RaLUg2ulD3pXj0Wf7huaC4y1P4Pu8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomi Valkeinen , Peter Ujfalusi , Sasha Levin Subject: [PATCH AUTOSEL 4.4 06/15] drm/omap: fix memory barrier bug in DMM driver Date: Sun, 4 Nov 2018 08:54:08 -0500 Message-Id: <20181104135417.88671-6-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135417.88671-1-sashal@kernel.org> References: <20181104135417.88671-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 083db3f5181f..8282ae0c4fc3 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -262,6 +262,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]);