From patchwork Thu Apr 30 22:10:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 186015 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp273088ilf; Fri, 1 May 2020 00:22:38 -0700 (PDT) X-Google-Smtp-Source: APiQypLx0kBlg94an6Jm2Y5UKLABoZ2+2sD2/sLbOP/j/xdX4osEROOR3Fd1j9ShwMNdASgC4MtP X-Received: by 2002:a17:902:59cd:: with SMTP id d13mr3080101plj.329.1588317758175; Fri, 01 May 2020 00:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588317758; cv=none; d=google.com; s=arc-20160816; b=Wp39G5TVN39Og6HQN5sqaoIxeguct1LX168urzdS2hY4JTR0mDH+QGUsyN2MkcqrGu r96PQpRv8Mu3UF3roLD6Ssc/sD6edFeoihFVh5URP8558nXoY7VJbLAV940NArjdmySJ /gbQRL215cNhZ8kTGRHs8H1TAJnAAfilqp+a65Zmko+ghJt5Qq2DOphxY9ly/WzM5wqg raQHKauU+PoI5d0ycxqxlRXJzU3aoxSEn14jRf6EhTagelf+Lk/6RW1SoU8B4ba54GyP NkTQ6NXuHRcSAykQM2khYvWchMFAqDF+J7c+KOhORgh9z+VGNqDqd4QEOY+x0VwqQFgM H97w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=3oQUdstRWOZgAVgIqEWYwqv0XPWtavUPASm+VqYbB34=; b=uqLTmvE7C5ttBP8mubVU1kkDEAP3vMth7TmGMdgv3q/gUrCBD8ybdFSpsMC+RbNX6f rQ3qNkONyzSmSxvadM6RTyhoUEWuoxsHukgWkbveomvn3v1aQd9gunXSWzyFD3YClE2O TCJ45/rfg2+RGPsQ0texAuVTTY6xixLdBHLtLBNExO7vZyQmpRa9LLFH0sAj3P8yp9TW OTvdvVcblPKAl9uDd0c63lKe9Nuws/mvAjo8NCS2uxl2E1pPpDXBxEOG/vm3Kk45NYwT 1PaJbcHie4N4Klgm8LdTvkLyZj1Stw4SKPYAlvUtbO7utOgL/Y5FhB5nRARveT8Y2uUa QoLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@zx2c4.com header.s=mail header.b=lHSlfuSc; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id bc1si1538085plb.299.2020.05.01.00.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:22:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@zx2c4.com header.s=mail header.b=lHSlfuSc; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F70C6EA62; Fri, 1 May 2020 07:22:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.zx2c4.com (mail.zx2c4.com [192.95.5.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C1F56E27C; Thu, 30 Apr 2020 22:10:50 +0000 (UTC) Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 5b2fc6ad; Thu, 30 Apr 2020 21:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=mail; bh=aJFrtx6lQiBbgvKXPLew//Y8Ivk=; b=lHSlfuScgujAfXJtyKYA 1RfqTOsRlND8ZJBESNTBjJ3IbgUyajG5cOXCrHYltelH69//dV1x/XPeXX0CwW+k 71LXbj/jJ2Gin8s/PKsrAEarzTAHG3r05Zr0d8J5ztjLV6r/9/J8jAVclxG9/AmO qZ3vfzKjL59/YIUuSJv9y42mR27ZmItkPkAlpMdz+8FG7km7xNnFbTc89TIpOvR3 aaPDDUGNxwP+d2F4hwlEjS6TaRD05C47OxTxwwFssa43xeY+EVn9WzaMYHqxJycL x5ydiSJeP5h3jGy2+hWAoaEV8pvtNtW2yTu4lEqijWGcY5j/AsHNqEdYirvth3iL iQ== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4ee62b72 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 30 Apr 2020 21:58:52 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, bigeasy@linutronix.de, tglx@linutronix.de, chris@chris-wilson.co.uk Subject: [PATCH] drm/i915: check to see if SIMD registers are available before using SIMD Date: Thu, 30 Apr 2020 16:10:16 -0600 Message-Id: <20200430221016.3866-1-Jason@zx2c4.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 01 May 2020 07:22:25 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A. Donenfeld" , stable@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Sometimes it's not okay to use SIMD registers, the conditions for which have changed subtly from kernel release to kernel release. Usually the pattern is to check for may_use_simd() and then fallback to using something slower in the unlikely case SIMD registers aren't available. So, this patch fixes up i915's accelerated memcpy routines to fallback to boring memcpy if may_use_simd() is false. Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld --- drivers/gpu/drm/i915/i915_memcpy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.26.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/i915/i915_memcpy.c b/drivers/gpu/drm/i915/i915_memcpy.c index fdd550405fd3..7c0e022586bc 100644 --- a/drivers/gpu/drm/i915/i915_memcpy.c +++ b/drivers/gpu/drm/i915/i915_memcpy.c @@ -24,6 +24,7 @@ #include #include +#include #include "i915_memcpy.h" @@ -38,6 +39,12 @@ static DEFINE_STATIC_KEY_FALSE(has_movntdqa); #ifdef CONFIG_AS_MOVNTDQA static void __memcpy_ntdqa(void *dst, const void *src, unsigned long len) { + if (unlikely(!may_use_simd())) { + memcpy(dst, src, len); + return; + } + + kernel_fpu_begin(); while (len >= 4) { @@ -67,6 +74,11 @@ static void __memcpy_ntdqa(void *dst, const void *src, unsigned long len) static void __memcpy_ntdqu(void *dst, const void *src, unsigned long len) { + if (unlikely(!may_use_simd())) { + memcpy(dst, src, len); + return; + } + kernel_fpu_begin(); while (len >= 4) {