Page MenuHomeFreeBSD

D45170.id138452.diff
No OneTemporary

D45170.id138452.diff

Index: sys/amd64/include/cpufunc.h
===================================================================
--- sys/amd64/include/cpufunc.h
+++ sys/amd64/include/cpufunc.h
@@ -65,10 +65,6 @@
#define bsfq(mask) __builtin_ctzl(mask)
-#define bsrl(mask) (__builtin_clz(mask) ^ 0x1f)
-
-#define bsrq(mask) (__builtin_clzl(mask) ^ 0x3f)
-
static __inline void
clflush(u_long addr)
{
Index: sys/arm64/iommu/smmu.c
===================================================================
--- sys/arm64/iommu/smmu.c
+++ sys/arm64/iommu/smmu.c
@@ -309,15 +309,6 @@
return (0);
}
-static inline int
-ilog2(long x)
-{
-
- KASSERT(x > 0 && powerof2(x), ("%s: invalid arg %ld", __func__, x));
-
- return (flsl(x) - 1);
-}
-
static int
smmu_init_queue(struct smmu_softc *sc, struct smmu_queue *q,
uint32_t prod_off, uint32_t cons_off, uint32_t dwords)
@@ -944,7 +935,7 @@
strtab = &sc->strtab;
- size = STRTAB_L1_SZ_SHIFT - (ilog2(STRTAB_L1_DESC_DWORDS) + 3);
+ size = STRTAB_L1_SZ_SHIFT - (ilog2l(STRTAB_L1_DESC_DWORDS) + 3);
size = min(size, sc->sid_bits - STRTAB_SPLIT);
strtab->num_l1_entries = (1 << size);
size += STRTAB_SPLIT;
@@ -1020,7 +1011,7 @@
return (0);
}
- size = 1 << (STRTAB_SPLIT + ilog2(STRTAB_STE_DWORDS) + 3);
+ size = 1 << (STRTAB_SPLIT + ilog2l(STRTAB_STE_DWORDS) + 3);
l1_desc->span = STRTAB_SPLIT + 1;
l1_desc->size = size;
Index: sys/dev/bxe/bxe.h
===================================================================
--- sys/dev/bxe/bxe.h
+++ sys/dev/bxe/bxe.h
@@ -126,16 +126,6 @@
#ifndef roundup
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#endif
-#ifndef ilog2
-static inline
-int bxe_ilog2(int x)
-{
- int log = 0;
- while (x >>= 1) log++;
- return (log);
-}
-#define ilog2(x) bxe_ilog2(x)
-#endif
#include "ecore_sp.h"
Index: sys/dev/bxe/ecore_sp.h
===================================================================
--- sys/dev/bxe/ecore_sp.h
+++ sys/dev/bxe/ecore_sp.h
@@ -159,7 +159,7 @@
#define ECORE_FREE(_s, _buf, _size) free(_buf, M_TEMP)
#define SC_ILT(sc) ((sc)->ilt)
-#define ILOG2(x) bxe_ilog2(x)
+#define ILOG2(x) ilog2(x)
#define ECORE_ILT_ZALLOC(x, y, size) \
do { \
Index: sys/dev/cxgbe/osdep.h
===================================================================
--- sys/dev/cxgbe/osdep.h
+++ sys/dev/cxgbe/osdep.h
@@ -130,14 +130,6 @@
#define PCI_EXP_LNKSTA_NLW PCIEM_LINK_STA_WIDTH
#define PCI_EXP_DEVCTL2 PCIER_DEVICE_CTL2
-static inline int
-ilog2(long x)
-{
- KASSERT(x > 0 && powerof2(x), ("%s: invalid arg %ld", __func__, x));
-
- return (flsl(x) - 1);
-}
-
static inline char *
strstrip(char *s)
{
Index: sys/dev/cxgbe/t4_main.c
===================================================================
--- sys/dev/cxgbe/t4_main.c
+++ sys/dev/cxgbe/t4_main.c
@@ -1942,7 +1942,7 @@
static inline int
stop_adapter(struct adapter *sc)
{
- if (atomic_testandset_int(&sc->error_flags, ilog2(ADAP_STOPPED)))
+ if (atomic_testandset_int(&sc->error_flags, ilog2l(ADAP_STOPPED)))
return (1); /* Already stopped. */
return (t4_shutdown_adapter(sc));
}
@@ -3624,7 +3624,7 @@
#ifdef TCP_OFFLOAD
t4_async_event(sc);
#endif
- if (atomic_testandclear_int(&sc->error_flags, ilog2(ADAP_CIM_ERR))) {
+ if (atomic_testandclear_int(&sc->error_flags, ilog2l(ADAP_CIM_ERR))) {
dump_cim_regs(sc);
dump_cimla(sc);
dump_devlog(sc);
@@ -3652,7 +3652,7 @@
const bool verbose = (sc->debug_flags & DF_VERBOSE_SLOWINTR) != 0;
stop_adapter(sc);
- if (atomic_testandset_int(&sc->error_flags, ilog2(ADAP_FATAL_ERR)))
+ if (atomic_testandset_int(&sc->error_flags, ilog2l(ADAP_FATAL_ERR)))
return;
if (fw_error) {
/*
@@ -3818,7 +3818,7 @@
t4_write_reg(sc,
PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_BASE_WIN, i),
(mw->mw_base + bar0) | V_BIR(0) |
- V_WINDOW(ilog2(mw->mw_aperture) - 10));
+ V_WINDOW(ilog2l(mw->mw_aperture) - 10));
rw_wlock(&mw->mw_lock);
position_memwin(sc, i, mw->mw_curpos);
rw_wunlock(&mw->mw_lock);
Index: sys/dev/cxgbe/t4_netmap.c
===================================================================
--- sys/dev/cxgbe/t4_netmap.c
+++ sys/dev/cxgbe/t4_netmap.c
@@ -317,7 +317,7 @@
c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(pi->tx_chan) |
F_FW_IQ_CMD_IQGTSMODE |
V_FW_IQ_CMD_IQINTCNTTHRESH(0) |
- V_FW_IQ_CMD_IQESIZE(ilog2(IQ_ESIZE) - 4));
+ V_FW_IQ_CMD_IQESIZE(ilog2l(IQ_ESIZE) - 4));
c.iqsize = htobe16(vi->qsize_rxq);
c.iqaddr = htobe64(nm_rxq->iq_ba);
if (cong_drop != -1) {
Index: sys/dev/cxgbe/t4_sge.c
===================================================================
--- sys/dev/cxgbe/t4_sge.c
+++ sys/dev/cxgbe/t4_sge.c
@@ -663,7 +663,7 @@
}
}
m = V_INGPADBOUNDARY(M_INGPADBOUNDARY);
- v = V_INGPADBOUNDARY(ilog2(pad) - pad_shift);
+ v = V_INGPADBOUNDARY(ilog2l(pad) - pad_shift);
t4_set_reg_field(sc, A_SGE_CONTROL, m, v);
if (is_t4(sc)) {
@@ -698,7 +698,7 @@
if (pack == 16)
v = V_INGPACKBOUNDARY(0);
else
- v = V_INGPACKBOUNDARY(ilog2(pack) - 5);
+ v = V_INGPACKBOUNDARY(ilog2l(pack) - 5);
MPASS(!is_t4(sc)); /* T4 doesn't have SGE_CONTROL2 */
t4_set_reg_field(sc, A_SGE_CONTROL2, m, v);
@@ -3557,7 +3557,7 @@
c.iqdroprss_to_iqesize = htobe16(V_FW_IQ_CMD_IQPCIECH(pi->tx_chan) |
F_FW_IQ_CMD_IQGTSMODE |
V_FW_IQ_CMD_IQINTCNTTHRESH(iq->intr_pktc_idx) |
- V_FW_IQ_CMD_IQESIZE(ilog2(IQ_ESIZE) - 4));
+ V_FW_IQ_CMD_IQESIZE(ilog2l(IQ_ESIZE) - 4));
c.iqsize = htobe16(iq->qsize);
c.iqaddr = htobe64(iq->ba);
c.iqns_to_fl0congen = htobe32(V_FW_IQ_CMD_IQTYPE(iq->qtype));
@@ -4222,7 +4222,7 @@
while (!powerof2(qsize))
qsize++;
- fthresh = ilog2(qsize);
+ fthresh = ilog2l(qsize);
if (fthresh > X_CIDXFLUSHTHRESH_128)
fthresh = X_CIDXFLUSHTHRESH_128;
Index: sys/dev/enetc/enetc_hw.h
===================================================================
--- sys/dev/enetc/enetc_hw.h
+++ sys/dev/enetc/enetc_hw.h
@@ -9,7 +9,6 @@
#define BIT(x) (1UL << (x))
#define GENMASK(h, l) (((~0U) - (1U << (l)) + 1) & (~0U >> (32 - 1 - (h))))
-#define ilog2(x) (flsl(x) - 1)
#define PCI_VENDOR_FREESCALE 0x1957
@@ -156,7 +155,7 @@
#define ENETC_TBICR0 0xa8
#define ENETC_TBICR0_ICEN BIT(31)
#define ENETC_TBICR0_ICPT_MASK 0xf
-#define ENETC_TBICR0_SET_ICPT(n) ((ilog2(n) + 1) & ENETC_TBICR0_ICPT_MASK)
+#define ENETC_TBICR0_SET_ICPT(n) ((ilog2l(n) + 1) & ENETC_TBICR0_ICPT_MASK)
#define ENETC_TBICR1 0xac
#define ENETC_RTBLENR_LEN(n) ((n) & ~0x7)
Index: sys/dev/mana/gdma_main.c
===================================================================
--- sys/dev/mana/gdma_main.c
+++ sys/dev/mana/gdma_main.c
@@ -794,7 +794,7 @@
queue->eq.msix_index = INVALID_PCI_MSIX_INDEX;
- log2_num_entries = ilog2(queue->queue_size / GDMA_EQE_SIZE);
+ log2_num_entries = ilog2l(queue->queue_size / GDMA_EQE_SIZE);
if (spec->eq.log2_throttle_limit > log2_num_entries) {
device_printf(dev,
@@ -835,7 +835,7 @@
mana_gd_create_cq(const struct gdma_queue_spec *spec,
struct gdma_queue *queue)
{
- uint32_t log2_num_entries = ilog2(spec->queue_size / GDMA_CQE_SIZE);
+ uint32_t log2_num_entries = ilog2l(spec->queue_size / GDMA_CQE_SIZE);
queue->head |= INITIALIZED_OWNER_BIT(log2_num_entries);
queue->cq.parent = spec->cq.parent_eq;
Index: sys/dev/mana/gdma_util.h
===================================================================
--- sys/dev/mana/gdma_util.h
+++ sys/dev/mana/gdma_util.h
@@ -170,15 +170,6 @@
return (max);
}
-static inline unsigned long
-ilog2(unsigned long x)
-{
- unsigned long log = x;
- while (x >>= 1)
- log++;
- return (log);
-}
-
static inline unsigned long
roundup_pow_of_two(unsigned long x)
{
Index: sys/dev/qat/qat/qat_ocf.c
===================================================================
--- sys/dev/qat/qat/qat_ocf.c
+++ sys/dev/qat/qat/qat_ocf.c
@@ -517,7 +517,7 @@
M_NOWAIT,
0,
~1UL,
- 1 << (bsrl(sessionCtxSize - 1) + 1),
+ 1 << (ilog2l(sessionCtxSize - 1) + 1),
0);
if (NULL == sessionCtx) {
device_printf(dev, "unable to allocate memory for session\n");
Index: sys/i386/include/cpufunc.h
===================================================================
--- sys/i386/include/cpufunc.h
+++ sys/i386/include/cpufunc.h
@@ -63,15 +63,6 @@
return (result);
}
-static __inline __pure2 u_int
-bsrl(u_int mask)
-{
- u_int result;
-
- __asm("bsrl %1,%0" : "=r" (result) : "rm" (mask) : "cc");
- return (result);
-}
-
static __inline void
clflush(u_long addr)
{
Index: sys/powerpc/booke/pmap.c
===================================================================
--- sys/powerpc/booke/pmap.c
+++ sys/powerpc/booke/pmap.c
@@ -239,7 +239,6 @@
static vm_size_t tsize2size(unsigned int);
static unsigned int size2tsize(vm_size_t);
-static unsigned long ilog2(unsigned long);
static void set_mas4_defaults(void);
@@ -2273,7 +2272,7 @@
* can be undefined, and exact mappings will be used instead.
*/
sz = size;
- size = roundup2(size, 1 << ilog2(size));
+ size = roundup2(size, 1 << ilog2l(size));
while (rounddown2(va, size) + size < va + sz)
size <<= 1;
va = rounddown2(va, size);
@@ -2709,7 +2708,7 @@
size2tsize(vm_size_t size)
{
- return (ilog2(size) / 2 - 5);
+ return (ilog2l(size) / 2 - 5);
}
/*
@@ -2774,7 +2773,7 @@
ssize = size;
while (size > 0) {
- sz = 1UL << (ilog2(size) & ~1);
+ sz = 1UL << (ilog2l(size) & ~1);
/* Align size to PA */
if (pa % sz != 0) {
do {
@@ -2909,11 +2908,11 @@
pa_base = rounddown(pa, PAGE_SIZE);
size = roundup(size + (pa - pa_base), PAGE_SIZE);
- tlb1_map_base = roundup2(tlb1_map_base, 1 << (ilog2(size) & ~1));
+ tlb1_map_base = roundup2(tlb1_map_base, 1 << (ilog2l(size) & ~1));
va = tlb1_map_base + (pa - pa_base);
do {
- sz = 1 << (ilog2(size) & ~1);
+ sz = 1 << (ilog2l(size) & ~1);
tlb1_set_entry(tlb1_map_base, pa_base, sz,
_TLB_ENTRY_SHARED | _TLB_ENTRY_IO);
size -= sz;
Index: sys/powerpc/booke/pmap_32.c
===================================================================
--- sys/powerpc/booke/pmap_32.c
+++ sys/powerpc/booke/pmap_32.c
@@ -116,7 +116,6 @@
#define VM_MAPDEV_BASE ((vm_offset_t)VM_MAXUSER_ADDRESS + PAGE_SIZE)
static void tid_flush(tlbtid_t tid);
-static unsigned long ilog2(unsigned long);
/**************************************************************************/
/* Page table management */
@@ -931,18 +930,6 @@
/* TID handling */
/**************************************************************************/
-/*
- * Return the largest uint value log such that 2^log <= num.
- */
-static unsigned long
-ilog2(unsigned long num)
-{
- long lz;
-
- __asm ("cntlzw %0, %1" : "=r" (lz) : "r" (num));
- return (31 - lz);
-}
-
/*
* Invalidate all TLB0 entries which match the given TID. Note this is
* dedicated for cases when invalidations should NOT be propagated to other
Index: sys/powerpc/booke/pmap_64.c
===================================================================
--- sys/powerpc/booke/pmap_64.c
+++ sys/powerpc/booke/pmap_64.c
@@ -125,7 +125,6 @@
#define VM_MAPDEV_PA_MAX 0x4000000000000000 /* Don't encroach on DMAP */
static void tid_flush(tlbtid_t tid);
-static unsigned long ilog2(unsigned long);
/**************************************************************************/
/* Page table management */
@@ -746,18 +745,6 @@
/* TID handling */
/**************************************************************************/
-/*
- * Return the largest uint value log such that 2^log <= num.
- */
-static unsigned long
-ilog2(unsigned long num)
-{
- long lz;
-
- __asm ("cntlzd %0, %1" : "=r" (lz) : "r" (num));
- return (63 - lz);
-}
-
/*
* Invalidate all TLB0 entries which match the given TID. Note this is
* dedicated for cases when invalidations should NOT be propagated to other
Index: sys/sys/libkern.h
===================================================================
--- sys/sys/libkern.h
+++ sys/sys/libkern.h
@@ -186,6 +186,31 @@
8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
}
+static __inline __pure2 int
+ilog2(int mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 - __builtin_clz((u_int)mask));
+}
+
+static __inline __pure2 int
+ilog2l(long mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 - __builtin_clzl((u_long)mask));
+}
+
+static __inline __pure2 int
+ilog2ll(long long mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 -
+ __builtin_clzll((unsigned long long)mask));
+}
+
#define bitcount64(x) __bitcount64((uint64_t)(x))
#define bitcount32(x) __bitcount32((uint32_t)(x))
#define bitcount16(x) __bitcount16((uint16_t)(x))

File Metadata

Mime Type
text/plain
Expires
Sat, Jul 18, 8:53 AM (14 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35193404
Default Alt Text
D45170.id138452.diff (12 KB)

Event Timeline