From patchwork Wed Mar 17 10:47:43 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: 12145475 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 16BDFC433E6 for ; Wed, 17 Mar 2021 10:48:19 +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 B578D64F21 for ; Wed, 17 Mar 2021 10:48:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B578D64F21 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 501986E51D; Wed, 17 Mar 2021 10:48:18 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 697F56E51D for ; Wed, 17 Mar 2021 10:48:17 +0000 (UTC) IronPort-SDR: yuigc6KbyKgegUF87VBWh8Mduo8Eg61A7FAErITNZ5HC6vz2wGeUIK9jSWohuuyysc06waHYTd xP98oExkT8sA== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="250796786" X-IronPort-AV: E=Sophos;i="5.81,256,1610438400"; d="scan'208";a="250796786" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 03:48:17 -0700 IronPort-SDR: CGBsUO7QSp8jS68apXrBl8FqWC97gF+6ZRMEjyUGe4sQ1LjW+3gvndHWsjz360XT3FcQUZNz5w 2F5N1c+eXPKg== X-IronPort-AV: E=Sophos;i="5.81,256,1610438400"; d="scan'208";a="412598707" 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 03:48:15 -0700 From: =?utf-8?q?Zbigniew_Kempczy=C5=84ski?= To: intel-gfx@lists.freedesktop.org Date: Wed, 17 Mar 2021 11:47:43 +0100 Message-Id: <20210317104743.94364-2-zbigniew.kempczynski@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20210317104743.94364-1-zbigniew.kempczynski@intel.com> References: <20210317104743.94364-1-zbigniew.kempczynski@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 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: , Cc: Daniel Vetter 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. 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..a3b603412448 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) < 9 || 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); /*