From patchwork Wed Sep 7 17:55:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gordon X-Patchwork-Id: 9319743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A3CF1607D3 for ; Wed, 7 Sep 2016 17:56:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B87D1293C9 for ; Wed, 7 Sep 2016 17:56:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD1D5293DD; Wed, 7 Sep 2016 17:56:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D4FD293C9 for ; Wed, 7 Sep 2016 17:56:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A30816EBAA; Wed, 7 Sep 2016 17:56:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69AA46EBAA for ; Wed, 7 Sep 2016 17:56:16 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP; 07 Sep 2016 10:56:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,296,1470726000"; d="scan'208";a="6077588" Received: from dsgordon-linux2.isw.intel.com ([10.102.226.88]) by orsmga004.jf.intel.com with ESMTP; 07 Sep 2016 10:56:14 -0700 From: Dave Gordon To: intel-gfx@lists.freedesktop.org Date: Wed, 7 Sep 2016 18:55:42 +0100 Message-Id: <1473270942-35905-6-git-send-email-david.s.gordon@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473270942-35905-1-git-send-email-david.s.gordon@intel.com> References: <1473270942-35905-1-git-send-email-david.s.gordon@intel.com> Organization: Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ Subject: [Intel-gfx] [CI_RESEND v4 5/5] drm/i915/guc: ignore unrecognised loading & submission options X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Previously the code allowed *any* values for the enable_guc_loading and enable_guc_submission parameters, and forced them into range by clipping at each extremum. This version instead ignores unknown values, treating them as DEFAULT (which then gets converted to DISABLED or PREFERRED). Of course we also have to report that we've ignored unknown values so that the administrator or developer knows the kernel command line wasn't sensible! Signed-off-by: Dave Gordon Cc: Jani Nikula --- drivers/gpu/drm/i915/intel_guc.h | 8 ++++---- drivers/gpu/drm/i915/intel_guc_loader.c | 34 ++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h index 83c2f295..c865bde 100644 --- a/drivers/gpu/drm/i915/intel_guc.h +++ b/drivers/gpu/drm/i915/intel_guc.h @@ -90,10 +90,10 @@ struct i915_guc_client { }; /* - * These signed ranges represent user-requested preferences. - * Out-of-range values from the user will be clipped towards - * zero: any negative value is treated as -1, anything over 2 - * is just 2. ANY user-supplied value also taints the kernel. + * These values represent user-requested preferences; any other value will be + * treated as DEFAULT, so the driver will then choose an appropriate value. + * + * ANY user-supplied value (even DEFAULT) also taints the kernel. */ enum { GUC_SUBMISSION_DEFAULT = -1, diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c index 833c7d7..486c8f3 100644 --- a/drivers/gpu/drm/i915/intel_guc_loader.c +++ b/drivers/gpu/drm/i915/intel_guc_loader.c @@ -533,9 +533,9 @@ int intel_guc_setup(struct drm_device *dev) * nonfatal error (i.e. it doesn't prevent driver load, but * marks the GPU as wedged until reset). */ - if (i915.enable_guc_loading >= FIRMWARE_LOAD_MANDATORY) { + if (i915.enable_guc_loading == FIRMWARE_LOAD_MANDATORY) { ret = -EIO; - } else if (i915.enable_guc_submission >= GUC_SUBMISSION_MANDATORY) { + } else if (i915.enable_guc_submission == GUC_SUBMISSION_MANDATORY) { ret = -EIO; } else { ret = 0; @@ -700,13 +700,37 @@ void intel_guc_init(struct drm_device *dev) struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; const char *fw_path; - /* Any negative value means "use platform default" */ - if (i915.enable_guc_loading <= FIRMWARE_LOAD_DEFAULT) + /* Sanitise user-specified options */ + switch (i915.enable_guc_loading) { + case FIRMWARE_LOAD_DISABLED: + case FIRMWARE_LOAD_PREFERRED: + case FIRMWARE_LOAD_MANDATORY: + break; + + default: + DRM_INFO("ignoring unknown value %d for 'enable_guc_loading'\n", + i915.enable_guc_loading); + /*FALLTHRU*/ + case FIRMWARE_LOAD_DEFAULT: i915.enable_guc_loading = HAS_GUC_UCODE(dev) ? FIRMWARE_LOAD_PREFERRED : FIRMWARE_LOAD_DISABLED; - if (i915.enable_guc_submission <= GUC_SUBMISSION_DEFAULT) + break; + } + + switch (i915.enable_guc_submission) { + case GUC_SUBMISSION_DISABLED: + case GUC_SUBMISSION_PREFERRED: + case GUC_SUBMISSION_MANDATORY: + break; + + default: + DRM_INFO("ignoring unknown value %d for 'enable_guc_submission'\n", + i915.enable_guc_submission); + /*FALLTHRU*/ + case GUC_SUBMISSION_DEFAULT: i915.enable_guc_submission = HAS_GUC_SCHED(dev) ? GUC_SUBMISSION_PREFERRED : GUC_SUBMISSION_DISABLED; + } if (!HAS_GUC_UCODE(dev)) { fw_path = NULL;