From patchwork Mon Jan 9 19:57:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 90574 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp251099qgi; Mon, 9 Jan 2017 11:58:43 -0800 (PST) X-Received: by 10.99.3.5 with SMTP id 5mr139574743pgd.150.1483991922999; Mon, 09 Jan 2017 11:58:42 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id q8si89616758pgc.289.2017.01.09.11.58.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 11:58:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQg5Y-0004Z6-57; Mon, 09 Jan 2017 19:58:40 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQg5P-00043V-FF for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 19:58:34 +0000 Received: by mail-wm0-x234.google.com with SMTP id c85so108577630wmi.1 for ; Mon, 09 Jan 2017 11:58:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ouR6px2S6qGXsQhN4oWO7SEk8Zy252OCQG6/E4s8IR4=; b=UmBcPGK560TtLzzk0gYcTojU08lSdOITbc9AYz00aNKFKmHhk5Y+iXXbpD/zktsLEs YySWga4WqqSe80AYN+02a8/FxeJMZPkfMWpieG0f8cxa8kVCYnEj/sKkw4j/cPJEDyuG q41OeKqoTo+p+ycZo5OpGLBEZDSCpyX2letgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ouR6px2S6qGXsQhN4oWO7SEk8Zy252OCQG6/E4s8IR4=; b=HHJMIwM8HMW3BS7DizWbyxUxoYmVXzZ02jyFWxHJoJ5ZFqCpgiPQbxhVGRRhoyek5G y8YKHfGDxaoUbrHXPNYa9fKSKPflke/k/UDaQoHpB/iaGHm2GjULu0vBq8vRfK3UOpTt CfPh8ELhFc0pgF9ZkgB70Gth88slsey4EEuOkEwg5TBo7/+19//6mAIQ/uOGBwDBvepp x3grSu878d1vp8mAQNSXbFuJA3sJbga9gBqNuTjj5crfw5U2mn+jbpijdrqbyC7kuMG7 jKzNaTfQDkUTEvcXJ18FXclTb9wAPzlXnM/U1IaCBXDxnXEg+6zefoZZzSwYIbwyshr0 vbDA== X-Gm-Message-State: AIkVDXJ77yRQgR+7oTHgRMflJa19wEHe1IZ/VutXUzRNeGlmqQ+f/V1PLmFUQZjxEeUtZ9T8 X-Received: by 10.28.48.145 with SMTP id w139mr5685467wmw.113.1483991888463; Mon, 09 Jan 2017 11:58:08 -0800 (PST) Received: from localhost.localdomain ([160.167.203.25]) by smtp.gmail.com with ESMTPSA id 135sm20641416wmh.14.2017.01.09.11.58.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 11:58:07 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 1/2] ARM: vfp - allow kernel mode NEON in softirq context Date: Mon, 9 Jan 2017 19:57:28 +0000 Message-Id: <1483991849-32448-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483991849-32448-1-git-send-email-ard.biesheuvel@linaro.org> References: <1483991849-32448-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170109_115831_810794_ACB3C043 X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:234 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , linux@armlinux.org.uk, nico@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This updates the kernel mode NEON handling to allow the NEON to be used in softirq context as well as process context. This involves disabling softirq processing when the NEON is used in kernel mode in process context, and dealing with the situation where 'current' is not the owner of the userland context that is present in the NEON register file when the NEON is enabled in kernel mode. The rationale for this change is that the NEON is shared with the ARMv8 Crypto Extensions (which are also defined for the AArch32 execution state), which can give a huge performance boost (15x) to use cases like mac80211 CCMP processing, which executes in softirq context. Signed-off-by: Ard Biesheuvel --- arch/arm/vfp/vfpmodule.c | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 569d5a650a4a..814752811537 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -690,26 +690,33 @@ void kernel_neon_begin(void) u32 fpexc; /* - * Kernel mode NEON is only allowed outside of interrupt context + * Kernel mode NEON is only allowed outside of hardirq context * with preemption disabled. This will make sure that the kernel * mode NEON register contents never need to be preserved. */ - BUG_ON(in_interrupt()); + BUG_ON(in_irq()); cpu = get_cpu(); + /* + * Disable softirq processing while the NEON is used by the kernel in + * process context. This ensures that only a single kernel mode NEON + * state is live at any given time. + */ + if (!in_serving_softirq()) + local_bh_disable(); + fpexc = fmrx(FPEXC) | FPEXC_EN; fmxr(FPEXC, fpexc); /* - * Save the userland NEON/VFP state. Under UP, - * the owner could be a task other than 'current' + * Save the userland NEON/VFP state. Under UP, or when executing in + * softirq context, the owner could be a task other than 'current' */ if (vfp_state_in_hw(cpu, thread)) vfp_save_state(&thread->vfpstate, fpexc); -#ifndef CONFIG_SMP else if (vfp_current_hw_state[cpu] != NULL) vfp_save_state(vfp_current_hw_state[cpu], fpexc); -#endif + vfp_current_hw_state[cpu] = NULL; } EXPORT_SYMBOL(kernel_neon_begin); @@ -718,7 +725,10 @@ void kernel_neon_end(void) { /* Disable the NEON/VFP unit. */ fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN); + if (!in_serving_softirq()) + local_bh_enable(); put_cpu(); + } EXPORT_SYMBOL(kernel_neon_end);