From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Javier Martinez Canillas <javierm@redhat.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Sasha Levin <sashal@kernel.org>,
daniel@ffwll.ch, deller@gmx.de, sam@ravnborg.org,
tzimmermann@suse.de, alexander.deucher@amd.com,
zheyuma97@gmail.com, thunder.leizhen@huawei.com,
deng.changcheng@zte.com.cn, linux-fbdev@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 5.15 13/18] fbdev: Disable sysfb device registration when removing conflicting FBs
Date: Wed, 6 Jul 2022 11:31:48 -0400 [thread overview]
Message-ID: <20220706153153.1598076-13-sashal@kernel.org> (raw)
In-Reply-To: <20220706153153.1598076-1-sashal@kernel.org>
From: Javier Martinez Canillas <javierm@redhat.com>
[ Upstream commit ee7a69aa38d87a3bbced7b8245c732c05ed0c6ec ]
The platform devices registered by sysfb match with firmware-based DRM or
fbdev drivers, that are used to have early graphics using a framebuffer
provided by the system firmware.
DRM or fbdev drivers later are probed and remove conflicting framebuffers,
leading to these platform devices for generic drivers to be unregistered.
But the current solution has a race, since the sysfb_init() function could
be called after a DRM or fbdev driver is probed and request to unregister
the devices for drivers with conflicting framebuffes.
To prevent this, disable any future sysfb platform device registration by
calling sysfb_disable(), if a driver requests to remove the conflicting
framebuffers.
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220607182338.344270-4-javierm@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/video/fbdev/core/fbmem.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 0371ad233fdf..ba9c66a95ada 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -19,6 +19,7 @@
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/slab.h>
+#include <linux/sysfb.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/vt.h>
@@ -1774,6 +1775,17 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
do_free = true;
}
+ /*
+ * If a driver asked to unregister a platform device registered by
+ * sysfb, then can be assumed that this is a driver for a display
+ * that is set up by the system firmware and has a generic driver.
+ *
+ * Drivers for devices that don't have a generic driver will never
+ * ask for this, so let's assume that a real driver for the display
+ * was already probed and prevent sysfb to register devices later.
+ */
+ sysfb_disable();
+
mutex_lock(®istration_lock);
do_remove_conflicting_framebuffers(a, name, primary);
mutex_unlock(®istration_lock);
--
2.35.1
next prev parent reply other threads:[~2022-07-06 15:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 15:31 [PATCH AUTOSEL 5.15 01/18] ksmbd: use SOCK_NONBLOCK type for kernel_accept() Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 02/18] powerpc/xive/spapr: correct bitmap allocation size Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 03/18] vdpa/mlx5: Initialize CVQ vringh only once Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 04/18] vduse: Tie vduse mgmtdev and its device Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 05/18] virtio_mmio: Add missing PM calls to freeze/restore Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 06/18] virtio_mmio: Restore guest page size on resume Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 07/18] netfilter: br_netfilter: do not skip all hooks with 0 priority Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 08/18] scsi: hisi_sas: Limit max hw sectors for v3 HW Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 09/18] cpufreq: pmac32-cpufreq: Fix refcount leak bug Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 10/18] platform/x86: hp-wmi: Ignore Sanitization Mode event Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 11/18] firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 12/18] firmware: sysfb: Add sysfb_disable() helper function Sasha Levin
2022-07-06 15:31 ` Sasha Levin [this message]
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 14/18] net: tipc: fix possible refcount leak in tipc_sk_create() Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 15/18] NFC: nxp-nci: don't print header length mismatch on i2c error Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 16/18] nvme-tcp: always fail a request when sending it failed Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 17/18] nvme: fix regression when disconnect a recovering ctrl Sasha Levin
2022-07-06 15:31 ` [PATCH AUTOSEL 5.15 18/18] net: sfp: fix memory leak in sfp_probe() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220706153153.1598076-13-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=alexander.deucher@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=deller@gmx.de \
--cc=deng.changcheng@zte.com.cn \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
--cc=stable@vger.kernel.org \
--cc=thunder.leizhen@huawei.com \
--cc=tzimmermann@suse.de \
--cc=zheyuma97@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox