[PATCH 1/3] drm/amdgpu: Merge amdkfd into amdgpu

Felix Kuehling felix.kuehling at amd.com
Thu Aug 23 22:21:17 UTC 2018


I believe you also need to edit drivers/gpu/drm/Kconfig. Otherwise
amdkfd/Kconfig will be included twice. With that fixed, this commit is

Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>

But let's give amdgpu reviewers some more time to respond.

Thanks,
  Felix

On 2018-08-23 11:17 AM, Amber Lin wrote:
> Since KFD is only supported by single GPU driver, it makes sense to merge
> amdgpu and amdkfd into one module. This patch is the initial step: merge
> Kconfig and Makefile.
>
> Change-Id: I21c996ba29d393c1bf8064bdb2f5d89541159649
> Signed-off-by: Amber Lin <Amber.Lin at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/Kconfig      |  1 +
>  drivers/gpu/drm/amd/amdgpu/Makefile     |  6 ++-
>  drivers/gpu/drm/amd/amdkfd/Kconfig      |  2 +-
>  drivers/gpu/drm/amd/amdkfd/Makefile     | 53 ++++++++++++++---------
>  drivers/gpu/drm/amd/amdkfd/kfd_module.c | 76 ++++++++++-----------------------
>  5 files changed, 63 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
> index e8af1f5..9221e54 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Kconfig
> +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
> @@ -42,3 +42,4 @@ config DRM_AMDGPU_GART_DEBUGFS
>  
>  source "drivers/gpu/drm/amd/acp/Kconfig"
>  source "drivers/gpu/drm/amd/display/Kconfig"
> +source "drivers/gpu/drm/amd/amdkfd/Kconfig"
> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
> index d2bafab..847536b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> @@ -35,7 +35,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
>  	-I$(FULL_AMD_DISPLAY_PATH) \
>  	-I$(FULL_AMD_DISPLAY_PATH)/include \
>  	-I$(FULL_AMD_DISPLAY_PATH)/dc \
> -	-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm
> +	-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
> +	-I$(FULL_AMD_PATH)/amdkfd
>  
>  amdgpu-y := amdgpu_drv.o
>  
> @@ -136,6 +137,9 @@ amdgpu-y += \
>  amdgpu-y += amdgpu_amdkfd.o
>  
>  ifneq ($(CONFIG_HSA_AMD),)
> +AMDKFD_PATH := ../amdkfd
> +include $(FULL_AMD_PATH)/amdkfd/Makefile
> +amdgpu-y += $(AMDKFD_FILES)
>  amdgpu-y += \
>  	 amdgpu_amdkfd_fence.o \
>  	 amdgpu_amdkfd_gpuvm.o \
> diff --git a/drivers/gpu/drm/amd/amdkfd/Kconfig b/drivers/gpu/drm/amd/amdkfd/Kconfig
> index 3858820..fbf0ee5 100644
> --- a/drivers/gpu/drm/amd/amdkfd/Kconfig
> +++ b/drivers/gpu/drm/amd/amdkfd/Kconfig
> @@ -3,7 +3,7 @@
>  #
>  
>  config HSA_AMD
> -	tristate "HSA kernel driver for AMD GPU devices"
> +	bool "HSA kernel driver for AMD GPU devices"
>  	depends on DRM_AMDGPU && X86_64
>  	imply AMD_IOMMU_V2
>  	select MMU_NOTIFIER
> diff --git a/drivers/gpu/drm/amd/amdkfd/Makefile b/drivers/gpu/drm/amd/amdkfd/Makefile
> index ffd096f..69ec969 100644
> --- a/drivers/gpu/drm/amd/amdkfd/Makefile
> +++ b/drivers/gpu/drm/amd/amdkfd/Makefile
> @@ -23,26 +23,41 @@
>  # Makefile for Heterogenous System Architecture support for AMD GPU devices
>  #
>  
> -ccflags-y := -Idrivers/gpu/drm/amd/include/  \
> -		-Idrivers/gpu/drm/amd/include/asic_reg
> -
> -amdkfd-y	:= kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \
> -		kfd_pasid.o kfd_doorbell.o kfd_flat_memory.o \
> -		kfd_process.o kfd_queue.o kfd_mqd_manager.o \
> -		kfd_mqd_manager_cik.o kfd_mqd_manager_vi.o \
> -		kfd_mqd_manager_v9.o \
> -		kfd_kernel_queue.o kfd_kernel_queue_cik.o \
> -		kfd_kernel_queue_vi.o kfd_kernel_queue_v9.o \
> -		kfd_packet_manager.o kfd_process_queue_manager.o \
> -		kfd_device_queue_manager.o kfd_device_queue_manager_cik.o \
> -		kfd_device_queue_manager_vi.o kfd_device_queue_manager_v9.o \
> -		kfd_interrupt.o kfd_events.o cik_event_interrupt.o \
> -		kfd_int_process_v9.o kfd_dbgdev.o kfd_dbgmgr.o kfd_crat.o
> +AMDKFD_FILES	:= $(AMDKFD_PATH)/kfd_module.o \
> +		$(AMDKFD_PATH)/kfd_device.o \
> +		$(AMDKFD_PATH)/kfd_chardev.o \
> +		$(AMDKFD_PATH)/kfd_topology.o \
> +		$(AMDKFD_PATH)/kfd_pasid.o \
> +		$(AMDKFD_PATH)/kfd_doorbell.o \
> +		$(AMDKFD_PATH)/kfd_flat_memory.o \
> +		$(AMDKFD_PATH)/kfd_process.o \
> +		$(AMDKFD_PATH)/kfd_queue.o \
> +		$(AMDKFD_PATH)/kfd_mqd_manager.o \
> +		$(AMDKFD_PATH)/kfd_mqd_manager_cik.o \
> +		$(AMDKFD_PATH)/kfd_mqd_manager_vi.o \
> +		$(AMDKFD_PATH)/kfd_mqd_manager_v9.o \
> +		$(AMDKFD_PATH)/kfd_kernel_queue.o \
> +		$(AMDKFD_PATH)/kfd_kernel_queue_cik.o \
> +		$(AMDKFD_PATH)/kfd_kernel_queue_vi.o \
> +		$(AMDKFD_PATH)/kfd_kernel_queue_v9.o \
> +		$(AMDKFD_PATH)/kfd_packet_manager.o \
> +		$(AMDKFD_PATH)/kfd_process_queue_manager.o \
> +		$(AMDKFD_PATH)/kfd_device_queue_manager.o \
> +		$(AMDKFD_PATH)/kfd_device_queue_manager_cik.o \
> +		$(AMDKFD_PATH)/kfd_device_queue_manager_vi.o \
> +		$(AMDKFD_PATH)/kfd_device_queue_manager_v9.o \
> +		$(AMDKFD_PATH)/kfd_interrupt.o \
> +		$(AMDKFD_PATH)/kfd_events.o \
> +		$(AMDKFD_PATH)/cik_event_interrupt.o \
> +		$(AMDKFD_PATH)/kfd_int_process_v9.o \
> +		$(AMDKFD_PATH)/kfd_dbgdev.o \
> +		$(AMDKFD_PATH)/kfd_dbgmgr.o \
> +		$(AMDKFD_PATH)/kfd_crat.o
>  
>  ifneq ($(CONFIG_AMD_IOMMU_V2),)
> -amdkfd-y += kfd_iommu.o
> +AMDKFD_FILES += $(AMDKFD_PATH)/kfd_iommu.o
>  endif
>  
> -amdkfd-$(CONFIG_DEBUG_FS) += kfd_debugfs.o
> -
> -obj-$(CONFIG_HSA_AMD)	+= amdkfd.o
> +ifneq ($(CONFIG_DEBUG_FS),)
> +AMDKFD_FILES += $(AMDKFD_PATH)/kfd_debugfs.o
> +endif
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_module.c b/drivers/gpu/drm/amd/amdkfd/kfd_module.c
> index 76bf2dc..8847514 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_module.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_module.c
> @@ -20,21 +20,11 @@
>   * OTHER DEALINGS IN THE SOFTWARE.
>   */
>  
> -#include <linux/module.h>
>  #include <linux/sched.h>
>  #include <linux/moduleparam.h>
>  #include <linux/device.h>
> -#include <linux/printk.h>
>  #include "kfd_priv.h"
>  
> -#define KFD_DRIVER_AUTHOR	"AMD Inc. and others"
> -
> -#define KFD_DRIVER_DESC		"Standalone HSA driver for AMD's GPUs"
> -#define KFD_DRIVER_DATE		"20150421"
> -#define KFD_DRIVER_MAJOR	0
> -#define KFD_DRIVER_MINOR	7
> -#define KFD_DRIVER_PATCHLEVEL	2
> -
>  static const struct kgd2kfd_calls kgd2kfd = {
>  	.exit		= kgd2kfd_exit,
>  	.probe		= kgd2kfd_probe,
> @@ -88,32 +78,7 @@ module_param_named(noretry, vega10_noretry, int, 0644);
>  MODULE_PARM_DESC(noretry,
>  	"Set sh_mem_config.retry_disable on Vega10 (0 = retry enabled (default), 1 = retry disabled)");
>  
> -static int amdkfd_init_completed;
> -
> -int kgd2kfd_init(unsigned int interface_version,
> -		const struct kgd2kfd_calls **g2f)
> -{
> -	if (!amdkfd_init_completed)
> -		return -EPROBE_DEFER;
> -
> -	/*
> -	 * Only one interface version is supported,
> -	 * no kfd/kgd version skew allowed.
> -	 */
> -	if (interface_version != KFD_INTERFACE_VERSION)
> -		return -EINVAL;
> -
> -	*g2f = &kgd2kfd;
> -
> -	return 0;
> -}
> -EXPORT_SYMBOL(kgd2kfd_init);
> -
> -void kgd2kfd_exit(void)
> -{
> -}
> -
> -static int __init kfd_module_init(void)
> +static int kfd_init(void)
>  {
>  	int err;
>  
> @@ -121,7 +86,7 @@ static int __init kfd_module_init(void)
>  	if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
>  		(sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
>  		pr_err("sched_policy has invalid value\n");
> -		return -1;
> +		return -EINVAL;
>  	}
>  
>  	/* Verify module parameters */
> @@ -129,7 +94,7 @@ static int __init kfd_module_init(void)
>  		(max_num_of_queues_per_device >
>  			KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
>  		pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
> -		return -1;
> +		return -EINVAL;
>  	}
>  
>  	err = kfd_chardev_init();
> @@ -146,10 +111,6 @@ static int __init kfd_module_init(void)
>  
>  	kfd_debugfs_init();
>  
> -	amdkfd_init_completed = 1;
> -
> -	dev_info(kfd_device, "Initialized module\n");
> -
>  	return 0;
>  
>  err_create_wq:
> @@ -160,23 +121,30 @@ static int __init kfd_module_init(void)
>  	return err;
>  }
>  
> -static void __exit kfd_module_exit(void)
> +static void kfd_exit(void)
>  {
> -	amdkfd_init_completed = 0;
> -
>  	kfd_debugfs_fini();
>  	kfd_process_destroy_wq();
>  	kfd_topology_shutdown();
>  	kfd_chardev_exit();
> -	pr_info("amdkfd: Removed module\n");
>  }
>  
> -module_init(kfd_module_init);
> -module_exit(kfd_module_exit);
> +int kgd2kfd_init(unsigned int interface_version,
> +		const struct kgd2kfd_calls **g2f)
> +{
> +	int err;
> +
> +	err = kfd_init();
> +	if (err)
> +		return err;
>  
> -MODULE_AUTHOR(KFD_DRIVER_AUTHOR);
> -MODULE_DESCRIPTION(KFD_DRIVER_DESC);
> -MODULE_LICENSE("GPL and additional rights");
> -MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "."
> -	       __stringify(KFD_DRIVER_MINOR) "."
> -	       __stringify(KFD_DRIVER_PATCHLEVEL));
> +	*g2f = &kgd2kfd;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(kgd2kfd_init);
> +
> +void kgd2kfd_exit(void)
> +{
> +	kfd_exit();
> +}



More information about the amd-gfx mailing list