From patchwork Wed Dec 19 16:57:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Kristian_H=C3=B8gsberg?= X-Patchwork-Id: 10737787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5395914DE for ; Wed, 19 Dec 2018 16:58:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 406142B41E for ; Wed, 19 Dec 2018 16:58:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 343712B519; Wed, 19 Dec 2018 16:58:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1D142B41E for ; Wed, 19 Dec 2018 16:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbeLSQ6Q (ORCPT ); Wed, 19 Dec 2018 11:58:16 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:55798 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728576AbeLSQ6Q (ORCPT ); Wed, 19 Dec 2018 11:58:16 -0500 Received: by mail-it1-f195.google.com with SMTP id m62so10671078ith.5 for ; Wed, 19 Dec 2018 08:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZadyrF8Mo4+oQwnfMFeMpdCNXSpGhudrVcvBeRkhKyE=; b=H/FBYSnDN72oykRClOCrWJgkk9HpIM9Uu2hf2GAoPYmxS7QcRZM5rs3yww0llNlyjq o9ir0rqUG50ooGs7sc4T9NMfepWQJNFZf7OeWNKsh3CfscPASWAoVDyUNeskGuAvFRv1 yMmPdGwV5bbw63UKOD3DVxfhCs7OEzIxuAW3e6wRDFWCsBgSapMp0PyiqPpZ/PPYRB6/ Fa7u8aXvT9scHsH2t/Z8h+TP01SV4BaDVn5huF9b+37Q69wyIpYS0ESemi+YLAjb5/5c fWp7IH2jGOUASh5LjjyPVKWTPNrA7LkLsSSFngOzG2Hpf4anuPq1wMj4neuUC6uMJsqm 99BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZadyrF8Mo4+oQwnfMFeMpdCNXSpGhudrVcvBeRkhKyE=; b=OZfgRD6h/pNceYq7XeK0vRpFgSvDF7XTsujAZNDDoAWGS37Tg/LXf6KJ996C/PJdo0 1wAPj7e/kiMtjUQPsf54DnXAkvnOTEj2/M0oa4iAoGTkKFuL7u1kJ9MyKyOFYimkuRyk x0cLQrK7ftLYLxLCqW+fXDyY0fpvp2tPBaL8fmL3BTlqZ1FMtHVvczKgEbausnmh1CU2 LYgMIWkcrV2q6LKyyHa04ReH7LZyKMuXOadE3LFfgPV5R5S52uT6mK+fehBf3MD6DrZE FjgduGaFN5v4vwe0d/XabI720BkjwqmfcjRfsfFdtdwE5HJoTk3jg2tWJ2t+b2tnysUR TQWg== X-Gm-Message-State: AA+aEWbRM3XXqHpjjJuRNblq2yd2U6D74E4zNj+Ha8IpcaO2AZJi5qsZ gTU4iZJ+EOcw5dA5FfZX7I4cRvz5 X-Google-Smtp-Source: AFSGD/WhQAbN+BdDD4eGKxyXpPCeEdcC6st1jORToqIznfoXchhQWm/XrbzAF0dzJb/mSgneOPttkA== X-Received: by 2002:a24:4a95:: with SMTP id k143mr7144442itb.77.1545238695044; Wed, 19 Dec 2018 08:58:15 -0800 (PST) Received: from hawkmoon.pdx.corp.google.com ([2620:15c:f:10:f576:f887:7d74:2d5f]) by smtp.gmail.com with ESMTPSA id p132sm1783762itb.35.2018.12.19.08.58.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 08:58:14 -0800 (PST) From: "Kristian H. Kristensen" X-Google-Original-From: "Kristian H. Kristensen" To: dri-devel@lists.freedesktop.org Cc: "Kristian H. Kristensen" , Rob Clark , David Airlie , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH] drm/msm: Unblock writer if reader closes file Date: Wed, 19 Dec 2018 08:57:41 -0800 Message-Id: <20181219165800.2821-1-hoegsberg@chromium.org> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prevents deadlock when fifo is full and reader closes file. Signed-off-by: Kristian H. Kristensen --- 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 b5672061ae085..d990b5f5154cf 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; }