Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26290C6FA8B for ; Sat, 10 Sep 2022 21:19:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2DE410E2E3; Sat, 10 Sep 2022 21:19:33 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9AC6E10E2DE; Sat, 10 Sep 2022 21:19:27 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 354CCB80955; Sat, 10 Sep 2022 21:19:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1728C433D7; Sat, 10 Sep 2022 21:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662844764; bh=ctclM3JBJrkIeibqeVrapq86rbugeEMyPRRRmJnwhBU=; h=From:To:Cc:Subject:Date:From; b=nxNAlAKioFR1/sFRXmsZ9XigiQuoNa+e12xWF7oae2aJC2CXp5WIQ6bYOV397IU9b FzVa1Te+6c8j80ZytxhvdHN53FoFol98o7Aoyeqj6FZHnxcQ+Mn/zBxbl5evwn1zlJ G/Qbl13SkO44mv2mWbiy58VjvrWsxkhUCV36e+OJJTWEFqUfRKgF3mzh9MvpRr1g/6 oGUb12ctypRA3rH23BKv9kef1uficGGqvcv//Y4fqJuXCsV08fa62uq0FPTAd5bVvV koJdBly/70IZb+qrBgJdDL9b+aT7+7OzYLXBH9rSu6HpAafKbi42Mxm1Uj0XUPYHPy wkPlcWxhWRogQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 1/8] drm/msm/rd: Fix FIFO-full deadlock Date: Sat, 10 Sep 2022 17:19:14 -0400 Message-Id: <20220910211921.70891-1-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Sasha Levin , airlied@linux.ie, linux-arm-msm@vger.kernel.org, quic_abhinavk@quicinc.com, dri-devel@lists.freedesktop.org, dmitry.baryshkov@linaro.org, freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark [ Upstream commit 174974d8463b77c2b4065e98513adb204e64de7d ] If the previous thing cat'ing $debugfs/rd left the FIFO full, then subsequent open could deadlock in rd_write() (because open is blocked, not giving a chance for read() to consume any data in the FIFO). Also it is generally a good idea to clear out old data from the FIFO. Signed-off-by: Rob Clark Patchwork: https://patchwork.freedesktop.org/patch/496706/ Link: https://lore.kernel.org/r/20220807160901.2353471-2-robdclark@gmail.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/msm_rd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c index d4cc5ceb22d01..bb65aab49c214 100644 --- a/drivers/gpu/drm/msm/msm_rd.c +++ b/drivers/gpu/drm/msm/msm_rd.c @@ -199,6 +199,9 @@ static int rd_open(struct inode *inode, struct file *file) file->private_data = rd; rd->open = true; + /* Reset fifo to clear any previously unread data: */ + rd->fifo.head = rd->fifo.tail = 0; + /* the parsing tools need to know gpu-id to know which * register database to load. */ -- 2.35.1