Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2816320ybl; Mon, 20 Jan 2020 09:52:44 -0800 (PST) X-Google-Smtp-Source: APXvYqwiBgIDmkGxrdVkA/awXVw++ZdPl3j5uDL80bEnJhl1eARfWRhK7aQfctXRFY4uz9QvXwgZ X-Received: by 2002:a05:6830:2111:: with SMTP id i17mr500110otc.24.1579542764486; Mon, 20 Jan 2020 09:52:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579542764; cv=none; d=google.com; s=arc-20160816; b=Z+oRCCoGSqri6QvAGfxYPv+SFtjVVYdyNNfddku2QmOW9694Qjr6finbfG3V1S/Wxs 2OtGkPAZqmQHj1DwB6Yewc0OSKaJLJLWaXttN765Ko8+F9AqswqaYhgGEV5DKARc/rfK 9DLjSU0WU4KDtlteh4WFqMHvtxKhQYJToi1ZWtN4kMDXhvmFEn30rBOvb67zore09zWl Q/iQzVQ+ebdO83FA9H9bl+i00KLDMWdwTvC8uEP/WYflGyW+6cGbyIvjwfY7Psa44Qd4 pygzaUPCY1vVgmIhF+i1TnagrNJZEZAV0XaDW3yVfX/zmME1jxaCoxd2KYVuxq18y/Sj AinA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:cc:to:subject:dkim-signature :dkim-filter; bh=LQu0WAK7L/G6p0pzpWUx1m8ZKHecfzvgq8NfbkxkCU0=; b=W2Pba20XHLN78CEjcNsHDPYP1oqfsADWXzN+A/WfjBxzP448v4iOM0B7iPtAQIjNIi CTJgxYc6up5DQ/DpXwul5m/xkfS7umFw8aVkg8O9Qt7CudH/Q3LG6jMjlGj3hSNxOKug XlyfO1Z5iDCrS9lVpRriEdHBDhg6BU8xjQh5wwWNrcW5jx1fftmpc3qSRF/yJLEy07ZG DfKImFUOPy7uG1Da3VHlzpHWwPYg79Hasq1SnFxd2kDqUrEpylLnWK8EPGYO6E7yAt9+ LYiih6lxcP5+qcVleBd1RDNYUYEBSVTPbTfVEnB+Zfcv4gVwsRI4fzwn6OLyQ7q0G0rm fOLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Ar8vgtEC; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l186si17832622oib.226.2020.01.20.09.52.32; Mon, 20 Jan 2020 09:52:44 -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=@samsung.com header.s=mail20170921 header.b=Ar8vgtEC; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgATRvT (ORCPT + 99 others); Mon, 20 Jan 2020 12:51:19 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:48856 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgATRvS (ORCPT ); Mon, 20 Jan 2020 12:51:18 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200120175116euoutp02404df0e30ccfbd914a613f7994d4de28~rqbH7cLo62804728047euoutp024 for ; Mon, 20 Jan 2020 17:51:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200120175116euoutp02404df0e30ccfbd914a613f7994d4de28~rqbH7cLo62804728047euoutp024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1579542676; bh=LQu0WAK7L/G6p0pzpWUx1m8ZKHecfzvgq8NfbkxkCU0=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=Ar8vgtECytJfvywEpNTjcLzPPy4YhgYqBqnmLZB+24xagcWdNkLH/qdm4tpq2nQgX ddj9O6xsUjNaRtLtSvOzqfDU0bWmlRfy4ctibvwTGQbakpLWOr1W3K2MG+XCJifRr/ ZzrziM+Q0lmcxHW9wyeJXc2TG98tjgn/mMcFyZyQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200120175116eucas1p2f7a33189967472123183610637356d7d~rqbHvE8lL3191431914eucas1p2m; Mon, 20 Jan 2020 17:51:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id AC.13.61286.398E52E5; Mon, 20 Jan 2020 17:51:15 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200120175115eucas1p16442cb8229ee7e4c54459a67902e12ec~rqbHVEuxl3013830138eucas1p1Y; Mon, 20 Jan 2020 17:51:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200120175115eusmtrp2079e2c08a928be485a3beb72e37b7782~rqbHUf0L83183031830eusmtrp2F; Mon, 20 Jan 2020 17:51:15 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-e2-5e25e893b0d7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A8.B8.07950.398E52E5; Mon, 20 Jan 2020 17:51:15 +0000 (GMT) Received: from [106.120.51.71] (unknown [106.120.51.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200120175113eusmtip2d62b016876d122c0463336b601643865~rqbFXydCR2105521055eusmtip2J; Mon, 20 Jan 2020 17:51:13 +0000 (GMT) Subject: Re: [PATCH] fbdev: wait for references go away To: Gerd Hoffmann , dri-devel@lists.freedesktop.org Cc: marmarek@invisiblethingslab.com, "open list:FRAMEBUFFER LAYER" , open list From: Bartlomiej Zolnierkiewicz Message-ID: Date: Mon, 20 Jan 2020 18:51:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200120100014.23488-1-kraxel@redhat.com> Content-Language: en-US Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsWy7djPc7qTX6jGGaz4ZGZx5et7Notnt04y W5zo+8BqcXnXHDaLz427WBxYPXr33WP3uN99nMnj/b6rbB6fN8kFsERx2aSk5mSWpRbp2yVw Zfz6s5CpYJ1wxeSnX1kaGF/zdzFyckgImEjMb//P3MXIxSEksIJR4uj9/UwQzhdGiWfbf7JC OJ8ZJeZ9WMEO0/Lq0hKoluWMElPmv2WBcN4ySqzbcpoZpEpYwFzi0YdXYLaIgJvE5RmrwYqY BXoYJV4fnAOWYBOwkpjYvooRxOYVsJN4dv0bE4jNIqAqse7QGzYQW1QgQuLTg8OsEDWCEidn PmEBsTmBFpw61ARWwywgLnHryXwmCFteonnrbGaIUxexS/yfVQhhu0h8+Hka6gVhiVfHt0DZ MhL/d84He1pCYB2jxN+OF8wQznZGieWT/7FBVFlL3Dn3C8jmANqgKbF+lz5E2FHiS9MSdpCw hACfxI23ghA38ElM2jadGSLMK9HRJgRRrSaxYdkGNpi1XTtXMk9gVJqF5LNZSL6ZheSbWQh7 FzCyrGIUTy0tzk1PLTbMSy3XK07MLS7NS9dLzs/dxAhMNKf/Hf+0g/HrpaRDjAIcjEo8v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/rPq1dMS2nsD1mewjLtqKP6yK/Ju/s+9aa 0SPCvOm4VvyHBxt4HR0EBS3PNH5N0psRu9p3HeMMBZFD+3YE6iuxFGckGmoxFxUnAgAK4CPR wgIAAA== X-CMS-MailID: 20200120175115eucas1p16442cb8229ee7e4c54459a67902e12ec X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200120100025eucas1p21f5e2da0fd7c1fcb33cb47a97e9e645c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200120100025eucas1p21f5e2da0fd7c1fcb33cb47a97e9e645c References: <20200120100014.23488-1-kraxel@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 1/20/20 11:00 AM, Gerd Hoffmann wrote: > Problem: do_unregister_framebuffer() might return before the device is > fully cleaned up, due to userspace having a file handle for /dev/fb0 do_unregister_framebuffer() doesn't guarantee that fb_info is freed after function's return (it only drops the kernel reference on fb_info). > open. Which can result in drm driver not being able to grab resources > (and fail initialization) because the firmware framebuffer still holds > them. Reportedly plymouth can trigger this. Could you please describe issue some more? I guess that a problem is happening during DRM driver load while fbdev driver is loaded? I assume do_unregister_framebuffer() is called inside do_remove_conflicting_framebuffers()? At first glance it seems to be an user-space issue as it should not be holding references on /dev/fb0 while DRM driver is being loaded. > Fix this by trying to wait until all references are gone. Don't wait > forever though given that userspace might keep the file handle open. Where does the 1s maximum delay come from? Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics > Reported-by: Marek Marczykowski-Górecki > Signed-off-by: Gerd Hoffmann > --- > drivers/video/fbdev/core/fbmem.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c > index d04554959ea7..2ea8ac05b065 100644 > --- a/drivers/video/fbdev/core/fbmem.c > +++ b/drivers/video/fbdev/core/fbmem.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > > #include > > @@ -1707,6 +1708,8 @@ static void unlink_framebuffer(struct fb_info *fb_info) > > static void do_unregister_framebuffer(struct fb_info *fb_info) > { > + int limit = 100; > + > unlink_framebuffer(fb_info); > if (fb_info->pixmap.addr && > (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT)) > @@ -1726,6 +1729,10 @@ static void do_unregister_framebuffer(struct fb_info *fb_info) > fbcon_fb_unregistered(fb_info); > console_unlock(); > > + /* try wait until all references are gone */ > + while (atomic_read(&fb_info->count) > 1 && --limit > 0) > + msleep(10); > + > /* this may free fb info */ > put_fb_info(fb_info); > }