drm: Make drm_buddy a part of drm module
Subsystems (3)
PATCH 1/1 drm: Make drm_buddy a part of drm module
The drm_buddy is just a software allocator, so don't need to create a module for this small part.
If drm_buddy is included in drm module, then only need to insmod drm.ko
--- drivers/gpu/drm/Kconfig | 2 +- drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_buddy.c | 7 ++----- drivers/gpu/drm/drm_drv.c | 10 ++++++++++ include/drm/drm_buddy.h | 3 +++ 5 files changed, 17 insertions(+), 6 deletions(-)
drivers/gpu/drm/Kconfig +1 -1
@@ -180,7 +180,7 @@ config DRM_TTM uses it. config DRM_BUDDY - tristate + bool depends on DRM help A page based buddy allocator
drivers/gpu/drm/Makefile +1 -0
@@ -29,6 +29,7 @@ drm-$(CONFIG_PCI) += drm_pci.o drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o drm_privacy_screen_x86.o +drm-$(CONFIG_DRM_BUDDY) += drm_buddy.o obj-$(CONFIG_DRM) += drm.o obj-$(CONFIG_DRM_NOMODESET) += drm_nomodeset.o
drivers/gpu/drm/drm_buddy.c +2 -5
@@ -767,12 +767,12 @@ void drm_buddy_print(struct drm_buddy *mm, struct drm_printer *p) }EXPORT_SYMBOL (drm_buddy_print); -static void drm_buddy_module_exit (void ) +void drm_buddy_slb_blk_put (void ) {kmem_cache_destroy (slab_blocks); } -static int __init drm_buddy_module_init (void ) +int __init drm_buddy_slb_blk_get (void ) { slab_blocks =KMEM_CACHE (drm_buddy_block,0 );if (!slab_blocks)
@@ -781,8 +781,5 @@ static int __init drm_buddy_module_init(void)return 0 ; } -module_init (drm_buddy_module_init); -module_exit (drm_buddy_module_exit); -MODULE_DESCRIPTION ("DRM Buddy Allocator" );MODULE_LICENSE ("Dual MIT/GPL" );
drivers/gpu/drm/drm_drv.c +10 -0
@@ -44,6 +44,7 @@#include <drm/drm_mode_object.h> #include <drm/drm_print.h> #include <drm/drm_privacy_screen_machine.h> +#include <drm/drm_buddy.h> #include "drm_crtc_internal.h" #include "drm_internal.h"
@@ -1034,6 +1035,9 @@ static const struct file_operations drm_stub_fops = {static void drm_core_exit (void ) {drm_privacy_screen_lookup_exit (); +#if IS_ENABLED (CONFIG_DRM_BUDDY ) +drm_buddy_slb_blk_put (); +#endif unregister_chrdev (DRM_MAJOR ,"drm" );debugfs_remove (drm_debugfs_root);drm_sysfs_destroy ();
@@ -1061,6 +1065,12 @@ static int __init drm_core_init(void)if (ret <0 ) goto error; +#if IS_ENABLED (CONFIG_DRM_BUDDY ) + ret =drm_buddy_slb_blk_get (); +if (!ret) + goto error; +#endif +drm_privacy_screen_lookup_init (); drm_core_init_complete = true;
include/drm/drm_buddy.h +3 -0
@@ -156,4 +156,7 @@ void drm_buddy_block_print(struct drm_buddy *mm,struct drm_buddy_block *block, struct drm_printer *p); +int __init drm_buddy_slb_blk_get (void ); +void drm_buddy_slb_blk_put (void ); +#endif
Signature · 1 line
2.25.1
kernel test robot
build botI love your patch! Yet something to improve:
Hi Cai,
I love your patch! Yet something to improve:
[auto build test ERROR on drm/drm-next]
[also build test ERROR on linus/master v5.19-rc2 next-20220617] [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]
url: https://github.com/intel-lab-lkp/linux/commits/Cai-Huoqing/drm-Make-drm_buddy-a-part-of-drm-module/20220621-095417 base: git://anongit.freedesktop.org/drm/drm drm-next config: x86_64-rhel-8.3-kunit (https://download.01.org/0day-ci/archive/20220621/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/517d5f44c861a5173eaa9a06efebe2ce2a6601a1 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Cai-Huoqing/drm-Make-drm_buddy-a-part-of-drm-module/20220621-095417 git checkout 517d5f44c861a5173eaa9a06efebe2ce2a6601a1 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
ld: drivers/gpu/drm/drm_buddy.o: in function `drm_buddy_print':
>> drivers/gpu/drm/drm_buddy.c:745: undefined reference to `drm_printf' >> ld: drivers/gpu/drm/drm_buddy.c:757: undefined reference to `drm_printf'
ld: drivers/gpu/drm/drm_buddy.c:763: undefined reference to `drm_printf'
ld: drivers/gpu/drm/drm_buddy.c:765: undefined reference to `drm_printf'
ld: drivers/gpu/drm/drm_buddy.c:761: undefined reference to `drm_printf'
ld: drivers/gpu/drm/drm_buddy.o:drivers/gpu/drm/drm_buddy.c:757: more undefined references to `drm_printf' follow
vim +745 drivers/gpu/drm/drm_buddy.c
6387a3c4b0c45a Arunpravin 2022-01-18 734
6387a3c4b0c45a Arunpravin 2022-01-18 735 /**
6387a3c4b0c45a Arunpravin 2022-01-18 736 * drm_buddy_print - print allocator state
6387a3c4b0c45a Arunpravin 2022-01-18 737 *
6387a3c4b0c45a Arunpravin 2022-01-18 738 * @mm: DRM buddy manager
6387a3c4b0c45a Arunpravin 2022-01-18 739 * @p: DRM printer to use
6387a3c4b0c45a Arunpravin 2022-01-18 740 */
6387a3c4b0c45a Arunpravin 2022-01-18 741 void drm_buddy_print(struct drm_buddy *mm, struct drm_printer *p)
6387a3c4b0c45a Arunpravin 2022-01-18 742 {
6387a3c4b0c45a Arunpravin 2022-01-18 743 int order;
6387a3c4b0c45a Arunpravin 2022-01-18 744
6387a3c4b0c45a Arunpravin 2022-01-18 @745 drm_printf(p, "chunk_size: %lluKiB, total: %lluMiB, free: %lluMiB\n",
6387a3c4b0c45a Arunpravin 2022-01-18 746 mm->chunk_size >> 10, mm->size >> 20, mm->avail >> 20);
6387a3c4b0c45a Arunpravin 2022-01-18 747
6387a3c4b0c45a Arunpravin 2022-01-18 748 for (order = mm->max_order; order >= 0; order--) {
6387a3c4b0c45a Arunpravin 2022-01-18 749 struct drm_buddy_block *block;
6387a3c4b0c45a Arunpravin 2022-01-18 750 u64 count = 0, free;
6387a3c4b0c45a Arunpravin 2022-01-18 751
6387a3c4b0c45a Arunpravin 2022-01-18 752 list_for_each_entry(block, &mm->free_list[order], link) {
6387a3c4b0c45a Arunpravin 2022-01-18 753 BUG_ON(!drm_buddy_block_is_free(block));
6387a3c4b0c45a Arunpravin 2022-01-18 754 count++;
6387a3c4b0c45a Arunpravin 2022-01-18 755 }
6387a3c4b0c45a Arunpravin 2022-01-18 756
6387a3c4b0c45a Arunpravin 2022-01-18 @757 drm_printf(p, "order-%d ", order);
6387a3c4b0c45a Arunpravin 2022-01-18 758
6387a3c4b0c45a Arunpravin 2022-01-18 759 free = count * (mm->chunk_size << order);
6387a3c4b0c45a Arunpravin 2022-01-18 760 if (free < SZ_1M)
6387a3c4b0c45a Arunpravin 2022-01-18 761 drm_printf(p, "free: %lluKiB", free >> 10);
6387a3c4b0c45a Arunpravin 2022-01-18 762 else
6387a3c4b0c45a Arunpravin 2022-01-18 763 drm_printf(p, "free: %lluMiB", free >> 20);
6387a3c4b0c45a Arunpravin 2022-01-18 764
6387a3c4b0c45a Arunpravin 2022-01-18 765 drm_printf(p, ", pages: %llu\n", count);
6387a3c4b0c45a Arunpravin 2022-01-18 766 }
6387a3c4b0c45a Arunpravin 2022-01-18 767 }
6387a3c4b0c45a Arunpravin 2022-01-18 768 EXPORT_SYMBOL(drm_buddy_print);
6387a3c4b0c45a Arunpravin 2022-01-18 769 Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botI love your patch! Yet something to improve:
Hi Cai,
I love your patch! Yet something to improve:
[auto build test ERROR on drm/drm-next]
[also build test ERROR on linus/master v5.19-rc2 next-20220617] [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]
url: https://github.com/intel-lab-lkp/linux/commits/Cai-Huoqing/drm-Make-drm_buddy-a-part-of-drm-module/20220621-095417 base: git://anongit.freedesktop.org/drm/drm drm-next config: microblaze-buildonly-randconfig-r003-20220620 (https://download.01.org/0day-ci/archive/20220621/[email protected]/config) compiler: microblaze-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/517d5f44c861a5173eaa9a06efebe2ce2a6601a1
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Cai-Huoqing/drm-Make-drm_buddy-a-part-of-drm-module/20220621-095417 git checkout 517d5f44c861a5173eaa9a06efebe2ce2a6601a1
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=microblaze SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
microblaze-linux-ld: drivers/gpu/drm/drm_buddy.o: in function `drm_buddy_block_print':
drivers/gpu/drm/drm_buddy.c:731: undefined reference to `drm_printf'
microblaze-linux-ld: drivers/gpu/drm/drm_buddy.o: in function `drm_buddy_print':
drivers/gpu/drm/drm_buddy.c:745: undefined reference to `drm_printf'
>> microblaze-linux-ld: drivers/gpu/drm/drm_buddy.c:757: undefined reference to `drm_printf'
microblaze-linux-ld: drivers/gpu/drm/drm_buddy.c:763: undefined reference to `drm_printf'
microblaze-linux-ld: drivers/gpu/drm/drm_buddy.c:765: undefined reference to `drm_printf'
microblaze-linux-ld: drivers/gpu/drm/drm_buddy.o:drivers/gpu/drm/drm_buddy.c:761: more undefined references to `drm_printf' follow
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp