From patchwork Tue Jul 9 13:18:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 2825280 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2C6D29F7D6 for ; Tue, 9 Jul 2013 13:19:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB42420164 for ; Tue, 9 Jul 2013 13:19:05 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF1C220161 for ; Tue, 9 Jul 2013 13:19:00 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UwXoe-0003gX-Oe; Tue, 09 Jul 2013 13:18:49 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UwXoc-0007wf-Ei; Tue, 09 Jul 2013 13:18:46 +0000 Received: from mail-wg0-f41.google.com ([74.125.82.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UwXoZ-0007w7-AA for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2013 13:18:43 +0000 Received: by mail-wg0-f41.google.com with SMTP id y10so9880803wgg.2 for ; Tue, 09 Jul 2013 06:18:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=HGtPJaeza/qHSM0P7Dk1opx/gcQSkH2tautg5/1uaxI=; b=Pc7LzEsSTi5Fr20/Ax/WyFuWM3pflYlBpBGIBAp9IlR0nNpDNNK74s35dIAvArg+h7 otBgF21gHcWQyAoxkQrqTTPIruTUvGMz4aLJfcQ+Vvr6gMyuNyWpoFC3br3L738ER0Ne ZIt13OEFw4zMuuxmhX/5il1mbzRFGCowhC15RyMlcd62bd6pT9JlMDSnefHCdtUbUdLJ DoGlkOwy07ObJKowbjFwY4cJU3sQp75KaNXHtsiQJ2EK5V4eZluossPWBSJGVksokzuF MRHsHQTvd683WKW1mGEFahZN1gqt+Rk9/KkqmmllrSTsA/EkcaXuw54mTkttgXa54xkD bptA== X-Received: by 10.180.20.116 with SMTP id m20mr3515647wie.46.1373375898857; Tue, 09 Jul 2013 06:18:18 -0700 (PDT) Received: from localhost.localdomain ([193.120.41.114]) by mx.google.com with ESMTPSA id d8sm29941380wiz.0.2013.07.09.06.18.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Jul 2013 06:18:18 -0700 (PDT) From: Ard Biesheuvel To: catalin.marinas@arm.com Subject: [PATCH v2] arm64: add support for kernel mode NEON Date: Tue, 9 Jul 2013 14:18:12 +0100 Message-Id: <1373375892-25390-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-Gm-Message-State: ALoCoQkU1/FfJ7ckhEcQ2i2SIJkk2g2NcDoe9wWeg7ApfEvVwnWav7JsS8VJVtj2I3+I7DZU8bO9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130709_091843_463913_1E7AB1A4 X-CRM114-Status: GOOD ( 14.06 ) X-Spam-Score: -2.6 (--) Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add containing kernel_neon_begin/kernel_neon_end function declarations and corresponding definitions in fpsimd.c These are needed to wrap uses of NEON in kernel mode. The names are identical to the ones used in arm/ so code using intrinsics or vectorized by GCC can be shared between arm and arm64. Signed-off-by: Ard Biesheuvel --- arch/arm64/Kconfig | 3 +++ arch/arm64/include/asm/neon.h | 14 ++++++++++++++ arch/arm64/kernel/fpsimd.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 arch/arm64/include/asm/neon.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 56b3f6d..46ba680 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -95,6 +95,9 @@ config SWIOTLB config IOMMU_HELPER def_bool SWIOTLB +config KERNEL_MODE_NEON + def_bool y + source "init/Kconfig" source "kernel/Kconfig.freezer" diff --git a/arch/arm64/include/asm/neon.h b/arch/arm64/include/asm/neon.h new file mode 100644 index 0000000..b0cc58a9 --- /dev/null +++ b/arch/arm64/include/asm/neon.h @@ -0,0 +1,14 @@ +/* + * linux/arch/arm64/include/asm/neon.h + * + * Copyright (C) 2013 Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#define cpu_has_neon() (1) + +void kernel_neon_begin(void); +void kernel_neon_end(void); diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index e8b8357..1f2e4d5 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -83,6 +84,33 @@ void fpsimd_flush_thread(void) fpsimd_load_state(¤t->thread.fpsimd_state); } +#ifdef CONFIG_KERNEL_MODE_NEON + +/* + * Kernel-side NEON support functions + */ +void kernel_neon_begin(void) +{ + /* Avoid using the NEON in interrupt context */ + BUG_ON(in_interrupt()); + preempt_disable(); + + if (current->mm) + fpsimd_save_state(¤t->thread.fpsimd_state); +} +EXPORT_SYMBOL(kernel_neon_begin); + +void kernel_neon_end(void) +{ + if (current->mm) + fpsimd_load_state(¤t->thread.fpsimd_state); + + preempt_enable(); +} +EXPORT_SYMBOL(kernel_neon_end); + +#endif /* CONFIG_KERNEL_MODE_NEON */ + /* * FP/SIMD support code initialisation. */