3939#include <linux/mmu_notifier.h>
4040#include <linux/suspend.h>
4141#include <linux/cc_platform.h>
42+ #include <linux/fb.h>
4243
4344#include "amdgpu.h"
4445#include "amdgpu_irq.h"
@@ -1890,6 +1891,26 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
18901891
18911892static const struct drm_driver amdgpu_kms_driver ;
18921893
1894+ static bool amdgpu_is_fw_framebuffer (resource_size_t base ,
1895+ resource_size_t size )
1896+ {
1897+ bool found = false;
1898+ #if IS_REACHABLE (CONFIG_FB )
1899+ struct apertures_struct * a ;
1900+
1901+ a = alloc_apertures (1 );
1902+ if (!a )
1903+ return false;
1904+
1905+ a -> ranges [0 ].base = base ;
1906+ a -> ranges [0 ].size = size ;
1907+
1908+ found = is_firmware_framebuffer (a );
1909+ kfree (a );
1910+ #endif
1911+ return found ;
1912+ }
1913+
18931914static int amdgpu_pci_probe (struct pci_dev * pdev ,
18941915 const struct pci_device_id * ent )
18951916{
@@ -1898,6 +1919,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
18981919 unsigned long flags = ent -> driver_data ;
18991920 int ret , retry = 0 , i ;
19001921 bool supports_atomic = false;
1922+ bool is_fw_fb ;
1923+ resource_size_t base , size ;
19011924
19021925 /* skip devices which are owned by radeon */
19031926 for (i = 0 ; i < ARRAY_SIZE (amdgpu_unsupported_pciidlist ); i ++ ) {
@@ -1966,6 +1989,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
19661989 }
19671990#endif
19681991
1992+ base = pci_resource_start (pdev , 0 );
1993+ size = pci_resource_len (pdev , 0 );
1994+ is_fw_fb = amdgpu_is_fw_framebuffer (base , size );
1995+
19691996 /* Get rid of things like offb */
19701997 ret = drm_aperture_remove_conflicting_pci_framebuffers (pdev , & amdgpu_kms_driver );
19711998 if (ret )
@@ -1978,6 +2005,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
19782005 adev -> dev = & pdev -> dev ;
19792006 adev -> pdev = pdev ;
19802007 ddev = adev_to_drm (adev );
2008+ adev -> is_fw_fb = is_fw_fb ;
19812009
19822010 if (!supports_atomic )
19832011 ddev -> driver_features &= ~DRIVER_ATOMIC ;
0 commit comments