Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp200198imj; Thu, 14 Feb 2019 18:32:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IbHBH3inVa13HKvH5Aajy0+TR6k7zJuh9LKfEXL3O7uya1Zn8gTMIC9dZ7xcwH1cl93eCy8 X-Received: by 2002:aa7:8d57:: with SMTP id s23mr7337066pfe.237.1550197954773; Thu, 14 Feb 2019 18:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197954; cv=none; d=google.com; s=arc-20160816; b=RMvzLZ93qGbiO5/rcvvgPmK2ZRJbI63emqzeroXn0sElHleX+b30vz4WhHxTgONZbI cCGT10/In02uOnM3AEqd1QVIIH0mkMF5Ujp6KT+tj+keQgrvxSi3lnCV9w1jGyThnuWC nXsN+Ghor0UQc8NmjAhuPqMkXojEap5DJawUYKkc0QecK7oQ/qekWyz3DNgG0jpKSRAl xY9PqQkO7OvuJXrZzGIVJXo9/luR8oHTr1+RXHzrkbh5NMS/XbEgapW7VnblNG0oNa5X iSYdF1HwF1u10ET6yPDoqy8R1E7YkIEMF8jr/4WG3AJYkfL1coWa+dFpI8cD3KV1i2e/ LvgA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Gm7lW/h+UUfyOxQJptVvlSEbD72iZI9TnJd2J+hlXU0=; b=tmutuQkUcFOQc8glUNEJo8kzPzTpN+Ov7xhhM8MHQSDpmcezosXhaKNZVWQKD1MxTF nat6wiEoQAgrvTwxCZlOX2imTlYnYYtcbJxJ6okFlwriKG/9z/Vg0qQ/v81tT+ZINjAB drVMErTPeYbzjS4UK4lbyYd9nHWXvuhHaY7uXpLTfAxMB2MSzYUosdcIIXf7y8bUa0Dy 3nBsovvRE9Q1+Ad8cCZCa5xG9nym5HOtUE9uDpHyNGcJE+dHO6SEiXpNPMCuLwii7mg1 9tngrKLuQNt0knOco7lCPT8KRRhaJsgYhwfNoq+ShGw/1aa8hOPYHPknt3A8Nojq4IpP fkhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dk2wrdH5; 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 m8si2267300pgp.322.2019.02.14.18.32.18; Thu, 14 Feb 2019 18:32:34 -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=Dk2wrdH5; 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 S2405984AbfBOCPx (ORCPT + 99 others); Thu, 14 Feb 2019 21:15:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:55434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391123AbfBOCPt (ORCPT ); Thu, 14 Feb 2019 21:15:49 -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 D24E220643; Fri, 15 Feb 2019 02:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196948; bh=LdcnhN3ppJ952Lcr4o+LXP9lBUdJiMNefPLQv+qOfX0=; h=From:To:Cc:Subject:Date:From; b=Dk2wrdH5mNlkvWT6dMa5dX6gmXDLKPUZKvn8hZirTLCvxW1R6KZ7ADlBWZOFsOGEl yIsFbFZRjsJj0Btgw/muK+SujqytWEat9M1HHnlPmMEdkWBLE272jG7dd+KnEsfdOI EAonEoLalgdhrFoOcYq/9Y+NJmGmgdSkdjk5FbMU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Kristian H. Kristensen" , "Kristian H . Kristensen" , Rob Clark , Sasha Levin , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH AUTOSEL 3.18 01/16] drm/msm: Unblock writer if reader closes file Date: Thu, 14 Feb 2019 21:15:31 -0500 Message-Id: <20190215021546.179605-1-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Kristian H. Kristensen" [ Upstream commit 99c66bc051e7407fe0bf0607b142ec0be1a1d1dd ] Prevents deadlock when fifo is full and reader closes file. Signed-off-by: Kristian H. Kristensen Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/msm_rd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c index 9a78c48817c6..909a52b21ebe 100644 --- a/drivers/gpu/drm/msm/msm_rd.c +++ b/drivers/gpu/drm/msm/msm_rd.c @@ -103,7 +103,9 @@ static void rd_write(struct msm_rd_state *rd, const void *buf, int sz) char *fptr = &fifo->buf[fifo->head]; int n; - wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0); + wait_event(rd->fifo_event, circ_space(&rd->fifo) > 0 || !rd->open); + if (!rd->open) + return; n = min(sz, circ_space_to_end(&rd->fifo)); memcpy(fptr, ptr, n); @@ -192,7 +194,10 @@ static int rd_open(struct inode *inode, struct file *file) static int rd_release(struct inode *inode, struct file *file) { struct msm_rd_state *rd = inode->i_private; + rd->open = false; + wake_up_all(&rd->fifo_event); + return 0; } -- 2.19.1