1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright © 2014 Intel Corporation
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a
5*4882a593Smuzhiyun * copy of this software and associated documentation files (the
6*4882a593Smuzhiyun * "Software"), to deal in the Software without restriction, including
7*4882a593Smuzhiyun * without limitation the rights to use, copy, modify, merge, publish,
8*4882a593Smuzhiyun * distribute, sub license, and/or sell copies of the Software, and to
9*4882a593Smuzhiyun * permit persons to whom the Software is furnished to do so, subject to
10*4882a593Smuzhiyun * the following conditions:
11*4882a593Smuzhiyun *
12*4882a593Smuzhiyun * The above copyright notice and this permission notice (including the
13*4882a593Smuzhiyun * next paragraph) shall be included in all copies or substantial portions
14*4882a593Smuzhiyun * of the Software.
15*4882a593Smuzhiyun *
16*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19*4882a593Smuzhiyun * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22*4882a593Smuzhiyun * IN THE SOFTWARE.
23*4882a593Smuzhiyun */
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun #include <drm/drm_print.h>
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun #include "i915_params.h"
28*4882a593Smuzhiyun #include "i915_drv.h"
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun #define i915_param_named(name, T, perm, desc) \
31*4882a593Smuzhiyun module_param_named(name, i915_modparams.name, T, perm); \
32*4882a593Smuzhiyun MODULE_PARM_DESC(name, desc)
33*4882a593Smuzhiyun #define i915_param_named_unsafe(name, T, perm, desc) \
34*4882a593Smuzhiyun module_param_named_unsafe(name, i915_modparams.name, T, perm); \
35*4882a593Smuzhiyun MODULE_PARM_DESC(name, desc)
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun struct i915_params i915_modparams __read_mostly = {
38*4882a593Smuzhiyun #define MEMBER(T, member, value, ...) .member = (value),
39*4882a593Smuzhiyun I915_PARAMS_FOR_EACH(MEMBER)
40*4882a593Smuzhiyun #undef MEMBER
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun /*
44*4882a593Smuzhiyun * Note: As a rule, keep module parameter sysfs permissions read-only
45*4882a593Smuzhiyun * 0400. Runtime changes are only supported through i915 debugfs.
46*4882a593Smuzhiyun *
47*4882a593Smuzhiyun * For any exceptions requiring write access and runtime changes through module
48*4882a593Smuzhiyun * parameter sysfs, prevent debugfs file creation by setting the parameter's
49*4882a593Smuzhiyun * debugfs mode to 0.
50*4882a593Smuzhiyun */
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun i915_param_named(modeset, int, 0400,
53*4882a593Smuzhiyun "Use kernel modesetting [KMS] (0=disable, "
54*4882a593Smuzhiyun "1=on, -1=force vga console preference [default])");
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun i915_param_named_unsafe(enable_dc, int, 0400,
57*4882a593Smuzhiyun "Enable power-saving display C-states. "
58*4882a593Smuzhiyun "(-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6; "
59*4882a593Smuzhiyun "3=up to DC5 with DC3CO; 4=up to DC6 with DC3CO)");
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun i915_param_named_unsafe(enable_fbc, int, 0400,
62*4882a593Smuzhiyun "Enable frame buffer compression for power savings "
63*4882a593Smuzhiyun "(default: -1 (use per-chip default))");
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun i915_param_named_unsafe(lvds_channel_mode, int, 0400,
66*4882a593Smuzhiyun "Specify LVDS channel mode "
67*4882a593Smuzhiyun "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun i915_param_named_unsafe(panel_use_ssc, int, 0400,
70*4882a593Smuzhiyun "Use Spread Spectrum Clock with panels [LVDS/eDP] "
71*4882a593Smuzhiyun "(default: auto from VBT)");
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun i915_param_named_unsafe(vbt_sdvo_panel_type, int, 0400,
74*4882a593Smuzhiyun "Override/Ignore selection of SDVO panel mode in the VBT "
75*4882a593Smuzhiyun "(-2=ignore, -1=auto [default], index in VBT BIOS table)");
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun i915_param_named_unsafe(reset, uint, 0400,
78*4882a593Smuzhiyun "Attempt GPU resets (0=disabled, 1=full gpu reset, 2=engine reset [default])");
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun i915_param_named_unsafe(vbt_firmware, charp, 0400,
81*4882a593Smuzhiyun "Load VBT from specified file under /lib/firmware");
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
84*4882a593Smuzhiyun i915_param_named(error_capture, bool, 0400,
85*4882a593Smuzhiyun "Record the GPU state following a hang. "
86*4882a593Smuzhiyun "This information in /sys/class/drm/card<N>/error is vital for "
87*4882a593Smuzhiyun "triaging and debugging hangs.");
88*4882a593Smuzhiyun #endif
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun i915_param_named_unsafe(enable_hangcheck, bool, 0400,
91*4882a593Smuzhiyun "Periodically check GPU activity for detecting hangs. "
92*4882a593Smuzhiyun "WARNING: Disabling this can cause system wide hangs. "
93*4882a593Smuzhiyun "(default: true)");
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun i915_param_named_unsafe(enable_psr, int, 0400,
96*4882a593Smuzhiyun "Enable PSR "
97*4882a593Smuzhiyun "(0=disabled, 1=enabled) "
98*4882a593Smuzhiyun "Default: -1 (use per-chip default)");
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun i915_param_named(psr_safest_params, bool, 0400,
101*4882a593Smuzhiyun "Replace PSR VBT parameters by the safest and not optimal ones. This "
102*4882a593Smuzhiyun "is helpful to detect if PSR issues are related to bad values set in "
103*4882a593Smuzhiyun " VBT. (0=use VBT parameters, 1=use safest parameters)");
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun i915_param_named_unsafe(enable_psr2_sel_fetch, bool, 0400,
106*4882a593Smuzhiyun "Enable PSR2 selective fetch "
107*4882a593Smuzhiyun "(0=disabled, 1=enabled) "
108*4882a593Smuzhiyun "Default: 0");
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun i915_param_named_unsafe(force_probe, charp, 0400,
111*4882a593Smuzhiyun "Force probe the driver for specified devices. "
112*4882a593Smuzhiyun "See CONFIG_DRM_I915_FORCE_PROBE for details.");
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun i915_param_named_unsafe(disable_power_well, int, 0400,
115*4882a593Smuzhiyun "Disable display power wells when possible "
116*4882a593Smuzhiyun "(-1=auto [default], 0=power wells always on, 1=power wells disabled when possible)");
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun i915_param_named_unsafe(enable_ips, int, 0400, "Enable IPS (default: true)");
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun i915_param_named(fastboot, int, 0400,
121*4882a593Smuzhiyun "Try to skip unnecessary mode sets at boot time "
122*4882a593Smuzhiyun "(0=disabled, 1=enabled) "
123*4882a593Smuzhiyun "Default: -1 (use per-chip default)");
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun i915_param_named_unsafe(load_detect_test, bool, 0400,
126*4882a593Smuzhiyun "Force-enable the VGA load detect code for testing (default:false). "
127*4882a593Smuzhiyun "For developers only.");
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun i915_param_named_unsafe(force_reset_modeset_test, bool, 0400,
130*4882a593Smuzhiyun "Force a modeset during gpu reset for testing (default:false). "
131*4882a593Smuzhiyun "For developers only.");
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun i915_param_named_unsafe(invert_brightness, int, 0400,
134*4882a593Smuzhiyun "Invert backlight brightness "
135*4882a593Smuzhiyun "(-1 force normal, 0 machine defaults, 1 force inversion), please "
136*4882a593Smuzhiyun "report PCI device ID, subsystem vendor and subsystem device ID "
137*4882a593Smuzhiyun "to dri-devel@lists.freedesktop.org, if your machine needs it. "
138*4882a593Smuzhiyun "It will then be included in an upcoming module version.");
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun i915_param_named(disable_display, bool, 0400,
141*4882a593Smuzhiyun "Disable display (default: false)");
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun i915_param_named(mmio_debug, int, 0400,
144*4882a593Smuzhiyun "Enable the MMIO debug code for the first N failures (default: off). "
145*4882a593Smuzhiyun "This may negatively affect performance.");
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun /* Special case writable file */
148*4882a593Smuzhiyun i915_param_named(verbose_state_checks, bool, 0600,
149*4882a593Smuzhiyun "Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions.");
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun i915_param_named_unsafe(nuclear_pageflip, bool, 0400,
152*4882a593Smuzhiyun "Force enable atomic functionality on platforms that don't have full support yet.");
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun /* WA to get away with the default setting in VBT for early platforms.Will be removed */
155*4882a593Smuzhiyun i915_param_named_unsafe(edp_vswing, int, 0400,
156*4882a593Smuzhiyun "Ignore/Override vswing pre-emph table selection from VBT "
157*4882a593Smuzhiyun "(0=use value from vbt [default], 1=low power swing(200mV),"
158*4882a593Smuzhiyun "2=default swing(400mV))");
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun i915_param_named_unsafe(enable_guc, int, 0400,
161*4882a593Smuzhiyun "Enable GuC load for GuC submission and/or HuC load. "
162*4882a593Smuzhiyun "Required functionality can be selected using bitmask values. "
163*4882a593Smuzhiyun "(-1=auto, 0=disable [default], 1=GuC submission, 2=HuC load)");
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun i915_param_named(guc_log_level, int, 0400,
166*4882a593Smuzhiyun "GuC firmware logging level. Requires GuC to be loaded. "
167*4882a593Smuzhiyun "(-1=auto [default], 0=disable, 1..4=enable with verbosity min..max)");
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun i915_param_named_unsafe(guc_firmware_path, charp, 0400,
170*4882a593Smuzhiyun "GuC firmware path to use instead of the default one");
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun i915_param_named_unsafe(huc_firmware_path, charp, 0400,
173*4882a593Smuzhiyun "HuC firmware path to use instead of the default one");
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun i915_param_named_unsafe(dmc_firmware_path, charp, 0400,
176*4882a593Smuzhiyun "DMC firmware path to use instead of the default one");
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun i915_param_named_unsafe(enable_dp_mst, bool, 0400,
179*4882a593Smuzhiyun "Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)");
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
182*4882a593Smuzhiyun i915_param_named_unsafe(inject_probe_failure, uint, 0400,
183*4882a593Smuzhiyun "Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point)");
184*4882a593Smuzhiyun #endif
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun i915_param_named(enable_dpcd_backlight, int, 0400,
187*4882a593Smuzhiyun "Enable support for DPCD backlight control"
188*4882a593Smuzhiyun "(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enabled)");
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_DRM_I915_GVT)
191*4882a593Smuzhiyun i915_param_named(enable_gvt, bool, 0400,
192*4882a593Smuzhiyun "Enable support for Intel GVT-g graphics virtualization host support(default:false)");
193*4882a593Smuzhiyun #endif
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)
196*4882a593Smuzhiyun i915_param_named_unsafe(fake_lmem_start, ulong, 0400,
197*4882a593Smuzhiyun "Fake LMEM start offset (default: 0)");
198*4882a593Smuzhiyun #endif
199*4882a593Smuzhiyun
_print_param(struct drm_printer * p,const char * name,const char * type,const void * x)200*4882a593Smuzhiyun static __always_inline void _print_param(struct drm_printer *p,
201*4882a593Smuzhiyun const char *name,
202*4882a593Smuzhiyun const char *type,
203*4882a593Smuzhiyun const void *x)
204*4882a593Smuzhiyun {
205*4882a593Smuzhiyun if (!__builtin_strcmp(type, "bool"))
206*4882a593Smuzhiyun drm_printf(p, "i915.%s=%s\n", name, yesno(*(const bool *)x));
207*4882a593Smuzhiyun else if (!__builtin_strcmp(type, "int"))
208*4882a593Smuzhiyun drm_printf(p, "i915.%s=%d\n", name, *(const int *)x);
209*4882a593Smuzhiyun else if (!__builtin_strcmp(type, "unsigned int"))
210*4882a593Smuzhiyun drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x);
211*4882a593Smuzhiyun else if (!__builtin_strcmp(type, "unsigned long"))
212*4882a593Smuzhiyun drm_printf(p, "i915.%s=%lu\n", name, *(const unsigned long *)x);
213*4882a593Smuzhiyun else if (!__builtin_strcmp(type, "char *"))
214*4882a593Smuzhiyun drm_printf(p, "i915.%s=%s\n", name, *(const char **)x);
215*4882a593Smuzhiyun else
216*4882a593Smuzhiyun WARN_ONCE(1, "no printer defined for param type %s (i915.%s)\n",
217*4882a593Smuzhiyun type, name);
218*4882a593Smuzhiyun }
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun /**
221*4882a593Smuzhiyun * i915_params_dump - dump i915 modparams
222*4882a593Smuzhiyun * @params: i915 modparams
223*4882a593Smuzhiyun * @p: the &drm_printer
224*4882a593Smuzhiyun *
225*4882a593Smuzhiyun * Pretty printer for i915 modparams.
226*4882a593Smuzhiyun */
i915_params_dump(const struct i915_params * params,struct drm_printer * p)227*4882a593Smuzhiyun void i915_params_dump(const struct i915_params *params, struct drm_printer *p)
228*4882a593Smuzhiyun {
229*4882a593Smuzhiyun #define PRINT(T, x, ...) _print_param(p, #x, #T, ¶ms->x);
230*4882a593Smuzhiyun I915_PARAMS_FOR_EACH(PRINT);
231*4882a593Smuzhiyun #undef PRINT
232*4882a593Smuzhiyun }
233*4882a593Smuzhiyun
dup_param(const char * type,void * x)234*4882a593Smuzhiyun static __always_inline void dup_param(const char *type, void *x)
235*4882a593Smuzhiyun {
236*4882a593Smuzhiyun if (!__builtin_strcmp(type, "char *"))
237*4882a593Smuzhiyun *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC);
238*4882a593Smuzhiyun }
239*4882a593Smuzhiyun
i915_params_copy(struct i915_params * dest,const struct i915_params * src)240*4882a593Smuzhiyun void i915_params_copy(struct i915_params *dest, const struct i915_params *src)
241*4882a593Smuzhiyun {
242*4882a593Smuzhiyun *dest = *src;
243*4882a593Smuzhiyun #define DUP(T, x, ...) dup_param(#T, &dest->x);
244*4882a593Smuzhiyun I915_PARAMS_FOR_EACH(DUP);
245*4882a593Smuzhiyun #undef DUP
246*4882a593Smuzhiyun }
247*4882a593Smuzhiyun
free_param(const char * type,void * x)248*4882a593Smuzhiyun static __always_inline void free_param(const char *type, void *x)
249*4882a593Smuzhiyun {
250*4882a593Smuzhiyun if (!__builtin_strcmp(type, "char *")) {
251*4882a593Smuzhiyun kfree(*(void **)x);
252*4882a593Smuzhiyun *(void **)x = NULL;
253*4882a593Smuzhiyun }
254*4882a593Smuzhiyun }
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun /* free the allocated members, *not* the passed in params itself */
i915_params_free(struct i915_params * params)257*4882a593Smuzhiyun void i915_params_free(struct i915_params *params)
258*4882a593Smuzhiyun {
259*4882a593Smuzhiyun #define FREE(T, x, ...) free_param(#T, ¶ms->x);
260*4882a593Smuzhiyun I915_PARAMS_FOR_EACH(FREE);
261*4882a593Smuzhiyun #undef FREE
262*4882a593Smuzhiyun }
263