Date: Fri, 13 May 2016 21:10:16 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r299697 - in user/ngie/bsnmp_cleanup: . lib/libc/tests/nss sys/amd64/amd64 sys/arm/allwinner sys/arm/allwinner/clk sys/arm/allwinner/h3 sys/arm/conf sys/arm64/arm64 sys/arm64/include sy... Message-ID: <201605132110.u4DLAGxO002078@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Fri May 13 21:10:16 2016 New Revision: 299697 URL: https://svnweb.freebsd.org/changeset/base/299697 Log: MFhead @ r299696 Added: user/ngie/bsnmp_cleanup/sys/arm/allwinner/h3/ - copied from r299696, head/sys/arm/allwinner/h3/ user/ngie/bsnmp_cleanup/sys/dev/cxgbe/firmware/t4fw-1.15.37.0.bin.uu - copied unchanged from r299696, head/sys/dev/cxgbe/firmware/t4fw-1.15.37.0.bin.uu user/ngie/bsnmp_cleanup/sys/dev/cxgbe/firmware/t5fw-1.15.37.0.bin.uu - copied unchanged from r299696, head/sys/dev/cxgbe/firmware/t5fw-1.15.37.0.bin.uu Deleted: user/ngie/bsnmp_cleanup/sys/dev/cxgbe/firmware/t4fw-1.15.28.0.bin.uu user/ngie/bsnmp_cleanup/sys/dev/cxgbe/firmware/t5fw-1.15.28.0.bin.uu Modified: user/ngie/bsnmp_cleanup/Makefile.inc1 user/ngie/bsnmp_cleanup/lib/libc/tests/nss/testutil.h user/ngie/bsnmp_cleanup/sys/amd64/amd64/pmap.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_ehci.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_gpio.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.h user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_ccu.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_usbphy.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_gate.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_pll.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_usbclk.c user/ngie/bsnmp_cleanup/sys/arm/allwinner/std.allwinner user/ngie/bsnmp_cleanup/sys/arm/conf/ALLWINNER user/ngie/bsnmp_cleanup/sys/arm64/arm64/busdma_bounce.c user/ngie/bsnmp_cleanup/sys/arm64/include/cpufunc.h user/ngie/bsnmp_cleanup/sys/boot/common/boot.c user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.c user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.h user/ngie/bsnmp_cleanup/sys/boot/i386/common/cons.h user/ngie/bsnmp_cleanup/sys/boot/i386/zfsboot/zfsboot.c user/ngie/bsnmp_cleanup/sys/cddl/boot/zfs/lz4.c user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/asm/pgtable.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/compiler.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/device.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/err.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/ioctl.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/jiffies.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kdev_t.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kernel.h user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/page.h user/ngie/bsnmp_cleanup/sys/conf/files user/ngie/bsnmp_cleanup/sys/conf/files.amd64 user/ngie/bsnmp_cleanup/sys/conf/kmod.mk user/ngie/bsnmp_cleanup/sys/conf/options.arm user/ngie/bsnmp_cleanup/sys/dev/bhnd/tools/nvram_map_gen.sh user/ngie/bsnmp_cleanup/sys/dev/bwn/if_bwnreg.h user/ngie/bsnmp_cleanup/sys/dev/cxgbe/firmware/t4fw_interface.h user/ngie/bsnmp_cleanup/sys/dev/isp/isp_target.c user/ngie/bsnmp_cleanup/sys/dev/mmc/host/dwmmc.c user/ngie/bsnmp_cleanup/sys/dev/mrsas/mrsas.c user/ngie/bsnmp_cleanup/sys/dev/mrsas/mrsas.h user/ngie/bsnmp_cleanup/sys/dev/mrsas/mrsas_cam.c user/ngie/bsnmp_cleanup/sys/dev/mrsas/mrsas_fp.c user/ngie/bsnmp_cleanup/sys/dev/mrsas/mrsas_ioctl.c user/ngie/bsnmp_cleanup/sys/dev/pci/pci_host_generic.c user/ngie/bsnmp_cleanup/sys/dev/sym/sym_hipd.c user/ngie/bsnmp_cleanup/sys/modules/cxgbe/t4_firmware/Makefile user/ngie/bsnmp_cleanup/sys/modules/cxgbe/t5_firmware/Makefile user/ngie/bsnmp_cleanup/sys/riscv/riscv/pmap.c user/ngie/bsnmp_cleanup/sys/x86/x86/mca.c user/ngie/bsnmp_cleanup/usr.sbin/bhyve/pci_emul.c user/ngie/bsnmp_cleanup/usr.sbin/bhyve/pci_virtio_block.c user/ngie/bsnmp_cleanup/usr.sbin/binmiscctl/binmiscctl.c user/ngie/bsnmp_cleanup/usr.sbin/i2c/i2c.c Directory Properties: user/ngie/bsnmp_cleanup/ (props changed) Modified: user/ngie/bsnmp_cleanup/Makefile.inc1 ============================================================================== --- user/ngie/bsnmp_cleanup/Makefile.inc1 Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/Makefile.inc1 Fri May 13 21:10:16 2016 (r299697) @@ -1002,8 +1002,8 @@ restage: .MAKE .PHONY @echo ">>> Installing everything" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install -.if defined(LIB32TMP) && ${MK_LIB32} != "no" - ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32 +.if defined(LIBCOMPAT) + ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat} .endif redistribute: .MAKE .PHONY Modified: user/ngie/bsnmp_cleanup/lib/libc/tests/nss/testutil.h ============================================================================== --- user/ngie/bsnmp_cleanup/lib/libc/tests/nss/testutil.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/lib/libc/tests/nss/testutil.h Fri May 13 21:10:16 2016 (r299697) @@ -252,9 +252,7 @@ int \ __##ent##_snapshot_read(char const *fname, struct ent##_test_data *td, \ int (*read_func)(struct ent *, char *)) \ { \ - char buffer[1024]; \ struct ent data; \ - char *s; \ FILE *fi; \ size_t len; \ int rv; \ @@ -267,23 +265,22 @@ __##ent##_snapshot_read(char const *fnam return (-1); \ \ rv = 0; \ - memset(buffer, 0, sizeof(buffer)); \ while (!feof(fi)) { \ - s = fgets(buffer, sizeof(buffer), fi); \ - if (s != NULL && s[0] != '#') { \ - len = strlen(s); \ - if (len == 0) \ - continue; \ - if (buffer[len - 1] == '\n') \ - buffer[len -1] = '\0'; \ - \ - rv = read_func(&data, s); \ - if (rv == 0) { \ - __##ent##_test_data_append(td, &data); \ - td->free_func(&data); \ - } else \ - goto fin; \ - } \ + char *buf = fgetln(fi, &len); \ + if (buf == NULL || len <= 1) \ + continue; \ + if (buf[len - 1] == '\n') \ + buf[len - 1] = '\0'; \ + else \ + buf[len] = '\0'; \ + if (buf[0] == '#') \ + continue; \ + rv = read_func(&data, buf); \ + if (rv == 0) { \ + __##ent##_test_data_append(td, &data); \ + td->free_func(&data); \ + } else \ + goto fin; \ } \ \ fin: \ Modified: user/ngie/bsnmp_cleanup/sys/amd64/amd64/pmap.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/amd64/amd64/pmap.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/amd64/amd64/pmap.c Fri May 13 21:10:16 2016 (r299697) @@ -119,7 +119,6 @@ __FBSDID("$FreeBSD$"); #include <sys/vmmeter.h> #include <sys/sched.h> #include <sys/sysctl.h> -#include <sys/_unrhdr.h> #include <sys/smp.h> #include <vm/vm.h> Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_ehci.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_ehci.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_ehci.c Fri May 13 21:10:16 2016 (r299697) @@ -113,6 +113,7 @@ static struct ofw_compat_data compat_dat { "allwinner,sun6i-a31-ehci", (uintptr_t)&a31_ehci_conf }, { "allwinner,sun7i-a20-ehci", (uintptr_t)&a10_ehci_conf }, { "allwinner,sun8i-a83t-ehci", (uintptr_t)&a31_ehci_conf }, + { "allwinner,sun8i-h3-ehci", (uintptr_t)&a31_ehci_conf }, { NULL, (uintptr_t)NULL } }; Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_gpio.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_gpio.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/a10_gpio.c Fri May 13 21:10:16 2016 (r299697) @@ -99,6 +99,12 @@ extern const struct allwinner_padconf a3 extern const struct allwinner_padconf a31_r_padconf; #endif +/* Defined in h3_padconf.c */ +#ifdef SOC_ALLWINNER_H3 +extern const struct allwinner_padconf h3_padconf; +extern const struct allwinner_padconf h3_r_padconf; +#endif + /* Defined in a83t_padconf.c */ #ifdef SOC_ALLWINNER_A83T extern const struct allwinner_padconf a83t_padconf; @@ -125,6 +131,10 @@ static struct ofw_compat_data compat_dat {"allwinner,sun8i-a83t-pinctrl", (uintptr_t)&a83t_padconf}, {"allwinner,sun8i-a83t-r-pinctrl", (uintptr_t)&a83t_r_padconf}, #endif +#ifdef SOC_ALLWINNER_H3 + {"allwinner,sun8i-h3-pinctrl", (uintptr_t)&h3_padconf}, + {"allwinner,sun8i-h3-r-pinctrl", (uintptr_t)&h3_r_padconf}, +#endif {NULL, 0} }; Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.c Fri May 13 21:10:16 2016 (r299697) @@ -103,6 +103,15 @@ a83t_attach(platform_t plat) return (0); } +static int +h3_attach(platform_t plat) +{ + soc_type = ALLWINNERSOC_H3; + soc_family = ALLWINNERSOC_SUN8I; + + return (0); +} + static vm_offset_t allwinner_lastaddr(platform_t plat) { @@ -220,6 +229,21 @@ static platform_method_t a83t_methods[] FDT_PLATFORM_DEF(a83t, "a83t", 0, "allwinner,sun8i-a83t", 200); #endif +#if defined(SOC_ALLWINNER_H3) +static platform_method_t h3_methods[] = { + PLATFORMMETHOD(platform_attach, h3_attach), + PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr), + PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), + +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), + PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), +#endif + PLATFORMMETHOD_END, +}; +FDT_PLATFORM_DEF(h3, "h3", 0, "allwinner,sun8i-h3", 200); +#endif + u_int allwinner_soc_type(void) { Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/allwinner_machdep.h Fri May 13 21:10:16 2016 (r299697) @@ -34,6 +34,7 @@ #define ALLWINNERSOC_A13 0x13000000 #define ALLWINNERSOC_A10S 0x10000001 #define ALLWINNERSOC_A20 0x20000000 +#define ALLWINNERSOC_H3 0x30000000 #define ALLWINNERSOC_A31 0x31000000 #define ALLWINNERSOC_A31S 0x31000001 #define ALLWINNERSOC_A83T 0x83000000 Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_ccu.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_ccu.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_ccu.c Fri May 13 21:10:16 2016 (r299697) @@ -80,6 +80,7 @@ static struct ofw_compat_data compat_dat { "allwinner,sun6i-a31", CLOCK_CCU }, { "allwinner,sun6i-a31s", CLOCK_CCU }, { "allwinner,sun8i-a83t", CLOCK_CCU|CLOCK_PRCM|CLOCK_SYSCTRL }, + { "allwinner,sun8i-h3", CLOCK_CCU }, { NULL, 0 } }; Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_usbphy.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_usbphy.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/aw_usbphy.c Fri May 13 21:10:16 2016 (r299697) @@ -56,6 +56,7 @@ static struct ofw_compat_data compat_dat { "allwinner,sun6i-a31-usb-phy", 1 }, { "allwinner,sun7i-a20-usb-phy", 1 }, { "allwinner,sun8i-a83t-usb-phy", 1 }, + { "allwinner,sun8i-h3-usb-phy", 1 }, { NULL, 0 } }; Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_gate.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_gate.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_gate.c Fri May 13 21:10:16 2016 (r299697) @@ -81,6 +81,9 @@ static struct ofw_compat_data compat_dat { "allwinner,sun8i-a83t-apb0-gates-clk", (uintptr_t)"Allwinner APB0 Clock Gates" }, + { "allwinner,sun8i-h3-bus-gates-clk", + (uintptr_t)"Allwinner Bus Clock Gates"}, + { "allwinner,sun9i-a80-apbs-gates-clk", (uintptr_t)"Allwinner APBS Clock Gates" }, Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_pll.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_pll.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_pll.c Fri May 13 21:10:16 2016 (r299697) @@ -101,6 +101,15 @@ __FBSDID("$FreeBSD$"); #define A10_PLL2_POST_DIV (0xf << 26) +#define A23_PLL1_FACTOR_N (0x1f << 8) +#define A23_PLL1_FACTOR_N_SHIFT 8 +#define A23_PLL1_FACTOR_K (0x3 << 4) +#define A23_PLL1_FACTOR_K_SHIFT 4 +#define A23_PLL1_FACTOR_M (0x3 << 0) +#define A23_PLL1_FACTOR_M_SHIFT 0 +#define A23_PLL1_FACTOR_P (0x3 << 16) +#define A23_PLL1_FACTOR_P_SHIFT 16 + #define A31_PLL1_LOCK (1 << 28) #define A31_PLL1_CPU_SIGMA_DELTA_EN (1 << 24) #define A31_PLL1_FACTOR_N (0x1f << 8) @@ -150,6 +159,7 @@ enum aw_pll_type { AWPLL_A10_PLL3, AWPLL_A10_PLL5, AWPLL_A10_PLL6, + AWPLL_A23_PLL1, AWPLL_A31_PLL1, AWPLL_A31_PLL6, AWPLL_A80_PLL4, @@ -452,6 +462,25 @@ a10_pll6_set_freq(struct aw_pll_sc *sc, } static int +a23_pll1_recalc(struct aw_pll_sc *sc, uint64_t *freq) +{ + uint32_t val, m, n, k, p; + + DEVICE_LOCK(sc); + PLL_READ(sc, &val); + DEVICE_UNLOCK(sc); + + m = ((val & A23_PLL1_FACTOR_M) >> A23_PLL1_FACTOR_M_SHIFT) + 1; + k = ((val & A23_PLL1_FACTOR_K) >> A23_PLL1_FACTOR_K_SHIFT) + 1; + n = ((val & A23_PLL1_FACTOR_N) >> A23_PLL1_FACTOR_N_SHIFT) + 1; + p = ((val & A23_PLL1_FACTOR_P) >> A23_PLL1_FACTOR_P_SHIFT) + 1; + + *freq = (*freq * n * k) / (m * p); + + return (0); +} + +static int a31_pll1_recalc(struct aw_pll_sc *sc, uint64_t *freq) { uint32_t val, m, n, k; @@ -562,6 +591,7 @@ static struct aw_pll_funcs aw_pll_func[] PLL(AWPLL_A10_PLL3, a10_pll3_recalc, a10_pll3_set_freq, a10_pll3_init), PLL(AWPLL_A10_PLL5, a10_pll5_recalc, NULL, NULL), PLL(AWPLL_A10_PLL6, a10_pll6_recalc, a10_pll6_set_freq, a10_pll6_init), + PLL(AWPLL_A23_PLL1, a23_pll1_recalc, NULL, NULL), PLL(AWPLL_A31_PLL1, a31_pll1_recalc, NULL, NULL), PLL(AWPLL_A31_PLL6, a31_pll6_recalc, NULL, a31_pll6_init), PLL(AWPLL_A80_PLL4, a80_pll4_recalc, NULL, NULL), @@ -575,6 +605,7 @@ static struct ofw_compat_data compat_dat { "allwinner,sun4i-a10-pll6-clk", AWPLL_A10_PLL6 }, { "allwinner,sun6i-a31-pll1-clk", AWPLL_A31_PLL1 }, { "allwinner,sun6i-a31-pll6-clk", AWPLL_A31_PLL6 }, + { "allwinner,sun8i-a23-pll1-clk", AWPLL_A23_PLL1 }, { "allwinner,sun9i-a80-pll4-clk", AWPLL_A80_PLL4 }, { NULL, 0 } }; Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_usbclk.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_usbclk.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/clk/aw_usbclk.c Fri May 13 21:10:16 2016 (r299697) @@ -63,17 +63,21 @@ enum aw_usbclk_type { AW_A10_USBCLK = 1, AW_A31_USBCLK, AW_A83T_USBCLK, + AW_H3_USBCLK, }; static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-usb-clk", AW_A10_USBCLK }, { "allwinner,sun6i-a31-usb-clk", AW_A31_USBCLK }, { "allwinner,sun8i-a83t-usb-clk", AW_A83T_USBCLK }, + { "allwinner,sun8i-h3-usb-clk", AW_H3_USBCLK }, { NULL, 0 } }; /* Clock indices for A10, as there is no clock-indices property in the DT */ static uint32_t aw_usbclk_indices_a10[] = { 6, 7, 8 }; +/* Clock indices for H3, as there is no clock-indices property in the DT */ +static uint32_t aw_usbclk_indices_h3[] = { 8, 9, 10, 11, 16, 17, 18, 19 }; struct aw_usbclk_softc { bus_addr_t reg; @@ -193,6 +197,8 @@ aw_usbclk_attach(device_t dev) if (indices == NULL && type == AW_A10_USBCLK) indices = aw_usbclk_indices_a10; + else if (indices == NULL && type == AW_H3_USBCLK) + indices = aw_usbclk_indices_h3; error = clk_get_by_ofw_index(dev, 0, &clk_parent); if (error != 0) { Modified: user/ngie/bsnmp_cleanup/sys/arm/allwinner/std.allwinner ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/allwinner/std.allwinner Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/allwinner/std.allwinner Fri May 13 21:10:16 2016 (r299697) @@ -15,3 +15,4 @@ files "../allwinner/files.allwinner" files "../allwinner/a20/files.a20" files "../allwinner/a31/files.a31" files "../allwinner/a83t/files.a83t" +files "../allwinner/h3/files.h3" Modified: user/ngie/bsnmp_cleanup/sys/arm/conf/ALLWINNER ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm/conf/ALLWINNER Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm/conf/ALLWINNER Fri May 13 21:10:16 2016 (r299697) @@ -29,6 +29,7 @@ options SOC_ALLWINNER_A20 options SOC_ALLWINNER_A31 options SOC_ALLWINNER_A31S options SOC_ALLWINNER_A83T +options SOC_ALLWINNER_H3 options HZ=100 options SCHED_ULE # ULE scheduler Modified: user/ngie/bsnmp_cleanup/sys/arm64/arm64/busdma_bounce.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm64/arm64/busdma_bounce.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm64/arm64/busdma_bounce.c Fri May 13 21:10:16 2016 (r299697) @@ -1,8 +1,11 @@ /*- * Copyright (c) 1997, 1998 Justin T. Gibbs. - * Copyright (c) 2015 The FreeBSD Foundation + * Copyright (c) 2015-2016 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Andrew Turner + * under sponsorship of the FreeBSD Foundation. + * * Portions of this software were developed by Semihalf * under sponsorship of the FreeBSD Foundation. * @@ -62,6 +65,7 @@ enum { BF_COULD_BOUNCE = 0x01, BF_MIN_ALLOC_COMP = 0x02, BF_KMEM_ALLOC = 0x04, + BF_COHERENT = 0x10, }; struct bounce_zone; @@ -113,6 +117,13 @@ static SYSCTL_NODE(_hw, OID_AUTO, busdma SYSCTL_INT(_hw_busdma, OID_AUTO, total_bpages, CTLFLAG_RD, &total_bpages, 0, "Total bounce pages"); +struct sync_list { + vm_offset_t vaddr; /* kva of client data */ + bus_addr_t paddr; /* physical address */ + vm_page_t pages; /* starting page of client data */ + bus_size_t datacount; /* client data count */ +}; + struct bus_dmamap { struct bp_list bpages; int pagesneeded; @@ -125,6 +136,8 @@ struct bus_dmamap { u_int flags; #define DMAMAP_COULD_BOUNCE (1 << 0) #define DMAMAP_FROM_DMAMEM (1 << 1) + int sync_count; + struct sync_list slist[]; }; static STAILQ_HEAD(, bus_dmamap) bounce_map_waitinglist; @@ -171,9 +184,19 @@ bounce_bus_dma_tag_create(bus_dma_tag_t newtag->map_count = 0; newtag->segments = NULL; - if (parent != NULL && ((newtag->common.filter != NULL) || - ((parent->bounce_flags & BF_COULD_BOUNCE) != 0))) - newtag->bounce_flags |= BF_COULD_BOUNCE; +#ifdef notyet + if ((flags & BUS_DMA_COHERENT) != 0) + newtag->bounce_flags |= BF_COHERENT; +#endif + + if (parent != NULL) { + if ((newtag->common.filter != NULL || + (parent->bounce_flags & BF_COULD_BOUNCE) != 0)) + newtag->bounce_flags |= BF_COULD_BOUNCE; + + /* Copy some flags from the parent */ + newtag->bounce_flags |= parent->bounce_flags & BF_COHERENT; + } if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) || newtag->common.alignment > 1) @@ -251,11 +274,14 @@ out: } static bus_dmamap_t -alloc_dmamap(int flags) +alloc_dmamap(bus_dma_tag_t dmat, int flags) { + u_long mapsize; bus_dmamap_t map; - map = malloc(sizeof(*map), M_DEVBUF, flags | M_ZERO); + mapsize = sizeof(*map); + mapsize += sizeof(struct sync_list) * dmat->common.nsegments; + map = malloc(mapsize, M_DEVBUF, flags | M_ZERO); if (map == NULL) return (NULL); @@ -288,7 +314,7 @@ bounce_bus_dmamap_create(bus_dma_tag_t d } } - *mapp = alloc_dmamap(M_NOWAIT); + *mapp = alloc_dmamap(dmat, M_NOWAIT); if (*mapp == NULL) { CTR3(KTR_BUSDMA, "%s: tag %p error %d", __func__, dmat, ENOMEM); @@ -360,7 +386,7 @@ bounce_bus_dmamap_destroy(bus_dma_tag_t if ((map->flags & DMAMAP_FROM_DMAMEM) != 0) panic("bounce_bus_dmamap_destroy: Invalid map freed\n"); - if (STAILQ_FIRST(&map->bpages) != NULL) { + if (STAILQ_FIRST(&map->bpages) != NULL || map->sync_count != 0) { CTR3(KTR_BUSDMA, "%s: tag %p error %d", __func__, dmat, EBUSY); return (EBUSY); } @@ -421,7 +447,7 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dm * Create the map, but don't set the could bounce flag as * this allocation should never bounce; */ - *mapp = alloc_dmamap(mflags); + *mapp = alloc_dmamap(dmat, mflags); if (*mapp == NULL) { CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", __func__, dmat, dmat->common.flags, ENOMEM); @@ -644,8 +670,9 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_ vm_paddr_t buf, bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp) { + struct sync_list *sl; bus_size_t sgsize; - bus_addr_t curaddr; + bus_addr_t curaddr, sl_end; int error; if (segs == NULL) @@ -660,6 +687,9 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_ } } + sl = map->slist + map->sync_count - 1; + sl_end = 0; + while (buflen > 0) { curaddr = buf; sgsize = MIN(buflen, dmat->common.maxsegsz); @@ -669,6 +699,23 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_ sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); + } else if ((dmat->bounce_flags & BF_COHERENT) == 0) { + if (map->sync_count > 0) + sl_end = sl->paddr + sl->datacount; + + if (map->sync_count == 0 || curaddr != sl_end) { + if (++map->sync_count > dmat->common.nsegments) + break; + sl++; + sl->vaddr = 0; + sl->paddr = curaddr; + sl->datacount = sgsize; + sl->pages = PHYS_TO_VM_PAGE(curaddr); + KASSERT(sl->pages != NULL, + ("%s: page at PA:0x%08lx is not in " + "vm_page_array", __func__, curaddr)); + } else + sl->datacount += sgsize; } sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs, segp); @@ -693,9 +740,10 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta bus_size_t buflen, pmap_t pmap, int flags, bus_dma_segment_t *segs, int *segp) { + struct sync_list *sl; bus_size_t sgsize, max_sgsize; - bus_addr_t curaddr; - vm_offset_t kvaddr, vaddr; + bus_addr_t curaddr, sl_pend; + vm_offset_t kvaddr, vaddr, sl_vend; int error; if (segs == NULL) @@ -710,7 +758,11 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta } } + sl = map->slist + map->sync_count - 1; vaddr = (vm_offset_t)buf; + sl_pend = 0; + sl_vend = 0; + while (buflen > 0) { /* * Get the physical address for this segment. @@ -735,6 +787,34 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta sgsize = MIN(sgsize, max_sgsize); curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, sgsize); + } else if ((dmat->bounce_flags & BF_COHERENT) == 0) { + sgsize = MIN(sgsize, max_sgsize); + if (map->sync_count > 0) { + sl_pend = sl->paddr + sl->datacount; + sl_vend = sl->vaddr + sl->datacount; + } + + if (map->sync_count == 0 || + (kvaddr != 0 && kvaddr != sl_vend) || + (curaddr != sl_pend)) { + + if (++map->sync_count > dmat->common.nsegments) + goto cleanup; + sl++; + sl->vaddr = kvaddr; + sl->paddr = curaddr; + if (kvaddr != 0) { + sl->pages = NULL; + } else { + sl->pages = PHYS_TO_VM_PAGE(curaddr); + KASSERT(sl->pages != NULL, + ("%s: page at PA:0x%08lx is not " + "in vm_page_array", __func__, + curaddr)); + } + sl->datacount = sgsize; + } else + sl->datacount += sgsize; } else { sgsize = MIN(sgsize, max_sgsize); } @@ -746,6 +826,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta buflen -= sgsize; } +cleanup: /* * Did we fit? */ @@ -783,13 +864,87 @@ bounce_bus_dmamap_unload(bus_dma_tag_t d { struct bounce_page *bpage; - if ((map->flags & DMAMAP_COULD_BOUNCE) == 0) - return; - while ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) { STAILQ_REMOVE_HEAD(&map->bpages, links); free_bounce_page(dmat, bpage); } + + map->sync_count = 0; +} + +static void +dma_preread_safe(vm_offset_t va, vm_size_t size) +{ + /* + * Write back any partial cachelines immediately before and + * after the DMA region. + */ + if (va & (dcache_line_size - 1)) + cpu_dcache_wb_range(va, 1); + if ((va + size) & (dcache_line_size - 1)) + cpu_dcache_wb_range(va + size, 1); + + cpu_dcache_inv_range(va, size); +} + +static void +dma_dcache_sync(struct sync_list *sl, bus_dmasync_op_t op) +{ + uint32_t len, offset; + vm_page_t m; + vm_paddr_t pa; + vm_offset_t va, tempva; + bus_size_t size; + + offset = sl->paddr & PAGE_MASK; + m = sl->pages; + size = sl->datacount; + pa = sl->paddr; + + for ( ; size != 0; size -= len, pa += len, offset = 0, ++m) { + tempva = 0; + if (sl->vaddr == 0) { + len = min(PAGE_SIZE - offset, size); + tempva = pmap_quick_enter_page(m); + va = tempva | offset; + KASSERT(pa == (VM_PAGE_TO_PHYS(m) | offset), + ("unexpected vm_page_t phys: 0x%16lx != 0x%16lx", + VM_PAGE_TO_PHYS(m) | offset, pa)); + } else { + len = sl->datacount; + va = sl->vaddr; + } + + switch (op) { + case BUS_DMASYNC_PREWRITE: + case BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD: + cpu_dcache_wb_range(va, len); + break; + case BUS_DMASYNC_PREREAD: + /* + * An mbuf may start in the middle of a cacheline. There + * will be no cpu writes to the beginning of that line + * (which contains the mbuf header) while dma is in + * progress. Handle that case by doing a writeback of + * just the first cacheline before invalidating the + * overall buffer. Any mbuf in a chain may have this + * misalignment. Buffers which are not mbufs bounce if + * they are not aligned to a cacheline. + */ + dma_preread_safe(va, len); + break; + case BUS_DMASYNC_POSTREAD: + case BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE: + cpu_dcache_inv_range(va, len); + break; + default: + panic("unsupported combination of sync operations: " + "0x%08x\n", op); + } + + if (tempva != 0) + pmap_quick_remove_page(tempva); + } } static void @@ -797,15 +952,9 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma bus_dmasync_op_t op) { struct bounce_page *bpage; + struct sync_list *sl, *end; vm_offset_t datavaddr, tempvaddr; - /* - * XXX ARM64TODO: - * This bus_dma implementation requires IO-Coherent architecutre. - * If IO-Coherency is not guaranteed, cache operations have to be - * added to this function. - */ - if ((op & BUS_DMASYNC_POSTREAD) != 0) { /* * Wait for any DMA operations to complete before the bcopy. @@ -832,13 +981,26 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma (void *)bpage->vaddr, bpage->datacount); if (tempvaddr != 0) pmap_quick_remove_page(tempvaddr); + if ((dmat->bounce_flags & BF_COHERENT) == 0) + cpu_dcache_wb_range(bpage->vaddr, + bpage->datacount); bpage = STAILQ_NEXT(bpage, links); } dmat->bounce_zone->total_bounced++; + } else if ((op & BUS_DMASYNC_PREREAD) != 0) { + while (bpage != NULL) { + if ((dmat->bounce_flags & BF_COHERENT) == 0) + cpu_dcache_wbinv_range(bpage->vaddr, + bpage->datacount); + bpage = STAILQ_NEXT(bpage, links); + } } if ((op & BUS_DMASYNC_POSTREAD) != 0) { while (bpage != NULL) { + if ((dmat->bounce_flags & BF_COHERENT) == 0) + cpu_dcache_inv_range(bpage->vaddr, + bpage->datacount); tempvaddr = 0; datavaddr = bpage->datavaddr; if (datavaddr == 0) { @@ -858,7 +1020,20 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma } } - if ((op & BUS_DMASYNC_PREWRITE) != 0) { + /* + * Cache maintenance for normal (non-COHERENT non-bounce) buffers. + */ + if (map->sync_count != 0) { + sl = &map->slist[0]; + end = &map->slist[map->sync_count]; + CTR3(KTR_BUSDMA, "%s: tag %p op 0x%x " + "performing sync", __func__, dmat, op); + + for ( ; sl != end; ++sl) + dma_dcache_sync(sl, op); + } + + if ((op & (BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE)) != 0) { /* * Wait for the bcopy to complete before any DMA operations. */ Modified: user/ngie/bsnmp_cleanup/sys/arm64/include/cpufunc.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/arm64/include/cpufunc.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/arm64/include/cpufunc.h Fri May 13 21:10:16 2016 (r299697) @@ -119,6 +119,11 @@ clrex(void) __asm __volatile("clrex" : : : "memory"); } +extern int64_t dcache_line_size; +extern int64_t icache_line_size; +extern int64_t idcache_line_size; +extern int64_t dczva_line_size; + #define cpu_nullop() arm64_nullop() #define cpufunc_nullop() arm64_nullop() #define cpu_setttb(a) arm64_setttb(a) Modified: user/ngie/bsnmp_cleanup/sys/boot/common/boot.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/boot/common/boot.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/boot/common/boot.c Fri May 13 21:10:16 2016 (r299697) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> +#include <strings.h> #include "bootstrap.h" Modified: user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.c Fri May 13 21:10:16 2016 (r299697) @@ -155,7 +155,7 @@ geli_attach(struct dsk *dskp, const char g_eli_crypto_hmac_update(&ctx, passphrase, strlen(passphrase)); } else if (geli_e->md.md_iterations > 0) { - printf("Calculating GELI Decryption Key disk%dp%d @ %lu" + printf("Calculating GELI Decryption Key disk%dp%d @ %d" " iterations...\n", dskp->unit, (dskp->slice > 0 ? dskp->slice : dskp->part), geli_e->md.md_iterations); Modified: user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/boot/geli/geliboot.h Fri May 13 21:10:16 2016 (r299697) @@ -86,4 +86,7 @@ int geli_decrypt(u_int algo, u_char *dat const u_char *key, size_t keysize, const uint8_t* iv); int geli_passphrase(char *pw, int disk, int parttype, int part, struct dsk *dskp); +int geliboot_crypt(u_int algo, int enc, u_char *data, size_t datasize, + const u_char *key, size_t keysize, u_char *iv); + #endif /* _GELIBOOT_H_ */ Modified: user/ngie/bsnmp_cleanup/sys/boot/i386/common/cons.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/boot/i386/common/cons.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/boot/i386/common/cons.h Fri May 13 21:10:16 2016 (r299697) @@ -28,6 +28,7 @@ void xputc(int c); void putchar(int c); int getc(int fn); int xgetc(int fn); +int getchar(void); int keyhit(unsigned int secs); void getstr(char *cmdstr, size_t cmdstrsize); Modified: user/ngie/bsnmp_cleanup/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/boot/i386/zfsboot/zfsboot.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/boot/i386/zfsboot/zfsboot.c Fri May 13 21:10:16 2016 (r299697) @@ -85,7 +85,6 @@ static const unsigned char flags[NOPT] = }; uint32_t opts; -static const char *const dev_nm[NDEV] = {"ad", "da", "fd"}; static const unsigned char dev_maj[NDEV] = {30, 4, 2}; static char cmd[512]; @@ -399,7 +398,9 @@ probe_drive(struct dsk *dsk) struct gpt_ent *ent; unsigned part, entries_per_sec; #endif +#ifdef LOADER_GELI_SUPPORT daddr_t slba, elba; +#endif struct dos_partition *dp; char *sec; unsigned i; Modified: user/ngie/bsnmp_cleanup/sys/cddl/boot/zfs/lz4.c ============================================================================== --- user/ngie/bsnmp_cleanup/sys/cddl/boot/zfs/lz4.c Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/cddl/boot/zfs/lz4.c Fri May 13 21:10:16 2016 (r299697) @@ -34,6 +34,8 @@ * $FreeBSD$ */ +#include <arpa/inet.h> + static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize); Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/asm/pgtable.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/asm/pgtable.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/asm/pgtable.h Fri May 13 21:10:16 2016 (r299697) @@ -31,6 +31,6 @@ #ifndef _ASM_PGTABLE_H_ #define _ASM_PGTABLE_H_ -typedef int pgprot_t; +#include <linux/page.h> #endif /* _ASM_PGTABLE_H_ */ Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/compiler.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/compiler.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/compiler.h Fri May 13 21:10:16 2016 (r299697) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * Copyright (c) 2015 François Tigeot * All rights reserved. * @@ -50,14 +50,17 @@ #define __cond_lock(x,c) (c) #define __bitwise #define __devinitdata +#define __deprecated #define __init #define __devinit #define __devexit #define __exit +#define __rcu #define __stringify(x) #x #define __attribute_const__ __attribute__((__const__)) #undef __always_inline #define __always_inline inline +#define ____cacheline_aligned __aligned(CACHE_LINE_SIZE) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) @@ -72,6 +75,9 @@ #define barrier() __asm__ __volatile__("": : :"memory") +#define ___PASTE(a,b) a##b +#define __PASTE(a,b) ___PASTE(a,b) + #define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x)) #define WRITE_ONCE(x,v) do { \ @@ -87,5 +93,9 @@ barrier(); \ __var; \ }) - + +#define lockless_dereference(p) READ_ONCE(p) + +#define _AT(T,X) ((T)(X)) + #endif /* _LINUX_COMPILER_H_ */ Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/device.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/device.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/device.h Fri May 13 21:10:16 2016 (r299697) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,11 +203,15 @@ device_register(struct device *dev) int unit; bsddev = NULL; + unit = -1; + if (dev->devt) { unit = MINOR(dev->devt); bsddev = devclass_get_device(dev->class->bsdclass, unit); - } else - unit = -1; + } else if (dev->parent == NULL) { + bsddev = devclass_get_device(dev->class->bsdclass, 0); + } + if (bsddev == NULL) bsddev = device_add_child(dev->parent->bsddev, dev->class->kobj.name, unit); Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/err.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/err.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/err.h Fri May 13 21:10:16 2016 (r299697) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,9 +31,11 @@ #ifndef _LINUX_ERR_H_ #define _LINUX_ERR_H_ +#include <linux/compiler.h> + #define MAX_ERRNO 4095 -#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) +#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) static inline void * ERR_PTR(long error) Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/ioctl.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/ioctl.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/ioctl.h Fri May 13 21:10:16 2016 (r299697) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,4 +33,6 @@ #include <sys/ioccom.h> +#define _IOC_SIZE(cmd) IOCPARM_LEN(cmd) + #endif /* _LINUX_IOCTL_H_ */ Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/jiffies.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/jiffies.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/jiffies.h Fri May 13 21:10:16 2016 (r299697) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,16 +39,6 @@ #include <sys/kernel.h> #include <sys/limits.h> -static inline int -msecs_to_jiffies(int msec) -{ - struct timeval tv; - - tv.tv_sec = msec / 1000; - tv.tv_usec = (msec % 1000) * 1000; - return (tvtohz(&tv) - 1); -} - #define jiffies ticks #define jiffies_64 ticks #define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz) @@ -78,17 +68,35 @@ timespec_to_jiffies(const struct timespe } static inline int -usecs_to_jiffies(const unsigned int u) +msecs_to_jiffies(const u64 msec) { u64 result; - result = ((u64)u * hz + 1000000 - 1) / 1000000; + result = howmany(msec * (u64)hz, 1000ULL); if (result > MAX_JIFFY_OFFSET) result = MAX_JIFFY_OFFSET; return ((int)result); } +static inline int +usecs_to_jiffies(const u64 u) +{ + u64 result; + + result = howmany(u * (u64)hz, 1000000ULL); + if (result > MAX_JIFFY_OFFSET) + result = MAX_JIFFY_OFFSET; + + return ((int)result); +} + +static inline u64 +nsecs_to_jiffies(const u64 n) +{ + return (usecs_to_jiffies(howmany(n, 1000ULL))); +} + static inline u64 get_jiffies_64(void) { Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kdev_t.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kdev_t.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kdev_t.h Fri May 13 21:10:16 2016 (r299697) @@ -35,4 +35,10 @@ #define MINOR(dev) minor((dev)) #define MKDEV(ma, mi) makedev((ma), (mi)) +static inline uint16_t +old_encode_dev(dev_t dev) +{ + return ((MAJOR(dev) << 8) | MINOR(dev)); +} + #endif /* _LINUX_KDEV_T_H_ */ Modified: user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kernel.h ============================================================================== --- user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kernel.h Fri May 13 21:05:09 2016 (r299696) +++ user/ngie/bsnmp_cleanup/sys/compat/linuxkpi/common/include/linux/kernel.h Fri May 13 21:10:16 2016 (r299697) @@ -62,11 +62,59 @@ #define KERN_INFO "<6>" #define KERN_DEBUG "<7>" +#define U8_MAX ((u8)~0U) +#define S8_MAX ((s8)(U8_MAX >> 1)) +#define S8_MIN ((s8)(-S8_MAX - 1)) +#define U16_MAX ((u16)~0U) +#define S16_MAX ((s16)(U16_MAX >> 1)) *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605132110.u4DLAGxO002078>