From patchwork Fri Jun 27 15:53:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 32626 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 85CB2201EF for ; Fri, 27 Jun 2014 15:55:27 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id h18sf7600987igc.10 for ; Fri, 27 Jun 2014 08:55:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=7T1TB72lHhsxF22q8jfK+AoCmHJCnDoNdzHRTx9v2R8=; b=Q0uK/EbJfZW+Uw1ZiJTbAcXak5Td9uaXkgH4B60Fgl9zjAIGUY+VAGyuGoaA+gHGGX jU2IxejLGMQ+kk7rGX0x0gbihDWI48xVvefR5lv8lP0pihpfQachDYgf+cuQozFqF/hL ZAK59rtVH6TMf1YUyWK3CJxxrUbIJX9TselHK6lqyzWY8MHuXNOjpOfJO7v+gTFnXCeE JX2q4NTqV0HbRjFzRimw0E+LccJPMUNJKG9vaSoJjFGe9AxQ7M1MfyK/jW9UcOdOue8r xgRJ4ECmnEPtRB30M6wOCm4XIPrq9jzf71EUYHs9mtcoxp7f3yWVogbYAxUNUNZzshw0 f6kA== X-Gm-Message-State: ALoCoQlAk1vJiiG9BJJ6Pu8psf2/Q1bR8pkkgPqFzRUhM/IwekO2F+KhvM/6TK7OYzo1BXNZDFJG X-Received: by 10.50.66.200 with SMTP id h8mr6261696igt.1.1403884526911; Fri, 27 Jun 2014 08:55:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.118 with SMTP id x109ls714349qge.74.gmail; Fri, 27 Jun 2014 08:55:26 -0700 (PDT) X-Received: by 10.58.94.13 with SMTP id cy13mr1037445veb.72.1403884526769; Fri, 27 Jun 2014 08:55:26 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id hi7si6627022veb.3.2014.06.27.08.55.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 08:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hy4so5271764vcb.20 for ; Fri, 27 Jun 2014 08:55:26 -0700 (PDT) X-Received: by 10.58.188.199 with SMTP id gc7mr17007745vec.4.1403884526657; Fri, 27 Jun 2014 08:55:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp117948vcb; Fri, 27 Jun 2014 08:55:26 -0700 (PDT) X-Received: by 10.66.180.34 with SMTP id dl2mr32070396pac.124.1403884525783; Fri, 27 Jun 2014 08:55:25 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qu8si14455211pbb.27.2014.06.27.08.55.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jun 2014 08:55:25 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X0YTD-0003Yz-Ht; Fri, 27 Jun 2014 15:53:47 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X0YT9-0003Sb-Dh for linux-arm-kernel@lists.infradead.org; Fri, 27 Jun 2014 15:53:44 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.161]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s5RFrGwo001761; Fri, 27 Jun 2014 16:53:16 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id E1AA11AE0A1E; Fri, 27 Jun 2014 16:53:21 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed Date: Fri, 27 Jun 2014 16:53:19 +0100 Message-Id: <1403884399-16359-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.0.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140627_085343_829717_5AA1F9AD X-CRM114-Status: UNSURE ( 9.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: catalin.marinas@arm.com, Will Deacon , Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Writing to the FPCR is commonly implemented as a self-synchronising operation in the CPU, so avoid writing to the register when the saved value matches that in the hardware already. Cc: Ard Biesheuvel Reviewed-by: Lorenzo Pieralisi Signed-off-by: Will Deacon --- v1 -> v2 : Move FPCR restoration out into a macro and update partial restore code too. arch/arm64/include/asm/fpsimdmacros.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h index 768414d55e64..f6b3eb5f4517 100644 --- a/arch/arm64/include/asm/fpsimdmacros.h +++ b/arch/arm64/include/asm/fpsimdmacros.h @@ -40,6 +40,19 @@ str w\tmpnr, [\state, #16 * 2 + 4] .endm +.macro fpsimd_restore_fpcr state, tmp + /* + * Writes to fpcr may be self-synchronising, so avoid restoring + * the register if it hasn't changed. + */ + mrs \tmp, fpcr + cmp \tmp, \state + b.eq 9999f + msr fpcr, \state +9999: +.endm + +/* Clobbers \state */ .macro fpsimd_restore state, tmpnr ldp q0, q1, [\state, #16 * 0] ldp q2, q3, [\state, #16 * 2] @@ -60,7 +73,7 @@ ldr w\tmpnr, [\state, #16 * 2] msr fpsr, x\tmpnr ldr w\tmpnr, [\state, #16 * 2 + 4] - msr fpcr, x\tmpnr + fpsimd_restore_fpcr x\tmpnr, \state .endm .altmacro @@ -84,7 +97,7 @@ .macro fpsimd_restore_partial state, tmpnr1, tmpnr2 ldp w\tmpnr1, w\tmpnr2, [\state] msr fpsr, x\tmpnr1 - msr fpcr, x\tmpnr2 + fpsimd_restore_fpcr x\tmpnr1, x\tmpnr2 adr x\tmpnr1, 0f ldr w\tmpnr2, [\state, #8] add \state, \state, x\tmpnr2, lsl #4