Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH 6.1 067/132] tty: vt: make consw::con_switch() return a bool
From: Greg Kroah-Hartman @ 2025-07-03 14:42 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiri Slaby (SUSE), Helge Deller,
	James E.J. Bottomley, Daniel Vetter, linux-fbdev, dri-devel,
	linux-parisc, Sasha Levin
In-Reply-To: <20250703143939.370927276@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby (SUSE) <jirislaby@kernel.org>

[ Upstream commit 8d5cc8eed738e3202379722295c626cba0849785 ]

The non-zero (true) return value from consw::con_switch() means a redraw
is needed. So make this return type a bool explicitly instead of int.
The latter might imply that -Eerrors are expected. They are not.

And document the hook.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-parisc@vger.kernel.org
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-31-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/vt/vt.c                 | 2 +-
 drivers/video/console/dummycon.c    | 4 ++--
 drivers/video/console/mdacon.c      | 4 ++--
 drivers/video/console/newport_con.c | 4 ++--
 drivers/video/console/sticon.c      | 4 ++--
 drivers/video/console/vgacon.c      | 4 ++--
 drivers/video/fbdev/core/fbcon.c    | 6 +++---
 include/linux/console.h             | 4 +++-
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 609d2bac58d0b..ccfd9d93c10c5 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1014,7 +1014,7 @@ void redraw_screen(struct vc_data *vc, int is_switch)
 	}
 
 	if (redraw) {
-		int update;
+		bool update;
 		int old_was_color = vc->vc_can_do_color;
 
 		set_origin(vc);
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index 6918014b02408..d701f2b51f5b1 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -119,9 +119,9 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
 	return false;
 }
 
-static int dummycon_switch(struct vc_data *vc)
+static bool dummycon_switch(struct vc_data *vc)
 {
-	return 0;
+	return false;
 }
 
 /*
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 1ddbb6cd5b0ca..26b41a8f36c87 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -454,9 +454,9 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,
 	scr_memsetw(dest, eattr, width * 2);
 }
 
-static int mdacon_switch(struct vc_data *c)
+static bool mdacon_switch(struct vc_data *c)
 {
-	return 1;	/* redrawing needed */
+	return true;	/* redrawing needed */
 }
 
 static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index 5dac00c825946..1ebb18bf10983 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -462,7 +462,7 @@ static void newport_cursor(struct vc_data *vc, int mode)
 	}
 }
 
-static int newport_switch(struct vc_data *vc)
+static bool newport_switch(struct vc_data *vc)
 {
 	static int logo_drawn = 0;
 
@@ -476,7 +476,7 @@ static int newport_switch(struct vc_data *vc)
 		}
 	}
 
-	return 1;
+	return true;
 }
 
 static int newport_blank(struct vc_data *c, int blank, int mode_switch)
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 58e983b18f1f4..6b82194a8ef36 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -309,9 +309,9 @@ static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx,
 	      conp->vc_video_erase_char, font_data[conp->vc_num]);
 }
 
-static int sticon_switch(struct vc_data *conp)
+static bool sticon_switch(struct vc_data *conp)
 {
-    return 1;	/* needs refreshing */
+    return true;	/* needs refreshing */
 }
 
 static int sticon_blank(struct vc_data *c, int blank, int mode_switch)
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 6998e28441c97..81f27cd610271 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -595,7 +595,7 @@ static int vgacon_doresize(struct vc_data *c,
 	return 0;
 }
 
-static int vgacon_switch(struct vc_data *c)
+static bool vgacon_switch(struct vc_data *c)
 {
 	int x = c->vc_cols * VGA_FONTWIDTH;
 	int y = c->vc_rows * c->vc_cell_height;
@@ -624,7 +624,7 @@ static int vgacon_switch(struct vc_data *c)
 			vgacon_doresize(c, c->vc_cols, c->vc_rows);
 	}
 
-	return 0;		/* Redrawing not needed */
+	return false;		/* Redrawing not needed */
 }
 
 static void vga_set_palette(struct vc_data *vc, const unsigned char *table)
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 3fd76dc6010b4..1a17274187112 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2073,7 +2073,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
 	return 0;
 }
 
-static int fbcon_switch(struct vc_data *vc)
+static bool fbcon_switch(struct vc_data *vc)
 {
 	struct fb_info *info, *old_info = NULL;
 	struct fbcon_ops *ops;
@@ -2195,9 +2195,9 @@ static int fbcon_switch(struct vc_data *vc)
 			      vc->vc_origin + vc->vc_size_row * vc->vc_top,
 			      vc->vc_size_row * (vc->vc_bottom -
 						 vc->vc_top) / 2);
-		return 0;
+		return false;
 	}
-	return 1;
+	return true;
 }
 
 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
diff --git a/include/linux/console.h b/include/linux/console.h
index d7b45c60cf02f..ab8b19f6affab 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -40,6 +40,8 @@ enum vc_intensity;
  * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
  *		Return true if no generic handling should be done.
  *		Invoked by csi_M and printing to the console.
+ * @con_switch: notifier about the console switch; it is supposed to return
+ *		true if a redraw is needed.
  * @con_set_palette: sets the palette of the console to @table (optional)
  * @con_scrolldelta: the contents of the console should be scrolled by @lines.
  *		     Invoked by user. (optional)
@@ -58,7 +60,7 @@ struct consw {
 	bool	(*con_scroll)(struct vc_data *vc, unsigned int top,
 			unsigned int bottom, enum con_scroll dir,
 			unsigned int lines);
-	int	(*con_switch)(struct vc_data *vc);
+	bool	(*con_switch)(struct vc_data *vc);
 	int	(*con_blank)(struct vc_data *vc, int blank, int mode_switch);
 	int	(*con_font_set)(struct vc_data *vc, struct console_font *font,
 			unsigned int flags);
-- 
2.39.5




^ permalink raw reply related

* [PATCH 6.1 068/132] dummycon: Trigger redraw when switching consoles with deferred takeover
From: Greg Kroah-Hartman @ 2025-07-03 14:42 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Thomas Zimmermann, Andrei Borzenkov,
	Javier Martinez Canillas, Hans de Goede, linux-fbdev, dri-devel,
	Sasha Levin
In-Reply-To: <20250703143939.370927276@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Zimmermann <tzimmermann@suse.de>

[ Upstream commit 03bcbbb3995ba5df43af9aba45334e35f2dfe27b ]

Signal vt subsystem to redraw console when switching to dummycon
with deferred takeover enabled. Makes the console switch to fbcon
and displays the available output.

With deferred takeover enabled, dummycon acts as the placeholder
until the first output to the console happens. At that point, fbcon
takes over. If the output happens while dummycon is not active, it
cannot inform fbcon. This is the case if the vt subsystem runs in
graphics mode.

A typical graphical boot starts plymouth, a display manager and a
compositor; all while leaving out dummycon. Switching to a text-mode
console leaves the console with dummycon even if a getty terminal
has been started.

Returning true from dummycon's con_switch helper signals the vt
subsystem to redraw the screen. If there's output available dummycon's
con_putc{s} helpers trigger deferred takeover of fbcon, which sets a
display mode and displays the output. If no output is available,
dummycon remains active.

v2:
- make the comment slightly more verbose (Javier)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reported-by: Andrei Borzenkov <arvidjaar@gmail.com>
Closes: https://bugzilla.suse.com/show_bug.cgi?id=1242191
Tested-by: Andrei Borzenkov <arvidjaar@gmail.com>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Fixes: 83d83bebf401 ("console/fbcon: Add support for deferred console takeover")
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.19+
Link: https://lore.kernel.org/r/20250520071418.8462-1-tzimmermann@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/console/dummycon.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index d701f2b51f5b1..d99e1b3e4e5c1 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -82,6 +82,15 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
 	/* Redraw, so that we get putc(s) for output done while blanked */
 	return 1;
 }
+
+static bool dummycon_switch(struct vc_data *vc)
+{
+	/*
+	 * Redraw, so that we get putc(s) for output done while switched
+	 * away. Informs deferred consoles to take over the display.
+	 */
+	return true;
+}
 #else
 static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
 static void dummycon_putcs(struct vc_data *vc, const unsigned short *s,
@@ -90,6 +99,10 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
 {
 	return 0;
 }
+static bool dummycon_switch(struct vc_data *vc)
+{
+	return false;
+}
 #endif
 
 static const char *dummycon_startup(void)
@@ -119,11 +132,6 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
 	return false;
 }
 
-static bool dummycon_switch(struct vc_data *vc)
-{
-	return false;
-}
-
 /*
  *  The console `switch' structure for the dummy console
  *
-- 
2.39.5




^ permalink raw reply related

* [PATCH] fbdev: simplefb: Use of_reserved_mem_region_to_resource() for "memory-region"
From: Rob Herring (Arm) @ 2025-07-03 18:35 UTC (permalink / raw)
  To: Hans de Goede, Helge Deller; +Cc: linux-fbdev, dri-devel, linux-kernel

Use the newly added of_reserved_mem_region_to_resource() function to
handle "memory-region" properties.

The error handling is a bit different. "memory-region" is optional, so
failed lookup is not an error. But then an error in
of_address_to_resource() is treated as an error. However, that
distinction is not really important. Either the region is available
and usable or it is not. So now, it is just
of_reserved_mem_region_to_resource() which is checked for an error.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 drivers/video/fbdev/simplefb.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index be95fcddce4c..1893815dc67f 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -21,9 +21,9 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
 #include <linux/of_clk.h>
 #include <linux/of_platform.h>
+#include <linux/of_reserved_mem.h>
 #include <linux/parser.h>
 #include <linux/pm_domain.h>
 #include <linux/regulator/consumer.h>
@@ -134,7 +134,7 @@ struct simplefb_params {
 static int simplefb_parse_dt(struct platform_device *pdev,
 			   struct simplefb_params *params)
 {
-	struct device_node *np = pdev->dev.of_node, *mem;
+	struct device_node *np = pdev->dev.of_node;
 	int ret;
 	const char *format;
 	int i;
@@ -174,19 +174,10 @@ static int simplefb_parse_dt(struct platform_device *pdev,
 		return -EINVAL;
 	}
 
-	mem = of_parse_phandle(np, "memory-region", 0);
-	if (mem) {
-		ret = of_address_to_resource(mem, 0, &params->memory);
-		if (ret < 0) {
-			dev_err(&pdev->dev, "failed to parse memory-region\n");
-			of_node_put(mem);
-			return ret;
-		}
-
+	ret = of_reserved_mem_region_to_resource(np, 0, &params->memory);
+	if (!ret) {
 		if (of_property_present(np, "reg"))
 			dev_warn(&pdev->dev, "preferring \"memory-region\" over \"reg\" property\n");
-
-		of_node_put(mem);
 	} else {
 		memset(&params->memory, 0, sizeof(params->memory));
 	}
-- 
2.47.2


^ permalink raw reply related

* Re: [PATCH v2 3/5] drm/sysfb: simpledrm: Add support for interconnect paths
From: Dmitry Baryshkov @ 2025-07-06 11:14 UTC (permalink / raw)
  To: Luca Weiss
  Cc: Hans de Goede, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Javier Martinez Canillas,
	Helge Deller, linux-fbdev, dri-devel, devicetree, linux-kernel
In-Reply-To: <20250623-simple-drm-fb-icc-v2-3-f69b86cd3d7d@fairphone.com>

On Mon, Jun 23, 2025 at 08:44:47AM +0200, Luca Weiss wrote:
> Some devices might require keeping an interconnect path alive so that
> the framebuffer continues working. Add support for that by setting the
> bandwidth requirements appropriately for all provided interconnect
> paths.
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
> ---
>  drivers/gpu/drm/sysfb/simpledrm.c | 83 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 83 insertions(+)

If simpledrm is being replaced by a proper DRM driver (thus removing
those extra votes), will it prevent ICC device from reaching the sync
state?

-- 
With best wishes
Dmitry

^ permalink raw reply

* Re: [PATCH v2 1/5] dt-bindings: display: simple-framebuffer: Add interconnects property
From: Dmitry Baryshkov @ 2025-07-06 11:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Hans de Goede, Luca Weiss, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Javier Martinez Canillas,
	Helge Deller, linux-fbdev, dri-devel, devicetree, linux-kernel
In-Reply-To: <6e4253dd-cd73-4302-b9df-44c8c311eb22@kernel.org>

On Wed, Jul 02, 2025 at 10:43:27PM +0200, Krzysztof Kozlowski wrote:
> On 30/06/2025 10:40, Hans de Goede wrote:
> >>
> >> No one asks to drop them from the driver. I only want specific front
> >> compatible which will list and constrain the properties. It is not
> >> contradictory to your statements, U-boot support, driver support. I
> >> really do not see ANY argument why this cannot follow standard DT rules.
> > 
> > So what you are saying is that you want something like:
> > 
> > framebuffer0: framebuffer@1d385000 {
> > 	compatible = "qcom.simple-framebuffer-sm8650-mdss", "simple-framebuffer";
> > }
> > 
> > and that the binding for qcom.simple-framebuffer-sm8650-mdss
> > can then list interconnects ?
> IMO yes (after adjusting above to coding style), but as mentioned in
> other response you can just get an ack or opinion from Rob or Conor.

But, this way we end up describing MDSS hardware block twice: once with
the proper device structure and once more in the simple-framebuffer
definition. I think this is a bit strange.

I understand your point of having a device-specific compatible string
and also having a verifiable schema, but I think it's an overkill here.

Consider regulator supplies of this simple-framebuffer. Obviously some
of them supply the panel and not the SoC parts. Should we also include
the panel into the respective compat string? What about describing the
device with two different DSI panels?

I think this explodes too quickly to be useful. I'd cast my (small) vote
into continuing using the simple-framebuffer as is, without additional
compatible strings and extend the bindings allowing unbound number of
interconnects.

-- 
With best wishes
Dmitry

^ permalink raw reply

* Re: [PATCH] fbdev: efifb: do not load efifb if PCI BAR has changed but not fixuped
From: Shixiong Ou @ 2025-07-07  9:24 UTC (permalink / raw)
  To: Thomas Zimmermann, Helge Deller
  Cc: Peter Jones, linux-fbdev, dri-devel, linux-kernel, Shixiong Ou
In-Reply-To: <3b3feb03-c417-4569-b7b0-44565d7cce4f@suse.de>


在 2025/6/27 17:13, Thomas Zimmermann 写道:
> Hi
>
> Am 26.06.25 um 11:49 schrieb oushixiong1025@163.com:
>> From: Shixiong Ou <oushixiong@kylinos.cn>
>>
>> [WHY]
>> On an ARM machine, the following log is present:
>> [    0.900884] efifb: framebuffer at 0x1020000000, using 3072k, total 
>> 3072k
>> [    2.297884] amdgpu 0000:04:00.0: 
>> remove_conflicting_pci_framebuffers: bar 0: 0x1000000000 -> 0x100fffffff
>> [    2.297886] amdgpu 0000:04:00.0: 
>> remove_conflicting_pci_framebuffers: bar 2: 0x1010000000 -> 0x10101fffff
>> [    2.297888] amdgpu 0000:04:00.0: 
>> remove_conflicting_pci_framebuffers: bar 5: 0x58200000 -> 0x5823ffff
>>
>> It show that the efifb framebuffer base is out of PCI BAR, and this
>> results in both efi-framebuffer and amdgpudrmfb co-existing.
>>
>> The fbcon will be bound to efi-framebuffer by default and cannot be 
>> used.
>>
>> [HOW]
>> Do not load efifb driver if PCI BAR has changed but not fixuped.
>> In the following cases:
>>     1. screen_info_lfb_pdev is NULL.
>>     2. __screen_info_relocation_is_valid return false.
>
> Apart from ruling out invalid screen_info, did you figure out why the 
> relocation tracking didn't work? It would be good to fix this if 
> possible.
>
> Best regards
> Thomas
>
I haven’t figure out the root cause yet.

This issue is quite rare and might be related to the EFI firmware.
However, I wonder if we could add some handling when no PCI resources 
are found in screen_info_fixup_lfb(), as a temporary workaround for the 
problem I mentioned earlier.

Best regards
Shixiong Ou

>>
>> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
>> ---
>>   drivers/video/fbdev/efifb.c     |  4 ++++
>>   drivers/video/screen_info_pci.c | 24 ++++++++++++++++++++++++
>>   include/linux/screen_info.h     |  5 +++++
>>   3 files changed, 33 insertions(+)
>>
>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>> index 0e1bd3dba255..de8d016c9a66 100644
>> --- a/drivers/video/fbdev/efifb.c
>> +++ b/drivers/video/fbdev/efifb.c
>> @@ -303,6 +303,10 @@ static void efifb_setup(struct screen_info *si, 
>> char *options)
>>     static inline bool fb_base_is_valid(struct screen_info *si)
>>   {
>> +    /* check whether fb_base has changed but not fixuped */
>> +    if (!screen_info_is_useful())
>> +        return false;
>> +
>>       if (si->lfb_base)
>>           return true;
>>   diff --git a/drivers/video/screen_info_pci.c 
>> b/drivers/video/screen_info_pci.c
>> index 66bfc1d0a6dc..ac57dcaf0cac 100644
>> --- a/drivers/video/screen_info_pci.c
>> +++ b/drivers/video/screen_info_pci.c
>> @@ -9,6 +9,8 @@ static struct pci_dev *screen_info_lfb_pdev;
>>   static size_t screen_info_lfb_bar;
>>   static resource_size_t screen_info_lfb_res_start; // original start 
>> of resource
>>   static resource_size_t screen_info_lfb_offset; // framebuffer 
>> offset within resource
>> +static bool screen_info_changed;
>> +static bool screen_info_fixuped;
>>     static bool __screen_info_relocation_is_valid(const struct 
>> screen_info *si, struct resource *pr)
>>   {
>> @@ -24,6 +26,24 @@ static bool 
>> __screen_info_relocation_is_valid(const struct screen_info *si, stru
>>       return true;
>>   }
>>   +bool screen_info_is_useful(void)
>> +{
>> +    unsigned int type;
>> +    const struct screen_info *si = &screen_info;
>> +
>> +    type = screen_info_video_type(si);
>> +    if (type != VIDEO_TYPE_EFI)
>> +        return true;
>> +
>> +    if (screen_info_changed && !screen_info_fixuped) {
>> +        pr_warn("The screen_info has changed but not fixuped");
>> +        return false;
>> +    }
>> +
>> +    pr_info("The screen_info is useful");
>> +    return true;
>> +}
>> +
>>   void screen_info_apply_fixups(void)
>>   {
>>       struct screen_info *si = &screen_info;
>> @@ -32,18 +52,22 @@ void screen_info_apply_fixups(void)
>>           struct resource *pr = 
>> &screen_info_lfb_pdev->resource[screen_info_lfb_bar];
>>             if (pr->start != screen_info_lfb_res_start) {
>> +            screen_info_changed = true;
>>               if (__screen_info_relocation_is_valid(si, pr)) {
>>                   /*
>>                    * Only update base if we have an actual
>>                    * relocation to a valid I/O range.
>>                    */
>>                   __screen_info_set_lfb_base(si, pr->start + 
>> screen_info_lfb_offset);
>> +                screen_info_fixuped = true;
>>                   pr_info("Relocating firmware framebuffer to offset 
>> %pa[d] within %pr\n",
>>                       &screen_info_lfb_offset, pr);
>>               } else {
>>                   pr_warn("Invalid relocating, disabling firmware 
>> framebuffer\n");
>>               }
>>           }
>> +    } else {
>> +        screen_info_changed = true;
>>       }
>>   }
>>   diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
>> index 923d68e07679..632cdbb1adbe 100644
>> --- a/include/linux/screen_info.h
>> +++ b/include/linux/screen_info.h
>> @@ -138,9 +138,14 @@ ssize_t screen_info_resources(const struct 
>> screen_info *si, struct resource *r,
>>   u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si);
>>     #if defined(CONFIG_PCI)
>> +bool screen_info_is_useful(void);
>>   void screen_info_apply_fixups(void);
>>   struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
>>   #else
>> +bool screen_info_is_useful(void)
>> +{
>> +    return true;
>> +}
>>   static inline void screen_info_apply_fixups(void)
>>   { }
>>   static inline struct pci_dev *screen_info_pci_dev(const struct 
>> screen_info *si)
>


^ permalink raw reply

* Re: [PATCH] fbdev: efifb: do not load efifb if PCI BAR has changed but not fixuped
From: Thomas Zimmermann @ 2025-07-07  9:28 UTC (permalink / raw)
  To: Shixiong Ou, Helge Deller
  Cc: Peter Jones, linux-fbdev, dri-devel, linux-kernel, Shixiong Ou
In-Reply-To: <a937f41f-2cee-459d-b94f-b7f979072f3e@163.com>

Hi

Am 07.07.25 um 11:24 schrieb Shixiong Ou:
>
> 在 2025/6/27 17:13, Thomas Zimmermann 写道:
>> Hi
>>
>> Am 26.06.25 um 11:49 schrieb oushixiong1025@163.com:
>>> From: Shixiong Ou <oushixiong@kylinos.cn>
>>>
>>> [WHY]
>>> On an ARM machine, the following log is present:
>>> [    0.900884] efifb: framebuffer at 0x1020000000, using 3072k, 
>>> total 3072k
>>> [    2.297884] amdgpu 0000:04:00.0: 
>>> remove_conflicting_pci_framebuffers: bar 0: 0x1000000000 -> 
>>> 0x100fffffff
>>> [    2.297886] amdgpu 0000:04:00.0: 
>>> remove_conflicting_pci_framebuffers: bar 2: 0x1010000000 -> 
>>> 0x10101fffff
>>> [    2.297888] amdgpu 0000:04:00.0: 
>>> remove_conflicting_pci_framebuffers: bar 5: 0x58200000 -> 0x5823ffff
>>>
>>> It show that the efifb framebuffer base is out of PCI BAR, and this
>>> results in both efi-framebuffer and amdgpudrmfb co-existing.
>>>
>>> The fbcon will be bound to efi-framebuffer by default and cannot be 
>>> used.
>>>
>>> [HOW]
>>> Do not load efifb driver if PCI BAR has changed but not fixuped.
>>> In the following cases:
>>>     1. screen_info_lfb_pdev is NULL.
>>>     2. __screen_info_relocation_is_valid return false.
>>
>> Apart from ruling out invalid screen_info, did you figure out why the 
>> relocation tracking didn't work? It would be good to fix this if 
>> possible.
>>
>> Best regards
>> Thomas
>>
> I haven’t figure out the root cause yet.
>
> This issue is quite rare and might be related to the EFI firmware.
> However, I wonder if we could add some handling when no PCI resources 
> are found in screen_info_fixup_lfb(), as a temporary workaround for 
> the problem I mentioned earlier.

As I said elsewhere in the thread, you can clear the screen_info's video 
type in the branch at [1] to disable it entirely. We should have 
probably done this anyway. Knowing the cause of the issue would still be 
nice though.

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v6.15.5/source/drivers/video/screen_info_pci.c#L44

>
> Best regards
> Shixiong Ou
>
>>>
>>> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
>>> ---
>>>   drivers/video/fbdev/efifb.c     |  4 ++++
>>>   drivers/video/screen_info_pci.c | 24 ++++++++++++++++++++++++
>>>   include/linux/screen_info.h     |  5 +++++
>>>   3 files changed, 33 insertions(+)
>>>
>>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>>> index 0e1bd3dba255..de8d016c9a66 100644
>>> --- a/drivers/video/fbdev/efifb.c
>>> +++ b/drivers/video/fbdev/efifb.c
>>> @@ -303,6 +303,10 @@ static void efifb_setup(struct screen_info *si, 
>>> char *options)
>>>     static inline bool fb_base_is_valid(struct screen_info *si)
>>>   {
>>> +    /* check whether fb_base has changed but not fixuped */
>>> +    if (!screen_info_is_useful())
>>> +        return false;
>>> +
>>>       if (si->lfb_base)
>>>           return true;
>>>   diff --git a/drivers/video/screen_info_pci.c 
>>> b/drivers/video/screen_info_pci.c
>>> index 66bfc1d0a6dc..ac57dcaf0cac 100644
>>> --- a/drivers/video/screen_info_pci.c
>>> +++ b/drivers/video/screen_info_pci.c
>>> @@ -9,6 +9,8 @@ static struct pci_dev *screen_info_lfb_pdev;
>>>   static size_t screen_info_lfb_bar;
>>>   static resource_size_t screen_info_lfb_res_start; // original 
>>> start of resource
>>>   static resource_size_t screen_info_lfb_offset; // framebuffer 
>>> offset within resource
>>> +static bool screen_info_changed;
>>> +static bool screen_info_fixuped;
>>>     static bool __screen_info_relocation_is_valid(const struct 
>>> screen_info *si, struct resource *pr)
>>>   {
>>> @@ -24,6 +26,24 @@ static bool 
>>> __screen_info_relocation_is_valid(const struct screen_info *si, stru
>>>       return true;
>>>   }
>>>   +bool screen_info_is_useful(void)
>>> +{
>>> +    unsigned int type;
>>> +    const struct screen_info *si = &screen_info;
>>> +
>>> +    type = screen_info_video_type(si);
>>> +    if (type != VIDEO_TYPE_EFI)
>>> +        return true;
>>> +
>>> +    if (screen_info_changed && !screen_info_fixuped) {
>>> +        pr_warn("The screen_info has changed but not fixuped");
>>> +        return false;
>>> +    }
>>> +
>>> +    pr_info("The screen_info is useful");
>>> +    return true;
>>> +}
>>> +
>>>   void screen_info_apply_fixups(void)
>>>   {
>>>       struct screen_info *si = &screen_info;
>>> @@ -32,18 +52,22 @@ void screen_info_apply_fixups(void)
>>>           struct resource *pr = 
>>> &screen_info_lfb_pdev->resource[screen_info_lfb_bar];
>>>             if (pr->start != screen_info_lfb_res_start) {
>>> +            screen_info_changed = true;
>>>               if (__screen_info_relocation_is_valid(si, pr)) {
>>>                   /*
>>>                    * Only update base if we have an actual
>>>                    * relocation to a valid I/O range.
>>>                    */
>>>                   __screen_info_set_lfb_base(si, pr->start + 
>>> screen_info_lfb_offset);
>>> +                screen_info_fixuped = true;
>>>                   pr_info("Relocating firmware framebuffer to offset 
>>> %pa[d] within %pr\n",
>>>                       &screen_info_lfb_offset, pr);
>>>               } else {
>>>                   pr_warn("Invalid relocating, disabling firmware 
>>> framebuffer\n");
>>>               }
>>>           }
>>> +    } else {
>>> +        screen_info_changed = true;
>>>       }
>>>   }
>>>   diff --git a/include/linux/screen_info.h 
>>> b/include/linux/screen_info.h
>>> index 923d68e07679..632cdbb1adbe 100644
>>> --- a/include/linux/screen_info.h
>>> +++ b/include/linux/screen_info.h
>>> @@ -138,9 +138,14 @@ ssize_t screen_info_resources(const struct 
>>> screen_info *si, struct resource *r,
>>>   u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si);
>>>     #if defined(CONFIG_PCI)
>>> +bool screen_info_is_useful(void);
>>>   void screen_info_apply_fixups(void);
>>>   struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
>>>   #else
>>> +bool screen_info_is_useful(void)
>>> +{
>>> +    return true;
>>> +}
>>>   static inline void screen_info_apply_fixups(void)
>>>   { }
>>>   static inline struct pci_dev *screen_info_pci_dev(const struct 
>>> screen_info *si)
>>
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


^ permalink raw reply

* Re: [PATCH] fbdev: efifb: do not load efifb if PCI BAR has changed but not fixuped
From: Shixiong Ou @ 2025-07-07 10:02 UTC (permalink / raw)
  To: Thomas Zimmermann, Helge Deller
  Cc: Peter Jones, linux-fbdev, dri-devel, linux-kernel, Shixiong Ou
In-Reply-To: <1687bb52-e724-46a8-af75-26b486634c20@suse.de>


在 2025/7/7 17:28, Thomas Zimmermann 写道:
> Hi
>
> Am 07.07.25 um 11:24 schrieb Shixiong Ou:
>>
>> 在 2025/6/27 17:13, Thomas Zimmermann 写道:
>>> Hi
>>>
>>> Am 26.06.25 um 11:49 schrieb oushixiong1025@163.com:
>>>> From: Shixiong Ou <oushixiong@kylinos.cn>
>>>>
>>>> [WHY]
>>>> On an ARM machine, the following log is present:
>>>> [    0.900884] efifb: framebuffer at 0x1020000000, using 3072k, 
>>>> total 3072k
>>>> [    2.297884] amdgpu 0000:04:00.0: 
>>>> remove_conflicting_pci_framebuffers: bar 0: 0x1000000000 -> 
>>>> 0x100fffffff
>>>> [    2.297886] amdgpu 0000:04:00.0: 
>>>> remove_conflicting_pci_framebuffers: bar 2: 0x1010000000 -> 
>>>> 0x10101fffff
>>>> [    2.297888] amdgpu 0000:04:00.0: 
>>>> remove_conflicting_pci_framebuffers: bar 5: 0x58200000 -> 0x5823ffff
>>>>
>>>> It show that the efifb framebuffer base is out of PCI BAR, and this
>>>> results in both efi-framebuffer and amdgpudrmfb co-existing.
>>>>
>>>> The fbcon will be bound to efi-framebuffer by default and cannot be 
>>>> used.
>>>>
>>>> [HOW]
>>>> Do not load efifb driver if PCI BAR has changed but not fixuped.
>>>> In the following cases:
>>>>     1. screen_info_lfb_pdev is NULL.
>>>>     2. __screen_info_relocation_is_valid return false.
>>>
>>> Apart from ruling out invalid screen_info, did you figure out why 
>>> the relocation tracking didn't work? It would be good to fix this if 
>>> possible.
>>>
>>> Best regards
>>> Thomas
>>>
>> I haven’t figure out the root cause yet.
>>
>> This issue is quite rare and might be related to the EFI firmware.
>> However, I wonder if we could add some handling when no PCI resources 
>> are found in screen_info_fixup_lfb(), as a temporary workaround for 
>> the problem I mentioned earlier.
>
> As I said elsewhere in the thread, you can clear the screen_info's 
> video type in the branch at [1] to disable it entirely. We should have 
> probably done this anyway. Knowing the cause of the issue would still 
> be nice though.
>
> Best regards
> Thomas
>
> [1] 
> https://elixir.bootlin.com/linux/v6.15.5/source/drivers/video/screen_info_pci.c#L44 
>
>
thanks for you suggestion, while there are two cases:
     1. screen_info_lfb_pdev is NULL.
     2. __screen_info_relocation_is_valid return false.

should we do it at [1] too?

Best regards
Shixiong Ou

[1] 
https://elixir.bootlin.com/linux/v6.15.5/source/drivers/video/screen_info_pci.c#L47

>>
>> Best regards
>> Shixiong Ou
>>
>>>>
>>>> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
>>>> ---
>>>>   drivers/video/fbdev/efifb.c     |  4 ++++
>>>>   drivers/video/screen_info_pci.c | 24 ++++++++++++++++++++++++
>>>>   include/linux/screen_info.h     |  5 +++++
>>>>   3 files changed, 33 insertions(+)
>>>>
>>>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>>>> index 0e1bd3dba255..de8d016c9a66 100644
>>>> --- a/drivers/video/fbdev/efifb.c
>>>> +++ b/drivers/video/fbdev/efifb.c
>>>> @@ -303,6 +303,10 @@ static void efifb_setup(struct screen_info 
>>>> *si, char *options)
>>>>     static inline bool fb_base_is_valid(struct screen_info *si)
>>>>   {
>>>> +    /* check whether fb_base has changed but not fixuped */
>>>> +    if (!screen_info_is_useful())
>>>> +        return false;
>>>> +
>>>>       if (si->lfb_base)
>>>>           return true;
>>>>   diff --git a/drivers/video/screen_info_pci.c 
>>>> b/drivers/video/screen_info_pci.c
>>>> index 66bfc1d0a6dc..ac57dcaf0cac 100644
>>>> --- a/drivers/video/screen_info_pci.c
>>>> +++ b/drivers/video/screen_info_pci.c
>>>> @@ -9,6 +9,8 @@ static struct pci_dev *screen_info_lfb_pdev;
>>>>   static size_t screen_info_lfb_bar;
>>>>   static resource_size_t screen_info_lfb_res_start; // original 
>>>> start of resource
>>>>   static resource_size_t screen_info_lfb_offset; // framebuffer 
>>>> offset within resource
>>>> +static bool screen_info_changed;
>>>> +static bool screen_info_fixuped;
>>>>     static bool __screen_info_relocation_is_valid(const struct 
>>>> screen_info *si, struct resource *pr)
>>>>   {
>>>> @@ -24,6 +26,24 @@ static bool 
>>>> __screen_info_relocation_is_valid(const struct screen_info *si, stru
>>>>       return true;
>>>>   }
>>>>   +bool screen_info_is_useful(void)
>>>> +{
>>>> +    unsigned int type;
>>>> +    const struct screen_info *si = &screen_info;
>>>> +
>>>> +    type = screen_info_video_type(si);
>>>> +    if (type != VIDEO_TYPE_EFI)
>>>> +        return true;
>>>> +
>>>> +    if (screen_info_changed && !screen_info_fixuped) {
>>>> +        pr_warn("The screen_info has changed but not fixuped");
>>>> +        return false;
>>>> +    }
>>>> +
>>>> +    pr_info("The screen_info is useful");
>>>> +    return true;
>>>> +}
>>>> +
>>>>   void screen_info_apply_fixups(void)
>>>>   {
>>>>       struct screen_info *si = &screen_info;
>>>> @@ -32,18 +52,22 @@ void screen_info_apply_fixups(void)
>>>>           struct resource *pr = 
>>>> &screen_info_lfb_pdev->resource[screen_info_lfb_bar];
>>>>             if (pr->start != screen_info_lfb_res_start) {
>>>> +            screen_info_changed = true;
>>>>               if (__screen_info_relocation_is_valid(si, pr)) {
>>>>                   /*
>>>>                    * Only update base if we have an actual
>>>>                    * relocation to a valid I/O range.
>>>>                    */
>>>>                   __screen_info_set_lfb_base(si, pr->start + 
>>>> screen_info_lfb_offset);
>>>> +                screen_info_fixuped = true;
>>>>                   pr_info("Relocating firmware framebuffer to 
>>>> offset %pa[d] within %pr\n",
>>>>                       &screen_info_lfb_offset, pr);
>>>>               } else {
>>>>                   pr_warn("Invalid relocating, disabling firmware 
>>>> framebuffer\n");
>>>>               }
>>>>           }
>>>> +    } else {
>>>> +        screen_info_changed = true;
>>>>       }
>>>>   }
>>>>   diff --git a/include/linux/screen_info.h 
>>>> b/include/linux/screen_info.h
>>>> index 923d68e07679..632cdbb1adbe 100644
>>>> --- a/include/linux/screen_info.h
>>>> +++ b/include/linux/screen_info.h
>>>> @@ -138,9 +138,14 @@ ssize_t screen_info_resources(const struct 
>>>> screen_info *si, struct resource *r,
>>>>   u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si);
>>>>     #if defined(CONFIG_PCI)
>>>> +bool screen_info_is_useful(void);
>>>>   void screen_info_apply_fixups(void);
>>>>   struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
>>>>   #else
>>>> +bool screen_info_is_useful(void)
>>>> +{
>>>> +    return true;
>>>> +}
>>>>   static inline void screen_info_apply_fixups(void)
>>>>   { }
>>>>   static inline struct pci_dev *screen_info_pci_dev(const struct 
>>>> screen_info *si)
>>>
>>
>


^ permalink raw reply

* Re: [PATCH] fbdev: efifb: do not load efifb if PCI BAR has changed but not fixuped
From: Thomas Zimmermann @ 2025-07-07 10:17 UTC (permalink / raw)
  To: Shixiong Ou, Helge Deller
  Cc: Peter Jones, linux-fbdev, dri-devel, linux-kernel, Shixiong Ou
In-Reply-To: <1567a84b-3f78-4f0a-9549-bfe9fd4aa96b@163.com>

Hi

Am 07.07.25 um 12:02 schrieb Shixiong Ou:
>
> 在 2025/7/7 17:28, Thomas Zimmermann 写道:
>> Hi
>>
>> Am 07.07.25 um 11:24 schrieb Shixiong Ou:
>>>
>>> 在 2025/6/27 17:13, Thomas Zimmermann 写道:
>>>> Hi
>>>>
>>>> Am 26.06.25 um 11:49 schrieb oushixiong1025@163.com:
>>>>> From: Shixiong Ou <oushixiong@kylinos.cn>
>>>>>
>>>>> [WHY]
>>>>> On an ARM machine, the following log is present:
>>>>> [    0.900884] efifb: framebuffer at 0x1020000000, using 3072k, 
>>>>> total 3072k
>>>>> [    2.297884] amdgpu 0000:04:00.0: 
>>>>> remove_conflicting_pci_framebuffers: bar 0: 0x1000000000 -> 
>>>>> 0x100fffffff
>>>>> [    2.297886] amdgpu 0000:04:00.0: 
>>>>> remove_conflicting_pci_framebuffers: bar 2: 0x1010000000 -> 
>>>>> 0x10101fffff
>>>>> [    2.297888] amdgpu 0000:04:00.0: 
>>>>> remove_conflicting_pci_framebuffers: bar 5: 0x58200000 -> 0x5823ffff
>>>>>
>>>>> It show that the efifb framebuffer base is out of PCI BAR, and this
>>>>> results in both efi-framebuffer and amdgpudrmfb co-existing.
>>>>>
>>>>> The fbcon will be bound to efi-framebuffer by default and cannot 
>>>>> be used.
>>>>>
>>>>> [HOW]
>>>>> Do not load efifb driver if PCI BAR has changed but not fixuped.
>>>>> In the following cases:
>>>>>     1. screen_info_lfb_pdev is NULL.
>>>>>     2. __screen_info_relocation_is_valid return false.
>>>>
>>>> Apart from ruling out invalid screen_info, did you figure out why 
>>>> the relocation tracking didn't work? It would be good to fix this 
>>>> if possible.
>>>>
>>>> Best regards
>>>> Thomas
>>>>
>>> I haven’t figure out the root cause yet.
>>>
>>> This issue is quite rare and might be related to the EFI firmware.
>>> However, I wonder if we could add some handling when no PCI 
>>> resources are found in screen_info_fixup_lfb(), as a temporary 
>>> workaround for the problem I mentioned earlier.
>>
>> As I said elsewhere in the thread, you can clear the screen_info's 
>> video type in the branch at [1] to disable it entirely. We should 
>> have probably done this anyway. Knowing the cause of the issue would 
>> still be nice though.
>>
>> Best regards
>> Thomas
>>
>> [1] 
>> https://elixir.bootlin.com/linux/v6.15.5/source/drivers/video/screen_info_pci.c#L44 
>>
>>
> thanks for you suggestion, while there are two cases:
>     1. screen_info_lfb_pdev is NULL.
>     2. __screen_info_relocation_is_valid return false.
>
> should we do it at [1] too?

No. This being NULL is an entirely valid state.

Best regards
Thomas

>
> Best regards
> Shixiong Ou
>
> [1] 
> https://elixir.bootlin.com/linux/v6.15.5/source/drivers/video/screen_info_pci.c#L47
>
>>>
>>> Best regards
>>> Shixiong Ou
>>>
>>>>>
>>>>> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
>>>>> ---
>>>>>   drivers/video/fbdev/efifb.c     |  4 ++++
>>>>>   drivers/video/screen_info_pci.c | 24 ++++++++++++++++++++++++
>>>>>   include/linux/screen_info.h     |  5 +++++
>>>>>   3 files changed, 33 insertions(+)
>>>>>
>>>>> diff --git a/drivers/video/fbdev/efifb.c 
>>>>> b/drivers/video/fbdev/efifb.c
>>>>> index 0e1bd3dba255..de8d016c9a66 100644
>>>>> --- a/drivers/video/fbdev/efifb.c
>>>>> +++ b/drivers/video/fbdev/efifb.c
>>>>> @@ -303,6 +303,10 @@ static void efifb_setup(struct screen_info 
>>>>> *si, char *options)
>>>>>     static inline bool fb_base_is_valid(struct screen_info *si)
>>>>>   {
>>>>> +    /* check whether fb_base has changed but not fixuped */
>>>>> +    if (!screen_info_is_useful())
>>>>> +        return false;
>>>>> +
>>>>>       if (si->lfb_base)
>>>>>           return true;
>>>>>   diff --git a/drivers/video/screen_info_pci.c 
>>>>> b/drivers/video/screen_info_pci.c
>>>>> index 66bfc1d0a6dc..ac57dcaf0cac 100644
>>>>> --- a/drivers/video/screen_info_pci.c
>>>>> +++ b/drivers/video/screen_info_pci.c
>>>>> @@ -9,6 +9,8 @@ static struct pci_dev *screen_info_lfb_pdev;
>>>>>   static size_t screen_info_lfb_bar;
>>>>>   static resource_size_t screen_info_lfb_res_start; // original 
>>>>> start of resource
>>>>>   static resource_size_t screen_info_lfb_offset; // framebuffer 
>>>>> offset within resource
>>>>> +static bool screen_info_changed;
>>>>> +static bool screen_info_fixuped;
>>>>>     static bool __screen_info_relocation_is_valid(const struct 
>>>>> screen_info *si, struct resource *pr)
>>>>>   {
>>>>> @@ -24,6 +26,24 @@ static bool 
>>>>> __screen_info_relocation_is_valid(const struct screen_info *si, stru
>>>>>       return true;
>>>>>   }
>>>>>   +bool screen_info_is_useful(void)
>>>>> +{
>>>>> +    unsigned int type;
>>>>> +    const struct screen_info *si = &screen_info;
>>>>> +
>>>>> +    type = screen_info_video_type(si);
>>>>> +    if (type != VIDEO_TYPE_EFI)
>>>>> +        return true;
>>>>> +
>>>>> +    if (screen_info_changed && !screen_info_fixuped) {
>>>>> +        pr_warn("The screen_info has changed but not fixuped");
>>>>> +        return false;
>>>>> +    }
>>>>> +
>>>>> +    pr_info("The screen_info is useful");
>>>>> +    return true;
>>>>> +}
>>>>> +
>>>>>   void screen_info_apply_fixups(void)
>>>>>   {
>>>>>       struct screen_info *si = &screen_info;
>>>>> @@ -32,18 +52,22 @@ void screen_info_apply_fixups(void)
>>>>>           struct resource *pr = 
>>>>> &screen_info_lfb_pdev->resource[screen_info_lfb_bar];
>>>>>             if (pr->start != screen_info_lfb_res_start) {
>>>>> +            screen_info_changed = true;
>>>>>               if (__screen_info_relocation_is_valid(si, pr)) {
>>>>>                   /*
>>>>>                    * Only update base if we have an actual
>>>>>                    * relocation to a valid I/O range.
>>>>>                    */
>>>>>                   __screen_info_set_lfb_base(si, pr->start + 
>>>>> screen_info_lfb_offset);
>>>>> +                screen_info_fixuped = true;
>>>>>                   pr_info("Relocating firmware framebuffer to 
>>>>> offset %pa[d] within %pr\n",
>>>>>                       &screen_info_lfb_offset, pr);
>>>>>               } else {
>>>>>                   pr_warn("Invalid relocating, disabling firmware 
>>>>> framebuffer\n");
>>>>>               }
>>>>>           }
>>>>> +    } else {
>>>>> +        screen_info_changed = true;
>>>>>       }
>>>>>   }
>>>>>   diff --git a/include/linux/screen_info.h 
>>>>> b/include/linux/screen_info.h
>>>>> index 923d68e07679..632cdbb1adbe 100644
>>>>> --- a/include/linux/screen_info.h
>>>>> +++ b/include/linux/screen_info.h
>>>>> @@ -138,9 +138,14 @@ ssize_t screen_info_resources(const struct 
>>>>> screen_info *si, struct resource *r,
>>>>>   u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si);
>>>>>     #if defined(CONFIG_PCI)
>>>>> +bool screen_info_is_useful(void);
>>>>>   void screen_info_apply_fixups(void);
>>>>>   struct pci_dev *screen_info_pci_dev(const struct screen_info *si);
>>>>>   #else
>>>>> +bool screen_info_is_useful(void)
>>>>> +{
>>>>> +    return true;
>>>>> +}
>>>>>   static inline void screen_info_apply_fixups(void)
>>>>>   { }
>>>>>   static inline struct pci_dev *screen_info_pci_dev(const struct 
>>>>> screen_info *si)
>>>>
>>>
>>
>
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


^ permalink raw reply

* RE: EXTERNAL: [PATCH 0/2] backlight: mp3309c: Drop pwm_apply_args()
From: FLAVIO SULIGOI @ 2025-07-07 15:44 UTC (permalink / raw)
  To: Uwe Kleine-König, Lee Jones, Daniel Thompson, Jingoo Han,
	Helge Deller
  Cc: Daniel Thompson, dri-devel@lists.freedesktop.org,
	linux-fbdev@vger.kernel.org, linux-pwm@vger.kernel.org
In-Reply-To: <cover.1751361465.git.u.kleine-koenig@baylibre.com>

Hi Uwe,

> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> Sent: martedì 1 luglio 2025 11:23
> To: FLAVIO SULIGOI <f.suligoi@asem.it>; Lee Jones <lee@kernel.org>;
> Daniel Thompson <danielt@kernel.org>; Jingoo Han <jingoohan1@gmail.com>;
> Helge Deller <deller@gmx.de>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>; dri-
> devel@lists.freedesktop.org; linux-fbdev@vger.kernel.org; linux-
> pwm@vger.kernel.org
> Subject: EXTERNAL: [PATCH 0/2] backlight: mp3309c: Drop pwm_apply_args()
> 
> [Use caution with links & attachments]
> 
> 
> 
> Hello,
> 
> the first patch of this series is what I really care about: There are
> hardly any drivers left that use pwm_apply_args(). When all of them are
> converted to not use it any more, I intend to drop that function.
> 
> The 2nd patch is just a change that I noticed while editing the driver
> that is IMHO nice. If you don't agree and only apply the first patch, I
> won't argue. It's an alternative approach to what Daniel Thompson did in
> commit 7ee6478d5aa9 ("backlight: mp3309c: Fully initialize
> backlight_properties during probe").

I've tested your patches on my board and all is ok.
Thanks!

> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (2):
>   backlight: mp3309c: Drop pwm_apply_args()
>   backlight: mp3309c: Initialize backlight properties without memset
> 
>  drivers/video/backlight/mp3309c.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> 
> base-commit: 1343433ed38923a21425c602e92120a1f1db5f7a
> --
> 2.49.0


Flavio

^ permalink raw reply

* RE: EXTERNAL: [PATCH 1/2] backlight: mp3309c: Drop pwm_apply_args()
From: FLAVIO SULIGOI @ 2025-07-07 15:48 UTC (permalink / raw)
  To: Uwe Kleine-König, Lee Jones, Daniel Thompson, Jingoo Han,
	Helge Deller
  Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-pwm@vger.kernel.org
In-Reply-To: <2d1075f5dd45c7c135e4326e279468de699f9d17.1751361465.git.u.kleine-koenig@baylibre.com>

Hi Uwe,

I've tested your patch on my board, all ok.


> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> Sent: martedì 1 luglio 2025 11:23
> To: FLAVIO SULIGOI <f.suligoi@asem.it>; Lee Jones <lee@kernel.org>;
> Daniel Thompson <danielt@kernel.org>; Jingoo Han <jingoohan1@gmail.com>;
> Helge Deller <deller@gmx.de>
> Cc: dri-devel@lists.freedesktop.org; linux-fbdev@vger.kernel.org; linux-
> pwm@vger.kernel.org
> Subject: EXTERNAL: [PATCH 1/2] backlight: mp3309c: Drop pwm_apply_args()
> 
> [Use caution with links & attachments]
> 
> 
> 
> pwm_apply_args() sole purpose is to initialize all parameters specified
> in the device tree for consumers that rely on pwm_config() and
> pwm_enable(). The mp3309c backlight driver uses pwm_apply_might_sleep()
> which gets passed the full configuration and so doesn't rely on the
> default being explicitly applied.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Tested-by: Flavio Suligoi <f.suligoi@asem.it>


^ permalink raw reply

* RE: EXTERNAL: [PATCH 2/2] backlight: mp3309c: Initialize backlight properties without memset
From: FLAVIO SULIGOI @ 2025-07-07 15:49 UTC (permalink / raw)
  To: Uwe Kleine-König, Lee Jones, Daniel Thompson, Jingoo Han,
	Helge Deller
  Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-pwm@vger.kernel.org
In-Reply-To: <14514a1b0d3df6438aa10bb74f1c4fc2367d9987.1751361465.git.u.kleine-koenig@baylibre.com>

Hi Uwe,

I've tested your patch on my board, all ok.

> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> Sent: martedì 1 luglio 2025 11:23
> To: FLAVIO SULIGOI <f.suligoi@asem.it>; Lee Jones <lee@kernel.org>;
> Daniel Thompson <danielt@kernel.org>; Jingoo Han <jingoohan1@gmail.com>;
> Helge Deller <deller@gmx.de>
> Cc: dri-devel@lists.freedesktop.org; linux-fbdev@vger.kernel.org; linux-
> pwm@vger.kernel.org
> Subject: EXTERNAL: [PATCH 2/2] backlight: mp3309c: Initialize backlight
> properties without memset
> 
> [Use caution with links & attachments]
> 
> 
> 
> Assigning values to a struct using a compound literal (since C99) also
> guarantees that all unspecified struct members are empty-initialized, so
> it properly replaces the memset to zero.
> 
> The code looks a bit nicer and more idiomatic (though that might be
> subjective?). The resulting binary is a bit smaller. On ARCH=arm with an
> allnoconfig + minimal changes to enable the mp3309c driver the
> difference is 12 bytes.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Tested-by: Flavio Suligoi <f.suligoi@asem.it>

^ permalink raw reply

* [PATCH] fbdev: kyro: Add missing PCI memory region request
From: Giovanni Di Santi @ 2025-07-08 14:46 UTC (permalink / raw)
  To: deller; +Cc: tzimmermann, linux-fbdev, dri-devel, linux-kernel,
	Giovanni Di Santi

The kyro framebuffer driver did not request its PCI memory regions,
which could lead to conflicts with other drivers.  This change
addresses the task "Request memory regions in all fbdev drivers"
from the file Documentation/gpu/todo.rst.

pci_request_regions() is now called during probe. To ensure proper
cleanup, the corresponding pci_release_regions() and a missing
pci_disable_device() call are added to both the driver's remove
function and the probe's error handling path.

Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
 drivers/video/fbdev/kyro/fbdev.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 08ee8baa79f8..80ac17337c1b 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -685,8 +685,14 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 
 	info = framebuffer_alloc(sizeof(struct kyrofb_info), &pdev->dev);
-	if (!info)
-		return -ENOMEM;
+	if (!info) {
+		err = -ENOMEM;
+		goto out_disable;
+	}
+
+	err = pci_request_regions(pdev, "kyrofb");
+	if (err)
+		goto out_free_fb;
 
 	currentpar = info->par;
 
@@ -695,10 +701,11 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	kyro_fix.mmio_start = pci_resource_start(pdev, 1);
 	kyro_fix.mmio_len   = pci_resource_len(pdev, 1);
 
+	err = -EINVAL;
 	currentpar->regbase = deviceInfo.pSTGReg =
 		ioremap(kyro_fix.mmio_start, kyro_fix.mmio_len);
 	if (!currentpar->regbase)
-		goto out_free_fb;
+		goto out_release;
 
 	info->screen_base = pci_ioremap_wc_bar(pdev, 0);
 	if (!info->screen_base)
@@ -752,10 +759,13 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	iounmap(info->screen_base);
 out_unmap_regs:
 	iounmap(currentpar->regbase);
+out_release:
+	pci_release_regions(pdev);
 out_free_fb:
 	framebuffer_release(info);
-
-	return -EINVAL;
+out_disable:
+	pci_disable_device(pdev);
+	return err;
 }
 
 static void kyrofb_remove(struct pci_dev *pdev)
@@ -780,6 +790,9 @@ static void kyrofb_remove(struct pci_dev *pdev)
 
 	unregister_framebuffer(info);
 	framebuffer_release(info);
+
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
 }
 
 static int __init kyrofb_init(void)
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH] fbdev: kyro: Add missing PCI memory region request
From: Thomas Zimmermann @ 2025-07-08 15:10 UTC (permalink / raw)
  To: Giovanni Di Santi, deller; +Cc: linux-fbdev, dri-devel, linux-kernel
In-Reply-To: <20250708144659.787676-1-giovanni.disanti.lkl@gmail.com>

Hi

Am 08.07.25 um 16:46 schrieb Giovanni Di Santi:
> The kyro framebuffer driver did not request its PCI memory regions,
> which could lead to conflicts with other drivers.  This change
> addresses the task "Request memory regions in all fbdev drivers"
> from the file Documentation/gpu/todo.rst.
>
> pci_request_regions() is now called during probe. To ensure proper
> cleanup, the corresponding pci_release_regions() and a missing
> pci_disable_device() call are added to both the driver's remove
> function and the probe's error handling path.
>
> Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
> ---
>   drivers/video/fbdev/kyro/fbdev.c | 23 ++++++++++++++++++-----
>   1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
> index 08ee8baa79f8..80ac17337c1b 100644
> --- a/drivers/video/fbdev/kyro/fbdev.c
> +++ b/drivers/video/fbdev/kyro/fbdev.c
> @@ -685,8 +685,14 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	}
>   
>   	info = framebuffer_alloc(sizeof(struct kyrofb_info), &pdev->dev);
> -	if (!info)
> -		return -ENOMEM;
> +	if (!info) {
> +		err = -ENOMEM;
> +		goto out_disable;
> +	}
> +
> +	err = pci_request_regions(pdev, "kyrofb");
> +	if (err)
> +		goto out_free_fb;

Could this use pcim_request_all_regions() [1] instead? Cleanup and error 
rollback would be automatic.

[1] 
https://elixir.bootlin.com/linux/v6.15.5/source/drivers/pci/devres.c#L927


>   
>   	currentpar = info->par;
>   
> @@ -695,10 +701,11 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	kyro_fix.mmio_start = pci_resource_start(pdev, 1);
>   	kyro_fix.mmio_len   = pci_resource_len(pdev, 1);
>   
> +	err = -EINVAL;
>   	currentpar->regbase = deviceInfo.pSTGReg =
>   		ioremap(kyro_fix.mmio_start, kyro_fix.mmio_len);
>   	if (!currentpar->regbase)
> -		goto out_free_fb;
> +		goto out_release;
>   
>   	info->screen_base = pci_ioremap_wc_bar(pdev, 0);
>   	if (!info->screen_base)
> @@ -752,10 +759,13 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	iounmap(info->screen_base);
>   out_unmap_regs:
>   	iounmap(currentpar->regbase);
> +out_release:
> +	pci_release_regions(pdev);
>   out_free_fb:
>   	framebuffer_release(info);
> -
> -	return -EINVAL;
> +out_disable:
> +	pci_disable_device(pdev);
> +	return err;
>   }
>   
>   static void kyrofb_remove(struct pci_dev *pdev)
> @@ -780,6 +790,9 @@ static void kyrofb_remove(struct pci_dev *pdev)
>   
>   	unregister_framebuffer(info);
>   	framebuffer_release(info);
> +
> +	pci_release_regions(pdev);
> +	pci_disable_device(pdev);

Instead of manual cleanup, you're better off using pcim_enable_device() 
[2] in kyrofb_probe(). Cleaning up is automatic then.

Best regards
Thomas

[2] 
https://elixir.bootlin.com/linux/v6.15.5/source/drivers/pci/devres.c#L476

>   }
>   
>   static int __init kyrofb_init(void)

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


^ permalink raw reply

* [PATCH 5.15 051/160] vgacon: switch vgacon_scrolldelta() and vgacon_restore_screen()
From: Greg Kroah-Hartman @ 2025-07-08 16:21 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiri Slaby (SUSE), Helge Deller,
	linux-fbdev, dri-devel, Sasha Levin
In-Reply-To: <20250708162231.503362020@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby (SUSE) <jirislaby@kernel.org>

[ Upstream commit 03b89a08484a88fb9e0604cab2b3eb0c2f265c74 ]

Switch vgacon_scrolldelta() and vgacon_restore_screen() positions, so
that the former is not needed to be forward-declared.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Helge Deller <deller@gmx.de>
Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/console/vgacon.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 7bce5a174f388..b2180fd183307 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -163,12 +163,6 @@ static inline void vga_set_mem_top(struct vc_data *c)
 	write_vga(12, (c->vc_visible_origin - vga_vram_base) / 2);
 }
 
-static void vgacon_restore_screen(struct vc_data *c)
-{
-	if (c->vc_origin != c->vc_visible_origin)
-		vgacon_scrolldelta(c, 0);
-}
-
 static void vgacon_scrolldelta(struct vc_data *c, int lines)
 {
 	vc_scrolldelta_helper(c, lines, vga_rolled_over, (void *)vga_vram_base,
@@ -176,6 +170,12 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
 	vga_set_mem_top(c);
 }
 
+static void vgacon_restore_screen(struct vc_data *c)
+{
+	if (c->vc_origin != c->vc_visible_origin)
+		vgacon_scrolldelta(c, 0);
+}
+
 static const char *vgacon_startup(void)
 {
 	const char *display_desc = NULL;
-- 
2.39.5




^ permalink raw reply related

* [PATCH 5.15 052/160] vgacon: remove unneeded forward declarations
From: Greg Kroah-Hartman @ 2025-07-08 16:21 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiri Slaby (SUSE), Helge Deller,
	linux-fbdev, dri-devel, Sasha Levin
In-Reply-To: <20250708162231.503362020@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby (SUSE) <jirislaby@kernel.org>

[ Upstream commit 6ceed69cde8fe4a78fe50d62d7a88a5c1eed4709 ]

Most of the forward declarations in vgacon are not needed. Drop them.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Helge Deller <deller@gmx.de>
Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/console/vgacon.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index b2180fd183307..9bfe451050209 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -65,16 +65,8 @@ static struct vgastate vgastate;
  *  Interface used by the world
  */
 
-static const char *vgacon_startup(void);
-static void vgacon_init(struct vc_data *c, int init);
-static void vgacon_deinit(struct vc_data *c);
-static void vgacon_cursor(struct vc_data *c, int mode);
-static int vgacon_switch(struct vc_data *c);
-static int vgacon_blank(struct vc_data *c, int blank, int mode_switch);
-static void vgacon_scrolldelta(struct vc_data *c, int lines);
 static int vgacon_set_origin(struct vc_data *c);
-static void vgacon_save_screen(struct vc_data *c);
-static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
+
 static struct uni_pagedict *vgacon_uni_pagedir;
 static int vgacon_refcount;
 
-- 
2.39.5




^ permalink raw reply related

* [PATCH 5.15 053/160] tty: vt: make init parameter of consw::con_init() a bool
From: Greg Kroah-Hartman @ 2025-07-08 16:21 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiri Slaby (SUSE),
	Geert Uytterhoeven, Helge Deller, James E.J. Bottomley,
	Daniel Vetter, linux-fbdev, dri-devel, linux-parisc, Sasha Levin
In-Reply-To: <20250708162231.503362020@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby (SUSE) <jirislaby@kernel.org>

[ Upstream commit dae3e6b6180f1a2394b984c596d39ed2c57d25fe ]

The 'init' parameter of consw::con_init() is true for the first call of
the hook on a particular console. So make the parameter a bool.

And document the hook.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-parisc@vger.kernel.org
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-21-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/vt/vt.c                 | 8 ++++----
 drivers/video/console/dummycon.c    | 2 +-
 drivers/video/console/mdacon.c      | 2 +-
 drivers/video/console/newport_con.c | 2 +-
 drivers/video/console/sticon.c      | 2 +-
 drivers/video/console/vgacon.c      | 4 ++--
 drivers/video/fbdev/core/fbcon.c    | 2 +-
 include/linux/console.h             | 4 +++-
 8 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index bd125ea5c51f4..0e3d7d8f5e75a 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1050,7 +1050,7 @@ int vc_cons_allocated(unsigned int i)
 	return (i < MAX_NR_CONSOLES && vc_cons[i].d);
 }
 
-static void visual_init(struct vc_data *vc, int num, int init)
+static void visual_init(struct vc_data *vc, int num, bool init)
 {
 	/* ++Geert: vc->vc_sw->con_init determines console size */
 	if (vc->vc_sw)
@@ -1134,7 +1134,7 @@ int vc_allocate(unsigned int currcons)	/* return 0 on success */
 	vc->port.ops = &vc_port_ops;
 	INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
 
-	visual_init(vc, currcons, 1);
+	visual_init(vc, currcons, true);
 
 	if (!*vc->vc_uni_pagedir_loc)
 		con_set_default_unimap(vc);
@@ -3521,7 +3521,7 @@ static int __init con_init(void)
 		vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT);
 		INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
 		tty_port_init(&vc->port);
-		visual_init(vc, currcons, 1);
+		visual_init(vc, currcons, true);
 		/* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */
 		vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
 		vc_init(vc, vc->vc_rows, vc->vc_cols,
@@ -3692,7 +3692,7 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
 		old_was_color = vc->vc_can_do_color;
 		vc->vc_sw->con_deinit(vc);
 		vc->vc_origin = (unsigned long)vc->vc_screenbuf;
-		visual_init(vc, i, 0);
+		visual_init(vc, i, false);
 		set_origin(vc);
 		update_attr(vc);
 
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index f1711b2f9ff05..9a19eb72a18b9 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -97,7 +97,7 @@ static const char *dummycon_startup(void)
     return "dummy device";
 }
 
-static void dummycon_init(struct vc_data *vc, int init)
+static void dummycon_init(struct vc_data *vc, bool init)
 {
     vc->vc_can_do_color = 1;
     if (init) {
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index ef29b321967f0..c5b255c968794 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -352,7 +352,7 @@ static const char *mdacon_startup(void)
 	return "MDA-2";
 }
 
-static void mdacon_init(struct vc_data *c, int init)
+static void mdacon_init(struct vc_data *c, bool init)
 {
 	c->vc_complement_mask = 0x0800;	 /* reverse video */
 	c->vc_display_fg = &mda_display_fg;
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index d9c682ae03926..4b7161a81b2f6 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -324,7 +324,7 @@ static const char *newport_startup(void)
 	return NULL;
 }
 
-static void newport_init(struct vc_data *vc, int init)
+static void newport_init(struct vc_data *vc, bool init)
 {
 	int cols, rows;
 
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index f304163e87e99..10302df885147 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -272,7 +272,7 @@ static int sticon_font_set(struct vc_data *vc, struct console_font *font,
 	return sticon_set_font(vc, font);
 }
 
-static void sticon_init(struct vc_data *c, int init)
+static void sticon_init(struct vc_data *c, bool init)
 {
     struct sti_struct *sti = sticon_sti;
     int vc_cols, vc_rows;
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 9bfe451050209..a9777fd38ad92 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -353,7 +353,7 @@ static const char *vgacon_startup(void)
 	return display_desc;
 }
 
-static void vgacon_init(struct vc_data *c, int init)
+static void vgacon_init(struct vc_data *c, bool init)
 {
 	struct uni_pagedict *p;
 
@@ -370,7 +370,7 @@ static void vgacon_init(struct vc_data *c, int init)
 	c->vc_scan_lines = vga_scan_lines;
 	c->vc_font.height = c->vc_cell_height = vga_video_font_height;
 
-	/* set dimensions manually if init != 0 since vc_resize() will fail */
+	/* set dimensions manually if init is true since vc_resize() will fail */
 	if (init) {
 		c->vc_cols = vga_video_num_columns;
 		c->vc_rows = vga_video_num_lines;
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index a3af7aacfaf11..f47dbba972fbb 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -983,7 +983,7 @@ static const char *fbcon_startup(void)
 	return display_desc;
 }
 
-static void fbcon_init(struct vc_data *vc, int init)
+static void fbcon_init(struct vc_data *vc, bool init)
 {
 	struct fb_info *info;
 	struct fbcon_ops *ops;
diff --git a/include/linux/console.h b/include/linux/console.h
index a97f277cfdfa3..9258cb8e0841e 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -34,6 +34,8 @@ enum vc_intensity;
 /**
  * struct consw - callbacks for consoles
  *
+ * @con_init:   initialize the console on @vc. @init is true for the very first
+ *		call on this @vc.
  * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
  *		Return true if no generic handling should be done.
  *		Invoked by csi_M and printing to the console.
@@ -44,7 +46,7 @@ enum vc_intensity;
 struct consw {
 	struct module *owner;
 	const char *(*con_startup)(void);
-	void	(*con_init)(struct vc_data *vc, int init);
+	void	(*con_init)(struct vc_data *vc, bool init);
 	void	(*con_deinit)(struct vc_data *vc);
 	void	(*con_clear)(struct vc_data *vc, int sy, int sx, int height,
 			int width);
-- 
2.39.5




^ permalink raw reply related

* [PATCH 5.15 054/160] tty: vt: sanitize arguments of consw::con_clear()
From: Greg Kroah-Hartman @ 2025-07-08 16:21 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiri Slaby (SUSE), Helge Deller,
	James E.J. Bottomley, Daniel Vetter, linux-fbdev, dri-devel,
	linux-parisc, Sasha Levin
In-Reply-To: <20250708162231.503362020@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby (SUSE) <jirislaby@kernel.org>

[ Upstream commit 559f01a0ee6d924c6fec3eaf6a5b078b15e71070 ]

In consw::con_clear():
* Height is always 1, so drop it.
* Offsets and width are always unsigned values, so re-type them as such.

This needs a new __fbcon_clear() in the fbcon code to still handle
height which might not be 1 when called internally.

Note that tests for negative count/width are left in place -- they are
taken care of in the next patches.

And document the hook.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-parisc@vger.kernel.org
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-22-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/vt/vt.c                 |  2 +-
 drivers/video/console/dummycon.c    |  4 ++--
 drivers/video/console/mdacon.c      | 15 +++++---------
 drivers/video/console/newport_con.c |  6 +++---
 drivers/video/console/sticon.c      |  8 ++++----
 drivers/video/console/vgacon.c      |  4 ++--
 drivers/video/fbdev/core/fbcon.c    | 32 +++++++++++++++++------------
 include/linux/console.h             |  5 +++--
 8 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 0e3d7d8f5e75a..765db5a7d5f52 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1628,7 +1628,7 @@ static void csi_X(struct vc_data *vc, unsigned int vpar)
 	vc_uniscr_clear_line(vc, vc->state.x, count);
 	scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count);
 	if (con_should_update(vc))
-		vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count);
+		vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count);
 	vc->vc_need_wrap = 0;
 }
 
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index 9a19eb72a18b9..6918014b02408 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -108,8 +108,8 @@ static void dummycon_init(struct vc_data *vc, bool init)
 }
 
 static void dummycon_deinit(struct vc_data *vc) { }
-static void dummycon_clear(struct vc_data *vc, int sy, int sx, int height,
-			   int width) { }
+static void dummycon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
+			   unsigned int width) { }
 static void dummycon_cursor(struct vc_data *vc, int mode) { }
 
 static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index c5b255c968794..1ddbb6cd5b0ca 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -442,23 +442,18 @@ static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
 	}
 }
 
-static void mdacon_clear(struct vc_data *c, int y, int x, 
-			  int height, int width)
+static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,
+			 unsigned int width)
 {
 	u16 *dest = mda_addr(x, y);
 	u16 eattr = mda_convert_attr(c->vc_video_erase_char);
 
-	if (width <= 0 || height <= 0)
+	if (width <= 0)
 		return;
 
-	if (x==0 && width==mda_num_columns) {
-		scr_memsetw(dest, eattr, height*width*2);
-	} else {
-		for (; height > 0; height--, dest+=mda_num_columns)
-			scr_memsetw(dest, eattr, width*2);
-	}
+	scr_memsetw(dest, eattr, width * 2);
 }
-                        
+
 static int mdacon_switch(struct vc_data *c)
 {
 	return 1;	/* redrawing needed */
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index 4b7161a81b2f6..5dac00c825946 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -346,12 +346,12 @@ static void newport_deinit(struct vc_data *c)
 	}
 }
 
-static void newport_clear(struct vc_data *vc, int sy, int sx, int height,
-			  int width)
+static void newport_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
+			  unsigned int width)
 {
 	int xend = ((sx + width) << 3) - 1;
 	int ystart = ((sy << 4) + topscan) & 0x3ff;
-	int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
+	int yend = (((sy + 1) << 4) + topscan - 1) & 0x3ff;
 
 	if (logo_active)
 		return;
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 10302df885147..58e983b18f1f4 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -299,13 +299,13 @@ static void sticon_deinit(struct vc_data *c)
 	sticon_set_def_font(i, NULL);
 }
 
-static void sticon_clear(struct vc_data *conp, int sy, int sx, int height,
-			 int width)
+static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx,
+			 unsigned int width)
 {
-    if (!height || !width)
+    if (!width)
 	return;
 
-    sti_clear(sticon_sti, sy, sx, height, width,
+    sti_clear(sticon_sti, sy, sx, 1, width,
 	      conp->vc_video_erase_char, font_data[conp->vc_num]);
 }
 
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index a9777fd38ad92..54d79edbe85e1 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -1187,8 +1187,8 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,
  *  The console `switch' structure for the VGA based console
  */
 
-static void vgacon_clear(struct vc_data *vc, int sy, int sx, int height,
-			 int width) { }
+static void vgacon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
+			 unsigned int width) { }
 static void vgacon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
 static void vgacon_putcs(struct vc_data *vc, const unsigned short *s,
 			 int count, int ypos, int xpos) { }
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index f47dbba972fbb..7467b7a27ce2f 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -1210,8 +1210,8 @@ static void fbcon_deinit(struct vc_data *vc)
  *  restriction is simplicity & efficiency at the moment.
  */
 
-static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
-			int width)
+static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
+			  unsigned int height, unsigned int width)
 {
 	struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
 	struct fbcon_ops *ops = info->fbcon_par;
@@ -1250,6 +1250,12 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
 		ops->clear(vc, info, real_y(p, sy), sx, height, width, fg, bg);
 }
 
+static void fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
+			unsigned int width)
+{
+	__fbcon_clear(vc, sy, sx, 1, width);
+}
+
 static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
 			int count, int ypos, int xpos)
 {
@@ -1673,7 +1679,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 		case SCROLL_MOVE:
 			fbcon_redraw_blit(vc, info, p, t, b - t - count,
 				     count);
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
 			scr_memsetw((unsigned short *) (vc->vc_origin +
 							vc->vc_size_row *
 							(b - count)),
@@ -1696,7 +1702,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 					    b - t - count, vc->vc_cols);
 			else
 				goto redraw_up;
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_PAN_REDRAW:
@@ -1714,7 +1720,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 							  vc->vc_rows - b, b);
 			} else
 				fbcon_redraw_move(vc, p, t + count, b - t - count, t);
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_PAN_MOVE:
@@ -1737,14 +1743,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 					    b - t - count, vc->vc_cols);
 			else
 				goto redraw_up;
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_REDRAW:
 		      redraw_up:
 			fbcon_redraw(vc, p, t, b - t - count,
 				     count * vc->vc_cols);
-			fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
 			scr_memsetw((unsigned short *) (vc->vc_origin +
 							vc->vc_size_row *
 							(b - count)),
@@ -1761,7 +1767,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 		case SCROLL_MOVE:
 			fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
 				     -count);
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, t, 0, count, vc->vc_cols);
 			scr_memsetw((unsigned short *) (vc->vc_origin +
 							vc->vc_size_row *
 							t),
@@ -1784,7 +1790,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 					    b - t - count, vc->vc_cols);
 			else
 				goto redraw_down;
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, t, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_PAN_MOVE:
@@ -1806,7 +1812,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 					    b - t - count, vc->vc_cols);
 			else
 				goto redraw_down;
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, t, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_PAN_REDRAW:
@@ -1823,14 +1829,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
 					fbcon_redraw_move(vc, p, count, t, 0);
 			} else
 				fbcon_redraw_move(vc, p, t, b - t - count, t + count);
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, t, 0, count, vc->vc_cols);
 			break;
 
 		case SCROLL_REDRAW:
 		      redraw_down:
 			fbcon_redraw(vc, p, b - 1, b - t - count,
 				     -count * vc->vc_cols);
-			fbcon_clear(vc, t, 0, count, vc->vc_cols);
+			__fbcon_clear(vc, t, 0, count, vc->vc_cols);
 			scr_memsetw((unsigned short *) (vc->vc_origin +
 							vc->vc_size_row *
 							t),
@@ -2175,7 +2181,7 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
 
 		oldc = vc->vc_video_erase_char;
 		vc->vc_video_erase_char &= charmask;
-		fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
+		__fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
 		vc->vc_video_erase_char = oldc;
 	}
 }
diff --git a/include/linux/console.h b/include/linux/console.h
index 9258cb8e0841e..bd7f3a6a64cd0 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -36,6 +36,7 @@ enum vc_intensity;
  *
  * @con_init:   initialize the console on @vc. @init is true for the very first
  *		call on this @vc.
+ * @con_clear:  erase @count characters at [@x, @y] on @vc. @count >= 1.
  * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
  *		Return true if no generic handling should be done.
  *		Invoked by csi_M and printing to the console.
@@ -48,8 +49,8 @@ struct consw {
 	const char *(*con_startup)(void);
 	void	(*con_init)(struct vc_data *vc, bool init);
 	void	(*con_deinit)(struct vc_data *vc);
-	void	(*con_clear)(struct vc_data *vc, int sy, int sx, int height,
-			int width);
+	void	(*con_clear)(struct vc_data *vc, unsigned int y,
+			     unsigned int x, unsigned int count);
 	void	(*con_putc)(struct vc_data *vc, int c, int ypos, int xpos);
 	void	(*con_putcs)(struct vc_data *vc, const unsigned short *s,
 			int count, int ypos, int xpos);
-- 
2.39.5




^ permalink raw reply related

* [PATCH 5.15 055/160] tty: vt: make consw::con_switch() return a bool
From: Greg Kroah-Hartman @ 2025-07-08 16:21 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiri Slaby (SUSE), Helge Deller,
	James E.J. Bottomley, Daniel Vetter, linux-fbdev, dri-devel,
	linux-parisc, Sasha Levin
In-Reply-To: <20250708162231.503362020@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Slaby (SUSE) <jirislaby@kernel.org>

[ Upstream commit 8d5cc8eed738e3202379722295c626cba0849785 ]

The non-zero (true) return value from consw::con_switch() means a redraw
is needed. So make this return type a bool explicitly instead of int.
The latter might imply that -Eerrors are expected. They are not.

And document the hook.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-parisc@vger.kernel.org
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-31-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/vt/vt.c                 | 2 +-
 drivers/video/console/dummycon.c    | 4 ++--
 drivers/video/console/mdacon.c      | 4 ++--
 drivers/video/console/newport_con.c | 4 ++--
 drivers/video/console/sticon.c      | 4 ++--
 drivers/video/console/vgacon.c      | 4 ++--
 drivers/video/fbdev/core/fbcon.c    | 6 +++---
 include/linux/console.h             | 4 +++-
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 765db5a7d5f52..a6e0c803e96ec 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1014,7 +1014,7 @@ void redraw_screen(struct vc_data *vc, int is_switch)
 	}
 
 	if (redraw) {
-		int update;
+		bool update;
 		int old_was_color = vc->vc_can_do_color;
 
 		set_origin(vc);
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index 6918014b02408..d701f2b51f5b1 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -119,9 +119,9 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
 	return false;
 }
 
-static int dummycon_switch(struct vc_data *vc)
+static bool dummycon_switch(struct vc_data *vc)
 {
-	return 0;
+	return false;
 }
 
 /*
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 1ddbb6cd5b0ca..26b41a8f36c87 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -454,9 +454,9 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,
 	scr_memsetw(dest, eattr, width * 2);
 }
 
-static int mdacon_switch(struct vc_data *c)
+static bool mdacon_switch(struct vc_data *c)
 {
-	return 1;	/* redrawing needed */
+	return true;	/* redrawing needed */
 }
 
 static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index 5dac00c825946..1ebb18bf10983 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -462,7 +462,7 @@ static void newport_cursor(struct vc_data *vc, int mode)
 	}
 }
 
-static int newport_switch(struct vc_data *vc)
+static bool newport_switch(struct vc_data *vc)
 {
 	static int logo_drawn = 0;
 
@@ -476,7 +476,7 @@ static int newport_switch(struct vc_data *vc)
 		}
 	}
 
-	return 1;
+	return true;
 }
 
 static int newport_blank(struct vc_data *c, int blank, int mode_switch)
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 58e983b18f1f4..6b82194a8ef36 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -309,9 +309,9 @@ static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx,
 	      conp->vc_video_erase_char, font_data[conp->vc_num]);
 }
 
-static int sticon_switch(struct vc_data *conp)
+static bool sticon_switch(struct vc_data *conp)
 {
-    return 1;	/* needs refreshing */
+    return true;	/* needs refreshing */
 }
 
 static int sticon_blank(struct vc_data *c, int blank, int mode_switch)
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 54d79edbe85e1..448aede31b946 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -616,7 +616,7 @@ static int vgacon_doresize(struct vc_data *c,
 	return 0;
 }
 
-static int vgacon_switch(struct vc_data *c)
+static bool vgacon_switch(struct vc_data *c)
 {
 	int x = c->vc_cols * VGA_FONTWIDTH;
 	int y = c->vc_rows * c->vc_cell_height;
@@ -645,7 +645,7 @@ static int vgacon_switch(struct vc_data *c)
 			vgacon_doresize(c, c->vc_cols, c->vc_rows);
 	}
 
-	return 0;		/* Redrawing not needed */
+	return false;		/* Redrawing not needed */
 }
 
 static void vga_set_palette(struct vc_data *vc, const unsigned char *table)
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 7467b7a27ce2f..1ce767de96c11 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2043,7 +2043,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
 	return 0;
 }
 
-static int fbcon_switch(struct vc_data *vc)
+static bool fbcon_switch(struct vc_data *vc)
 {
 	struct fb_info *info, *old_info = NULL;
 	struct fbcon_ops *ops;
@@ -2166,9 +2166,9 @@ static int fbcon_switch(struct vc_data *vc)
 			      vc->vc_origin + vc->vc_size_row * vc->vc_top,
 			      vc->vc_size_row * (vc->vc_bottom -
 						 vc->vc_top) / 2);
-		return 0;
+		return false;
 	}
-	return 1;
+	return true;
 }
 
 static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
diff --git a/include/linux/console.h b/include/linux/console.h
index bd7f3a6a64cd0..e2862542a162d 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -40,6 +40,8 @@ enum vc_intensity;
  * @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
  *		Return true if no generic handling should be done.
  *		Invoked by csi_M and printing to the console.
+ * @con_switch: notifier about the console switch; it is supposed to return
+ *		true if a redraw is needed.
  * @con_set_palette: sets the palette of the console to @table (optional)
  * @con_scrolldelta: the contents of the console should be scrolled by @lines.
  *		     Invoked by user. (optional)
@@ -58,7 +60,7 @@ struct consw {
 	bool	(*con_scroll)(struct vc_data *vc, unsigned int top,
 			unsigned int bottom, enum con_scroll dir,
 			unsigned int lines);
-	int	(*con_switch)(struct vc_data *vc);
+	bool	(*con_switch)(struct vc_data *vc);
 	int	(*con_blank)(struct vc_data *vc, int blank, int mode_switch);
 	int	(*con_font_set)(struct vc_data *vc, struct console_font *font,
 			unsigned int flags);
-- 
2.39.5




^ permalink raw reply related

* [PATCH 5.15 056/160] dummycon: Trigger redraw when switching consoles with deferred takeover
From: Greg Kroah-Hartman @ 2025-07-08 16:21 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Thomas Zimmermann, Andrei Borzenkov,
	Javier Martinez Canillas, Hans de Goede, linux-fbdev, dri-devel,
	Sasha Levin
In-Reply-To: <20250708162231.503362020@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Thomas Zimmermann <tzimmermann@suse.de>

[ Upstream commit 03bcbbb3995ba5df43af9aba45334e35f2dfe27b ]

Signal vt subsystem to redraw console when switching to dummycon
with deferred takeover enabled. Makes the console switch to fbcon
and displays the available output.

With deferred takeover enabled, dummycon acts as the placeholder
until the first output to the console happens. At that point, fbcon
takes over. If the output happens while dummycon is not active, it
cannot inform fbcon. This is the case if the vt subsystem runs in
graphics mode.

A typical graphical boot starts plymouth, a display manager and a
compositor; all while leaving out dummycon. Switching to a text-mode
console leaves the console with dummycon even if a getty terminal
has been started.

Returning true from dummycon's con_switch helper signals the vt
subsystem to redraw the screen. If there's output available dummycon's
con_putc{s} helpers trigger deferred takeover of fbcon, which sets a
display mode and displays the output. If no output is available,
dummycon remains active.

v2:
- make the comment slightly more verbose (Javier)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reported-by: Andrei Borzenkov <arvidjaar@gmail.com>
Closes: https://bugzilla.suse.com/show_bug.cgi?id=1242191
Tested-by: Andrei Borzenkov <arvidjaar@gmail.com>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Fixes: 83d83bebf401 ("console/fbcon: Add support for deferred console takeover")
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.19+
Link: https://lore.kernel.org/r/20250520071418.8462-1-tzimmermann@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/console/dummycon.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index d701f2b51f5b1..d99e1b3e4e5c1 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -82,6 +82,15 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
 	/* Redraw, so that we get putc(s) for output done while blanked */
 	return 1;
 }
+
+static bool dummycon_switch(struct vc_data *vc)
+{
+	/*
+	 * Redraw, so that we get putc(s) for output done while switched
+	 * away. Informs deferred consoles to take over the display.
+	 */
+	return true;
+}
 #else
 static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
 static void dummycon_putcs(struct vc_data *vc, const unsigned short *s,
@@ -90,6 +99,10 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
 {
 	return 0;
 }
+static bool dummycon_switch(struct vc_data *vc)
+{
+	return false;
+}
 #endif
 
 static const char *dummycon_startup(void)
@@ -119,11 +132,6 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
 	return false;
 }
 
-static bool dummycon_switch(struct vc_data *vc)
-{
-	return false;
-}
-
 /*
  *  The console `switch' structure for the dummy console
  *
-- 
2.39.5




^ permalink raw reply related

* [PATCH v2] fbdev: kyro: Add missing PCI memory region request
From: Giovanni Di Santi @ 2025-07-08 18:57 UTC (permalink / raw)
  To: tzimmermann, deller
  Cc: giovanni.disanti.lkl, linux-fbdev, dri-devel, linux-kernel
In-Reply-To: <55e427bc-53d6-4ec8-b86a-99bd7367d5bb@suse.de>

Hi Thomas,

Thanks for the feedback.

On Tue, 8 Jul 2025 at 5:10, Thomas Zimmermann wrote:
> Could this use pcim_request_all_regions() [1] instead? Cleanup and error
> rollback would be automatic.
> ...
> Instead of manual cleanup, you're better off using pcim_enable_device()
> [2] in kyrofb_probe(). Cleaning up is automatic then.

I've applied the changes. I noticed that the driver still has manual
ioremap() and pci_ioremap_wc_bar() calls inside the probe function.
Should these also be converted to devm_ioremap() and devm_ioremap_wc() to
make the cleanup fully automatic? Or should I do it in another patch?

Changes in v2:
- Use pcim_enable_device() instead of pci_enable_device()
- Use pcim_request_all_regions() instead of pci_request_regions()
- Removed manual cleanup code as it's now automatic

---

The kyro framebuffer driver did not request its PCI memory regions,
which could lead to conflicts with other drivers.  This change
addresses the task "Request memory regions in all fbdev drivers"
from the file Documentation/gpu/todo.rst.

This is addressed by using the managed device functions pcim_enable_device()
and pcim_request_all_regions(). This simplifies the code by making error
handling and driver removal cleanup automatic for these resources.

Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
 drivers/video/fbdev/kyro/fbdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 08ee8baa79f8..86e5d60ed0ff 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -679,7 +679,8 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	if ((err = pci_enable_device(pdev))) {
+	err = pcim_enable_device(pdev);
+	if (err) {
 		printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
 		return err;
 	}
@@ -688,6 +689,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!info)
 		return -ENOMEM;
 
+	err = pcim_request_all_regions(pdev, "kyrofb");
+	if (err)
+		goto out_free_fb;
+
 	currentpar = info->par;
 
 	kyro_fix.smem_start = pci_resource_start(pdev, 0);
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH v2] fbdev: kyro: Add missing PCI memory region request
From: Thomas Zimmermann @ 2025-07-09  8:11 UTC (permalink / raw)
  To: Giovanni Di Santi, deller; +Cc: linux-fbdev, dri-devel, linux-kernel
In-Reply-To: <20250708185808.845692-1-giovanni.disanti.lkl@gmail.com>

Hi

Am 08.07.25 um 20:57 schrieb Giovanni Di Santi:
> Hi Thomas,
>
> Thanks for the feedback.
>
> On Tue, 8 Jul 2025 at 5:10, Thomas Zimmermann wrote:
>> Could this use pcim_request_all_regions() [1] instead? Cleanup and error
>> rollback would be automatic.
>> ...
>> Instead of manual cleanup, you're better off using pcim_enable_device()
>> [2] in kyrofb_probe(). Cleaning up is automatic then.
> I've applied the changes. I noticed that the driver still has manual
> ioremap() and pci_ioremap_wc_bar() calls inside the probe function.
> Should these also be converted to devm_ioremap() and devm_ioremap_wc() to
> make the cleanup fully automatic? Or should I do it in another patch?

If you have the time and interest, you're welcome to change it to the 
devm_ functions. Ideally, you'd send a series, which each patch 
addressing a single function.

Best regards
Thomas

>
> Changes in v2:
> - Use pcim_enable_device() instead of pci_enable_device()
> - Use pcim_request_all_regions() instead of pci_request_regions()
> - Removed manual cleanup code as it's now automatic
>
> ---
>
> The kyro framebuffer driver did not request its PCI memory regions,
> which could lead to conflicts with other drivers.  This change
> addresses the task "Request memory regions in all fbdev drivers"
> from the file Documentation/gpu/todo.rst.
>
> This is addressed by using the managed device functions pcim_enable_device()
> and pcim_request_all_regions(). This simplifies the code by making error
> handling and driver removal cleanup automatic for these resources.
>
> Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
> ---
>   drivers/video/fbdev/kyro/fbdev.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
> index 08ee8baa79f8..86e5d60ed0ff 100644
> --- a/drivers/video/fbdev/kyro/fbdev.c
> +++ b/drivers/video/fbdev/kyro/fbdev.c
> @@ -679,7 +679,8 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	if (err)
>   		return err;
>   
> -	if ((err = pci_enable_device(pdev))) {
> +	err = pcim_enable_device(pdev);
> +	if (err) {
>   		printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
>   		return err;
>   	}
> @@ -688,6 +689,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	if (!info)
>   		return -ENOMEM;
>   
> +	err = pcim_request_all_regions(pdev, "kyrofb");
> +	if (err)
> +		goto out_free_fb;
> +
>   	currentpar = info->par;
>   
>   	kyro_fix.smem_start = pci_resource_start(pdev, 0);

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


^ permalink raw reply

* [PATCH v3 0/3] fbdev: kyro: Convert to managed device resources
From: Giovanni Di Santi @ 2025-07-09  9:53 UTC (permalink / raw)
  To: tzimmermann, deller
  Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi

This series aims to address the TODO item "Request memory regions in all
fbdev drivers" from Documentation/gpu/todo.rst.
Additionally, it also converts the kyro framebuffer driver to use managed device
functions.

In summary, it converts the driver to use:
1. Managed PCI device enable and region request functions
2. Managed ioremap for MMIO registers  
3. Managed ioremap_wc for screen memory

This simplifies error handling and removes the need for manual cleanup
in the remove function.

Changes in v3:
- Split into a patch series as suggested by Thomas Zimmermann [1]
- Convert ioremap calls to devm_ variants

Changes in v2:
- Use pcim_enable_device() instead of pci_enable_device()
- Use pcim_request_all_regions() instead of pci_request_regions()
- Removed manual cleanup code as it's now automatic

[1] https://lore.kernel.org/lkml/fd6403d7-93f4-4fa4-ad0d-3ab91cba8183@suse.de/

Giovanni Di Santi (3):
  fbdev: kyro: Add missing PCI memory region request
  fbdev: kyro: Use devm_ioremap() for mmio registers
  fbdev: kyro: Use devm_ioremap_wc() for screen mem

 drivers/video/fbdev/kyro/fbdev.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

-- 
2.43.0


^ permalink raw reply

* [PATCH v3 1/3] fbdev: kyro: Add missing PCI memory region request
From: Giovanni Di Santi @ 2025-07-09  9:53 UTC (permalink / raw)
  To: tzimmermann, deller
  Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi
In-Reply-To: <20250709095354.931589-1-giovanni.disanti.lkl@gmail.com>

The kyro framebuffer driver did not request its PCI memory regions,
which could lead to conflicts with other drivers.  This change
addresses the task "Request memory regions in all fbdev drivers"
from the file Documentation/gpu/todo.rst.

This is addressed by using the managed device functions pcim_enable_device()
and pcim_request_all_regions(). This simplifies the code by making error
handling and driver removal cleanup automatic for these resources.

Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
 drivers/video/fbdev/kyro/fbdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 08ee8baa79f8..86e5d60ed0ff 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -679,7 +679,8 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		return err;
 
-	if ((err = pci_enable_device(pdev))) {
+	err = pcim_enable_device(pdev);
+	if (err) {
 		printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
 		return err;
 	}
@@ -688,6 +689,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!info)
 		return -ENOMEM;
 
+	err = pcim_request_all_regions(pdev, "kyrofb");
+	if (err)
+		goto out_free_fb;
+
 	currentpar = info->par;
 
 	kyro_fix.smem_start = pci_resource_start(pdev, 0);
-- 
2.43.0


^ permalink raw reply related

* [PATCH v3 2/3] fbdev: kyro: Use devm_ioremap() for mmio registers
From: Giovanni Di Santi @ 2025-07-09  9:53 UTC (permalink / raw)
  To: tzimmermann, deller
  Cc: linux-fbdev, dri-devel, linux-kernel, Giovanni Di Santi
In-Reply-To: <20250709095354.931589-1-giovanni.disanti.lkl@gmail.com>

Replace the manual ioremap() call for the MMIO registers with the
device-managed devm_ioremap() variant.

This simplifies the driver's resource management by ensuring the memory is
automatically unmapped when the driver detaches from the device.

Signed-off-by: Giovanni Di Santi <giovanni.disanti.lkl@gmail.com>
---
 drivers/video/fbdev/kyro/fbdev.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 86e5d60ed0ff..ddc241f508b1 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -701,13 +701,14 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	kyro_fix.mmio_len   = pci_resource_len(pdev, 1);
 
 	currentpar->regbase = deviceInfo.pSTGReg =
-		ioremap(kyro_fix.mmio_start, kyro_fix.mmio_len);
+		devm_ioremap(&pdev->dev, kyro_fix.mmio_start,
+			     kyro_fix.mmio_len);
 	if (!currentpar->regbase)
 		goto out_free_fb;
 
 	info->screen_base = pci_ioremap_wc_bar(pdev, 0);
 	if (!info->screen_base)
-		goto out_unmap_regs;
+		goto out_free_fb;
 
 	if (!nomtrr)
 		currentpar->wc_cookie = arch_phys_wc_add(kyro_fix.smem_start,
@@ -755,8 +756,6 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 out_unmap:
 	iounmap(info->screen_base);
-out_unmap_regs:
-	iounmap(currentpar->regbase);
 out_free_fb:
 	framebuffer_release(info);
 
@@ -779,7 +778,6 @@ static void kyrofb_remove(struct pci_dev *pdev)
 	deviceInfo.ulOverlayOffset = 0;
 
 	iounmap(info->screen_base);
-	iounmap(par->regbase);
 
 	arch_phys_wc_del(par->wc_cookie);
 
-- 
2.43.0


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox