162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright © 2014 Intel Corporation 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the 662306a36Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 762306a36Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 862306a36Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 962306a36Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 1062306a36Sopenharmony_ci * the following conditions: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the 1362306a36Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 1462306a36Sopenharmony_ci * of the Software. 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1762306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1862306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1962306a36Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2062306a36Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2162306a36Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2262306a36Sopenharmony_ci * IN THE SOFTWARE. 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#include <linux/string_helpers.h> 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#include <drm/drm_print.h> 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#include "i915_params.h" 3062306a36Sopenharmony_ci#include "i915_drv.h" 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciDECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 3362306a36Sopenharmony_ci "DRM_UT_CORE", 3462306a36Sopenharmony_ci "DRM_UT_DRIVER", 3562306a36Sopenharmony_ci "DRM_UT_KMS", 3662306a36Sopenharmony_ci "DRM_UT_PRIME", 3762306a36Sopenharmony_ci "DRM_UT_ATOMIC", 3862306a36Sopenharmony_ci "DRM_UT_VBL", 3962306a36Sopenharmony_ci "DRM_UT_STATE", 4062306a36Sopenharmony_ci "DRM_UT_LEASE", 4162306a36Sopenharmony_ci "DRM_UT_DP", 4262306a36Sopenharmony_ci "DRM_UT_DRMRES"); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define i915_param_named(name, T, perm, desc) \ 4562306a36Sopenharmony_ci module_param_named(name, i915_modparams.name, T, perm); \ 4662306a36Sopenharmony_ci MODULE_PARM_DESC(name, desc) 4762306a36Sopenharmony_ci#define i915_param_named_unsafe(name, T, perm, desc) \ 4862306a36Sopenharmony_ci module_param_named_unsafe(name, i915_modparams.name, T, perm); \ 4962306a36Sopenharmony_ci MODULE_PARM_DESC(name, desc) 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cistruct i915_params i915_modparams __read_mostly = { 5262306a36Sopenharmony_ci#define MEMBER(T, member, value, ...) .member = (value), 5362306a36Sopenharmony_ci I915_PARAMS_FOR_EACH(MEMBER) 5462306a36Sopenharmony_ci#undef MEMBER 5562306a36Sopenharmony_ci}; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* 5862306a36Sopenharmony_ci * Note: As a rule, keep module parameter sysfs permissions read-only 5962306a36Sopenharmony_ci * 0400. Runtime changes are only supported through i915 debugfs. 6062306a36Sopenharmony_ci * 6162306a36Sopenharmony_ci * For any exceptions requiring write access and runtime changes through module 6262306a36Sopenharmony_ci * parameter sysfs, prevent debugfs file creation by setting the parameter's 6362306a36Sopenharmony_ci * debugfs mode to 0. 6462306a36Sopenharmony_ci */ 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_cii915_param_named(modeset, int, 0400, 6762306a36Sopenharmony_ci "Use kernel modesetting [KMS] (0=disable, " 6862306a36Sopenharmony_ci "1=on, -1=force vga console preference [default])"); 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_cii915_param_named_unsafe(enable_dc, int, 0400, 7162306a36Sopenharmony_ci "Enable power-saving display C-states. " 7262306a36Sopenharmony_ci "(-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6; " 7362306a36Sopenharmony_ci "3=up to DC5 with DC3CO; 4=up to DC6 with DC3CO)"); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cii915_param_named_unsafe(enable_fbc, int, 0400, 7662306a36Sopenharmony_ci "Enable frame buffer compression for power savings " 7762306a36Sopenharmony_ci "(default: -1 (use per-chip default))"); 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cii915_param_named_unsafe(lvds_channel_mode, int, 0400, 8062306a36Sopenharmony_ci "Specify LVDS channel mode " 8162306a36Sopenharmony_ci "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)"); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_cii915_param_named_unsafe(panel_use_ssc, int, 0400, 8462306a36Sopenharmony_ci "Use Spread Spectrum Clock with panels [LVDS/eDP] " 8562306a36Sopenharmony_ci "(default: auto from VBT)"); 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_cii915_param_named_unsafe(vbt_sdvo_panel_type, int, 0400, 8862306a36Sopenharmony_ci "Override/Ignore selection of SDVO panel mode in the VBT " 8962306a36Sopenharmony_ci "(-2=ignore, -1=auto [default], index in VBT BIOS table)"); 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_cii915_param_named_unsafe(reset, uint, 0400, 9262306a36Sopenharmony_ci "Attempt GPU resets (0=disabled, 1=full gpu reset, 2=engine reset [default])"); 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_cii915_param_named_unsafe(vbt_firmware, charp, 0400, 9562306a36Sopenharmony_ci "Load VBT from specified file under /lib/firmware"); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) 9862306a36Sopenharmony_cii915_param_named(error_capture, bool, 0400, 9962306a36Sopenharmony_ci "Record the GPU state following a hang. " 10062306a36Sopenharmony_ci "This information in /sys/class/drm/card<N>/error is vital for " 10162306a36Sopenharmony_ci "triaging and debugging hangs."); 10262306a36Sopenharmony_ci#endif 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cii915_param_named_unsafe(enable_hangcheck, bool, 0400, 10562306a36Sopenharmony_ci "Periodically check GPU activity for detecting hangs. " 10662306a36Sopenharmony_ci "WARNING: Disabling this can cause system wide hangs. " 10762306a36Sopenharmony_ci "(default: true)"); 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cii915_param_named_unsafe(enable_psr, int, 0400, 11062306a36Sopenharmony_ci "Enable PSR " 11162306a36Sopenharmony_ci "(0=disabled, 1=enable up to PSR1, 2=enable up to PSR2) " 11262306a36Sopenharmony_ci "Default: -1 (use per-chip default)"); 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_cii915_param_named(psr_safest_params, bool, 0400, 11562306a36Sopenharmony_ci "Replace PSR VBT parameters by the safest and not optimal ones. This " 11662306a36Sopenharmony_ci "is helpful to detect if PSR issues are related to bad values set in " 11762306a36Sopenharmony_ci " VBT. (0=use VBT parameters, 1=use safest parameters)"); 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_cii915_param_named_unsafe(enable_psr2_sel_fetch, bool, 0400, 12062306a36Sopenharmony_ci "Enable PSR2 selective fetch " 12162306a36Sopenharmony_ci "(0=disabled, 1=enabled) " 12262306a36Sopenharmony_ci "Default: 0"); 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_cii915_param_named_unsafe(enable_sagv, bool, 0600, 12562306a36Sopenharmony_ci "Enable system agent voltage/frequency scaling (SAGV) (default: true)"); 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_cii915_param_named_unsafe(force_probe, charp, 0400, 12862306a36Sopenharmony_ci "Force probe options for specified supported devices. " 12962306a36Sopenharmony_ci "See CONFIG_DRM_I915_FORCE_PROBE for details."); 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cii915_param_named_unsafe(disable_power_well, int, 0400, 13262306a36Sopenharmony_ci "Disable display power wells when possible " 13362306a36Sopenharmony_ci "(-1=auto [default], 0=power wells always on, 1=power wells disabled when possible)"); 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_cii915_param_named_unsafe(enable_ips, int, 0400, "Enable IPS (default: true)"); 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_cii915_param_named_unsafe(enable_dpt, bool, 0400, 13862306a36Sopenharmony_ci "Enable display page table (DPT) (default: true)"); 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cii915_param_named(fastboot, int, 0400, 14162306a36Sopenharmony_ci "Try to skip unnecessary mode sets at boot time " 14262306a36Sopenharmony_ci "(0=disabled, 1=enabled) " 14362306a36Sopenharmony_ci "Default: -1 (use per-chip default)"); 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cii915_param_named_unsafe(load_detect_test, bool, 0400, 14662306a36Sopenharmony_ci "Force-enable the VGA load detect code for testing (default:false). " 14762306a36Sopenharmony_ci "For developers only."); 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_cii915_param_named_unsafe(force_reset_modeset_test, bool, 0400, 15062306a36Sopenharmony_ci "Force a modeset during gpu reset for testing (default:false). " 15162306a36Sopenharmony_ci "For developers only."); 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_cii915_param_named_unsafe(invert_brightness, int, 0400, 15462306a36Sopenharmony_ci "Invert backlight brightness " 15562306a36Sopenharmony_ci "(-1 force normal, 0 machine defaults, 1 force inversion), please " 15662306a36Sopenharmony_ci "report PCI device ID, subsystem vendor and subsystem device ID " 15762306a36Sopenharmony_ci "to dri-devel@lists.freedesktop.org, if your machine needs it. " 15862306a36Sopenharmony_ci "It will then be included in an upcoming module version."); 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_cii915_param_named(disable_display, bool, 0400, 16162306a36Sopenharmony_ci "Disable display (default: false)"); 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_cii915_param_named(memtest, bool, 0400, 16462306a36Sopenharmony_ci "Perform a read/write test of all device memory on module load (default: off)"); 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_cii915_param_named(mmio_debug, int, 0400, 16762306a36Sopenharmony_ci "Enable the MMIO debug code for the first N failures (default: off). " 16862306a36Sopenharmony_ci "This may negatively affect performance."); 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci/* Special case writable file */ 17162306a36Sopenharmony_cii915_param_named(verbose_state_checks, bool, 0600, 17262306a36Sopenharmony_ci "Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions."); 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_cii915_param_named_unsafe(nuclear_pageflip, bool, 0400, 17562306a36Sopenharmony_ci "Force enable atomic functionality on platforms that don't have full support yet."); 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci/* WA to get away with the default setting in VBT for early platforms.Will be removed */ 17862306a36Sopenharmony_cii915_param_named_unsafe(edp_vswing, int, 0400, 17962306a36Sopenharmony_ci "Ignore/Override vswing pre-emph table selection from VBT " 18062306a36Sopenharmony_ci "(0=use value from vbt [default], 1=low power swing(200mV)," 18162306a36Sopenharmony_ci "2=default swing(400mV))"); 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_cii915_param_named_unsafe(enable_guc, int, 0400, 18462306a36Sopenharmony_ci "Enable GuC load for GuC submission and/or HuC load. " 18562306a36Sopenharmony_ci "Required functionality can be selected using bitmask values. " 18662306a36Sopenharmony_ci "(-1=auto [default], 0=disable, 1=GuC submission, 2=HuC load)"); 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_cii915_param_named(guc_log_level, int, 0400, 18962306a36Sopenharmony_ci "GuC firmware logging level. Requires GuC to be loaded. " 19062306a36Sopenharmony_ci "(-1=auto [default], 0=disable, 1..4=enable with verbosity min..max)"); 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_cii915_param_named_unsafe(guc_firmware_path, charp, 0400, 19362306a36Sopenharmony_ci "GuC firmware path to use instead of the default one"); 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_cii915_param_named_unsafe(huc_firmware_path, charp, 0400, 19662306a36Sopenharmony_ci "HuC firmware path to use instead of the default one"); 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_cii915_param_named_unsafe(dmc_firmware_path, charp, 0400, 19962306a36Sopenharmony_ci "DMC firmware path to use instead of the default one"); 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_cii915_param_named_unsafe(gsc_firmware_path, charp, 0400, 20262306a36Sopenharmony_ci "GSC firmware path to use instead of the default one"); 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_cii915_param_named_unsafe(enable_dp_mst, bool, 0400, 20562306a36Sopenharmony_ci "Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)"); 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_DRM_I915_DEBUG) 20862306a36Sopenharmony_cii915_param_named_unsafe(inject_probe_failure, uint, 0400, 20962306a36Sopenharmony_ci "Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point)"); 21062306a36Sopenharmony_ci#endif 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_cii915_param_named(enable_dpcd_backlight, int, 0400, 21362306a36Sopenharmony_ci "Enable support for DPCD backlight control" 21462306a36Sopenharmony_ci "(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enable, 2=force VESA interface, 3=force Intel interface)"); 21562306a36Sopenharmony_ci 21662306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_DRM_I915_GVT) 21762306a36Sopenharmony_cii915_param_named(enable_gvt, bool, 0400, 21862306a36Sopenharmony_ci "Enable support for Intel GVT-g graphics virtualization host support(default:false)"); 21962306a36Sopenharmony_ci#endif 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci#if CONFIG_DRM_I915_REQUEST_TIMEOUT 22262306a36Sopenharmony_cii915_param_named_unsafe(request_timeout_ms, uint, 0600, 22362306a36Sopenharmony_ci "Default request/fence/batch buffer expiration timeout."); 22462306a36Sopenharmony_ci#endif 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_cii915_param_named_unsafe(lmem_size, uint, 0400, 22762306a36Sopenharmony_ci "Set the lmem size(in MiB) for each region. (default: 0, all memory)"); 22862306a36Sopenharmony_cii915_param_named_unsafe(lmem_bar_size, uint, 0400, 22962306a36Sopenharmony_ci "Set the lmem bar size(in MiB)."); 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_cistatic void _param_print_bool(struct drm_printer *p, const char *name, 23262306a36Sopenharmony_ci bool val) 23362306a36Sopenharmony_ci{ 23462306a36Sopenharmony_ci drm_printf(p, "i915.%s=%s\n", name, str_yes_no(val)); 23562306a36Sopenharmony_ci} 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_cistatic void _param_print_int(struct drm_printer *p, const char *name, 23862306a36Sopenharmony_ci int val) 23962306a36Sopenharmony_ci{ 24062306a36Sopenharmony_ci drm_printf(p, "i915.%s=%d\n", name, val); 24162306a36Sopenharmony_ci} 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_cistatic void _param_print_uint(struct drm_printer *p, const char *name, 24462306a36Sopenharmony_ci unsigned int val) 24562306a36Sopenharmony_ci{ 24662306a36Sopenharmony_ci drm_printf(p, "i915.%s=%u\n", name, val); 24762306a36Sopenharmony_ci} 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_cistatic void _param_print_ulong(struct drm_printer *p, const char *name, 25062306a36Sopenharmony_ci unsigned long val) 25162306a36Sopenharmony_ci{ 25262306a36Sopenharmony_ci drm_printf(p, "i915.%s=%lu\n", name, val); 25362306a36Sopenharmony_ci} 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_cistatic void _param_print_charp(struct drm_printer *p, const char *name, 25662306a36Sopenharmony_ci const char *val) 25762306a36Sopenharmony_ci{ 25862306a36Sopenharmony_ci drm_printf(p, "i915.%s=%s\n", name, val); 25962306a36Sopenharmony_ci} 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci#define _param_print(p, name, val) \ 26262306a36Sopenharmony_ci _Generic(val, \ 26362306a36Sopenharmony_ci bool: _param_print_bool, \ 26462306a36Sopenharmony_ci int: _param_print_int, \ 26562306a36Sopenharmony_ci unsigned int: _param_print_uint, \ 26662306a36Sopenharmony_ci unsigned long: _param_print_ulong, \ 26762306a36Sopenharmony_ci char *: _param_print_charp)(p, name, val) 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci/** 27062306a36Sopenharmony_ci * i915_params_dump - dump i915 modparams 27162306a36Sopenharmony_ci * @params: i915 modparams 27262306a36Sopenharmony_ci * @p: the &drm_printer 27362306a36Sopenharmony_ci * 27462306a36Sopenharmony_ci * Pretty printer for i915 modparams. 27562306a36Sopenharmony_ci */ 27662306a36Sopenharmony_civoid i915_params_dump(const struct i915_params *params, struct drm_printer *p) 27762306a36Sopenharmony_ci{ 27862306a36Sopenharmony_ci#define PRINT(T, x, ...) _param_print(p, #x, params->x); 27962306a36Sopenharmony_ci I915_PARAMS_FOR_EACH(PRINT); 28062306a36Sopenharmony_ci#undef PRINT 28162306a36Sopenharmony_ci} 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_cistatic void _param_dup_charp(char **valp) 28462306a36Sopenharmony_ci{ 28562306a36Sopenharmony_ci *valp = kstrdup(*valp, GFP_ATOMIC); 28662306a36Sopenharmony_ci} 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_cistatic void _param_nop(void *valp) 28962306a36Sopenharmony_ci{ 29062306a36Sopenharmony_ci} 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci#define _param_dup(valp) \ 29362306a36Sopenharmony_ci _Generic(valp, \ 29462306a36Sopenharmony_ci char **: _param_dup_charp, \ 29562306a36Sopenharmony_ci default: _param_nop)(valp) 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_civoid i915_params_copy(struct i915_params *dest, const struct i915_params *src) 29862306a36Sopenharmony_ci{ 29962306a36Sopenharmony_ci *dest = *src; 30062306a36Sopenharmony_ci#define DUP(T, x, ...) _param_dup(&dest->x); 30162306a36Sopenharmony_ci I915_PARAMS_FOR_EACH(DUP); 30262306a36Sopenharmony_ci#undef DUP 30362306a36Sopenharmony_ci} 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_cistatic void _param_free_charp(char **valp) 30662306a36Sopenharmony_ci{ 30762306a36Sopenharmony_ci kfree(*valp); 30862306a36Sopenharmony_ci *valp = NULL; 30962306a36Sopenharmony_ci} 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci#define _param_free(valp) \ 31262306a36Sopenharmony_ci _Generic(valp, \ 31362306a36Sopenharmony_ci char **: _param_free_charp, \ 31462306a36Sopenharmony_ci default: _param_nop)(valp) 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci/* free the allocated members, *not* the passed in params itself */ 31762306a36Sopenharmony_civoid i915_params_free(struct i915_params *params) 31862306a36Sopenharmony_ci{ 31962306a36Sopenharmony_ci#define FREE(T, x, ...) _param_free(¶ms->x); 32062306a36Sopenharmony_ci I915_PARAMS_FOR_EACH(FREE); 32162306a36Sopenharmony_ci#undef FREE 32262306a36Sopenharmony_ci} 323