Changes in 4.9.185 tracing: Silence GCC 9 array bounds warning gcc-9: silence 'address-of-packed-member' warning scsi: ufs: Avoid runtime suspend possibly being blocked forever usb: chipidea: udc: workaround for endpoint conflict issue IB/hfi1: Silence txreq allocation warnings Input: uinput - add compat ioctl number translation for UI_*_FF_UPLOAD apparmor: enforce nullbyte at end of tag string ARC: fix build warnings with !CONFIG_KPROBES parport: Fix mem leak in parport_register_dev_model parisc: Fix compiler warnings in float emulation code IB/rdmavt: Fix alloc_qpn() WARN_ON() IB/hfi1: Insure freeze_work work_struct is canceled on shutdown IB/{qib, hfi1, rdmavt}: Correct ibv_devinfo max_mr value MIPS: uprobes: remove set but not used variable 'epc' net: dsa: mv88e6xxx: avoid error message on remove from VLAN 0 net: hns: Fix loopback test failed at copper ports sparc: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD net: ethernet: mediatek: Use hw_feature to judge if HWLRO is supported net: ethernet: mediatek: Use NET_IP_ALIGN to judge if HW RX_2BYTE_OFFSET is enabled drm/arm/hdlcd: Allow a bit of clock tolerance scripts/checkstack.pl: Fix arm64 wrong or unknown architecture scsi: ufs: Check that space was properly alloced in copy_query_response s390/qeth: fix VLAN attribute in bridge_hostnotify udev event hwmon: (pmbus/core) Treat parameters as paged if on multiple pages nvme: Fix u32 overflow in the number of namespace list calculation btrfs: start readahead also in seed devices can: flexcan: fix timeout when set small bitrate can: purge socket error queue on sock destruct powerpc/bpf: use unsigned division instruction for 64-bit operations ARM: imx: cpuidle-imx6sx: Restrict the SW2ISO increase to i.MX6SX Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Bluetooth: Fix regression with minimum encryption key size alignment cfg80211: fix memory leak of wiphy device name mac80211: drop robust management frames from unknown TA mac80211: Do not use stack memory with scatterlist for GMAC IB/hfi1: Avoid hardlockup with flushlist_lock perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul perf help: Remove needless use of strncpy() perf header: Fix unchecked usage of strncpy() 9p/rdma: do not disconnect on down_interruptible EAGAIN 9p: acl: fix uninitialized iattr access 9p/rdma: remove useless check in cm_event_handler 9p: p9dirent_read: check network-provided name length net/9p: include trans_common.h to fix missing prototype warning. fs/proc/array.c: allow reporting eip/esp for all coredumping threads fs/binfmt_flat.c: make load_flat_shared_library() work mm/page_idle.c: fix oops because end_pfn is larger than max_pfn scsi: vmw_pscsi: Fix use-after-free in pvscsi_queue_lck() x86/speculation: Allow guests to use SSBD even if host does not NFS/flexfiles: Use the correct TCP timeout for flexfiles I/O cpu/speculation: Warn on unsupported mitigations= parameter af_packet: Block execution of tasks waiting for transmit to complete in AF_PACKET net: stmmac: fixed new system time seconds value calculation sctp: change to hold sk after auth shkey is created successfully tipc: change to use register_pernet_device tipc: check msg->req data len in tipc_nl_compat_bearer_disable tun: wake up waitqueues after IFF_UP is set team: Always enable vlan tx offload bonding: Always enable vlan tx offload ipv4: Use return value of inet_iif() for __raw_v4_lookup in the while loop bpf: udp: Avoid calling reuseport's bpf_prog from udp_gro bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err tipc: pass tunnel dev as NULL to udp_tunnel(6)_xmit_skb Bluetooth: Fix faulty expression for minimum encryption key size check ASoC : cs4265 : readable register too low ASoC: soc-pcm: BE dai needs prepare when pause release after resume spi: bitbang: Fix NULL pointer dereference in spi_unregister_master drm/mediatek: fix unbind functions ASoC: max98090: remove 24-bit format support if RJ is 0 usb: gadget: fusb300_udc: Fix memory leak of fusb300->ep[i] usb: gadget: udc: lpc32xx: allocate descriptor with GFP_ATOMIC scsi: hpsa: correct ioaccel2 chaining scripts/decode_stacktrace.sh: prefix addr2line with $CROSS_COMPILE mm/mlock.c: change count_mm_mlocked_page_nr return type MIPS: math-emu: do not use bools for arithmetic MIPS: netlogic: xlr: Remove erroneous check in nlm_fmn_send() mfd: omap-usb-tll: Fix register offsets ARC: fix allnoconfig build warning bug.h: work around GCC PR82365 in BUG() ARC: handle gcc generated __builtin_trap for older compiler clk: sunxi: fix uninitialized access KVM: x86: degrade WARN to pr_warn_ratelimited drm/i915/dmc: protect against reading random memory MIPS: Workaround GCC __builtin_unreachable reordering bug ptrace: Fix ->ptracer_cred handling for PTRACE_TRACEME crypto: user - prevent operating on larval algorithms ALSA: seq: fix incorrect order of dest_client/dest_ports arguments ALSA: firewire-lib/fireworks: fix miss detection of received MIDI messages ALSA: line6: Fix write on zero-sized buffer ALSA: usb-audio: fix sign unintended sign extension on left shifts lib/mpi: Fix karactx leak in mpi_powm drm/imx: notify drm core before sending event during crtc disable drm/imx: only send event on crtc disable if kept disabled btrfs: Ensure replaced device doesn't have pending chunk allocation tty: rocket: fix incorrect forward declaration of 'rp_init()' arm64, vdso: Define vdso_{start,end} as array KVM: LAPIC: Fix pending interrupt in IRR blocked by software disable LAPIC IB/hfi1: Close PSM sdma_progress sleep window MIPS: Add missing EHB in mtc0 -> mfc0 sequence. dmaengine: imx-sdma: remove BD_INTR for channel0 arm64: kaslr: keep modules inside module region when KASAN is enabled Linux 4.9.185 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
543 lines
14 KiB
C
543 lines
14 KiB
C
/*
|
|
* Copyright © 2014 Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
#include <linux/firmware.h>
|
|
#include "i915_drv.h"
|
|
#include "i915_reg.h"
|
|
|
|
/**
|
|
* DOC: csr support for dmc
|
|
*
|
|
* Display Context Save and Restore (CSR) firmware support added from gen9
|
|
* onwards to drive newly added DMC (Display microcontroller) in display
|
|
* engine to save and restore the state of display engine when it enter into
|
|
* low-power state and comes back to normal.
|
|
*/
|
|
|
|
#define I915_CSR_KBL "i915/kbl_dmc_ver1_01.bin"
|
|
MODULE_FIRMWARE(I915_CSR_KBL);
|
|
#define KBL_CSR_VERSION_REQUIRED CSR_VERSION(1, 1)
|
|
|
|
#define I915_CSR_SKL "i915/skl_dmc_ver1_26.bin"
|
|
MODULE_FIRMWARE(I915_CSR_SKL);
|
|
#define SKL_CSR_VERSION_REQUIRED CSR_VERSION(1, 26)
|
|
|
|
#define I915_CSR_BXT "i915/bxt_dmc_ver1_07.bin"
|
|
MODULE_FIRMWARE(I915_CSR_BXT);
|
|
#define BXT_CSR_VERSION_REQUIRED CSR_VERSION(1, 7)
|
|
|
|
#define FIRMWARE_URL "https://01.org/linuxgraphics/intel-linux-graphics-firmwares"
|
|
|
|
|
|
|
|
|
|
#define CSR_MAX_FW_SIZE 0x2FFF
|
|
#define CSR_DEFAULT_FW_OFFSET 0xFFFFFFFF
|
|
|
|
struct intel_css_header {
|
|
/* 0x09 for DMC */
|
|
uint32_t module_type;
|
|
|
|
/* Includes the DMC specific header in dwords */
|
|
uint32_t header_len;
|
|
|
|
/* always value would be 0x10000 */
|
|
uint32_t header_ver;
|
|
|
|
/* Not used */
|
|
uint32_t module_id;
|
|
|
|
/* Not used */
|
|
uint32_t module_vendor;
|
|
|
|
/* in YYYYMMDD format */
|
|
uint32_t date;
|
|
|
|
/* Size in dwords (CSS_Headerlen + PackageHeaderLen + dmc FWsLen)/4 */
|
|
uint32_t size;
|
|
|
|
/* Not used */
|
|
uint32_t key_size;
|
|
|
|
/* Not used */
|
|
uint32_t modulus_size;
|
|
|
|
/* Not used */
|
|
uint32_t exponent_size;
|
|
|
|
/* Not used */
|
|
uint32_t reserved1[12];
|
|
|
|
/* Major Minor */
|
|
uint32_t version;
|
|
|
|
/* Not used */
|
|
uint32_t reserved2[8];
|
|
|
|
/* Not used */
|
|
uint32_t kernel_header_info;
|
|
} __packed;
|
|
|
|
struct intel_fw_info {
|
|
uint16_t reserved1;
|
|
|
|
/* Stepping (A, B, C, ..., *). * is a wildcard */
|
|
char stepping;
|
|
|
|
/* Sub-stepping (0, 1, ..., *). * is a wildcard */
|
|
char substepping;
|
|
|
|
uint32_t offset;
|
|
uint32_t reserved2;
|
|
} __packed;
|
|
|
|
struct intel_package_header {
|
|
/* DMC container header length in dwords */
|
|
unsigned char header_len;
|
|
|
|
/* always value would be 0x01 */
|
|
unsigned char header_ver;
|
|
|
|
unsigned char reserved[10];
|
|
|
|
/* Number of valid entries in the FWInfo array below */
|
|
uint32_t num_entries;
|
|
|
|
struct intel_fw_info fw_info[20];
|
|
} __packed;
|
|
|
|
struct intel_dmc_header {
|
|
/* always value would be 0x40403E3E */
|
|
uint32_t signature;
|
|
|
|
/* DMC binary header length */
|
|
unsigned char header_len;
|
|
|
|
/* 0x01 */
|
|
unsigned char header_ver;
|
|
|
|
/* Reserved */
|
|
uint16_t dmcc_ver;
|
|
|
|
/* Major, Minor */
|
|
uint32_t project;
|
|
|
|
/* Firmware program size (excluding header) in dwords */
|
|
uint32_t fw_size;
|
|
|
|
/* Major Minor version */
|
|
uint32_t fw_version;
|
|
|
|
/* Number of valid MMIO cycles present. */
|
|
uint32_t mmio_count;
|
|
|
|
/* MMIO address */
|
|
uint32_t mmioaddr[8];
|
|
|
|
/* MMIO data */
|
|
uint32_t mmiodata[8];
|
|
|
|
/* FW filename */
|
|
unsigned char dfile[32];
|
|
|
|
uint32_t reserved1[2];
|
|
} __packed;
|
|
|
|
struct stepping_info {
|
|
char stepping;
|
|
char substepping;
|
|
};
|
|
|
|
static const struct stepping_info kbl_stepping_info[] = {
|
|
{'A', '0'}, {'B', '0'}, {'C', '0'},
|
|
{'D', '0'}, {'E', '0'}, {'F', '0'},
|
|
{'G', '0'}, {'H', '0'}, {'I', '0'},
|
|
};
|
|
|
|
static const struct stepping_info skl_stepping_info[] = {
|
|
{'A', '0'}, {'B', '0'}, {'C', '0'},
|
|
{'D', '0'}, {'E', '0'}, {'F', '0'},
|
|
{'G', '0'}, {'H', '0'}, {'I', '0'},
|
|
{'J', '0'}, {'K', '0'}
|
|
};
|
|
|
|
static const struct stepping_info bxt_stepping_info[] = {
|
|
{'A', '0'}, {'A', '1'}, {'A', '2'},
|
|
{'B', '0'}, {'B', '1'}, {'B', '2'}
|
|
};
|
|
|
|
static const struct stepping_info no_stepping_info = { '*', '*' };
|
|
|
|
static const struct stepping_info *
|
|
intel_get_stepping_info(struct drm_i915_private *dev_priv)
|
|
{
|
|
const struct stepping_info *si;
|
|
unsigned int size;
|
|
|
|
if (IS_KABYLAKE(dev_priv)) {
|
|
size = ARRAY_SIZE(kbl_stepping_info);
|
|
si = kbl_stepping_info;
|
|
} else if (IS_SKYLAKE(dev_priv)) {
|
|
size = ARRAY_SIZE(skl_stepping_info);
|
|
si = skl_stepping_info;
|
|
} else if (IS_BROXTON(dev_priv)) {
|
|
size = ARRAY_SIZE(bxt_stepping_info);
|
|
si = bxt_stepping_info;
|
|
} else {
|
|
size = 0;
|
|
}
|
|
|
|
if (INTEL_REVID(dev_priv) < size)
|
|
return si + INTEL_REVID(dev_priv);
|
|
|
|
return &no_stepping_info;
|
|
}
|
|
|
|
static void gen9_set_dc_state_debugmask(struct drm_i915_private *dev_priv)
|
|
{
|
|
uint32_t val, mask;
|
|
|
|
mask = DC_STATE_DEBUG_MASK_MEMORY_UP;
|
|
|
|
if (IS_BROXTON(dev_priv))
|
|
mask |= DC_STATE_DEBUG_MASK_CORES;
|
|
|
|
/* The below bit doesn't need to be cleared ever afterwards */
|
|
val = I915_READ(DC_STATE_DEBUG);
|
|
if ((val & mask) != mask) {
|
|
val |= mask;
|
|
I915_WRITE(DC_STATE_DEBUG, val);
|
|
POSTING_READ(DC_STATE_DEBUG);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* intel_csr_load_program() - write the firmware from memory to register.
|
|
* @dev_priv: i915 drm device.
|
|
*
|
|
* CSR firmware is read from a .bin file and kept in internal memory one time.
|
|
* Everytime display comes back from low power state this function is called to
|
|
* copy the firmware from internal memory to registers.
|
|
*/
|
|
void intel_csr_load_program(struct drm_i915_private *dev_priv)
|
|
{
|
|
u32 *payload = dev_priv->csr.dmc_payload;
|
|
uint32_t i, fw_size;
|
|
|
|
if (!IS_GEN9(dev_priv)) {
|
|
DRM_ERROR("No CSR support available for this platform\n");
|
|
return;
|
|
}
|
|
|
|
if (!dev_priv->csr.dmc_payload) {
|
|
DRM_ERROR("Tried to program CSR with empty payload\n");
|
|
return;
|
|
}
|
|
|
|
fw_size = dev_priv->csr.dmc_fw_size;
|
|
for (i = 0; i < fw_size; i++)
|
|
I915_WRITE(CSR_PROGRAM(i), payload[i]);
|
|
|
|
for (i = 0; i < dev_priv->csr.mmio_count; i++) {
|
|
I915_WRITE(dev_priv->csr.mmioaddr[i],
|
|
dev_priv->csr.mmiodata[i]);
|
|
}
|
|
|
|
dev_priv->csr.dc_state = 0;
|
|
|
|
gen9_set_dc_state_debugmask(dev_priv);
|
|
}
|
|
|
|
static uint32_t *parse_csr_fw(struct drm_i915_private *dev_priv,
|
|
const struct firmware *fw)
|
|
{
|
|
struct intel_css_header *css_header;
|
|
struct intel_package_header *package_header;
|
|
struct intel_dmc_header *dmc_header;
|
|
struct intel_csr *csr = &dev_priv->csr;
|
|
const struct stepping_info *si = intel_get_stepping_info(dev_priv);
|
|
uint32_t dmc_offset = CSR_DEFAULT_FW_OFFSET, readcount = 0, nbytes;
|
|
uint32_t i;
|
|
uint32_t *dmc_payload;
|
|
uint32_t required_version;
|
|
size_t fsize;
|
|
|
|
if (!fw)
|
|
return NULL;
|
|
|
|
fsize = sizeof(struct intel_css_header) +
|
|
sizeof(struct intel_package_header) +
|
|
sizeof(struct intel_dmc_header);
|
|
if (fsize > fw->size)
|
|
goto error_truncated;
|
|
|
|
/* Extract CSS Header information*/
|
|
css_header = (struct intel_css_header *)fw->data;
|
|
if (sizeof(struct intel_css_header) !=
|
|
(css_header->header_len * 4)) {
|
|
DRM_ERROR("Firmware has wrong CSS header length %u bytes\n",
|
|
(css_header->header_len * 4));
|
|
return NULL;
|
|
}
|
|
|
|
csr->version = css_header->version;
|
|
|
|
if (IS_KABYLAKE(dev_priv)) {
|
|
required_version = KBL_CSR_VERSION_REQUIRED;
|
|
} else if (IS_SKYLAKE(dev_priv)) {
|
|
required_version = SKL_CSR_VERSION_REQUIRED;
|
|
} else if (IS_BROXTON(dev_priv)) {
|
|
required_version = BXT_CSR_VERSION_REQUIRED;
|
|
} else {
|
|
MISSING_CASE(INTEL_REVID(dev_priv));
|
|
required_version = 0;
|
|
}
|
|
|
|
if (csr->version != required_version) {
|
|
DRM_INFO("Refusing to load DMC firmware v%u.%u,"
|
|
" please use v%u.%u [" FIRMWARE_URL "].\n",
|
|
CSR_VERSION_MAJOR(csr->version),
|
|
CSR_VERSION_MINOR(csr->version),
|
|
CSR_VERSION_MAJOR(required_version),
|
|
CSR_VERSION_MINOR(required_version));
|
|
return NULL;
|
|
}
|
|
|
|
readcount += sizeof(struct intel_css_header);
|
|
|
|
/* Extract Package Header information*/
|
|
package_header = (struct intel_package_header *)
|
|
&fw->data[readcount];
|
|
if (sizeof(struct intel_package_header) !=
|
|
(package_header->header_len * 4)) {
|
|
DRM_ERROR("Firmware has wrong package header length %u bytes\n",
|
|
(package_header->header_len * 4));
|
|
return NULL;
|
|
}
|
|
readcount += sizeof(struct intel_package_header);
|
|
|
|
/* Search for dmc_offset to find firware binary. */
|
|
for (i = 0; i < package_header->num_entries; i++) {
|
|
if (package_header->fw_info[i].substepping == '*' &&
|
|
si->stepping == package_header->fw_info[i].stepping) {
|
|
dmc_offset = package_header->fw_info[i].offset;
|
|
break;
|
|
} else if (si->stepping == package_header->fw_info[i].stepping &&
|
|
si->substepping == package_header->fw_info[i].substepping) {
|
|
dmc_offset = package_header->fw_info[i].offset;
|
|
break;
|
|
} else if (package_header->fw_info[i].stepping == '*' &&
|
|
package_header->fw_info[i].substepping == '*')
|
|
dmc_offset = package_header->fw_info[i].offset;
|
|
}
|
|
if (dmc_offset == CSR_DEFAULT_FW_OFFSET) {
|
|
DRM_ERROR("Firmware not supported for %c stepping\n",
|
|
si->stepping);
|
|
return NULL;
|
|
}
|
|
readcount += dmc_offset;
|
|
fsize += dmc_offset;
|
|
if (fsize > fw->size)
|
|
goto error_truncated;
|
|
|
|
/* Extract dmc_header information. */
|
|
dmc_header = (struct intel_dmc_header *)&fw->data[readcount];
|
|
if (sizeof(struct intel_dmc_header) != (dmc_header->header_len)) {
|
|
DRM_ERROR("Firmware has wrong dmc header length %u bytes\n",
|
|
(dmc_header->header_len));
|
|
return NULL;
|
|
}
|
|
readcount += sizeof(struct intel_dmc_header);
|
|
|
|
/* Cache the dmc header info. */
|
|
if (dmc_header->mmio_count > ARRAY_SIZE(csr->mmioaddr)) {
|
|
DRM_ERROR("Firmware has wrong mmio count %u\n",
|
|
dmc_header->mmio_count);
|
|
return NULL;
|
|
}
|
|
csr->mmio_count = dmc_header->mmio_count;
|
|
for (i = 0; i < dmc_header->mmio_count; i++) {
|
|
if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
|
|
dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
|
|
DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
|
|
dmc_header->mmioaddr[i]);
|
|
return NULL;
|
|
}
|
|
csr->mmioaddr[i] = _MMIO(dmc_header->mmioaddr[i]);
|
|
csr->mmiodata[i] = dmc_header->mmiodata[i];
|
|
}
|
|
|
|
/* fw_size is in dwords, so multiplied by 4 to convert into bytes. */
|
|
nbytes = dmc_header->fw_size * 4;
|
|
fsize += nbytes;
|
|
if (fsize > fw->size)
|
|
goto error_truncated;
|
|
|
|
if (nbytes > CSR_MAX_FW_SIZE) {
|
|
DRM_ERROR("CSR firmware too big (%u) bytes\n", nbytes);
|
|
return NULL;
|
|
}
|
|
csr->dmc_fw_size = dmc_header->fw_size;
|
|
|
|
dmc_payload = kmalloc(nbytes, GFP_KERNEL);
|
|
if (!dmc_payload) {
|
|
DRM_ERROR("Memory allocation failed for dmc payload\n");
|
|
return NULL;
|
|
}
|
|
|
|
return memcpy(dmc_payload, &fw->data[readcount], nbytes);
|
|
|
|
error_truncated:
|
|
DRM_ERROR("Truncated DMC firmware, rejecting.\n");
|
|
return NULL;
|
|
}
|
|
|
|
static void csr_load_work_fn(struct work_struct *work)
|
|
{
|
|
struct drm_i915_private *dev_priv;
|
|
struct intel_csr *csr;
|
|
const struct firmware *fw;
|
|
int ret;
|
|
|
|
dev_priv = container_of(work, typeof(*dev_priv), csr.work);
|
|
csr = &dev_priv->csr;
|
|
|
|
ret = request_firmware(&fw, dev_priv->csr.fw_path,
|
|
&dev_priv->drm.pdev->dev);
|
|
if (fw)
|
|
dev_priv->csr.dmc_payload = parse_csr_fw(dev_priv, fw);
|
|
|
|
if (dev_priv->csr.dmc_payload) {
|
|
intel_csr_load_program(dev_priv);
|
|
|
|
intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
|
|
|
|
DRM_INFO("Finished loading %s (v%u.%u)\n",
|
|
dev_priv->csr.fw_path,
|
|
CSR_VERSION_MAJOR(csr->version),
|
|
CSR_VERSION_MINOR(csr->version));
|
|
} else {
|
|
dev_notice(dev_priv->drm.dev,
|
|
"Failed to load DMC firmware"
|
|
" [" FIRMWARE_URL "],"
|
|
" disabling runtime power management.\n");
|
|
}
|
|
|
|
release_firmware(fw);
|
|
}
|
|
|
|
/**
|
|
* intel_csr_ucode_init() - initialize the firmware loading.
|
|
* @dev_priv: i915 drm device.
|
|
*
|
|
* This function is called at the time of loading the display driver to read
|
|
* firmware from a .bin file and copied into a internal memory.
|
|
*/
|
|
void intel_csr_ucode_init(struct drm_i915_private *dev_priv)
|
|
{
|
|
struct intel_csr *csr = &dev_priv->csr;
|
|
|
|
INIT_WORK(&dev_priv->csr.work, csr_load_work_fn);
|
|
|
|
if (!HAS_CSR(dev_priv))
|
|
return;
|
|
|
|
if (IS_KABYLAKE(dev_priv))
|
|
csr->fw_path = I915_CSR_KBL;
|
|
else if (IS_SKYLAKE(dev_priv))
|
|
csr->fw_path = I915_CSR_SKL;
|
|
else if (IS_BROXTON(dev_priv))
|
|
csr->fw_path = I915_CSR_BXT;
|
|
else {
|
|
DRM_ERROR("Unexpected: no known CSR firmware for platform\n");
|
|
return;
|
|
}
|
|
|
|
DRM_DEBUG_KMS("Loading %s\n", csr->fw_path);
|
|
|
|
/*
|
|
* Obtain a runtime pm reference, until CSR is loaded,
|
|
* to avoid entering runtime-suspend.
|
|
*/
|
|
intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
|
|
|
|
schedule_work(&dev_priv->csr.work);
|
|
}
|
|
|
|
/**
|
|
* intel_csr_ucode_suspend() - prepare CSR firmware before system suspend
|
|
* @dev_priv: i915 drm device
|
|
*
|
|
* Prepare the DMC firmware before entering system suspend. This includes
|
|
* flushing pending work items and releasing any resources acquired during
|
|
* init.
|
|
*/
|
|
void intel_csr_ucode_suspend(struct drm_i915_private *dev_priv)
|
|
{
|
|
if (!HAS_CSR(dev_priv))
|
|
return;
|
|
|
|
flush_work(&dev_priv->csr.work);
|
|
|
|
/* Drop the reference held in case DMC isn't loaded. */
|
|
if (!dev_priv->csr.dmc_payload)
|
|
intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
|
|
}
|
|
|
|
/**
|
|
* intel_csr_ucode_resume() - init CSR firmware during system resume
|
|
* @dev_priv: i915 drm device
|
|
*
|
|
* Reinitialize the DMC firmware during system resume, reacquiring any
|
|
* resources released in intel_csr_ucode_suspend().
|
|
*/
|
|
void intel_csr_ucode_resume(struct drm_i915_private *dev_priv)
|
|
{
|
|
if (!HAS_CSR(dev_priv))
|
|
return;
|
|
|
|
/*
|
|
* Reacquire the reference to keep RPM disabled in case DMC isn't
|
|
* loaded.
|
|
*/
|
|
if (!dev_priv->csr.dmc_payload)
|
|
intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
|
|
}
|
|
|
|
/**
|
|
* intel_csr_ucode_fini() - unload the CSR firmware.
|
|
* @dev_priv: i915 drm device.
|
|
*
|
|
* Firmmware unloading includes freeing the internal memory and reset the
|
|
* firmware loading status.
|
|
*/
|
|
void intel_csr_ucode_fini(struct drm_i915_private *dev_priv)
|
|
{
|
|
if (!HAS_CSR(dev_priv))
|
|
return;
|
|
|
|
intel_csr_ucode_suspend(dev_priv);
|
|
|
|
kfree(dev_priv->csr.dmc_payload);
|
|
}
|