From patchwork Wed Mar 17 11:17:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Zbigniew_Kempczy=C5=84ski?= X-Patchwork-Id: 12145567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1892DC433E6 for ; Wed, 17 Mar 2021 11:18:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CED5A64E20 for ; Wed, 17 Mar 2021 11:17:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CED5A64E20 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 151DF89FAC; Wed, 17 Mar 2021 11:17:58 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 86B2F89E9E for ; Wed, 17 Mar 2021 11:17:56 +0000 (UTC) IronPort-SDR: yzXChfqM5+yw5XXObVvWzvtGB8468TtrUd1plr6ahEAVQTkt4MgExU0PMcsYg4RaZSGhq/rsP1 DEDGl9ub/SgQ== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="177037075" X-IronPort-AV: E=Sophos;i="5.81,256,1610438400"; d="scan'208";a="177037075" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 04:17:56 -0700 IronPort-SDR: eVXaBJQz41jrzkayTd3g6wPynZwtbcyK6wur8lJabpyD0ebgYCZbn47NSTa73EcFlKE3nG8Rty rGJE2+gYiNCA== X-IronPort-AV: E=Sophos;i="5.81,256,1610438400"; d="scan'208";a="412606375" Received: from pompl-mobl.ger.corp.intel.com (HELO zkempczy-mobl2.ger.corp.intel.com) ([10.252.34.158]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 04:17:55 -0700 From: =?utf-8?q?Zbigniew_Kempczy=C5=84ski?= To: intel-gfx@lists.freedesktop.org Date: Wed, 17 Mar 2021 12:17:44 +0100 Message-Id: <20210317111744.97872-2-zbigniew.kempczynski@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20210317111744.97872-1-zbigniew.kempczynski@intel.com> References: <20210317111744.97872-1-zbigniew.kempczynski@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 1/1] drm/i915/gem: Drop relocation support on all new hardware X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Ensure we don't pass any relocation data in execbuf for any new hardware. Patch likely is not optimal but is doing hard cut before entering execbuf. v2: fixing version (< 12 instead of incidentally tested < 9) Signed-off-by: Zbigniew KempczyƄski Cc: Jason Ekstrand Cc: Daniel Vetter --- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index fe170186dd42..7d42ec5b8eb5 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -3394,6 +3394,22 @@ static bool check_buffer_count(size_t count) return !(count < 1 || count > INT_MAX || count > SIZE_MAX / sz - 1); } +static bool check_objects_correctness(const struct drm_i915_private *i915, + const struct drm_i915_gem_exec_object2 *objs, + uint32_t buffer_count) +{ + uint32_t i; + + if (INTEL_GEN(i915) < 12 || IS_TIGERLAKE(i915)) + return true; + + for (i = 0; i < buffer_count; i++) + if (objs[i].relocation_count) + return false; + + return true; +} + /* * Legacy execbuffer just creates an exec2 list from the original exec object * list array and passes it to the real function. @@ -3529,6 +3545,12 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data, return -EFAULT; } + if (!check_objects_correctness(i915, exec2_list, count)) { + drm_dbg(&i915->drm, "Relocations are not supported\n"); + kvfree(exec2_list); + return -EINVAL; + } + err = i915_gem_do_execbuffer(dev, file, args, exec2_list); /*