diff mbox series

video/aperture: match the pci device when calling sysfb_disable()

Message ID 20240809150327.2485848-1-alexander.deucher@amd.com (mailing list archive)
State New, archived
Headers show
Series video/aperture: match the pci device when calling sysfb_disable() | expand

Commit Message

Deucher, Alexander Aug. 9, 2024, 3:03 p.m. UTC
In aperture_remove_conflicting_pci_devices(), match the pci
device determine whether or not to call sysfb_disable().  This
fixes cases where the pimary device is not VGA compatible which
leads to the following problem:

1. A PCI device with a non-VGA class is the the boot display
2. That device is probed first and it is not a vga device so
   sysfb_disable() is not called, but the device resources
   are freed by aperture_detach_platform_device()
3. Non-primary GPU is vga device and it ends up calling sysfb_disable()
4. NULL pointer dereference via sysfb_disable() since the resources
   have already been freed by aperture_detach_platform_device() when
   it was called by the other device.

Fix this by calling sysfb_disable() on the device associated with it.

Fixes: 5ae3716cfdcd ("video/aperture: Only remove sysfb on the default vga pci device")
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Helge Deller <deller@gmx.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
---
 drivers/video/aperture.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

kernel test robot Aug. 10, 2024, 11:44 a.m. UTC | #1
Hi Alex,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.11-rc2 next-20240809]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
patch subject: [PATCH] video/aperture: match the pci device when calling sysfb_disable()
config: csky-randconfig-001-20240810 (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408101951.tXyqYOzv-lkp@intel.com/

All errors (new ones prefixed by >>):

   csky-linux-ld: drivers/video/aperture.o: in function `aperture_remove_conflicting_pci_devices':
>> aperture.c:(.text+0x222): undefined reference to `screen_info_pci_dev'
   csky-linux-ld: drivers/video/aperture.o: in function `devm_aperture_acquire_release':
>> aperture.c:(.text+0x2c0): undefined reference to `screen_info'
>> csky-linux-ld: aperture.c:(.text+0x2c4): undefined reference to `screen_info_pci_dev'
kernel test robot Aug. 10, 2024, 12:25 p.m. UTC | #2
Hi Alex,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.11-rc2 next-20240809]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
patch subject: [PATCH] video/aperture: match the pci device when calling sysfb_disable()
config: i386-randconfig-001-20240810 (https://download.01.org/0day-ci/archive/20240810/202408102027.iWri1VXT-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408102027.iWri1VXT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408102027.iWri1VXT-lkp@intel.com/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: screen_info_pci_dev
   >>> referenced by aperture.c:358 (drivers/video/aperture.c:358)
   >>>               drivers/video/aperture.o:(aperture_remove_conflicting_pci_devices) in archive vmlinux.a
Thomas Zimmermann Aug. 12, 2024, 12:10 p.m. UTC | #3
Hi

Am 10.08.24 um 13:44 schrieb kernel test robot:
> Hi Alex,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on drm-misc/drm-misc-next]
> [also build test ERROR on linus/master v6.11-rc2 next-20240809]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
> base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
> patch link:    https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
> patch subject: [PATCH] video/aperture: match the pci device when calling sysfb_disable()
> config: csky-randconfig-001-20240810 (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/config)
> compiler: csky-linux-gcc (GCC) 14.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202408101951.tXyqYOzv-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>     csky-linux-ld: drivers/video/aperture.o: in function `aperture_remove_conflicting_pci_devices':
>>> aperture.c:(.text+0x222): undefined reference to `screen_info_pci_dev'

Strange. There's a already placeholder [1] for architectures without 
PCI. Otherwise the source file is listed at [2].

[1] 
https://elixir.bootlin.com/linux/v6.10/source/include/linux/screen_info.h#L127
[2] https://elixir.bootlin.com/linux/v6.10/source/drivers/video/Makefile#L11

Best regards
Thomas

>     csky-linux-ld: drivers/video/aperture.o: in function `devm_aperture_acquire_release':
>>> aperture.c:(.text+0x2c0): undefined reference to `screen_info'
>>> csky-linux-ld: aperture.c:(.text+0x2c4): undefined reference to `screen_info_pci_dev'
Alex Deucher Aug. 16, 2024, 8:57 p.m. UTC | #4
On Mon, Aug 12, 2024 at 8:10 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 10.08.24 um 13:44 schrieb kernel test robot:
> > Hi Alex,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on drm-misc/drm-misc-next]
> > [also build test ERROR on linus/master v6.11-rc2 next-20240809]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> > url:    https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
> > base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
> > patch link:    https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
> > patch subject: [PATCH] video/aperture: match the pci device when calling sysfb_disable()
> > config: csky-randconfig-001-20240810 (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/config)
> > compiler: csky-linux-gcc (GCC) 14.1.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202408101951.tXyqYOzv-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> >     csky-linux-ld: drivers/video/aperture.o: in function `aperture_remove_conflicting_pci_devices':
> >>> aperture.c:(.text+0x222): undefined reference to `screen_info_pci_dev'
>
> Strange. There's a already placeholder [1] for architectures without
> PCI. Otherwise the source file is listed at [2].

So I dug into this, and the problem seems to be that
CONFIG_SCREEN_INFO is not defined in that config.  I can't figure out
how this should work in that case or why this is not a problem in
drivers/firmware/sysfb.c.

Something like this works:
diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
index 56a5a0bc2b1af..50e98210c9fe5 100644
--- a/drivers/video/aperture.c
+++ b/drivers/video/aperture.c
@@ -347,7 +347,9 @@ EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices);
  */
 int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,
const char *name)
 {
+#if defined(CONFIG_SCREEN_INFO)
        struct screen_info *si = &screen_info;
+#endif
        bool primary = false;
        resource_size_t base, size;
        int bar, ret = 0;
@@ -355,8 +357,10 @@ int
aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const
char *na
        if (pdev == vga_default_device())
                primary = true;

+#if defined(CONFIG_SCREEN_INFO)
        if (pdev == screen_info_pci_dev(si))
                sysfb_disable();
+#endif

        for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
                if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))

But that can't be the right fix...  Any ideas?

Alex

>
> [1]
> https://elixir.bootlin.com/linux/v6.10/source/include/linux/screen_info.h#L127
> [2] https://elixir.bootlin.com/linux/v6.10/source/drivers/video/Makefile#L11
>
> Best regards
> Thomas
>
> >     csky-linux-ld: drivers/video/aperture.o: in function `devm_aperture_acquire_release':
> >>> aperture.c:(.text+0x2c0): undefined reference to `screen_info'
> >>> csky-linux-ld: aperture.c:(.text+0x2c4): undefined reference to `screen_info_pci_dev'
>
> --
> --
> 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)
>
Thomas Zimmermann Aug. 19, 2024, 8:04 a.m. UTC | #5
Hi

Am 16.08.24 um 22:57 schrieb Alex Deucher:
> On Mon, Aug 12, 2024 at 8:10 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>> Hi
>>
>> Am 10.08.24 um 13:44 schrieb kernel test robot:
>>> Hi Alex,
>>>
>>> kernel test robot noticed the following build errors:
>>>
>>> [auto build test ERROR on drm-misc/drm-misc-next]
>>> [also build test ERROR on linus/master v6.11-rc2 next-20240809]
>>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>>> And when submitting patch, we suggest to use '--base' as documented in
>>> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>>>
>>> url:    https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
>>> base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
>>> patch link:    https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
>>> patch subject: [PATCH] video/aperture: match the pci device when calling sysfb_disable()
>>> config: csky-randconfig-001-20240810 (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/config)
>>> compiler: csky-linux-gcc (GCC) 14.1.0
>>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/reproduce)
>>>
>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>> the same patch/commit), kindly add following tags
>>> | Reported-by: kernel test robot <lkp@intel.com>
>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202408101951.tXyqYOzv-lkp@intel.com/
>>>
>>> All errors (new ones prefixed by >>):
>>>
>>>      csky-linux-ld: drivers/video/aperture.o: in function `aperture_remove_conflicting_pci_devices':
>>>>> aperture.c:(.text+0x222): undefined reference to `screen_info_pci_dev'
>> Strange. There's a already placeholder [1] for architectures without
>> PCI. Otherwise the source file is listed at [2].
> So I dug into this, and the problem seems to be that
> CONFIG_SCREEN_INFO is not defined in that config.  I can't figure out
> how this should work in that case or why this is not a problem in
> drivers/firmware/sysfb.c.
>
> Something like this works:
> diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
> index 56a5a0bc2b1af..50e98210c9fe5 100644
> --- a/drivers/video/aperture.c
> +++ b/drivers/video/aperture.c
> @@ -347,7 +347,9 @@ EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices);
>    */
>   int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,
> const char *name)
>   {
> +#if defined(CONFIG_SCREEN_INFO)
>          struct screen_info *si = &screen_info;
> +#endif
>          bool primary = false;
>          resource_size_t base, size;
>          int bar, ret = 0;
> @@ -355,8 +357,10 @@ int
> aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const
> char *na
>          if (pdev == vga_default_device())
>                  primary = true;
>
> +#if defined(CONFIG_SCREEN_INFO)
>          if (pdev == screen_info_pci_dev(si))
>                  sysfb_disable();
> +#endif
>
>          for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
>                  if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
>
> But that can't be the right fix...  Any ideas?

Thanks for investigating. I'd say we should pass the device (pdev->dev) 
to sysfb_disable() and  do the test there. In sysfb.c, next to 
sysfb_disable(), you'll find sysfb_parent_dev(), which gives the Linux 
device of the screen_info.

The code then looks something like this:

sysfb_disable(struct device *dev)
{
     if (dev && dev == sysfb_parent_dev(screen_info))
       return

   /* else do the current code */
}

there's an invocation of sysfb_disable() in drivers/of/platform.c where 
you can pass NULL.

Best regards
Thomas

>
> Alex
>
>> [1]
>> https://elixir.bootlin.com/linux/v6.10/source/include/linux/screen_info.h#L127
>> [2] https://elixir.bootlin.com/linux/v6.10/source/drivers/video/Makefile#L11
>>
>> Best regards
>> Thomas
>>
>>>      csky-linux-ld: drivers/video/aperture.o: in function `devm_aperture_acquire_release':
>>>>> aperture.c:(.text+0x2c0): undefined reference to `screen_info'
>>>>> csky-linux-ld: aperture.c:(.text+0x2c4): undefined reference to `screen_info_pci_dev'
>> --
>> --
>> 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)
>>
Javier Martinez Canillas Aug. 19, 2024, 1:36 p.m. UTC | #6
Thomas Zimmermann <tzimmermann@suse.de> writes:

Hello Alex and Thomas,

> Hi
>
> Am 16.08.24 um 22:57 schrieb Alex Deucher:
>> On Mon, Aug 12, 2024 at 8:10 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>> Hi
>>>
>>> Am 10.08.24 um 13:44 schrieb kernel test robot:
>>>> Hi Alex,
>>>>
>>>> kernel test robot noticed the following build errors:
>>>>
>>>> [auto build test ERROR on drm-misc/drm-misc-next]
>>>> [also build test ERROR on linus/master v6.11-rc2 next-20240809]
>>>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>>>> And when submitting patch, we suggest to use '--base' as documented in
>>>> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>>>>
>>>> url:    https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
>>>> base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
>>>> patch link:    https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
>>>> patch subject: [PATCH] video/aperture: match the pci device when calling sysfb_disable()
>>>> config: csky-randconfig-001-20240810 (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/config)
>>>> compiler: csky-linux-gcc (GCC) 14.1.0
>>>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/reproduce)
>>>>
>>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>>> the same patch/commit), kindly add following tags
>>>> | Reported-by: kernel test robot <lkp@intel.com>
>>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202408101951.tXyqYOzv-lkp@intel.com/
>>>>
>>>> All errors (new ones prefixed by >>):
>>>>
>>>>      csky-linux-ld: drivers/video/aperture.o: in function `aperture_remove_conflicting_pci_devices':
>>>>>> aperture.c:(.text+0x222): undefined reference to `screen_info_pci_dev'
>>> Strange. There's a already placeholder [1] for architectures without
>>> PCI. Otherwise the source file is listed at [2].
>> So I dug into this, and the problem seems to be that
>> CONFIG_SCREEN_INFO is not defined in that config.  I can't figure out
>> how this should work in that case or why this is not a problem in
>> drivers/firmware/sysfb.c.
>>
>> Something like this works:
>> diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
>> index 56a5a0bc2b1af..50e98210c9fe5 100644
>> --- a/drivers/video/aperture.c
>> +++ b/drivers/video/aperture.c
>> @@ -347,7 +347,9 @@ EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices);
>>    */
>>   int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,
>> const char *name)
>>   {
>> +#if defined(CONFIG_SCREEN_INFO)
>>          struct screen_info *si = &screen_info;
>> +#endif
>>          bool primary = false;
>>          resource_size_t base, size;
>>          int bar, ret = 0;
>> @@ -355,8 +357,10 @@ int
>> aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const
>> char *na
>>          if (pdev == vga_default_device())
>>                  primary = true;
>>
>> +#if defined(CONFIG_SCREEN_INFO)
>>          if (pdev == screen_info_pci_dev(si))
>>                  sysfb_disable();
>> +#endif
>>
>>          for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
>>                  if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
>>
>> But that can't be the right fix...  Any ideas?
>
> Thanks for investigating. I'd say we should pass the device (pdev->dev) 
> to sysfb_disable() and  do the test there. In sysfb.c, next to 
> sysfb_disable(), you'll find sysfb_parent_dev(), which gives the Linux 
> device of the screen_info.
>
> The code then looks something like this:
>
> sysfb_disable(struct device *dev)
> {
>      if (dev && dev == sysfb_parent_dev(screen_info))
>        return
>
>    /* else do the current code */
> }
>
> there's an invocation of sysfb_disable() in drivers/of/platform.c where 
> you can pass NULL.
>

Agreed. That sounds like the best approach.

> Best regards
> Thomas
>
Thomas Zimmermann Aug. 19, 2024, 3:14 p.m. UTC | #7
Am 19.08.24 um 10:04 schrieb Thomas Zimmermann:
> Hi
>
> Am 16.08.24 um 22:57 schrieb Alex Deucher:
>> On Mon, Aug 12, 2024 at 8:10 AM Thomas Zimmermann 
>> <tzimmermann@suse.de> wrote:
>>> Hi
>>>
>>> Am 10.08.24 um 13:44 schrieb kernel test robot:
>>>> Hi Alex,
>>>>
>>>> kernel test robot noticed the following build errors:
>>>>
>>>> [auto build test ERROR on drm-misc/drm-misc-next]
>>>> [also build test ERROR on linus/master v6.11-rc2 next-20240809]
>>>> [If your patch is applied to the wrong git tree, kindly drop us a 
>>>> note.
>>>> And when submitting patch, we suggest to use '--base' as documented in
>>>> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>>>>
>>>> url: 
>>>> https://github.com/intel-lab-lkp/linux/commits/Alex-Deucher/video-aperture-match-the-pci-device-when-calling-sysfb_disable/20240810-021357
>>>> base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
>>>> patch link: 
>>>> https://lore.kernel.org/r/20240809150327.2485848-1-alexander.deucher%40amd.com
>>>> patch subject: [PATCH] video/aperture: match the pci device when 
>>>> calling sysfb_disable()
>>>> config: csky-randconfig-001-20240810 
>>>> (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/config)
>>>> compiler: csky-linux-gcc (GCC) 14.1.0
>>>> reproduce (this is a W=1 build): 
>>>> (https://download.01.org/0day-ci/archive/20240810/202408101951.tXyqYOzv-lkp@intel.com/reproduce)
>>>>
>>>> If you fix the issue in a separate patch/commit (i.e. not just a 
>>>> new version of
>>>> the same patch/commit), kindly add following tags
>>>> | Reported-by: kernel test robot <lkp@intel.com>
>>>> | Closes: 
>>>> https://lore.kernel.org/oe-kbuild-all/202408101951.tXyqYOzv-lkp@intel.com/
>>>>
>>>> All errors (new ones prefixed by >>):
>>>>
>>>>      csky-linux-ld: drivers/video/aperture.o: in function 
>>>> `aperture_remove_conflicting_pci_devices':
>>>>>> aperture.c:(.text+0x222): undefined reference to 
>>>>>> `screen_info_pci_dev'
>>> Strange. There's a already placeholder [1] for architectures without
>>> PCI. Otherwise the source file is listed at [2].
>> So I dug into this, and the problem seems to be that
>> CONFIG_SCREEN_INFO is not defined in that config.  I can't figure out
>> how this should work in that case or why this is not a problem in
>> drivers/firmware/sysfb.c.
>>
>> Something like this works:
>> diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
>> index 56a5a0bc2b1af..50e98210c9fe5 100644
>> --- a/drivers/video/aperture.c
>> +++ b/drivers/video/aperture.c
>> @@ -347,7 +347,9 @@ EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices);
>>    */
>>   int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,
>> const char *name)
>>   {
>> +#if defined(CONFIG_SCREEN_INFO)
>>          struct screen_info *si = &screen_info;
>> +#endif
>>          bool primary = false;
>>          resource_size_t base, size;
>>          int bar, ret = 0;
>> @@ -355,8 +357,10 @@ int
>> aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const
>> char *na
>>          if (pdev == vga_default_device())
>>                  primary = true;
>>
>> +#if defined(CONFIG_SCREEN_INFO)
>>          if (pdev == screen_info_pci_dev(si))
>>                  sysfb_disable();
>> +#endif
>>
>>          for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
>>                  if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
>>
>> But that can't be the right fix...  Any ideas?
>
> Thanks for investigating. I'd say we should pass the device 
> (pdev->dev) to sysfb_disable() and  do the test there. In sysfb.c, 
> next to sysfb_disable(), you'll find sysfb_parent_dev(), which gives 
> the Linux device of the screen_info.
>
> The code then looks something like this:
>
> sysfb_disable(struct device *dev)
> {
>     if (dev && dev == sysfb_parent_dev(screen_info))

s/==/!=

> return
>
>   /* else do the current code */
> }
>
> there's an invocation of sysfb_disable() in drivers/of/platform.c 
> where you can pass NULL.
>
> Best regards
> Thomas
>
>>
>> Alex
>>
>>> [1]
>>> https://elixir.bootlin.com/linux/v6.10/source/include/linux/screen_info.h#L127 
>>>
>>> [2] 
>>> https://elixir.bootlin.com/linux/v6.10/source/drivers/video/Makefile#L11 
>>>
>>>
>>> Best regards
>>> Thomas
>>>
>>>>      csky-linux-ld: drivers/video/aperture.o: in function 
>>>> `devm_aperture_acquire_release':
>>>>>> aperture.c:(.text+0x2c0): undefined reference to `screen_info'
>>>>>> csky-linux-ld: aperture.c:(.text+0x2c4): undefined reference to 
>>>>>> `screen_info_pci_dev'
>>> -- 
>>> -- 
>>> 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)
>>>
>
diff mbox series

Patch

diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c
index 561be8feca96..56a5a0bc2b1a 100644
--- a/drivers/video/aperture.c
+++ b/drivers/video/aperture.c
@@ -6,6 +6,7 @@ 
 #include <linux/mutex.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/screen_info.h>
 #include <linux/slab.h>
 #include <linux/sysfb.h>
 #include <linux/types.h>
@@ -346,6 +347,7 @@  EXPORT_SYMBOL(__aperture_remove_legacy_vga_devices);
  */
 int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name)
 {
+	struct screen_info *si = &screen_info;
 	bool primary = false;
 	resource_size_t base, size;
 	int bar, ret = 0;
@@ -353,7 +355,7 @@  int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na
 	if (pdev == vga_default_device())
 		primary = true;
 
-	if (primary)
+	if (pdev == screen_info_pci_dev(si))
 		sysfb_disable();
 
 	for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {