forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/gpu/drm/i915/i915_params.c
....@@ -35,10 +35,19 @@
3535 MODULE_PARM_DESC(name, desc)
3636
3737 struct i915_params i915_modparams __read_mostly = {
38
-#define MEMBER(T, member, value) .member = (value),
38
+#define MEMBER(T, member, value, ...) .member = (value),
3939 I915_PARAMS_FOR_EACH(MEMBER)
4040 #undef MEMBER
4141 };
42
+
43
+/*
44
+ * Note: As a rule, keep module parameter sysfs permissions read-only
45
+ * 0400. Runtime changes are only supported through i915 debugfs.
46
+ *
47
+ * For any exceptions requiring write access and runtime changes through module
48
+ * parameter sysfs, prevent debugfs file creation by setting the parameter's
49
+ * debugfs mode to 0.
50
+ */
4251
4352 i915_param_named(modeset, int, 0400,
4453 "Use kernel modesetting [KMS] (0=disable, "
....@@ -46,9 +55,10 @@
4655
4756 i915_param_named_unsafe(enable_dc, int, 0400,
4857 "Enable power-saving display C-states. "
49
- "(-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6)");
58
+ "(-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6; "
59
+ "3=up to DC5 with DC3CO; 4=up to DC6 with DC3CO)");
5060
51
-i915_param_named_unsafe(enable_fbc, int, 0600,
61
+i915_param_named_unsafe(enable_fbc, int, 0400,
5262 "Enable frame buffer compression for power savings "
5363 "(default: -1 (use per-chip default))");
5464
....@@ -56,7 +66,7 @@
5666 "Specify LVDS channel mode "
5767 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
5868
59
-i915_param_named_unsafe(panel_use_ssc, int, 0600,
69
+i915_param_named_unsafe(panel_use_ssc, int, 0400,
6070 "Use Spread Spectrum Clock with panels [LVDS/eDP] "
6171 "(default: auto from VBT)");
6272
....@@ -64,59 +74,63 @@
6474 "Override/Ignore selection of SDVO panel mode in the VBT "
6575 "(-2=ignore, -1=auto [default], index in VBT BIOS table)");
6676
67
-i915_param_named_unsafe(reset, int, 0600,
77
+i915_param_named_unsafe(reset, uint, 0400,
6878 "Attempt GPU resets (0=disabled, 1=full gpu reset, 2=engine reset [default])");
6979
7080 i915_param_named_unsafe(vbt_firmware, charp, 0400,
7181 "Load VBT from specified file under /lib/firmware");
7282
7383 #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
74
-i915_param_named(error_capture, bool, 0600,
84
+i915_param_named(error_capture, bool, 0400,
7585 "Record the GPU state following a hang. "
7686 "This information in /sys/class/drm/card<N>/error is vital for "
7787 "triaging and debugging hangs.");
7888 #endif
7989
80
-i915_param_named_unsafe(enable_hangcheck, bool, 0644,
90
+i915_param_named_unsafe(enable_hangcheck, bool, 0400,
8191 "Periodically check GPU activity for detecting hangs. "
8292 "WARNING: Disabling this can cause system wide hangs. "
8393 "(default: true)");
8494
85
-i915_param_named_unsafe(enable_ppgtt, int, 0400,
86
- "Override PPGTT usage. "
87
- "(-1=auto [default], 0=disabled, 1=aliasing, 2=full, 3=full with extended address space)");
88
-
89
-i915_param_named_unsafe(enable_psr, int, 0600,
95
+i915_param_named_unsafe(enable_psr, int, 0400,
9096 "Enable PSR "
9197 "(0=disabled, 1=enabled) "
9298 "Default: -1 (use per-chip default)");
9399
94
-i915_param_named_unsafe(alpha_support, bool, 0400,
95
- "Enable alpha quality driver support for latest hardware. "
96
- "See also CONFIG_DRM_I915_ALPHA_SUPPORT.");
100
+i915_param_named(psr_safest_params, bool, 0400,
101
+ "Replace PSR VBT parameters by the safest and not optimal ones. This "
102
+ "is helpful to detect if PSR issues are related to bad values set in "
103
+ " VBT. (0=use VBT parameters, 1=use safest parameters)");
104
+
105
+i915_param_named_unsafe(enable_psr2_sel_fetch, bool, 0400,
106
+ "Enable PSR2 selective fetch "
107
+ "(0=disabled, 1=enabled) "
108
+ "Default: 0");
109
+
110
+i915_param_named_unsafe(force_probe, charp, 0400,
111
+ "Force probe the driver for specified devices. "
112
+ "See CONFIG_DRM_I915_FORCE_PROBE for details.");
97113
98114 i915_param_named_unsafe(disable_power_well, int, 0400,
99115 "Disable display power wells when possible "
100116 "(-1=auto [default], 0=power wells always on, 1=power wells disabled when possible)");
101117
102
-i915_param_named_unsafe(enable_ips, int, 0600, "Enable IPS (default: true)");
118
+i915_param_named_unsafe(enable_ips, int, 0400, "Enable IPS (default: true)");
103119
104
-i915_param_named(fastboot, bool, 0600,
105
- "Try to skip unnecessary mode sets at boot time (default: false)");
120
+i915_param_named(fastboot, int, 0400,
121
+ "Try to skip unnecessary mode sets at boot time "
122
+ "(0=disabled, 1=enabled) "
123
+ "Default: -1 (use per-chip default)");
106124
107
-i915_param_named_unsafe(prefault_disable, bool, 0600,
108
- "Disable page prefaulting for pread/pwrite/reloc (default:false). "
109
- "For developers only.");
110
-
111
-i915_param_named_unsafe(load_detect_test, bool, 0600,
125
+i915_param_named_unsafe(load_detect_test, bool, 0400,
112126 "Force-enable the VGA load detect code for testing (default:false). "
113127 "For developers only.");
114128
115
-i915_param_named_unsafe(force_reset_modeset_test, bool, 0600,
129
+i915_param_named_unsafe(force_reset_modeset_test, bool, 0400,
116130 "Force a modeset during gpu reset for testing (default:false). "
117131 "For developers only.");
118132
119
-i915_param_named_unsafe(invert_brightness, int, 0600,
133
+i915_param_named_unsafe(invert_brightness, int, 0400,
120134 "Invert backlight brightness "
121135 "(-1 force normal, 0 machine defaults, 1 force inversion), please "
122136 "report PCI device ID, subsystem vendor and subsystem device ID "
....@@ -126,10 +140,11 @@
126140 i915_param_named(disable_display, bool, 0400,
127141 "Disable display (default: false)");
128142
129
-i915_param_named(mmio_debug, int, 0600,
143
+i915_param_named(mmio_debug, int, 0400,
130144 "Enable the MMIO debug code for the first N failures (default: off). "
131145 "This may negatively affect performance.");
132146
147
+/* Special case writable file */
133148 i915_param_named(verbose_state_checks, bool, 0600,
134149 "Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions.");
135150
....@@ -160,19 +175,27 @@
160175 i915_param_named_unsafe(dmc_firmware_path, charp, 0400,
161176 "DMC firmware path to use instead of the default one");
162177
163
-i915_param_named_unsafe(enable_dp_mst, bool, 0600,
178
+i915_param_named_unsafe(enable_dp_mst, bool, 0400,
164179 "Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)");
165180
166181 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
167
-i915_param_named_unsafe(inject_load_failure, uint, 0400,
182
+i915_param_named_unsafe(inject_probe_failure, uint, 0400,
168183 "Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point)");
169184 #endif
170185
171
-i915_param_named(enable_dpcd_backlight, bool, 0600,
172
- "Enable support for DPCD backlight control (default:false)");
186
+i915_param_named(enable_dpcd_backlight, int, 0400,
187
+ "Enable support for DPCD backlight control"
188
+ "(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enabled)");
173189
190
+#if IS_ENABLED(CONFIG_DRM_I915_GVT)
174191 i915_param_named(enable_gvt, bool, 0400,
175192 "Enable support for Intel GVT-g graphics virtualization host support(default:false)");
193
+#endif
194
+
195
+#if IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)
196
+i915_param_named_unsafe(fake_lmem_start, ulong, 0400,
197
+ "Fake LMEM start offset (default: 0)");
198
+#endif
176199
177200 static __always_inline void _print_param(struct drm_printer *p,
178201 const char *name,
....@@ -185,10 +208,13 @@
185208 drm_printf(p, "i915.%s=%d\n", name, *(const int *)x);
186209 else if (!__builtin_strcmp(type, "unsigned int"))
187210 drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x);
211
+ else if (!__builtin_strcmp(type, "unsigned long"))
212
+ drm_printf(p, "i915.%s=%lu\n", name, *(const unsigned long *)x);
188213 else if (!__builtin_strcmp(type, "char *"))
189214 drm_printf(p, "i915.%s=%s\n", name, *(const char **)x);
190215 else
191
- BUILD_BUG();
216
+ WARN_ONCE(1, "no printer defined for param type %s (i915.%s)\n",
217
+ type, name);
192218 }
193219
194220 /**
....@@ -204,3 +230,33 @@
204230 I915_PARAMS_FOR_EACH(PRINT);
205231 #undef PRINT
206232 }
233
+
234
+static __always_inline void dup_param(const char *type, void *x)
235
+{
236
+ if (!__builtin_strcmp(type, "char *"))
237
+ *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC);
238
+}
239
+
240
+void i915_params_copy(struct i915_params *dest, const struct i915_params *src)
241
+{
242
+ *dest = *src;
243
+#define DUP(T, x, ...) dup_param(#T, &dest->x);
244
+ I915_PARAMS_FOR_EACH(DUP);
245
+#undef DUP
246
+}
247
+
248
+static __always_inline void free_param(const char *type, void *x)
249
+{
250
+ if (!__builtin_strcmp(type, "char *")) {
251
+ kfree(*(void **)x);
252
+ *(void **)x = NULL;
253
+ }
254
+}
255
+
256
+/* free the allocated members, *not* the passed in params itself */
257
+void i915_params_free(struct i915_params *params)
258
+{
259
+#define FREE(T, x, ...) free_param(#T, &params->x);
260
+ I915_PARAMS_FOR_EACH(FREE);
261
+#undef FREE
262
+}