From patchwork Thu Jul 10 11:40:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 33418 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1DC09203C0 for ; Thu, 10 Jul 2014 11:41:45 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id a41sf35133573yho.1 for ; Thu, 10 Jul 2014 04:41:44 -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=vwbzpUHwIE3KsRJSdPvLiR1uYxROHBJ3Tw+DtwXXGn8=; b=c/tsgBgAF0TVUR0Nk6NqzVKn5d6Vw8KZYmh7GgJGwPaHIOfnTzZRnkuJ4rqeB8Ck3l 7lmryn23yKdDyZsSqBY+qC+VwnULrXiccCaIOkw3W05Pv1yjG2jArj+RVkjTiXBXQ0OY SLBv010D3kDLO93ybv7qPWWOmPxDcF57N99YVxLCrqhq8DnSlcRL+9xgqnjEg/DCYhZU n7kZhqUKyK3kJIxAhuCH9BGhaEjk0J1QpvLVSNL/LLF4wZb/bU3MsjozbUN4hGRS2x5d SpOxX9UdzANpYr3Ert+hLvONTdA6eFgGJPG6T60Oe0ettUt2JfJJtKAVyJM3NFscrBNW BGjA== X-Gm-Message-State: ALoCoQniHwSxkDbEkA8Ss7UnZ6t5idpOIEAoRmlhZTCjdqW61rRbEoiIUNnbCp//mVfSaiUmRNII X-Received: by 10.236.126.170 with SMTP id b30mr19933429yhi.3.1404992504854; Thu, 10 Jul 2014 04:41:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.165 with SMTP id d34ls35884qgd.25.gmail; Thu, 10 Jul 2014 04:41:44 -0700 (PDT) X-Received: by 10.58.65.104 with SMTP id w8mr23603352ves.19.1404992504764; Thu, 10 Jul 2014 04:41:44 -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 ft1si4809609vec.94.2014.07.10.04.41.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 04:41:44 -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 hy4so10173037vcb.20 for ; Thu, 10 Jul 2014 04:41:44 -0700 (PDT) X-Received: by 10.220.92.193 with SMTP id s1mr143610vcm.34.1404992504671; Thu, 10 Jul 2014 04:41:44 -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 tc5csp125695vcb; Thu, 10 Jul 2014 04:41:44 -0700 (PDT) X-Received: by 10.70.138.45 with SMTP id qn13mr16664448pdb.20.1404992503131; Thu, 10 Jul 2014 04:41:43 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ot2si15232867pab.34.2014.07.10.04.41.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jul 2014 04:41:43 -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 1X5CiA-0007zl-Tu; Thu, 10 Jul 2014 11:40:26 +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 1X5Ci8-0006vp-5B for linux-arm-kernel@lists.infradead.org; Thu, 10 Jul 2014 11:40:24 +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 s6ABdwwo014999; Thu, 10 Jul 2014 12:39:58 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 9205C1AE2E16; Thu, 10 Jul 2014 12:40:10 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv3] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed Date: Thu, 10 Jul 2014 12:40:09 +0100 Message-Id: <1404992409-6968-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-20140710_044024_563114_AB02085A X-CRM114-Status: UNSURE ( 9.16 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.7 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 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 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 --- 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..007618b8188c 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\tmpnr2, x\tmpnr1 adr x\tmpnr1, 0f ldr w\tmpnr2, [\state, #8] add \state, \state, x\tmpnr2, lsl #4