From patchwork Thu Feb 15 15:29:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 128500 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2022441ljc; Thu, 15 Feb 2018 10:02:38 -0800 (PST) X-Google-Smtp-Source: AH8x225gReLEPcum/Iq5H9qEuCN5UOSMQDlb8zIJ41FCRxoRwaWcokcmHfoBUBRdJx/HMDMT/jM/ X-Received: by 10.98.198.1 with SMTP id m1mr3345440pfg.90.1518717747942; Thu, 15 Feb 2018 10:02:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518717747; cv=none; d=google.com; s=arc-20160816; b=EFDMjdmMDnlZrY+9WL4oNaD6iydG04sopz+daQvzYT4YGY5LVkxz7l8GGIzelK+Tkz 08zi2mFZxFzWOC09h12goKuGlKZ+ioI8iO/YnURmPsG36l/F9QUOwu04GA+q3AMZvEXC 2RoM9dBG3HoiHhYLZrbpz+/ObRxcBY2YbKP1uaQIPKmnTrcuQnk7x7I6d8cHBGGBIfmy HsEcxqCUL1ky+HwTDjy/EAQkjCfShx2gJbtHvSV01h8L1bfJIlc1z41aMnVQPH9LagQj RDxBUE02qA0ZzGORVF+yFU+jBnr+k0zLoBZYmC+RvdrqmDwwxcg7rzlaXypfOYb/G+2A tnfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=/+VEGj06cId9d/VU3wf6YG12ZvlZpRQpvBF/x8dHNtE=; b=jGe3+Hx/TxMpFzARp19niQQh/XudKUqN+XLyAh2t9xKpHilo5fK6L1xRybl3rVJnxR 3KaA5AVIQnG+hUBcnOKOobjUUY1QZDck4W9+PBdTtlTs5L0RSmolGCITW/x33p5v787S OGjM36M11f3qAjIwfQum4sL3+Mo3GVPNxQhPmZiTjfIQXo294Vwr99BY/MR0J/AehE83 GBbZVHo8bJUpF2UzptXXiEBpB7BvYSRluO5bcObOaJKrFSwttiFs7XlRpyeIzkH41Day HrKkwHtgQA4nF2PqkeLHjac6a63qkrJf1C9o0ZHA7yVk1Ai0CqGTb38mxK7EiTCVwAbP vF4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12-v6si1976952plm.481.2018.02.15.10.02.27; Thu, 15 Feb 2018 10:02:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967990AbeBOR4B (ORCPT + 28 others); Thu, 15 Feb 2018 12:56:01 -0500 Received: from foss.arm.com ([217.140.101.70]:55998 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164184AbeBOPaO (ORCPT ); Thu, 15 Feb 2018 10:30:14 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87559164F; Thu, 15 Feb 2018 07:30:14 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 597763F592; Thu, 15 Feb 2018 07:30:14 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id B98461AE546A; Thu, 15 Feb 2018 15:30:21 +0000 (GMT) From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, peterz@infradead.org, mingo@kernel.org, Will Deacon Subject: [RFC PATCH 4/5] arm64: Replace our atomic bitops implementation with asm-generic Date: Thu, 15 Feb 2018 15:29:34 +0000 Message-Id: <1518708575-12284-5-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1518708575-12284-1-git-send-email-will.deacon@arm.com> References: <1518708575-12284-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The asm-generic/bitops/atomic.h implementation is built around the atomic-fetch ops, which we implement efficiently for both LSE and LL/SC systems. Use that instead of our hand-rolled, out-of-line bitops.S. Signed-off-by: Will Deacon --- arch/arm64/include/asm/bitops.h | 13 +------ arch/arm64/lib/Makefile | 2 +- arch/arm64/lib/bitops.S | 76 ----------------------------------------- 3 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 arch/arm64/lib/bitops.S -- 2.1.4 diff --git a/arch/arm64/include/asm/bitops.h b/arch/arm64/include/asm/bitops.h index 9c19594ce7cb..817233fbf249 100644 --- a/arch/arm64/include/asm/bitops.h +++ b/arch/arm64/include/asm/bitops.h @@ -17,22 +17,11 @@ #define __ASM_BITOPS_H #include -#include #ifndef _LINUX_BITOPS_H #error only can be included directly #endif -/* - * Little endian assembly atomic bitops. - */ -extern void set_bit(int nr, volatile unsigned long *p); -extern void clear_bit(int nr, volatile unsigned long *p); -extern void change_bit(int nr, volatile unsigned long *p); -extern int test_and_set_bit(int nr, volatile unsigned long *p); -extern int test_and_clear_bit(int nr, volatile unsigned long *p); -extern int test_and_change_bit(int nr, volatile unsigned long *p); - #include #include #include @@ -44,8 +33,8 @@ extern int test_and_change_bit(int nr, volatile unsigned long *p); #include #include -#include +#include #include #include diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index 4e696f96451f..73095a04c0ad 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ +lib-y := clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_in_user.o copy_page.o \ clear_page.o memchr.o memcpy.o memmove.o memset.o \ memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ diff --git a/arch/arm64/lib/bitops.S b/arch/arm64/lib/bitops.S deleted file mode 100644 index 43ac736baa5b..000000000000 --- a/arch/arm64/lib/bitops.S +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Based on arch/arm/lib/bitops.h - * - * Copyright (C) 2013 ARM 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -/* - * x0: bits 5:0 bit offset - * bits 31:6 word offset - * x1: address - */ - .macro bitop, name, llsc, lse -ENTRY( \name ) - and w3, w0, #63 // Get bit offset - eor w0, w0, w3 // Clear low bits - mov x2, #1 - add x1, x1, x0, lsr #3 // Get word offset -alt_lse " prfm pstl1strm, [x1]", "nop" - lsl x3, x2, x3 // Create mask - -alt_lse "1: ldxr x2, [x1]", "\lse x3, [x1]" -alt_lse " \llsc x2, x2, x3", "nop" -alt_lse " stxr w0, x2, [x1]", "nop" -alt_lse " cbnz w0, 1b", "nop" - - ret -ENDPROC(\name ) - .endm - - .macro testop, name, llsc, lse -ENTRY( \name ) - and w3, w0, #63 // Get bit offset - eor w0, w0, w3 // Clear low bits - mov x2, #1 - add x1, x1, x0, lsr #3 // Get word offset -alt_lse " prfm pstl1strm, [x1]", "nop" - lsl x4, x2, x3 // Create mask - -alt_lse "1: ldxr x2, [x1]", "\lse x4, x2, [x1]" - lsr x0, x2, x3 -alt_lse " \llsc x2, x2, x4", "nop" -alt_lse " stlxr w5, x2, [x1]", "nop" -alt_lse " cbnz w5, 1b", "nop" -alt_lse " dmb ish", "nop" - - and x0, x0, #1 - ret -ENDPROC(\name ) - .endm - -/* - * Atomic bit operations. - */ - bitop change_bit, eor, steor - bitop clear_bit, bic, stclr - bitop set_bit, orr, stset - - testop test_and_change_bit, eor, ldeoral - testop test_and_clear_bit, bic, ldclral - testop test_and_set_bit, orr, ldsetal