<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">在 2025/6/27 16:12, Thomas Zimmermann
写道:<br>
</div>
<blockquote type="cite"
cite="mid:855d6faa-9f72-466e-9294-d6059bb9d920@suse.de">Hi
<br>
<br>
Am 27.06.25 um 10:07 schrieb Shixiong Ou:
<br>
<blockquote type="cite">
<br>
在 2025/6/26 18:31, Thomas Zimmermann 写道:
<br>
<blockquote type="cite">Hi
<br>
<br>
Am 26.06.25 um 11:49 schrieb <a class="moz-txt-link-abbreviated" href="mailto:oushixiong1025@163.com">oushixiong1025@163.com</a>:
<br>
<blockquote type="cite">From: Shixiong Ou
<a class="moz-txt-link-rfc2396E" href="mailto:oushixiong@kylinos.cn"><oushixiong@kylinos.cn></a>
<br>
<br>
[WHY]
<br>
On an ARM machine, the following log is present:
<br>
[ 0.900884] efifb: framebuffer at 0x1020000000, using
3072k, total 3072k
<br>
[ 2.297884] amdgpu 0000:04:00.0:
remove_conflicting_pci_framebuffers: bar 0: 0x1000000000
-> 0x100fffffff
<br>
[ 2.297886] amdgpu 0000:04:00.0:
remove_conflicting_pci_framebuffers: bar 2: 0x1010000000
-> 0x10101fffff
<br>
[ 2.297888] amdgpu 0000:04:00.0:
remove_conflicting_pci_framebuffers: bar 5: 0x58200000 ->
0x5823ffff
<br>
<br>
It show that the efifb framebuffer base is out of PCI BAR,
and this
<br>
</blockquote>
<br>
The patch at
<br>
<br>
<a class="moz-txt-link-freetext" href="https://patchwork.freedesktop.org/series/148057/">https://patchwork.freedesktop.org/series/148057/</a>
<br>
<br>
is supposed to fix the problem. It has been merged with
v6.16-rc1 as commit 2f29b5c23101 ("video: screen_info:
Relocate framebuffers behind PCI bridges"). It is in your
tree?
<br>
<br>
Best regards
<br>
Thomas
<br>
<br>
</blockquote>
yeah, this patch is in my tree. but do not fix the problem.
<br>
</blockquote>
<br>
The patch's final revision had a rough development. Just for
testing purposes, could you revert the commit and instead apply
the patch's earlier revision from
<br>
<br>
<a class="moz-txt-link-freetext" href="https://patchwork.freedesktop.org/patch/649527/?series=148057&rev=1">https://patchwork.freedesktop.org/patch/649527/?series=148057&rev=1</a>
<br>
<br>
?
<br>
<br>
Thanks a lot.
<br>
<br>
Best regards
<br>
Thomas <br>
<br>
</blockquote>
<p>I have revert the commit and applied this patch, and added some
prints as:</p>
<p>+ printk("pcibios_bus_to_resource orginal: start =
%llx, end = %llx",<br>
+ r->start, r->end);<br>
+ pcibios_bus_to_resource(pdev->bus, r,
&bus_region);<br>
+ printk("pcibios_bus_to_resource finished: start =
%llx, end = %llx",<br>
+ r->start, r->end);<br>
+</p>
<p>and the kernel message as follow:</p>
<p>kylin@kylin-pc:~$ dmesg | grep pcibios_bus_to_resource<br>
[ 0.684698] pcibios_bus_to_resource orginal: start =
1020000000, end = 10202fffff<br>
[ 0.684702] pcibios_bus_to_resource finished: start =
1020000000, end = 10202fffff<br>
</p>
<div id="tta_output_ta"
class="tta_no_click_outline tta_output_hastxt tta_focusTextExtraExtraSmall"
dir="ltr" data-placeholder="翻译" style="height: 48px;"
lang="zh-Hans" tabindex="0">The address doesn't seem to have been
modified.</div>
<div
class="tta_no_click_outline tta_output_hastxt tta_focusTextExtraExtraSmall"
dir="ltr" data-placeholder="翻译" style="height: 48px;"
lang="zh-Hans" tabindex="0">Best regards
<br>
Shixiong.
<br>
<br>
</div>
<blockquote type="cite"
cite="mid:855d6faa-9f72-466e-9294-d6059bb9d920@suse.de">
<blockquote type="cite">
<br>
this is some message:
<br>
<br>
kylin@kylin-pc:~$ dmesg | grep BAR
<br>
[ 0.688192] pci 0000:00:03.0: BAR 15: assigned [mem
0x1000000000-0x101fffffff 64bit pref]
<br>
[ 0.688200] pci 0000:00:00.0: BAR 0: assigned [mem
0x1020000000-0x10200fffff 64bit pref]
<br>
[ 0.688205] pci 0000:00:00.0: BAR 14: assigned [mem
0x58000000-0x580fffff]
<br>
[ 0.688210] pci 0000:00:01.0: BAR 0: assigned [mem
0x1020100000-0x10201fffff 64bit pref]
<br>
[ 0.688215] pci 0000:00:02.0: BAR 0: assigned [mem
0x1020200000-0x10202fffff 64bit pref]
<br>
[ 0.688221] pci 0000:00:02.0: BAR 14: assigned [mem
0x58100000-0x581fffff]
<br>
[ 0.688225] pci 0000:00:03.0: BAR 0: assigned [mem
0x1020300000-0x10203fffff 64bit pref]
<br>
[ 0.688231] pci 0000:00:03.0: BAR 14: assigned [mem
0x58200000-0x585fffff]
<br>
[ 0.688237] pci 0000:00:04.0: BAR 0: assigned [mem
0x1020400000-0x10204fffff 64bit pref]
<br>
[ 0.688243] pci 0000:00:05.0: BAR 0: assigned [mem
0x1020500000-0x10205fffff 64bit pref]
<br>
[ 0.688249] pci 0000:00:05.0: BAR 14: assigned [mem
0x58600000-0x586fffff]
<br>
[ 0.688253] pci 0000:01:00.0: BAR 0: assigned [mem
0x58000000-0x58003fff 64bit]
<br>
[ 0.688290] pci 0000:03:00.0: BAR 6: assigned [mem
0x58100000-0x5817ffff pref]
<br>
[ 0.688296] pci 0000:03:00.0: BAR 0: assigned [mem
0x58180000-0x58181fff]
<br>
[ 0.688303] pci 0000:03:00.0: BAR 5: assigned [mem
0x58182000-0x58183fff]
<br>
[ 0.688317] pci 0000:04:00.0: BAR 1: assigned [mem
0x1000000000-0x101fffffff 64bit pref]
<br>
[ 0.688326] pci 0000:04:00.0: BAR 0: assigned [mem
0x58200000-0x583fffff]
<br>
[ 0.688332] pci 0000:04:00.0: BAR 6: assigned [mem
0x58400000-0x584fffff pref]
<br>
[ 0.688336] pci 0000:04:00.1: BAR 0: assigned [mem
0x58500000-0x58503fff]
<br>
[ 0.688360] pci 0000:06:00.0: BAR 0: assigned [mem
0x58600000-0x58601fff 64bit]
<br>
kylin@kylin-pc:~$ dmesg | grep framebuffer
<br>
[ 1.137536] efifb: framebuffer at 0x1020000000, using 3072k,
total 3072k
<br>
<br>
the efifb base address is still at 0x1020000000 after calling
pcibios_bus_to_resource().
<br>
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">results in both efi-framebuffer and
amdgpudrmfb co-existing.
<br>
<br>
The fbcon will be bound to efi-framebuffer by default and
cannot be used.
<br>
<br>
[HOW]
<br>
Do not load efifb driver if PCI BAR has changed but not
fixuped.
<br>
In the following cases:
<br>
1. screen_info_lfb_pdev is NULL.
<br>
2. __screen_info_relocation_is_valid return false.
<br>
<br>
Signed-off-by: Shixiong Ou <a class="moz-txt-link-rfc2396E" href="mailto:oushixiong@kylinos.cn"><oushixiong@kylinos.cn></a>
<br>
---
<br>
drivers/video/fbdev/efifb.c | 4 ++++
<br>
drivers/video/screen_info_pci.c | 24
++++++++++++++++++++++++
<br>
include/linux/screen_info.h | 5 +++++
<br>
3 files changed, 33 insertions(+)
<br>
<br>
diff --git a/drivers/video/fbdev/efifb.c
b/drivers/video/fbdev/efifb.c
<br>
index 0e1bd3dba255..de8d016c9a66 100644
<br>
--- a/drivers/video/fbdev/efifb.c
<br>
+++ b/drivers/video/fbdev/efifb.c
<br>
@@ -303,6 +303,10 @@ static void efifb_setup(struct
screen_info *si, char *options)
<br>
static inline bool fb_base_is_valid(struct screen_info
*si)
<br>
{
<br>
+ /* check whether fb_base has changed but not fixuped */
<br>
+ if (!screen_info_is_useful())
<br>
+ return false;
<br>
+
<br>
if (si->lfb_base)
<br>
return true;
<br>
diff --git a/drivers/video/screen_info_pci.c
b/drivers/video/screen_info_pci.c
<br>
index 66bfc1d0a6dc..ac57dcaf0cac 100644
<br>
--- a/drivers/video/screen_info_pci.c
<br>
+++ b/drivers/video/screen_info_pci.c
<br>
@@ -9,6 +9,8 @@ static struct pci_dev *screen_info_lfb_pdev;
<br>
static size_t screen_info_lfb_bar;
<br>
static resource_size_t screen_info_lfb_res_start; //
original start of resource
<br>
static resource_size_t screen_info_lfb_offset; //
framebuffer offset within resource
<br>
+static bool screen_info_changed;
<br>
+static bool screen_info_fixuped;
<br>
static bool __screen_info_relocation_is_valid(const
struct screen_info *si, struct resource *pr)
<br>
{
<br>
@@ -24,6 +26,24 @@ static bool
__screen_info_relocation_is_valid(const struct screen_info
*si, stru
<br>
return true;
<br>
}
<br>
+bool screen_info_is_useful(void)
<br>
+{
<br>
+ unsigned int type;
<br>
+ const struct screen_info *si = &screen_info;
<br>
+
<br>
+ type = screen_info_video_type(si);
<br>
+ if (type != VIDEO_TYPE_EFI)
<br>
+ return true;
<br>
+
<br>
+ if (screen_info_changed &&
!screen_info_fixuped) {
<br>
+ pr_warn("The screen_info has changed but not
fixuped");
<br>
+ return false;
<br>
+ }
<br>
+
<br>
+ pr_info("The screen_info is useful");
<br>
+ return true;
<br>
+}
<br>
+
<br>
void screen_info_apply_fixups(void)
<br>
{
<br>
struct screen_info *si = &screen_info;
<br>
@@ -32,18 +52,22 @@ void screen_info_apply_fixups(void)
<br>
struct resource *pr =
&screen_info_lfb_pdev->resource[screen_info_lfb_bar];
<br>
if (pr->start != screen_info_lfb_res_start) {
<br>
+ screen_info_changed = true;
<br>
if (__screen_info_relocation_is_valid(si, pr))
{
<br>
/*
<br>
* Only update base if we have an actual
<br>
* relocation to a valid I/O range.
<br>
*/
<br>
__screen_info_set_lfb_base(si,
pr->start + screen_info_lfb_offset);
<br>
+ screen_info_fixuped = true;
<br>
pr_info("Relocating firmware framebuffer
to offset %pa[d] within %pr\n",
<br>
&screen_info_lfb_offset, pr);
<br>
} else {
<br>
pr_warn("Invalid relocating, disabling
firmware framebuffer\n");
<br>
</blockquote>
</blockquote>
<br>
And should something be done
after __screen_info_relocation_is_valid() return false?
<br>
<br>
Best regards
<br>
Shixiong.
<br>
<br>
<blockquote type="cite">
<blockquote type="cite"> }
<br>
}
<br>
+ } else {
<br>
+ screen_info_changed = true;
<br>
}
<br>
}
<br>
diff --git a/include/linux/screen_info.h
b/include/linux/screen_info.h
<br>
index 923d68e07679..632cdbb1adbe 100644
<br>
--- a/include/linux/screen_info.h
<br>
+++ b/include/linux/screen_info.h
<br>
@@ -138,9 +138,14 @@ ssize_t screen_info_resources(const
struct screen_info *si, struct resource *r,
<br>
u32 __screen_info_lfb_bits_per_pixel(const struct
screen_info *si);
<br>
#if defined(CONFIG_PCI)
<br>
+bool screen_info_is_useful(void);
<br>
void screen_info_apply_fixups(void);
<br>
struct pci_dev *screen_info_pci_dev(const struct
screen_info *si);
<br>
#else
<br>
+bool screen_info_is_useful(void)
<br>
+{
<br>
+ return true;
<br>
+}
<br>
static inline void screen_info_apply_fixups(void)
<br>
{ }
<br>
static inline struct pci_dev *screen_info_pci_dev(const
struct screen_info *si)
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
</body>
</html>