From patchwork Wed Feb 19 10:22:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11391187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D81491580 for ; Wed, 19 Feb 2020 10:24:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A99592464E for ; Wed, 19 Feb 2020 10:24:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="FkEq7aFm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A99592464E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4MVe-0004lC-Lk; Wed, 19 Feb 2020 10:23:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4MVd-0004kz-B5 for xen-devel@lists.xenproject.org; Wed, 19 Feb 2020 10:23:13 +0000 X-Inumbo-ID: d2e61eb1-5301-11ea-8325-12813bfff9fa Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d2e61eb1-5301-11ea-8325-12813bfff9fa; Wed, 19 Feb 2020 10:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582107789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/CINnrZJiZvYGHu3NNhmSrOJGvo2xoCBUI1NmiQfglg=; b=FkEq7aFmToZVCrnl3R94539oyAy4HVAiKnanBN1neMcE/YsnCJ6i/HIY E1i3RMsIwQn2tERo4xUW9s8p66YUznCJ/becFXs6SKAn4eoe4YD+V7+yj btfaIvz5TeUctSYd8j0phDw4AIBoQtpSvc7VewVAv5ffL0WlI9/208IM7 s=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Afpes8D0iLWVj55Zgwty+mpshrUF+d/RctdlJjg8+R3PMaiOxDmRXp15SvW7CMLvVZpGZMaMIv G/jZ3909rqJtJ3vwcM7kbstAarwNPI2u2V6Kp87bqRwp3wHIKpFNnhV9VxrsumGz+v70IhqTB9 +WKTUt/RbHOwvnNDVE6GdPOuoqfxAHk0RGIEJpq0eVNWe2zPbK95EtVY9+buZkmmOKtTe0ymwS kTUefTe9a0feOQisZfw5PRqohQlu5jPoMLqYkTHjKX8D8R6MI/T+jnHg7FSPyxRMOIpJVeFhLU XLw= X-SBRS: 2.7 X-MesageID: 13111544 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,459,1574139600"; d="scan'208";a="13111544" From: Roger Pau Monne To: Date: Wed, 19 Feb 2020 11:22:54 +0100 Message-ID: <20200219102256.81594-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200219102256.81594-1-roger.pau@citrix.com> References: <20200219102256.81594-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v6 1/3] arm: rename BIT_{WORD/MASK/PER_WORD) to BITOP_* X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Volodymyr Babchuk , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" So BIT_WORD can be imported from Linux. The difference between current Linux implementation of BIT_WORD is that the size of the word unit is a long integer, while the Xen one is hardcoded to 32 bits. Current users of BITOP_WORD on Arm (which considers a word a long integer) are switched to use the generic BIT_WORD which also operates on long integers. No functional change intended. Suggested-by: Julien Grall Suggested-by: Jan Beulich Signed-off-by: Roger Pau Monné Acked-by: Julien Grall --- Changes since v5: - Also rename BIT_MASK and BITS_PER_WORD. Changes since v4: - New in this version. --- xen/arch/arm/arm32/lib/bitops.c | 10 +++++----- xen/arch/arm/arm64/lib/bitops.c | 10 +++++----- xen/arch/arm/arm64/lib/find_next_bit.c | 10 ++++------ xen/include/asm-arm/bitops.h | 20 ++++++++++---------- xen/include/xen/bitops.h | 2 ++ 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/xen/arch/arm/arm32/lib/bitops.c b/xen/arch/arm/arm32/lib/bitops.c index 3dca769bf0..ceddd76d1b 100644 --- a/xen/arch/arm/arm32/lib/bitops.c +++ b/xen/arch/arm/arm32/lib/bitops.c @@ -33,8 +33,8 @@ static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\ unsigned int max_try) \ { \ - volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr); \ - const uint32_t mask = BIT_MASK((unsigned int)nr); \ + volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr); \ + const uint32_t mask = BITOP_MASK((unsigned int)nr); \ unsigned long res, tmp; \ \ ASSERT(((vaddr_t)p & 0x3) == 0); \ @@ -71,9 +71,9 @@ bool name##_timeout(int nr, volatile void *p, unsigned int max_try) \ static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \ bool timeout, unsigned int max_try) \ { \ - volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr); \ - unsigned int bit = (unsigned int)nr % BITS_PER_WORD; \ - const uint32_t mask = BIT_MASK(bit); \ + volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr); \ + unsigned int bit = (unsigned int)nr % BITOP_BITS_PER_WORD; \ + const uint32_t mask = BITOP_MASK(bit); \ unsigned long res, tmp; \ \ ASSERT(((vaddr_t)p & 0x3) == 0); \ diff --git a/xen/arch/arm/arm64/lib/bitops.c b/xen/arch/arm/arm64/lib/bitops.c index 27688e5418..20e3f3d6ce 100644 --- a/xen/arch/arm/arm64/lib/bitops.c +++ b/xen/arch/arm/arm64/lib/bitops.c @@ -32,8 +32,8 @@ static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\ unsigned int max_try) \ { \ - volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr); \ - const uint32_t mask = BIT_MASK((unsigned int)nr); \ + volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr); \ + const uint32_t mask = BITOP_MASK((unsigned int)nr); \ unsigned long res, tmp; \ \ do \ @@ -67,9 +67,9 @@ bool name##_timeout(int nr, volatile void *p, unsigned int max_try) \ static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \ bool timeout, unsigned int max_try) \ { \ - volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr); \ - unsigned int bit = (unsigned int)nr % BITS_PER_WORD; \ - const uint32_t mask = BIT_MASK(bit); \ + volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr); \ + unsigned int bit = (unsigned int)nr % BITOP_BITS_PER_WORD; \ + const uint32_t mask = BITOP_MASK(bit); \ unsigned long res, tmp; \ \ do \ diff --git a/xen/arch/arm/arm64/lib/find_next_bit.c b/xen/arch/arm/arm64/lib/find_next_bit.c index 17cb176266..8ebf8bfe97 100644 --- a/xen/arch/arm/arm64/lib/find_next_bit.c +++ b/xen/arch/arm/arm64/lib/find_next_bit.c @@ -12,8 +12,6 @@ #include #include -#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) - #ifndef find_next_bit /* * Find the next set bit in a memory region. @@ -21,7 +19,7 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { - const unsigned long *p = addr + BITOP_WORD(offset); + const unsigned long *p = addr + BIT_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); unsigned long tmp; @@ -67,7 +65,7 @@ EXPORT_SYMBOL(find_next_bit); unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { - const unsigned long *p = addr + BITOP_WORD(offset); + const unsigned long *p = addr + BIT_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); unsigned long tmp; @@ -197,7 +195,7 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned if (offset >= size) return size; - p += BITOP_WORD(offset); + p += BIT_WORD(offset); size -= result; offset &= (BITS_PER_LONG - 1UL); if (offset) { @@ -243,7 +241,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned if (offset >= size) return size; - p += BITOP_WORD(offset); + p += BIT_WORD(offset); size -= result; offset &= (BITS_PER_LONG - 1UL); if (offset) { diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h index fbb4b82413..71ae14cab3 100644 --- a/xen/include/asm-arm/bitops.h +++ b/xen/include/asm-arm/bitops.h @@ -20,9 +20,9 @@ #define __set_bit(n,p) set_bit(n,p) #define __clear_bit(n,p) clear_bit(n,p) -#define BITS_PER_WORD 32 -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_WORD)) -#define BIT_WORD(nr) ((nr) / BITS_PER_WORD) +#define BITOP_BITS_PER_WORD 32 +#define BITOP_MASK(nr) (1UL << ((nr) % BITOP_BITS_PER_WORD)) +#define BITOP_WORD(nr) ((nr) / BITOP_BITS_PER_WORD) #define BITS_PER_BYTE 8 #define ADDR (*(volatile int *) addr) @@ -85,9 +85,9 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *p, */ static inline int __test_and_set_bit(int nr, volatile void *addr) { - unsigned int mask = BIT_MASK(nr); + unsigned int mask = BITOP_MASK(nr); volatile unsigned int *p = - ((volatile unsigned int *)addr) + BIT_WORD(nr); + ((volatile unsigned int *)addr) + BITOP_WORD(nr); unsigned int old = *p; *p = old | mask; @@ -105,9 +105,9 @@ static inline int __test_and_set_bit(int nr, volatile void *addr) */ static inline int __test_and_clear_bit(int nr, volatile void *addr) { - unsigned int mask = BIT_MASK(nr); + unsigned int mask = BITOP_MASK(nr); volatile unsigned int *p = - ((volatile unsigned int *)addr) + BIT_WORD(nr); + ((volatile unsigned int *)addr) + BITOP_WORD(nr); unsigned int old = *p; *p = old & ~mask; @@ -118,9 +118,9 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr) static inline int __test_and_change_bit(int nr, volatile void *addr) { - unsigned int mask = BIT_MASK(nr); + unsigned int mask = BITOP_MASK(nr); volatile unsigned int *p = - ((volatile unsigned int *)addr) + BIT_WORD(nr); + ((volatile unsigned int *)addr) + BITOP_WORD(nr); unsigned int old = *p; *p = old ^ mask; @@ -135,7 +135,7 @@ static inline int __test_and_change_bit(int nr, static inline int test_bit(int nr, const volatile void *addr) { const volatile unsigned int *p = (const volatile unsigned int *)addr; - return 1UL & (p[BIT_WORD(nr)] >> (nr & (BITS_PER_WORD-1))); + return 1UL & (p[BITOP_WORD(nr)] >> (nr & (BITOP_BITS_PER_WORD-1))); } /* diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index dfb70417c2..a64595f68e 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -245,4 +245,6 @@ static inline __u32 ror32(__u32 word, unsigned int shift) (bit) < (size); \ (bit) = find_next_bit(addr, size, (bit) + 1) ) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) + #endif