Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/guc: Limit number of scratch registers used for H2G

We wrongly assumed that GuC is only using last scratch register
for G2H messages, but in fact it is also using register [14] to
report sleep state status. Remove that register from our H2G
send registers pool.

v2: No message from host to GuC uses more than 8 registers and
the GuC FW itself uses an 8-element array to store the H2G message,
so we may reduce our send array to just 8 registers (Daniele)
v3: use explicit define (Daniele)
v4: and explicit comment (Daniele)

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20181019101725.14024-1-michal.wajdeczko@intel.com

authored by

Michal Wajdeczko and committed by
Chris Wilson
9128b102 d364dc66

+7 -2
+2 -1
drivers/gpu/drm/i915/intel_guc.c
··· 50 50 unsigned int i; 51 51 52 52 guc->send_regs.base = i915_mmio_reg_offset(SOFT_SCRATCH(0)); 53 - guc->send_regs.count = SOFT_SCRATCH_COUNT - 1; 53 + guc->send_regs.count = GUC_MAX_MMIO_MSG_LEN; 54 + BUILD_BUG_ON(GUC_MAX_MMIO_MSG_LEN > SOFT_SCRATCH_COUNT); 54 55 55 56 for (i = 0; i < guc->send_regs.count; i++) { 56 57 fw_domains |= intel_uncore_forcewake_for_reg(dev_priv,
+5 -1
drivers/gpu/drm/i915/intel_guc_fwif.h
··· 601 601 * registers, where first register holds data treated as message header, 602 602 * and other registers are used to hold message payload. 603 603 * 604 - * For Gen9+, GuC uses software scratch registers 0xC180-0xC1B8 604 + * For Gen9+, GuC uses software scratch registers 0xC180-0xC1B8, 605 + * but no H2G command takes more than 8 parameters and the GuC FW 606 + * itself uses an 8-element array to store the H2G message. 605 607 * 606 608 * +-----------+---------+---------+---------+ 607 609 * | MMIO[0] | MMIO[1] | ... | MMIO[n] | ··· 634 632 * response data can be returned in remaining payload registers or **data** 635 633 * field. 636 634 */ 635 + 636 + #define GUC_MAX_MMIO_MSG_LEN 8 637 637 638 638 #define INTEL_GUC_MSG_TYPE_SHIFT 28 639 639 #define INTEL_GUC_MSG_TYPE_MASK (0xF << INTEL_GUC_MSG_TYPE_SHIFT)