[PATCH] drm: rework FB_CORE dependency

Arnd Bergmann posted 1 patch 6 days, 20 hours ago
There is a newer version of this series
drivers/gpu/drm/Kconfig | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] drm: rework FB_CORE dependency
Posted by Arnd Bergmann 6 days, 20 hours ago
From: Arnd Bergmann <arnd@arndb.de>

The 'select FB_CORE' statement moved from CONFIG_DRM to DRM_CLIENT_LIB,
but there are now configurations that have code calling into fb_core
as built-in even though the client_lib itself is a loadable module:

x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_driver_fbdev_probe':
drm_fbdev_shmem.c:(.text+0x1fc): undefined reference to `fb_deferred_io_init'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_fb_destroy':
drm_fbdev_shmem.c:(.text+0x2e1): undefined reference to `fb_deferred_io_cleanup'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_fb_mmap':
drm_fbdev_shmem.c:(.text+0x34c): undefined reference to `fb_deferred_io_mmap'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_imageblit':
drm_fbdev_shmem.c:(.text+0x35f): undefined reference to `sys_imageblit'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_copyarea':
drm_fbdev_shmem.c:(.text+0x38b): undefined reference to `sys_copyarea'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_fillrect':
drm_fbdev_shmem.c:(.text+0x3b7): undefined reference to `sys_fillrect'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_write':
drm_fbdev_shmem.c:(.text+0x3e9): undefined reference to `fb_sys_write'
x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_read':
drm_fbdev_shmem.c:(.text+0x413): undefined reference to `fb_sys_read'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_set_suspend':
drm_fb_helper.c:(.text+0x2c6): undefined reference to `fb_set_suspend'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_resume_worker':
drm_fb_helper.c:(.text+0x2e1): undefined reference to `fb_set_suspend'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_alloc_info':
drm_fb_helper.c:(.text+0x33a): undefined reference to `framebuffer_alloc'
x86_64-linux-ld: drm_fb_helper.c:(.text+0x359): undefined reference to `fb_alloc_cmap'
x86_64-linux-ld: drm_fb_helper.c:(.text+0x368): undefined reference to `framebuffer_release'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_release_info':
drm_fb_helper.c:(.text+0x3a4): undefined reference to `fb_dealloc_cmap'
x86_64-linux-ld: drm_fb_helper.c:(.text+0x3ab): undefined reference to `framebuffer_release'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_unregister_info':
drm_fb_helper.c:(.text+0x3bb): undefined reference to `unregister_framebuffer'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `__drm_fb_helper_initial_config_and_unlock':
drm_fb_helper.c:(.text+0xb6d): undefined reference to `register_framebuffer'
x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_set_suspend_unlocked':
drm_fb_helper.c:(.text+0x167a): undefined reference to `fb_set_suspend'

Since the code that calls into fb_core is not actually in the client_lib
module but in other helper libraries, move the 'select' again to the
places that actually call into fb_core, in this case DRM_GEM_SHMEM_HELPER
and DRM_KMS_HELPER.

Fixes: dadd28d4142f ("drm/client: Add client-lib module")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I have only given this light build testing. It seems sensible on the surface,
but there is a chance that there are additional helpers that need the same
'select'. Moving it into CONFIG_DRM itself would be the safer option, but
that seems to defeat the purpose of the client-lib module.
---
 drivers/gpu/drm/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index a4a092ee70d9..4f21bff6282a 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -98,6 +98,7 @@ config DRM_KUNIT_TEST
 config DRM_KMS_HELPER
 	tristate
 	depends on DRM
+	select FB_CORE if DRM_FBDEV_EMULATION
 	help
 	  CRTC helpers for KMS drivers.
 
@@ -220,7 +221,6 @@ config DRM_CLIENT_LIB
 	tristate
 	depends on DRM
 	select DRM_KMS_HELPER if DRM_FBDEV_EMULATION
-	select FB_CORE if DRM_FBDEV_EMULATION
 	help
 	  This option enables the DRM client library and selects all
 	  modules and components according to the enabled clients.
@@ -372,6 +372,7 @@ config DRM_GEM_SHMEM_HELPER
 	tristate
 	depends on DRM && MMU
 	select FB_SYSMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
+	select FB_CORE if DRM_FBDEV_EMULATION
 	help
 	  Choose this if you need the GEM shmem helper functions
 
-- 
2.39.5
Re: [PATCH] drm: rework FB_CORE dependency
Posted by kernel test robot 5 days, 6 hours ago
Hi Arnd,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-exynos/exynos-drm-next]
[also build test ERROR on next-20241115]
[cannot apply to linus/master v6.12-rc7]
[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/Arnd-Bergmann/drm-rework-FB_CORE-dependency/20241117-003714
base:   https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next
patch link:    https://lore.kernel.org/r/20241115152722.3537630-1-arnd%40kernel.org
patch subject: [PATCH] drm: rework FB_CORE dependency
config: arc-randconfig-052-20241117 (attached as .config)
compiler: arc-elf-gcc (GCC) 13.2.0
dtschema version: 2024.12.dev1+gcabb5b9
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/202411171217.DZow6M4R-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/202411171217.DZow6M4R-lkp@intel.com/

All errors (new ones prefixed by >>):

>> error: recursive dependency detected!
   symbol BACKLIGHT_CLASS_DEVICE is selected by FB_BACKLIGHT
   symbol FB_BACKLIGHT is selected by FB_SH_MOBILE_LCDC
   symbol FB_SH_MOBILE_LCDC depends on FB_DEVICE
   symbol FB_DEVICE depends on FB_CORE
   symbol FB_CORE is selected by DRM_KMS_HELPER
   symbol DRM_KMS_HELPER is selected by DRM_MIPI_DBI
   symbol DRM_MIPI_DBI is selected by DRM_PANEL_ILITEK_ILI9341
   symbol DRM_PANEL_ILITEK_ILI9341 depends on BACKLIGHT_CLASS_DEVICE
   For a resolution refer to Documentation/kbuild/kconfig-language.rst
   subsection "Kconfig recursive dependency limitations"

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] drm: rework FB_CORE dependency
Posted by Thomas Zimmermann 6 days, 19 hours ago
Hi


Am 15.11.24 um 16:27 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The 'select FB_CORE' statement moved from CONFIG_DRM to DRM_CLIENT_LIB,
> but there are now configurations that have code calling into fb_core
> as built-in even though the client_lib itself is a loadable module:
>
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_driver_fbdev_probe':
> drm_fbdev_shmem.c:(.text+0x1fc): undefined reference to `fb_deferred_io_init'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_fb_destroy':
> drm_fbdev_shmem.c:(.text+0x2e1): undefined reference to `fb_deferred_io_cleanup'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_fb_mmap':
> drm_fbdev_shmem.c:(.text+0x34c): undefined reference to `fb_deferred_io_mmap'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_imageblit':
> drm_fbdev_shmem.c:(.text+0x35f): undefined reference to `sys_imageblit'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_copyarea':
> drm_fbdev_shmem.c:(.text+0x38b): undefined reference to `sys_copyarea'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_fillrect':
> drm_fbdev_shmem.c:(.text+0x3b7): undefined reference to `sys_fillrect'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_write':
> drm_fbdev_shmem.c:(.text+0x3e9): undefined reference to `fb_sys_write'
> x86_64-linux-ld: drivers/gpu/drm/drm_fbdev_shmem.o: in function `drm_fbdev_shmem_defio_read':
> drm_fbdev_shmem.c:(.text+0x413): undefined reference to `fb_sys_read'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_set_suspend':
> drm_fb_helper.c:(.text+0x2c6): undefined reference to `fb_set_suspend'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_resume_worker':
> drm_fb_helper.c:(.text+0x2e1): undefined reference to `fb_set_suspend'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_alloc_info':
> drm_fb_helper.c:(.text+0x33a): undefined reference to `framebuffer_alloc'
> x86_64-linux-ld: drm_fb_helper.c:(.text+0x359): undefined reference to `fb_alloc_cmap'
> x86_64-linux-ld: drm_fb_helper.c:(.text+0x368): undefined reference to `framebuffer_release'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_release_info':
> drm_fb_helper.c:(.text+0x3a4): undefined reference to `fb_dealloc_cmap'
> x86_64-linux-ld: drm_fb_helper.c:(.text+0x3ab): undefined reference to `framebuffer_release'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_unregister_info':
> drm_fb_helper.c:(.text+0x3bb): undefined reference to `unregister_framebuffer'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `__drm_fb_helper_initial_config_and_unlock':
> drm_fb_helper.c:(.text+0xb6d): undefined reference to `register_framebuffer'
> x86_64-linux-ld: drivers/gpu/drm/drm_fb_helper.o: in function `drm_fb_helper_set_suspend_unlocked':
> drm_fb_helper.c:(.text+0x167a): undefined reference to `fb_set_suspend'
>
> Since the code that calls into fb_core is not actually in the client_lib
> module but in other helper libraries, move the 'select' again to the
> places that actually call into fb_core, in this case DRM_GEM_SHMEM_HELPER
> and DRM_KMS_HELPER.

Thanks a lot for the fix. The dependency handling of among the modules 
is nightmare-ish.

>
> Fixes: dadd28d4142f ("drm/client: Add client-lib module")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> I have only given this light build testing. It seems sensible on the surface,
> but there is a chance that there are additional helpers that need the same
> 'select'. Moving it into CONFIG_DRM itself would be the safer option, but
> that seems to defeat the purpose of the client-lib module.

This patch's idea looks correct to me. It's likely a matter of finding 
all corner cases. As you say, selecting FB_CORE from CONFIG_DRM is too 
strong a dependency. Fbdev emulation is implemented throughout a number 
of helper and driver modules. So fbdev should be an independent module 
if possible.

> ---
>   drivers/gpu/drm/Kconfig | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index a4a092ee70d9..4f21bff6282a 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -98,6 +98,7 @@ config DRM_KUNIT_TEST
>   config DRM_KMS_HELPER
>   	tristate
>   	depends on DRM
> +	select FB_CORE if DRM_FBDEV_EMULATION
>   	help
>   	  CRTC helpers for KMS drivers.
>   
> @@ -220,7 +221,6 @@ config DRM_CLIENT_LIB
>   	tristate
>   	depends on DRM
>   	select DRM_KMS_HELPER if DRM_FBDEV_EMULATION
> -	select FB_CORE if DRM_FBDEV_EMULATION

This should remain. More fbdev code will move into drm_fbdev_client.c 
and that will require FB_CORE.

>   	help
>   	  This option enables the DRM client library and selects all
>   	  modules and components according to the enabled clients.
> @@ -372,6 +372,7 @@ config DRM_GEM_SHMEM_HELPER
>   	tristate
>   	depends on DRM && MMU
>   	select FB_SYSMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
> +	select FB_CORE if DRM_FBDEV_EMULATION

This select is also needed by DRM_GEM_DMA_HELPER and DRM_GEM_TTM_HELPER.

Please sort these select statements alphabetically.

Best regards
Thomas

>   	help
>   	  Choose this if you need the GEM shmem helper functions
>   

-- 
--
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)
Re: [PATCH] drm: rework FB_CORE dependency
Posted by Arnd Bergmann 6 days, 19 hours ago
On Fri, Nov 15, 2024, at 16:54, Thomas Zimmermann wrote:
> Am 15.11.24 um 16:27 schrieb Arnd Bergmann:
>>   
>> @@ -220,7 +221,6 @@ config DRM_CLIENT_LIB
>>   	tristate
>>   	depends on DRM
>>   	select DRM_KMS_HELPER if DRM_FBDEV_EMULATION
>> -	select FB_CORE if DRM_FBDEV_EMULATION
>
> This should remain. More fbdev code will move into drm_fbdev_client.c 
> and that will require FB_CORE.

Got it.

>>   	help
>>   	  This option enables the DRM client library and selects all
>>   	  modules and components according to the enabled clients.
>> @@ -372,6 +372,7 @@ config DRM_GEM_SHMEM_HELPER
>>   	tristate
>>   	depends on DRM && MMU
>>   	select FB_SYSMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
>> +	select FB_CORE if DRM_FBDEV_EMULATION
>
> This select is also needed by DRM_GEM_DMA_HELPER and DRM_GEM_TTM_HELPER.
>
> Please sort these select statements alphabetically.

Sent a v2 now.

     Arnd