Commit 6127896f authored by Huang Rui's avatar Huang Rui Committed by Alex Deucher
Browse files

drm/amdkfd: implement the dGPU fallback path for apu (v6)



We still have a few iommu issues which need to address, so force raven
as "dgpu" path for the moment.

This is to add the fallback path to bypass IOMMU if IOMMU v2 is disabled
or ACPI CRAT table not correct.

v2: Use ignore_crat parameter to decide whether it will go with IOMMUv2.
v3: Align with existed thunk, don't change the way of raven, only renoir
    will use "dgpu" path by default.
v4: don't update global ignore_crat in the driver, and revise fallback
    function if CRAT is broken.
v5: refine acpi crat good but no iommu support case, and rename the
    title.
v6: fix the issue of dGPU initialized firstly, just modify the report
    value in the node_show().

Signed-off-by: default avatarHuang Rui <ray.huang@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bfcc0c16
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -680,11 +680,14 @@ MODULE_PARM_DESC(debug_largebar,
 * Ignore CRAT table during KFD initialization. By default, KFD uses the ACPI CRAT
 * table to get information about AMD APUs. This option can serve as a workaround on
 * systems with a broken CRAT table.
 *
 * Default is auto (according to asic type, iommu_v2, and crat table, to decide
 * whehter use CRAT)
 */
int ignore_crat;
module_param(ignore_crat, int, 0444);
MODULE_PARM_DESC(ignore_crat,
	"Ignore CRAT table during KFD initialization (0 = use CRAT (default), 1 = ignore CRAT)");
	"Ignore CRAT table during KFD initialization (0 = auto (default), 1 = ignore CRAT)");

/**
 * DOC: halt_if_hws_hang (int)
+1 −1
Original line number Diff line number Diff line
@@ -1254,7 +1254,7 @@ bool kfd_dev_is_large_bar(struct kfd_dev *dev)
		return true;
	}

	if (dev->device_info->needs_iommu_device)
	if (dev->use_iommu_v2)
		return false;

	amdgpu_amdkfd_get_local_mem_info(dev->kgd, &mem_info);
+17 −1
Original line number Diff line number Diff line
@@ -742,6 +742,22 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev,
	return 0;
}

static bool kfd_ignore_crat(void)
{
	bool ret;

	if (ignore_crat)
		return true;

#ifndef KFD_SUPPORT_IOMMU_V2
	ret = true;
#else
	ret = false;
#endif

	return ret;
}

/*
 * kfd_create_crat_image_acpi - Allocates memory for CRAT image and
 * copies CRAT from ACPI (if available).
@@ -776,7 +792,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)
		return -EINVAL;
	}

	if (ignore_crat) {
	if (kfd_ignore_crat()) {
		pr_info("CRAT table disabled by module option\n");
		return -ENODATA;
	}
+4 −1
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ static const struct kfd_device_info carrizo_device_info = {
	.num_xgmi_sdma_engines = 0,
	.num_sdma_queues_per_engine = 2,
};
#endif

static const struct kfd_device_info raven_device_info = {
	.asic_family = CHIP_RAVEN,
@@ -134,7 +135,6 @@ static const struct kfd_device_info raven_device_info = {
	.num_xgmi_sdma_engines = 0,
	.num_sdma_queues_per_engine = 2,
};
#endif

static const struct kfd_device_info hawaii_device_info = {
	.asic_family = CHIP_HAWAII,
@@ -738,6 +738,9 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
		goto gws_error;
	}

	/* If CRAT is broken, won't set iommu enabled */
	kfd_double_confirm_iommu_support(kfd);

	if (kfd_iommu_device_init(kfd)) {
		dev_err(kfd_device, "Error initializing iommuv2\n");
		goto device_iommu_error;
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ static int update_qpd_v9(struct device_queue_manager *dqm,
				SH_MEM_ALIGNMENT_MODE_UNALIGNED <<
					SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT;
		if (amdgpu_noretry &&
		    !dqm->dev->device_info->needs_iommu_device)
		    !dqm->dev->use_iommu_v2)
			qpd->sh_mem_config |=
				1 << SH_MEM_CONFIG__RETRY_DISABLE__SHIFT;

Loading