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: 10737789 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 A9AAD14DE for ; Wed, 19 Dec 2018 16:58:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 994CD2B41E for ; Wed, 19 Dec 2018 16:58:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D6DD2B522; Wed, 19 Dec 2018 16:58:18 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3CA332B41E for ; Wed, 19 Dec 2018 16:58:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C1376F0CE; Wed, 19 Dec 2018 16:58:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-it1-x142.google.com (mail-it1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by gabe.freedesktop.org (Postfix) with ESMTPS id 243866F0CE; Wed, 19 Dec 2018 16:58:16 +0000 (UTC) Received: by mail-it1-x142.google.com with SMTP id z7so10712868iti.0; Wed, 19 Dec 2018 08:58:16 -0800 (PST) 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=PqjuGxu2TFBmVZABKS0+IkofXksIxtGBChe3l8qLWhiKKoe5hTzsk+N7GSAyvicaNA 27W9p3QS0D/s7UxwpaJT2VRzfn10QGvWI9lzC3ZNO7I7WEeuxGTBDFvJ6OdrsJCFXBxd BRCxyEtsCLcsnwtw88zqZOIHxeF6Ysq0LPzUNGeNoAOVAzRU1kxBCoRrW/XueWXg1SDz 7nr+BZ9f0Vb1KUfBOd+jNKpoItOioZMdNQgkpi7ff6VrgaQmkAG/1HxDSkesLtGqqUdQ x3jA+wp2iz1+jJgYgaql1RfUfv5hyRO2kJ5dO+yE0W6eOJfeD0/zg4mcqQDTNkSYFfhP CSQw== X-Gm-Message-State: AA+aEWboWn6FY2RSSHBCseIebzgbwQby1rhQL000g134SDEJO6B3MnDS y36cXjhR71uXHOTInFMkMLYITZKw 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-arm-msm@vger.kernel.org, "Kristian H. Kristensen" , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }