On 17-04-25 02:28 AM, Michel Dänzer wrote:
> On 22/04/17 02:05 AM, Felix Kuehling wrote:
>> __setup doesn't work in modules.
> Right. We could build something like
> drivers/video/fbdev/core/fb_cmdline.c:video_setup() into the kernel to
> handle this, but it's a bit ugly, which is one reason why I was leaning
> towards:
>
>
>> s8250_options is only compiled if the driver is not a module.
> That doesn't prevent us from using __module_param_call directly, does it?
>
> Although, that still doesn't work as I envision if only one driver's
> option is set e.g. in /etc/modprobe.d/*.conf .
>
>
> So, I'm starting to think we need a shared module for this, which
> provides one or multiple module parameters to choose which driver to use
> for CIK/SI[0], and provides the result to the amdgpu/radeon drivers.
> That might make things easier for amdgpu-pro / other standalone amdgpu
> versions in the long run as well, as they could add files to
> /etc/modprobe.d/ choosing themselves by default, without having to
> blacklist radeon.
>
> What do you guys think?

Hi Michel,

You said in an earlier email that it doesn't have to be convenient. With
that in mind, I went back to a minimalistic solution that doesn't need
any additional Kconfig options and only uses two module parameters (one
in radeon, one in amdgpu).

I'm attaching my WIP patches for reference (currently based on
amd-kfd-staging). For an official review I'd rebase them on
amd-staging-4.9, remove the #if-0-ed hack that didn't work out, and add
the same for SI.

Can everyone can agree that this is good enough?

Regards,
  Felix

>
>
> [0] or possibly even more fine-grained in the future
>

>From e1d5fc320dbe2f60d922c466986863489f4bfe77 Mon Sep 17 00:00:00 2001
From: Felix Kuehling <felix.kuehl...@amd.com>
Date: Thu, 20 Apr 2017 14:41:34 -0400
Subject: [PATCH 1/2] drm/radeon: Add module param to control CIK support

If AMDGPU supports CIK, add a module parameter to control CIK
support in radeon. It's off by default in radeon, while it will be
on by default in AMDGPU.

Change-Id: Ib594f7359b9b3143c859b3be5c0244a9a2a773cd
Signed-off-by: Felix Kuehling <felix.kuehl...@amd.com>
---
 drivers/gpu/drm/radeon/radeon.h     |  4 ++++
 drivers/gpu/drm/radeon/radeon_drv.c |  6 ++++++
 drivers/gpu/drm/radeon/radeon_kms.c | 18 ++++++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5f16bf3..a05aaea 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -116,6 +116,10 @@
 extern int radeon_uvd;
 extern int radeon_vce;
 
+#ifdef CONFIG_DRM_AMDGPU_CIK
+extern int radeon_cik_support;
+#endif
+
 /*
  * Copy from radeon_drv.h so we don't have to include both and have conflicting
  * symbol;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 2e5d680..2cdb01b 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -301,6 +301,12 @@ static inline void radeon_unregister_atpx_handler(void) {}
 MODULE_PARM_DESC(vce, "vce enable/disable vce support (1 = enable, 0 = disable)");
 module_param_named(vce, radeon_vce, int, 0444);
 
+#ifdef CONFIG_DRM_AMDGPU_CIK
+int radeon_cik_support = 0;
+MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled, 0 = disabled (default))");
+module_param_named(cik_support, radeon_cik_support, int, 0444);
+#endif
+
 static struct pci_device_id pciidlist[] = {
 	radeon_PCI_IDS
 };
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index d6d58bc..28ab255 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -99,6 +99,24 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
 	struct radeon_device *rdev;
 	int r, acpi_status;
 
+#ifdef CONFIG_DRM_AMDGPU_CIK
+	if (!radeon_cik_support) {
+		switch (flags & RADEON_FAMILY_MASK) {
+		case CHIP_KAVERI:
+		case CHIP_BONAIRE:
+		case CHIP_HAWAII:
+		case CHIP_KABINI:
+		case CHIP_MULLINS:
+			dev_warn(dev->dev,
+				 "CIK support provided by amdgpu.\n");
+			dev_warn(dev->dev,
+		"Use radeon.cik_support=1 amdgpu.cik_support=0 to override.\n"
+				);
+			return -ENODEV;
+		}
+	}
+#endif
+
 	rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
 	if (rdev == NULL) {
 		return -ENOMEM;
-- 
1.9.1

>From 18d4b8b6282215073c3c6762f36c9009b1218f3c Mon Sep 17 00:00:00 2001
From: Felix Kuehling <felix.kuehl...@amd.com>
Date: Thu, 20 Apr 2017 14:42:04 -0400
Subject: [PATCH 2/2] drm/amdgpu: Add module param to control CIK support

If AMDGPU supports CIK, add a module parameter to control CIK
support. It's on by default in AMDGPU, while it is off by default
in radeon.

Change-Id: Ica1296beae96b1c5f48698c06cfd2453fe1ff080
Signed-off-by: Felix Kuehling <felix.kuehl...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  4 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 41 ++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 15 ++++++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index e6e623a..eaf980d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -113,6 +113,10 @@
 extern int amdgpu_cntl_sb_buf_per_se;
 extern int amdgpu_param_buf_per_se;
 
+#ifdef CONFIG_DRM_AMDGPU_CIK
+extern int amdgpu_cik_support;
+#endif
+
 #define AMDGPU_DEFAULT_GTT_SIZE_MB		3072ULL /* 3GB by default */
 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS	        3000
 #define AMDGPU_MAX_USEC_TIMEOUT			100000	/* 100 ms */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d19ac0f..654a782 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -239,6 +239,12 @@
 MODULE_PARM_DESC(param_buf_per_se, "the size of Off-Chip Pramater Cache per Shader Engine (default depending on gfx)");
 module_param_named(param_buf_per_se, amdgpu_param_buf_per_se, int, 0444);
 
+#ifdef CONFIG_DRM_AMDGPU_CIK
+int amdgpu_cik_support = 1;
+MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
+module_param_named(cik_support, amdgpu_cik_support, int, 0444);
+#endif
+
 
 static const struct pci_device_id pciidlist[] = {
 #ifdef  CONFIG_DRM_AMDGPU_SI
@@ -787,12 +793,45 @@ long amdgpu_drm_ioctl(struct file *filp,
 	.driver.pm = &amdgpu_pm_ops,
 };
 
-
+#if 0
+static int radeon_cik_support = 0;
+static int param_set(const char *val, const struct kernel_param *kp)
+{
+	return kstrtoint(val, 0, kp.arg);
+}
+static struct kernel_param_ops radeon_force_cik_param_ops = {
+	.flags = 0,
+	.set = param_set,
+	.get = NULL,
+	.free = NULL
+};
+static struct kernel_param radeon_cik_support_param = {
+	.name = "radeon.cik_support",
+	.mod = THIS_MODULE,
+	.ops = radeon_cik_support_param_ops,
+	.perm = 0444,
+	.level = -1,
+	.flags = 0,
+	.arg = &radeon_cik_support
+};
+#endif
 
 static int __init amdgpu_init(void)
 {
 	int r;
 
+#if 0
+	/* Doesn't work because saved_command_line isn't exported to
+	 * modules */
+	r = parse_args("amdgpu", saved_command_line,
+		       &radeon_cik_support_param, 1,
+		       -32768, 32767, NULL, NULL);
+	if (r)
+		return r;
+
+	amdgpu_cik_support = !radeon_cik_support;
+#endif
+
 	r = amdgpu_sync_init();
 	if (r)
 		goto error_sync;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 6443e24..e51c92f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -88,6 +88,21 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 	struct amdgpu_device *adev;
 	int r, acpi_status;
 
+#ifdef CONFIG_DRM_AMDGPU_CIK
+	if (!amdgpu_cik_support) {
+		switch (flags & AMD_ASIC_MASK) {
+		case CHIP_KAVERI:
+		case CHIP_BONAIRE:
+		case CHIP_HAWAII:
+		case CHIP_KABINI:
+		case CHIP_MULLINS:
+			dev_warn(dev->dev,
+				 "CIK support disabled by module param\n");
+			return -ENODEV;
+		}
+	}
+#endif
+
 	adev = kzalloc(sizeof(struct amdgpu_device), GFP_KERNEL);
 	if (adev == NULL) {
 		return -ENOMEM;
-- 
1.9.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to