2023-06-13 03:13:41

by Sui Jingfeng

[permalink] [raw]
Subject: [PATCH v7 0/8] PCI/VGA: Introduce is_boot_device function callback to vga_client_register

The vga_is_firmware_default() function is arch-dependent, it's probably
wrong if we simply remove the arch guard. As the VRAM BAR which contains
firmware framebuffer may move, while the lfb_base and lfb_size members of
the screen_info does not change accordingly. In short, it should take the
re-allocation of the PCI BAR into consideration.

With the observation that device drivers or video aperture helpers may
have better knowledge about which PCI bar contains the firmware fb,
which could avoid the need to iterate all of the PCI BARs. But as a PCI
function at pci/vgaarb.c, vga_is_firmware_default() is not suitable to
make such an optimization since it is loaded too early.

There are PCI display controllers that don't have a dedicated VRAM bar,
this function will lose its effectiveness in such a case. Luckily, the
device driver can provide an accurate workaround.

Therefore, this patch introduces a callback that allows the device driver
to tell the VGAARB if the device is the default boot device. Also honor
the comment: "Clients have two callback mechanisms they can use"

Sui Jingfeng (8):
PCI/VGA: Use unsigned type for the io_state variable
PCI/VGA: Deal only with VGA class devices
PCI/VGA: Tidy up the code and comment format
PCI/VGA: Replace full MIT license text with SPDX identifier
video/aperture: Add a helper to detect if an aperture contains
firmware FB
PCI/VGA: Introduce is_boot_device function callback to
vga_client_register
drm/amdgpu: Implement the is_boot_device callback function
drm/radeon: Implement the is_boot_device callback function

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +-
drivers/gpu/drm/drm_aperture.c | 16 +++
drivers/gpu/drm/i915/display/intel_vga.c | 3 +-
drivers/gpu/drm/nouveau/nouveau_vga.c | 2 +-
drivers/gpu/drm/radeon/radeon_device.c | 12 +-
drivers/pci/vgaarb.c | 153 +++++++++++++--------
drivers/vfio/pci/vfio_pci_core.c | 2 +-
drivers/video/aperture.c | 29 ++++
include/drm/drm_aperture.h | 2 +
include/linux/aperture.h | 7 +
include/linux/vgaarb.h | 35 ++---
11 files changed, 184 insertions(+), 89 deletions(-)

--
2.25.1



2023-06-13 03:13:57

by Sui Jingfeng

[permalink] [raw]
Subject: [PATCH v7 5/8] video/aperture: Add a helper to detect if an aperture contains firmware FB

From: Sui Jingfeng <[email protected]>

This patch adds the aperture_contain_firmware_fb() function to do the
determination. Unfortunately due to the fact that apertures list will be
freed dynamically, the location and size information of the firmware fb
will be lost after dedicated drivers call
aperture_remove_conflicting_devices(),
aperture_remove_conflicting_pci_devices() or
aperture_remove_all_conflicting_devices() functions

We handle this problem by introducing two static variables which record the
firmware framebuffer's start addrness and end addrness. It assumes that the
system has only one active firmware framebuffer driver at a time.

We don't use the global structure screen_info here, because PCI resource
may get reallocated(the VRAM BAR could be moved) at kernel boot stage.

Cc: Thomas Zimmermann <[email protected]>
Cc: Javier Martinez Canillas <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Helge Deller <[email protected]>
Signed-off-by: Sui Jingfeng <[email protected]>
---
drivers/gpu/drm/drm_aperture.c | 16 ++++++++++++++++
drivers/video/aperture.c | 29 +++++++++++++++++++++++++++++
include/drm/drm_aperture.h | 2 ++
include/linux/aperture.h | 7 +++++++
4 files changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c
index 5729f3bb4398..6e5d8a08683c 100644
--- a/drivers/gpu/drm/drm_aperture.c
+++ b/drivers/gpu/drm/drm_aperture.c
@@ -190,3 +190,19 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
return aperture_remove_conflicting_pci_devices(pdev, req_driver->name);
}
EXPORT_SYMBOL(drm_aperture_remove_conflicting_pci_framebuffers);
+
+/**
+ * drm_aperture_contain_firmware_fb - Determine if a aperture contains firmware framebuffer
+ *
+ * @base: the aperture's base address in physical memory
+ * @size: aperture size in bytes
+ *
+ * Returns:
+ * true on if there is a firmware framebuffer belong to the aperture passed in,
+ * or false otherwise.
+ */
+bool drm_aperture_contain_firmware_fb(resource_size_t base, resource_size_t size)
+{
+ return aperture_contain_firmware_fb(base, base + size);
+}
+EXPORT_SYMBOL(drm_aperture_contain_firmware_fb);
diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
index 561be8feca96..5a5422cec669 100644
--- a/drivers/video/aperture.c
+++ b/drivers/video/aperture.c
@@ -141,6 +141,9 @@ struct aperture_range {
static LIST_HEAD(apertures);
static DEFINE_MUTEX(apertures_lock);

+static resource_size_t firm_fb_start;
+static resource_size_t firm_fb_end;
+
static bool overlap(resource_size_t base1, resource_size_t end1,
resource_size_t base2, resource_size_t end2)
{
@@ -170,6 +173,9 @@ static int devm_aperture_acquire(struct device *dev,

mutex_lock(&apertures_lock);

+ firm_fb_start = base;
+ firm_fb_end = end;
+
list_for_each(pos, &apertures) {
ap = container_of(pos, struct aperture_range, lh);
if (overlap(base, end, ap->base, ap->base + ap->size)) {
@@ -377,3 +383,26 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na

}
EXPORT_SYMBOL(aperture_remove_conflicting_pci_devices);
+
+/**
+ * aperture_contain_firmware_fb - Detect if the firmware framebuffer belong to
+ * a aperture.
+ * @ap_start: the aperture's start address in physical memory
+ * @ap_end: the aperture's end address in physical memory
+ *
+ * Returns:
+ * true on if there is a firmware framebuffer belong to the aperture passed in,
+ * or false otherwise.
+ */
+bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end)
+{
+ /* No firmware framebuffer support */
+ if (!firm_fb_start || !firm_fb_end)
+ return false;
+
+ if (firm_fb_start >= ap_start && firm_fb_end <= ap_end)
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL(aperture_contain_firmware_fb);
diff --git a/include/drm/drm_aperture.h b/include/drm/drm_aperture.h
index cbe33b49fd5d..6a0b9bacb081 100644
--- a/include/drm/drm_aperture.h
+++ b/include/drm/drm_aperture.h
@@ -35,4 +35,6 @@ drm_aperture_remove_framebuffers(const struct drm_driver *req_driver)
req_driver);
}

+bool drm_aperture_contain_firmware_fb(resource_size_t base, resource_size_t size);
+
#endif
diff --git a/include/linux/aperture.h b/include/linux/aperture.h
index 1a9a88b11584..d4dc5917c49b 100644
--- a/include/linux/aperture.h
+++ b/include/linux/aperture.h
@@ -19,6 +19,8 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si
int __aperture_remove_legacy_vga_devices(struct pci_dev *pdev);

int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name);
+
+bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end);
#else
static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
resource_size_t base,
@@ -42,6 +44,11 @@ static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,
{
return 0;
}
+
+static inline bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end)
+{
+ return false;
+}
#endif

/**
--
2.25.1


2023-06-13 03:14:33

by Sui Jingfeng

[permalink] [raw]
Subject: [PATCH v7 7/8] drm/amdgpu: Implement the is_boot_device callback function

From: Sui Jingfeng <[email protected]>

[why]

The vga_is_firmware_default() defined in drivers/pci/vgaarb.c is
arch-dependent, it's a dummy on non-x86 architectures currently.
This made VGAARB lost an important condition for the arbitration.
It could still be wrong even if we remove the #ifdef and #endif guards.
because the PCI bar will move (resource re-allocation).

[how]

The device that owns the firmware framebuffer should be the default boot
device. This patch adds an arch-independent function to enforce this rule.
The vgaarb subsystem will call back to amdgpu_is_boot_device() function
when drm/amdgpu is successfully bound to an AMDGPU device.

Cc: Alex Deucher <[email protected]>
Cc: Christian Konig <[email protected]>
Cc: Pan Xinhui <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Hawking Zhang <[email protected]>
Cc: Mario Limonciello <[email protected]>
Cc: Lijo Lazar <[email protected]>
Cc: YiPeng Chai <[email protected]>
Cc: Bokun Zhang <[email protected]>
CC: Likun Gao <[email protected]>
Signed-off-by: Sui Jingfeng <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7a096f2d5c16..77624e8062d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3560,6 +3560,15 @@ static const struct attribute *amdgpu_dev_attributes[] = {
NULL
};

+static bool amdgpu_is_boot_device(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+ struct amdgpu_device *adev = drm_to_adev(dev);
+ struct amdgpu_gmc *gmc = &adev->gmc;
+
+ return drm_aperture_contain_firmware_fb(gmc->aper_base, gmc->aper_size);
+}
+
/**
* amdgpu_device_init - initialize the driver
*
@@ -3960,7 +3969,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
/* this will fail for cards that aren't VGA class devices, just
* ignore it */
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
- vga_client_register(adev->pdev, amdgpu_device_vga_set_decode, NULL);
+ vga_client_register(adev->pdev, amdgpu_device_vga_set_decode,
+ amdgpu_is_boot_device);

px = amdgpu_device_supports_px(ddev);

--
2.25.1


2023-06-13 03:14:40

by Sui Jingfeng

[permalink] [raw]
Subject: [PATCH v7 8/8] drm/radeon: Implement the is_boot_device callback function

From: Sui Jingfeng <[email protected]>

[why]

The vga_is_firmware_default() defined in drivers/pci/vgaarb.c is
arch-dependent, it's a dummy on non-x86 architectures currently.
This made VGAARB lost an important condition for the arbitration.
It could still be wrong even if we remove the #ifdef and #endif guards.
because the PCI bar will move (resource re-allocation).

[how]

The device that owns the firmware framebuffer should be the default boot
device. This patch adds an arch-independent function to enforce this rule.
The vgaarb subsystem will call back to radeon_is_boot_device() function
when drm/radeon is successfully bound to a radeon GPU device.

Cc: Alex Deucher <[email protected]>
Cc: Christian Konig <[email protected]>
Cc: Pan Xinhui <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Daniel Vetter <[email protected]>
Signed-off-by: Sui Jingfeng <[email protected]>
---
drivers/gpu/drm/radeon/radeon_device.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 71f2ff39d6a1..afb49000830c 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -34,6 +34,7 @@
#include <linux/vga_switcheroo.h>
#include <linux/vgaarb.h>

+#include <drm/drm_aperture.h>
#include <drm/drm_cache.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_device.h>
@@ -1263,6 +1264,15 @@ static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
.can_switch = radeon_switcheroo_can_switch,
};

+static bool radeon_is_boot_device(struct pci_dev *pdev)
+{
+ struct drm_device *dev = pci_get_drvdata(pdev);
+ struct radeon_device *rdev = dev->dev_private;
+ struct radeon_mc *gmc = &rdev->mc;
+
+ return drm_aperture_contain_firmware_fb(gmc->aper_base, gmc->aper_size);
+}
+
/**
* radeon_device_init - initialize the driver
*
@@ -1425,7 +1435,7 @@ int radeon_device_init(struct radeon_device *rdev,
/* if we have > 1 VGA cards, then disable the radeon VGA resources */
/* this will fail for cards that aren't VGA class devices, just
* ignore it */
- vga_client_register(rdev->pdev, radeon_vga_set_decode, NULL);
+ vga_client_register(rdev->pdev, radeon_vga_set_decode, radeon_is_boot_device);

if (rdev->flags & RADEON_IS_PX)
runtime = true;
--
2.25.1


2023-06-15 07:13:27

by Sui Jingfeng

[permalink] [raw]
Subject: Re: [PATCH v7 7/8] drm/amdgpu: Implement the is_boot_device callback function

Hi,


Does anyone has the bandwidth to review this?

I provide more additional information here, hope it helps.


On a non-x86 multiple platform, the discrete AMDGPU fails to override
the integrated one.

because the PCI BAR 0 of the AMDGPU gets moved.

Below is the log of 'dmesg | grep vgaarb'.

So relaying on screen_info is not always reliable.


[ 0.361928] pci 0000:00:06.1: vgaarb: setting as boot VGA device
[ 0.361932] pci 0000:00:06.1: vgaarb: bridge control possible
[ 0.361933] pci 0000:00:06.1: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none
[ 0.361940] pci 0000:05:00.0: vgaarb: bridge control possible
[ 0.361941] pci 0000:05:00.0: vgaarb: VGA device added: decodes=io+mem,owns=none,locks=none
[ 0.361943] vgaarb: loaded
[ 11.352087] amdgpu 0000:05:00.0: vgaarb: Set as boot device (dictated by driver)
[ 11.575505] loongson 0000:00:06.1: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=io+mem
[ 11.585100] amdgpu 0000:05:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none


dmesg | grep efifb:


[    0.356355] pci 0000:05:00.0: BAR 0: assigned to efifb
[    0.375793] efifb: probing for efifb
[    0.375795] pci 0000:05:00.0: BAR has moved, updating efifb address
[    0.375803] efifb: framebuffer at 0xe0030000000, using 976k, total 975k
[    0.375805] efifb: mode is 800x600x16, linelength=1664, pages=1
[    0.375806] efifb: scrolling: redraw
[    0.375808] efifb: Truecolor: size=0:5:6:5, shift=0:11:5:0


efifb can also prove that "BAR has been moved"


From dmesg |  grep "pci 0000:05:00.0":


[    0.356286] pci 0000:05:00.0: [1002:699f] type 00 class 0x030000
[    0.356303] pci 0000:05:00.0: reg 0x10: [mem
0xe0020000000-0xe002fffffff 64bit pref]
[    0.356315] pci 0000:05:00.0: reg 0x18: [mem
0xe0030000000-0xe00301fffff 64bit pref]
[    0.356323] pci 0000:05:00.0: reg 0x20: [io  0x40000-0x400ff]
[    0.356331] pci 0000:05:00.0: reg 0x24: [mem 0xe0053100000-0xe005313ffff]
[    0.356339] pci 0000:05:00.0: reg 0x30: [mem 0xfffe0000-0xffffffff pref]
[    0.356346] pci 0000:05:00.0: enabling Extended Tags
[    0.356355] pci 0000:05:00.0: BAR 0: assigned to efifb
[    0.356421] pci 0000:05:00.0: supports D1 D2
[    0.356422] pci 0000:05:00.0: PME# supported from D1 D2 D3hot D3cold
[    0.356858] pci 0000:05:00.0: BAR 0: assigned [mem
0xe0030000000-0xe003fffffff 64bit pref]
[    0.356866] pci 0000:05:00.0: BAR 2: assigned [mem
0xe0040000000-0xe00401fffff 64bit pref]
[    0.356875] pci 0000:05:00.0: BAR 5: assigned [mem
0xe0049000000-0xe004903ffff]
[    0.356878] pci 0000:05:00.0: BAR 6: assigned [mem
0xe0049040000-0xe004905ffff pref]
[    0.356889] pci 0000:05:00.0: BAR 4: assigned [io 0x4000-0x40ff]
[    0.361940] pci 0000:05:00.0: vgaarb: bridge control possible
[    0.361941] pci 0000:05:00.0: vgaarb: VGA device added:
decodes=io+mem,owns=none,locks=none
[    0.375795] pci 0000:05:00.0: BAR has moved, updating efifb address

We can see that the Bar 0 of AMDGPU

moved from '0xe0020000000-0xe002fffffff'  to '0xe0030000000-0xe003fffffff'

while the fb location information recorded by the screen_info still
belong to '0xe0020000000-0xe002fffffff'


I suspect this is also the reason that video/aperture don't relay on the
information provided by screen_info

in the contrast, it require the firmware framebuffer driver(efifb) to call

devm_aperture_acquire_from_firmware() function, only in this way
video/aperture

could record the correct information about the aperture being used the
by the firmware framebuffe.


While vgaarb is loaded too early, even before efifb.

so that we can only relay on the pci_notifier call back to us.


On 2023/6/13 11:01, Sui Jingfeng wrote:
> From: Sui Jingfeng <[email protected]>
>
> [why]
>
> The vga_is_firmware_default() defined in drivers/pci/vgaarb.c is
> arch-dependent, it's a dummy on non-x86 architectures currently.
> This made VGAARB lost an important condition for the arbitration.
> It could still be wrong even if we remove the #ifdef and #endif guards.
> because the PCI bar will move (resource re-allocation).
>
> [how]
>
> The device that owns the firmware framebuffer should be the default boot
> device. This patch adds an arch-independent function to enforce this rule

--
Jingfeng


2023-06-27 14:35:23

by Sui Jingfeng

[permalink] [raw]
Subject: Re: [PATCH v7 5/8] video/aperture: Add a helper to detect if an aperture contains firmware FB

 PING ?

On 2023/6/13 11:01, Sui Jingfeng wrote:
> From: Sui Jingfeng <[email protected]>
>
> This patch adds the aperture_contain_firmware_fb() function to do the
> determination. Unfortunately due to the fact that apertures list will be
> freed dynamically, the location and size information of the firmware fb
> will be lost after dedicated drivers call
> aperture_remove_conflicting_devices(),
> aperture_remove_conflicting_pci_devices() or
> aperture_remove_all_conflicting_devices() functions
>
> We handle this problem by introducing two static variables which record the
> firmware framebuffer's start addrness and end addrness. It assumes that the
> system has only one active firmware framebuffer driver at a time.
>
> We don't use the global structure screen_info here, because PCI resource
> may get reallocated(the VRAM BAR could be moved) at kernel boot stage.
>
> Cc: Thomas Zimmermann <[email protected]>
> Cc: Javier Martinez Canillas <[email protected]>
> Cc: Maarten Lankhorst <[email protected]>
> Cc: Maxime Ripard <[email protected]>
> Cc: David Airlie <[email protected]>
> Cc: Daniel Vetter <[email protected]>
> Cc: Helge Deller <[email protected]>
> Signed-off-by: Sui Jingfeng <[email protected]>
> ---
> drivers/gpu/drm/drm_aperture.c | 16 ++++++++++++++++
> drivers/video/aperture.c | 29 +++++++++++++++++++++++++++++
> include/drm/drm_aperture.h | 2 ++
> include/linux/aperture.h | 7 +++++++
> 4 files changed, 54 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c
> index 5729f3bb4398..6e5d8a08683c 100644
> --- a/drivers/gpu/drm/drm_aperture.c
> +++ b/drivers/gpu/drm/drm_aperture.c
> @@ -190,3 +190,19 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
> return aperture_remove_conflicting_pci_devices(pdev, req_driver->name);
> }
> EXPORT_SYMBOL(drm_aperture_remove_conflicting_pci_framebuffers);
> +
> +/**
> + * drm_aperture_contain_firmware_fb - Determine if a aperture contains firmware framebuffer
> + *
> + * @base: the aperture's base address in physical memory
> + * @size: aperture size in bytes
> + *
> + * Returns:
> + * true on if there is a firmware framebuffer belong to the aperture passed in,
> + * or false otherwise.
> + */
> +bool drm_aperture_contain_firmware_fb(resource_size_t base, resource_size_t size)
> +{
> + return aperture_contain_firmware_fb(base, base + size);
> +}
> +EXPORT_SYMBOL(drm_aperture_contain_firmware_fb);
> diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
> index 561be8feca96..5a5422cec669 100644
> --- a/drivers/video/aperture.c
> +++ b/drivers/video/aperture.c
> @@ -141,6 +141,9 @@ struct aperture_range {
> static LIST_HEAD(apertures);
> static DEFINE_MUTEX(apertures_lock);
>
> +static resource_size_t firm_fb_start;
> +static resource_size_t firm_fb_end;
> +
> static bool overlap(resource_size_t base1, resource_size_t end1,
> resource_size_t base2, resource_size_t end2)
> {
> @@ -170,6 +173,9 @@ static int devm_aperture_acquire(struct device *dev,
>
> mutex_lock(&apertures_lock);
>
> + firm_fb_start = base;
> + firm_fb_end = end;
> +
> list_for_each(pos, &apertures) {
> ap = container_of(pos, struct aperture_range, lh);
> if (overlap(base, end, ap->base, ap->base + ap->size)) {
> @@ -377,3 +383,26 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na
>
> }
> EXPORT_SYMBOL(aperture_remove_conflicting_pci_devices);
> +
> +/**
> + * aperture_contain_firmware_fb - Detect if the firmware framebuffer belong to
> + * a aperture.
> + * @ap_start: the aperture's start address in physical memory
> + * @ap_end: the aperture's end address in physical memory
> + *
> + * Returns:
> + * true on if there is a firmware framebuffer belong to the aperture passed in,
> + * or false otherwise.
> + */
> +bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end)
> +{
> + /* No firmware framebuffer support */
> + if (!firm_fb_start || !firm_fb_end)
> + return false;
> +
> + if (firm_fb_start >= ap_start && firm_fb_end <= ap_end)
> + return true;
> +
> + return false;
> +}
> +EXPORT_SYMBOL(aperture_contain_firmware_fb);
> diff --git a/include/drm/drm_aperture.h b/include/drm/drm_aperture.h
> index cbe33b49fd5d..6a0b9bacb081 100644
> --- a/include/drm/drm_aperture.h
> +++ b/include/drm/drm_aperture.h
> @@ -35,4 +35,6 @@ drm_aperture_remove_framebuffers(const struct drm_driver *req_driver)
> req_driver);
> }
>
> +bool drm_aperture_contain_firmware_fb(resource_size_t base, resource_size_t size);
> +
> #endif
> diff --git a/include/linux/aperture.h b/include/linux/aperture.h
> index 1a9a88b11584..d4dc5917c49b 100644
> --- a/include/linux/aperture.h
> +++ b/include/linux/aperture.h
> @@ -19,6 +19,8 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si
> int __aperture_remove_legacy_vga_devices(struct pci_dev *pdev);
>
> int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name);
> +
> +bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end);
> #else
> static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
> resource_size_t base,
> @@ -42,6 +44,11 @@ static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,
> {
> return 0;
> }
> +
> +static inline bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end)
> +{
> + return false;
> +}
> #endif
>
> /**

--
Jingfeng


2023-06-27 14:35:59

by Sui Jingfeng

[permalink] [raw]
Subject: Re: [PATCH v7 8/8] drm/radeon: Implement the is_boot_device callback function


PING ?


On 2023/6/13 11:01, Sui Jingfeng wrote:
> From: Sui Jingfeng <[email protected]>
>
> [why]
>
> The vga_is_firmware_default() defined in drivers/pci/vgaarb.c is
> arch-dependent, it's a dummy on non-x86 architectures currently.
> This made VGAARB lost an important condition for the arbitration.
> It could still be wrong even if we remove the #ifdef and #endif guards.
> because the PCI bar will move (resource re-allocation).
>
> [how]
>
> The device that owns the firmware framebuffer should be the default boot
> device. This patch adds an arch-independent function to enforce this rule

--
Jingfeng