Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp197335imj; Thu, 14 Feb 2019 18:28:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IYntPhY67P6t71FE7PRDEDL2dVUNbCJMZTEFfQGQ2DhUTrAWhZAxe5jk5QHSJsQiYzxo0oG X-Received: by 2002:a62:11ca:: with SMTP id 71mr3277618pfr.18.1550197733830; Thu, 14 Feb 2019 18:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197733; cv=none; d=google.com; s=arc-20160816; b=NFwuF5gsylPi7DjZwuSLWaXLVnkgTCuA57UT4Z8ugedbMM5KPgQZl0306LExeuLuse nS654m9M6AWMEZhyqsP1a1OnVdkhEn+Z2LmNE1pqeeTJA/3c0jjv9PQoZ7lqTliQ+fm6 80PS5bIEiB6iVqPdNGlXnG18wYqdxzLZEVAtvpPRacc2c1OTyp5ErnOiVqBkQSOTbe9J WzeKrDjfJF9rMgsg/ruguUTjTqGGtF4x5Prha+LHiVgaHzbdTCeaQrKdEPwWJFK1XAyw fTusfoEruA14AFrwniTmImO9Mbd9benT1n+Tb2/5NgMGVvDfzoFG6HoFLsu0rcxgHoRH XsxA== 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=OMz+6nr4H8F7yHLQmigyZJ4p/IYAFQ1Svn4V4R3OUcE=; b=uGyQaLEvhJ9MPc5C43MhrP/ElBntAafMZl9RJID1w5wW6Ph0jAJUEtcqaLQLfDa0ew WZcqbFzUUg8v99mIM/l8BPkuGXafwp69EuP6x2olYQFyKQ7ABl484S8qlyYpNiEdqNzF 5pNPsNoy2fXyn/+TJV1FEUhJSrGJ+pZ8szW7n1aHiH8lJiOleE93ekxiP5whXssGWtLH 5LT6n4TRdmsr48bFpJcYMiNF3+8vFZJu8VF0VwnUoc7F2MGyFFgdDFJyrQ+hmVwCetaX nL/6yDjbRgyqlVzrt5tcx8GiLxP7kz7s9WLGK7HeIlO4ZwCoEg1TLiZT0mB1AqdtRqsP ubNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xGat0EnT; 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 g2si4095734pfd.200.2019.02.14.18.28.37; Thu, 14 Feb 2019 18:28:53 -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=xGat0EnT; 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 S1731407AbfBOCI7 (ORCPT + 99 others); Thu, 14 Feb 2019 21:08:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:49146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726237AbfBOCI6 (ORCPT ); Thu, 14 Feb 2019 21:08:58 -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 3E443206BA; Fri, 15 Feb 2019 02:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196538; bh=Q//WEul+NCweA1gN4aPnNqITUch2XHQmjN1abGufL60=; h=From:To:Cc:Subject:Date:From; b=xGat0EnThfUcllOtN5jYpMNovO5EmfaYI8l5Ekm/tj3cmTWY4JlRdN4LHI8k/tzJ5 r2xLQT6gkRawSiv7mvpOYnW1wQGcFGpE2+5lotIVop2xoXaTWFP+6ozrwnv661iCzW u3Wm0culttYTHcopOytglQDtNc+oF8fXtSDpFRLU= 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 4.20 01/77] drm/msm: Unblock writer if reader closes file Date: Thu, 14 Feb 2019 21:07:39 -0500 Message-Id: <20190215020855.176727-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 0c2c8d2c631f..25fc161ab618 100644 --- a/drivers/gpu/drm/msm/msm_rd.c +++ b/drivers/gpu/drm/msm/msm_rd.c @@ -115,7 +115,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; /* Note that smp_load_acquire() is not strictly required * as CIRC_SPACE_TO_END() does not access the tail more @@ -213,7 +215,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