xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/i915/i915_params.c (revision 21412d4a46257b4fb44cf72e7225cb38d500c717)
1*21412d4aSriastradh /*	$NetBSD: i915_params.c,v 1.6 2021/12/19 01:43:51 riastradh Exp $	*/
2d01ac146Sriastradh 
39d20d926Sriastradh /*
49d20d926Sriastradh  * Copyright © 2014 Intel Corporation
59d20d926Sriastradh  *
69d20d926Sriastradh  * Permission is hereby granted, free of charge, to any person obtaining a
79d20d926Sriastradh  * copy of this software and associated documentation files (the
89d20d926Sriastradh  * "Software"), to deal in the Software without restriction, including
99d20d926Sriastradh  * without limitation the rights to use, copy, modify, merge, publish,
109d20d926Sriastradh  * distribute, sub license, and/or sell copies of the Software, and to
119d20d926Sriastradh  * permit persons to whom the Software is furnished to do so, subject to
129d20d926Sriastradh  * the following conditions:
139d20d926Sriastradh  *
149d20d926Sriastradh  * The above copyright notice and this permission notice (including the
159d20d926Sriastradh  * next paragraph) shall be included in all copies or substantial portions
169d20d926Sriastradh  * of the Software.
179d20d926Sriastradh  *
189d20d926Sriastradh  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
199d20d926Sriastradh  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
209d20d926Sriastradh  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
219d20d926Sriastradh  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
229d20d926Sriastradh  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
239d20d926Sriastradh  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
249d20d926Sriastradh  * IN THE SOFTWARE.
259d20d926Sriastradh  */
269d20d926Sriastradh 
27d01ac146Sriastradh #include <sys/cdefs.h>
28*21412d4aSriastradh __KERNEL_RCSID(0, "$NetBSD: i915_params.c,v 1.6 2021/12/19 01:43:51 riastradh Exp $");
29d01ac146Sriastradh 
3041ec0267Sriastradh #include <drm/drm_print.h>
3141ec0267Sriastradh 
3241ec0267Sriastradh #include "i915_params.h"
339d20d926Sriastradh #include "i915_drv.h"
349d20d926Sriastradh 
3541ec0267Sriastradh #define i915_param_named(name, T, perm, desc) \
3641ec0267Sriastradh 	module_param_named(name, i915_modparams.name, T, perm); \
3741ec0267Sriastradh 	MODULE_PARM_DESC(name, desc)
3841ec0267Sriastradh #define i915_param_named_unsafe(name, T, perm, desc) \
3941ec0267Sriastradh 	module_param_named_unsafe(name, i915_modparams.name, T, perm); \
4041ec0267Sriastradh 	MODULE_PARM_DESC(name, desc)
4141ec0267Sriastradh 
4241ec0267Sriastradh struct i915_params i915_modparams __read_mostly = {
4341ec0267Sriastradh #define MEMBER(T, member, value) .member = (value),
4441ec0267Sriastradh 	I915_PARAMS_FOR_EACH(MEMBER)
4541ec0267Sriastradh #undef MEMBER
469d20d926Sriastradh };
479d20d926Sriastradh 
4841ec0267Sriastradh i915_param_named(modeset, int, 0400,
49d01ac146Sriastradh 	"Use kernel modesetting [KMS] (0=disable, "
509d20d926Sriastradh 	"1=on, -1=force vga console preference [default])");
519d20d926Sriastradh 
5241ec0267Sriastradh i915_param_named_unsafe(enable_dc, int, 0400,
5341ec0267Sriastradh 	"Enable power-saving display C-states. "
5441ec0267Sriastradh 	"(-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6; "
5541ec0267Sriastradh 	"3=up to DC5 with DC3CO; 4=up to DC6 with DC3CO)");
569d20d926Sriastradh 
5741ec0267Sriastradh i915_param_named_unsafe(enable_fbc, int, 0600,
589d20d926Sriastradh 	"Enable frame buffer compression for power savings "
599d20d926Sriastradh 	"(default: -1 (use per-chip default))");
609d20d926Sriastradh 
6141ec0267Sriastradh i915_param_named_unsafe(lvds_channel_mode, int, 0400,
629d20d926Sriastradh 	 "Specify LVDS channel mode "
639d20d926Sriastradh 	 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
649d20d926Sriastradh 
6541ec0267Sriastradh i915_param_named_unsafe(panel_use_ssc, int, 0600,
669d20d926Sriastradh 	"Use Spread Spectrum Clock with panels [LVDS/eDP] "
679d20d926Sriastradh 	"(default: auto from VBT)");
689d20d926Sriastradh 
6941ec0267Sriastradh i915_param_named_unsafe(vbt_sdvo_panel_type, int, 0400,
709d20d926Sriastradh 	"Override/Ignore selection of SDVO panel mode in the VBT "
719d20d926Sriastradh 	"(-2=ignore, -1=auto [default], index in VBT BIOS table)");
729d20d926Sriastradh 
7341ec0267Sriastradh i915_param_named_unsafe(reset, int, 0600,
7441ec0267Sriastradh 	"Attempt GPU resets (0=disabled, 1=full gpu reset, 2=engine reset [default])");
759d20d926Sriastradh 
7641ec0267Sriastradh i915_param_named_unsafe(vbt_firmware, charp, 0400,
7741ec0267Sriastradh 	"Load VBT from specified file under /lib/firmware");
7841ec0267Sriastradh 
7941ec0267Sriastradh #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
8041ec0267Sriastradh i915_param_named(error_capture, bool, 0600,
8141ec0267Sriastradh 	"Record the GPU state following a hang. "
8241ec0267Sriastradh 	"This information in /sys/class/drm/card<N>/error is vital for "
8341ec0267Sriastradh 	"triaging and debugging hangs.");
8441ec0267Sriastradh #endif
8541ec0267Sriastradh 
8641ec0267Sriastradh i915_param_named_unsafe(enable_hangcheck, bool, 0600,
879d20d926Sriastradh 	"Periodically check GPU activity for detecting hangs. "
889d20d926Sriastradh 	"WARNING: Disabling this can cause system wide hangs. "
899d20d926Sriastradh 	"(default: true)");
909d20d926Sriastradh 
9141ec0267Sriastradh i915_param_named_unsafe(enable_psr, int, 0600,
9241ec0267Sriastradh 	"Enable PSR "
9341ec0267Sriastradh 	"(0=disabled, 1=enabled) "
9441ec0267Sriastradh 	"Default: -1 (use per-chip default)");
959d20d926Sriastradh 
9641ec0267Sriastradh i915_param_named_unsafe(force_probe, charp, 0400,
9741ec0267Sriastradh 	"Force probe the driver for specified devices. "
9841ec0267Sriastradh 	"See CONFIG_DRM_I915_FORCE_PROBE for details.");
99d01ac146Sriastradh 
10041ec0267Sriastradh i915_param_named_unsafe(alpha_support, bool, 0400,
10141ec0267Sriastradh 	"Deprecated. See i915.force_probe.");
1029d20d926Sriastradh 
10341ec0267Sriastradh i915_param_named_unsafe(disable_power_well, int, 0400,
104d01ac146Sriastradh 	"Disable display power wells when possible "
105d01ac146Sriastradh 	"(-1=auto [default], 0=power wells always on, 1=power wells disabled when possible)");
1069d20d926Sriastradh 
10741ec0267Sriastradh i915_param_named_unsafe(enable_ips, int, 0600, "Enable IPS (default: true)");
1089d20d926Sriastradh 
10941ec0267Sriastradh i915_param_named(fastboot, int, 0600,
11041ec0267Sriastradh 	"Try to skip unnecessary mode sets at boot time "
11141ec0267Sriastradh 	"(0=disabled, 1=enabled) "
11241ec0267Sriastradh 	"Default: -1 (use per-chip default)");
1139d20d926Sriastradh 
11441ec0267Sriastradh i915_param_named_unsafe(prefault_disable, bool, 0600,
1159d20d926Sriastradh 	"Disable page prefaulting for pread/pwrite/reloc (default:false). "
1169d20d926Sriastradh 	"For developers only.");
1179d20d926Sriastradh 
11841ec0267Sriastradh i915_param_named_unsafe(load_detect_test, bool, 0600,
119d01ac146Sriastradh 	"Force-enable the VGA load detect code for testing (default:false). "
120d01ac146Sriastradh 	"For developers only.");
121d01ac146Sriastradh 
12241ec0267Sriastradh i915_param_named_unsafe(force_reset_modeset_test, bool, 0600,
12341ec0267Sriastradh 	"Force a modeset during gpu reset for testing (default:false). "
12441ec0267Sriastradh 	"For developers only.");
12541ec0267Sriastradh 
12641ec0267Sriastradh i915_param_named_unsafe(invert_brightness, int, 0600,
1279d20d926Sriastradh 	"Invert backlight brightness "
1289d20d926Sriastradh 	"(-1 force normal, 0 machine defaults, 1 force inversion), please "
1299d20d926Sriastradh 	"report PCI device ID, subsystem vendor and subsystem device ID "
1309d20d926Sriastradh 	"to dri-devel@lists.freedesktop.org, if your machine needs it. "
1319d20d926Sriastradh 	"It will then be included in an upcoming module version.");
1329d20d926Sriastradh 
13341ec0267Sriastradh i915_param_named(disable_display, bool, 0400,
13441ec0267Sriastradh 	"Disable display (default: false)");
1359d20d926Sriastradh 
13641ec0267Sriastradh i915_param_named(mmio_debug, int, 0600,
137d01ac146Sriastradh 	"Enable the MMIO debug code for the first N failures (default: off). "
138d01ac146Sriastradh 	"This may negatively affect performance.");
139d01ac146Sriastradh 
14041ec0267Sriastradh i915_param_named(verbose_state_checks, bool, 0600,
141d01ac146Sriastradh 	"Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions.");
142d01ac146Sriastradh 
14341ec0267Sriastradh i915_param_named_unsafe(nuclear_pageflip, bool, 0400,
14441ec0267Sriastradh 	"Force enable atomic functionality on platforms that don't have full support yet.");
145d01ac146Sriastradh 
146d01ac146Sriastradh /* WA to get away with the default setting in VBT for early platforms.Will be removed */
14741ec0267Sriastradh i915_param_named_unsafe(edp_vswing, int, 0400,
148d01ac146Sriastradh 	"Ignore/Override vswing pre-emph table selection from VBT "
149d01ac146Sriastradh 	"(0=use value from vbt [default], 1=low power swing(200mV),"
150d01ac146Sriastradh 	"2=default swing(400mV))");
151d01ac146Sriastradh 
15241ec0267Sriastradh i915_param_named_unsafe(enable_guc, int, 0400,
15341ec0267Sriastradh 	"Enable GuC load for GuC submission and/or HuC load. "
15441ec0267Sriastradh 	"Required functionality can be selected using bitmask values. "
15541ec0267Sriastradh 	"(-1=auto, 0=disable [default], 1=GuC submission, 2=HuC load)");
156d01ac146Sriastradh 
15741ec0267Sriastradh i915_param_named(guc_log_level, int, 0400,
15841ec0267Sriastradh 	"GuC firmware logging level. Requires GuC to be loaded. "
15941ec0267Sriastradh 	"(-1=auto [default], 0=disable, 1..4=enable with verbosity min..max)");
16041ec0267Sriastradh 
16141ec0267Sriastradh i915_param_named_unsafe(guc_firmware_path, charp, 0400,
16241ec0267Sriastradh 	"GuC firmware path to use instead of the default one");
16341ec0267Sriastradh 
16441ec0267Sriastradh i915_param_named_unsafe(huc_firmware_path, charp, 0400,
16541ec0267Sriastradh 	"HuC firmware path to use instead of the default one");
16641ec0267Sriastradh 
16741ec0267Sriastradh i915_param_named_unsafe(dmc_firmware_path, charp, 0400,
16841ec0267Sriastradh 	"DMC firmware path to use instead of the default one");
16941ec0267Sriastradh 
17041ec0267Sriastradh i915_param_named_unsafe(enable_dp_mst, bool, 0600,
17141ec0267Sriastradh 	"Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)");
17241ec0267Sriastradh 
17341ec0267Sriastradh #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
17441ec0267Sriastradh i915_param_named_unsafe(inject_probe_failure, uint, 0400,
17541ec0267Sriastradh 	"Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point)");
17641ec0267Sriastradh #endif
17741ec0267Sriastradh 
17841ec0267Sriastradh i915_param_named(enable_dpcd_backlight, int, 0600,
17941ec0267Sriastradh 	"Enable support for DPCD backlight control"
18041ec0267Sriastradh 	"(-1=use per-VBT LFP backlight type setting, 0=disabled [default], 1=enabled)");
18141ec0267Sriastradh 
18241ec0267Sriastradh #if IS_ENABLED(CONFIG_DRM_I915_GVT)
18341ec0267Sriastradh i915_param_named(enable_gvt, bool, 0400,
18441ec0267Sriastradh 	"Enable support for Intel GVT-g graphics virtualization host support(default:false)");
18541ec0267Sriastradh #endif
18641ec0267Sriastradh 
18741ec0267Sriastradh #if IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)
18841ec0267Sriastradh i915_param_named_unsafe(fake_lmem_start, ulong, 0600,
18941ec0267Sriastradh 	"Fake LMEM start offset (default: 0)");
19041ec0267Sriastradh #endif
19141ec0267Sriastradh 
_print_param(struct drm_printer * p,const char * name,const char * type,const void * x)19241ec0267Sriastradh static __always_inline void _print_param(struct drm_printer *p,
19341ec0267Sriastradh 					 const char *name,
19441ec0267Sriastradh 					 const char *type,
19541ec0267Sriastradh 					 const void *x)
19641ec0267Sriastradh {
19741ec0267Sriastradh 	if (!__builtin_strcmp(type, "bool"))
19841ec0267Sriastradh 		drm_printf(p, "i915.%s=%s\n", name, yesno(*(const bool *)x));
19941ec0267Sriastradh 	else if (!__builtin_strcmp(type, "int"))
20041ec0267Sriastradh 		drm_printf(p, "i915.%s=%d\n", name, *(const int *)x);
20141ec0267Sriastradh 	else if (!__builtin_strcmp(type, "unsigned int"))
20241ec0267Sriastradh 		drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x);
20341ec0267Sriastradh 	else if (!__builtin_strcmp(type, "unsigned long"))
20441ec0267Sriastradh 		drm_printf(p, "i915.%s=%lu\n", name, *(const unsigned long *)x);
20541ec0267Sriastradh 	else if (!__builtin_strcmp(type, "char *"))
206*21412d4aSriastradh 		drm_printf(p, "i915.%s=%s\n", name, *(const char *const *)x);
20741ec0267Sriastradh 	else
20841ec0267Sriastradh 		WARN_ONCE(1, "no printer defined for param type %s (i915.%s)\n",
20941ec0267Sriastradh 			  type, name);
21041ec0267Sriastradh }
21141ec0267Sriastradh 
21241ec0267Sriastradh /**
21341ec0267Sriastradh  * i915_params_dump - dump i915 modparams
21441ec0267Sriastradh  * @params: i915 modparams
21541ec0267Sriastradh  * @p: the &drm_printer
21641ec0267Sriastradh  *
21741ec0267Sriastradh  * Pretty printer for i915 modparams.
21841ec0267Sriastradh  */
i915_params_dump(const struct i915_params * params,struct drm_printer * p)21941ec0267Sriastradh void i915_params_dump(const struct i915_params *params, struct drm_printer *p)
22041ec0267Sriastradh {
22141ec0267Sriastradh #define PRINT(T, x, ...) _print_param(p, #x, #T, &params->x);
22241ec0267Sriastradh 	I915_PARAMS_FOR_EACH(PRINT);
22341ec0267Sriastradh #undef PRINT
22441ec0267Sriastradh }
22541ec0267Sriastradh 
dup_param(const char * type,void * x)22641ec0267Sriastradh static __always_inline void dup_param(const char *type, void *x)
22741ec0267Sriastradh {
22841ec0267Sriastradh 	if (!__builtin_strcmp(type, "char *"))
22941ec0267Sriastradh 		*(void **)x = kstrdup(*(void **)x, GFP_ATOMIC);
23041ec0267Sriastradh }
23141ec0267Sriastradh 
i915_params_copy(struct i915_params * dest,const struct i915_params * src)23241ec0267Sriastradh void i915_params_copy(struct i915_params *dest, const struct i915_params *src)
23341ec0267Sriastradh {
23441ec0267Sriastradh 	*dest = *src;
23541ec0267Sriastradh #define DUP(T, x, ...) dup_param(#T, &dest->x);
23641ec0267Sriastradh 	I915_PARAMS_FOR_EACH(DUP);
23741ec0267Sriastradh #undef DUP
23841ec0267Sriastradh }
23941ec0267Sriastradh 
free_param(const char * type,void * x)24041ec0267Sriastradh static __always_inline void free_param(const char *type, void *x)
24141ec0267Sriastradh {
24241ec0267Sriastradh 	if (!__builtin_strcmp(type, "char *")) {
24341ec0267Sriastradh 		kfree(*(void **)x);
24441ec0267Sriastradh 		*(void **)x = NULL;
24541ec0267Sriastradh 	}
24641ec0267Sriastradh }
24741ec0267Sriastradh 
24841ec0267Sriastradh /* free the allocated members, *not* the passed in params itself */
i915_params_free(struct i915_params * params)24941ec0267Sriastradh void i915_params_free(struct i915_params *params)
25041ec0267Sriastradh {
25141ec0267Sriastradh #define FREE(T, x, ...) free_param(#T, &params->x);
25241ec0267Sriastradh 	I915_PARAMS_FOR_EACH(FREE);
25341ec0267Sriastradh #undef FREE
25441ec0267Sriastradh }
255