From 66c8095956124a8e73c2dc3cf6a060474f703ba4 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 10 Oct 2014 06:24:09 +0000 Subject: [PATCH 001/112] Rename elf*-powerpc into elf*-powerpc-freebsd in binutils The powerpc support was the only supported architecture not prepending the elf format name with "-freebsd" in base this change makes it consistent with other architectures. On newer version of binutils the powerpc format is also prepended with "-freebsd". Also modify the kernel ldscripts in that regards. As a result it is now possible cross build the kernel on powerpc using newer binutils Differential Revision: https://reviews.freebsd.org/D926 Differential Revision: https://reviews.freebsd.org/D928 --- contrib/binutils/bfd/elf32-ppc.c | 2 +- contrib/binutils/bfd/elf64-ppc.c | 2 +- contrib/binutils/gas/config/tc-ppc.c | 2 +- contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh | 2 ++ contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh | 1 + sys/boot/powerpc/ofw/ldscript.powerpc | 3 ++- sys/boot/powerpc/ps3/ldscript.powerpc | 3 ++- sys/boot/powerpc/uboot/ldscript.powerpc | 3 ++- sys/conf/ldscript.powerpc | 3 ++- sys/conf/ldscript.powerpc64 | 3 ++- 10 files changed, 16 insertions(+), 8 deletions(-) diff --git a/contrib/binutils/bfd/elf32-ppc.c b/contrib/binutils/bfd/elf32-ppc.c index d67ad866a6f..d7700140667 100644 --- a/contrib/binutils/bfd/elf32-ppc.c +++ b/contrib/binutils/bfd/elf32-ppc.c @@ -7572,7 +7572,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd, #define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec #define TARGET_LITTLE_NAME "elf32-powerpcle" #define TARGET_BIG_SYM bfd_elf32_powerpc_vec -#define TARGET_BIG_NAME "elf32-powerpc" +#define TARGET_BIG_NAME "elf32-powerpc-freebsd" #define ELF_ARCH bfd_arch_powerpc #define ELF_MACHINE_CODE EM_PPC #ifdef __QNXTARGET__ diff --git a/contrib/binutils/bfd/elf64-ppc.c b/contrib/binutils/bfd/elf64-ppc.c index c292d1ef636..717452d6369 100644 --- a/contrib/binutils/bfd/elf64-ppc.c +++ b/contrib/binutils/bfd/elf64-ppc.c @@ -58,7 +58,7 @@ static bfd_vma opd_entry_value #define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec #define TARGET_LITTLE_NAME "elf64-powerpcle" #define TARGET_BIG_SYM bfd_elf64_powerpc_vec -#define TARGET_BIG_NAME "elf64-powerpc" +#define TARGET_BIG_NAME "elf64-powerpc-freebsd" #define ELF_ARCH bfd_arch_powerpc #define ELF_MACHINE_CODE EM_PPC64 #define ELF_MAXPAGESIZE 0x10000 diff --git a/contrib/binutils/gas/config/tc-ppc.c b/contrib/binutils/gas/config/tc-ppc.c index a0e116d8669..1ecd99faea5 100644 --- a/contrib/binutils/gas/config/tc-ppc.c +++ b/contrib/binutils/gas/config/tc-ppc.c @@ -1210,7 +1210,7 @@ ppc_target_format (void) return "elf32-powerpc-vxworks"; # else return (target_big_endian - ? (ppc_obj64 ? "elf64-powerpc" : "elf32-powerpc") + ? (ppc_obj64 ? "elf64-powerpc-freebsd" : "elf32-powerpc-freebsd") : (ppc_obj64 ? "elf64-powerpcle" : "elf32-powerpcle")); # endif #endif diff --git a/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh b/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh index 2bac85c738e..2f8b72e6382 100644 --- a/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh +++ b/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh @@ -1,2 +1,4 @@ . ${srcdir}/emulparams/elf32ppc.sh . ${srcdir}/emulparams/elf_fbsd.sh + +OUTPUT_FORMAT="elf32-powerpc-freebsd" diff --git a/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh b/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh index ec2374fc544..3f73ed9a429 100644 --- a/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh +++ b/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh @@ -1,3 +1,4 @@ . ${srcdir}/emulparams/elf64ppc.sh . ${srcdir}/emulparams/elf_fbsd.sh +OUTPUT_FORMAT="elf64-powerpc-freebsd" diff --git a/sys/boot/powerpc/ofw/ldscript.powerpc b/sys/boot/powerpc/ofw/ldscript.powerpc index 92046fc827c..3a2765047db 100644 --- a/sys/boot/powerpc/ofw/ldscript.powerpc +++ b/sys/boot/powerpc/ofw/ldscript.powerpc @@ -1,6 +1,7 @@ /* $FreeBSD$ */ -OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") +OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", + "elf32-powerpc-freebsd") OUTPUT_ARCH(powerpc:common) ENTRY(_start) SEARCH_DIR(/usr/lib); diff --git a/sys/boot/powerpc/ps3/ldscript.powerpc b/sys/boot/powerpc/ps3/ldscript.powerpc index c425f60ec8e..12f3e751fb5 100644 --- a/sys/boot/powerpc/ps3/ldscript.powerpc +++ b/sys/boot/powerpc/ps3/ldscript.powerpc @@ -1,6 +1,7 @@ /* $FreeBSD$ */ -OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") +OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", + "elf32-powerpc-freebsd") OUTPUT_ARCH(powerpc:common) ENTRY(_start) SEARCH_DIR(/usr/lib); diff --git a/sys/boot/powerpc/uboot/ldscript.powerpc b/sys/boot/powerpc/uboot/ldscript.powerpc index fdba57c0076..92383836579 100644 --- a/sys/boot/powerpc/uboot/ldscript.powerpc +++ b/sys/boot/powerpc/uboot/ldscript.powerpc @@ -1,6 +1,7 @@ /* $FreeBSD$ */ -OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") +OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", + "elf32-powerpc-freebsd") OUTPUT_ARCH(powerpc:common) ENTRY(_start) SEARCH_DIR(/usr/lib); diff --git a/sys/conf/ldscript.powerpc b/sys/conf/ldscript.powerpc index a05eaad7b23..efc0dfdf127 100644 --- a/sys/conf/ldscript.powerpc +++ b/sys/conf/ldscript.powerpc @@ -1,6 +1,7 @@ /* $FreeBSD$ */ -OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") +OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", + "elf32-powerpc-freebsd") OUTPUT_ARCH(powerpc) ENTRY(__start) SEARCH_DIR(/usr/lib); diff --git a/sys/conf/ldscript.powerpc64 b/sys/conf/ldscript.powerpc64 index fafce7b2b10..ce235516f0d 100644 --- a/sys/conf/ldscript.powerpc64 +++ b/sys/conf/ldscript.powerpc64 @@ -1,6 +1,7 @@ /* $FreeBSD$ */ -OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") +OUTPUT_FORMAT("elf64-powerpc-freebsd", "elf64-powerpc-freebsd", + "elf64-powerpc-freebsd") OUTPUT_ARCH(powerpc:common64) ENTRY(__start) SEARCH_DIR(/usr/lib); From 3c3136b1dd81794273948d7293be8f9b84cf0c7d Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Fri, 10 Oct 2014 06:45:13 +0000 Subject: [PATCH 002/112] Virtualize if_epair(4). An if_xname check for both "a" and "b" interfaces is added to return EEXIST when only "b" interface exists---this can happen when epairb is moved to a vnet jail and then "ifconfig epair create" is invoked there. --- sys/net/if_epair.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 13d7e0b30d1..e9a8ed5239b 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -101,7 +101,7 @@ static int epair_clone_destroy(struct if_clone *, struct ifnet *); static const char epairname[] = "epair"; -/* Netisr realted definitions and sysctl. */ +/* Netisr related definitions and sysctl. */ static struct netisr_handler epair_nh = { .nh_name = epairname, .nh_proto = NETISR_EPAIR, @@ -172,7 +172,8 @@ STAILQ_HEAD(eid_list, epair_ifp_drain); static MALLOC_DEFINE(M_EPAIR, epairname, "Pair of virtual cross-over connected Ethernet-like interfaces"); -static struct if_clone *epair_cloner; +static VNET_DEFINE(struct if_clone *, epair_cloner); +#define V_epair_cloner VNET(epair_cloner) /* * DPCPU area and functions. @@ -760,10 +761,17 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifc_free_unit(ifc, unit); return (ENOSPC); } - *dp = 'a'; + *dp = 'b'; /* Must not change dp so we can replace 'a' by 'b' later. */ *(dp+1) = '\0'; + /* Check if 'a' and 'b' interfaces already exist. */ + if (ifunit(name) != NULL) + return (EEXIST); + *dp = 'a'; + if (ifunit(name) != NULL) + return (EEXIST); + /* Allocate memory for both [ab] interfaces */ sca = malloc(sizeof(struct epair_softc), M_EPAIR, M_WAITOK | M_ZERO); EPAIR_REFCOUNT_INIT(&sca->refcount, 1); @@ -944,6 +952,25 @@ epair_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) return (0); } +static void +vnet_epair_init(const void *unused __unused) +{ + + V_epair_cloner = if_clone_advanced(epairname, 0, + epair_clone_match, epair_clone_create, epair_clone_destroy); +} +VNET_SYSINIT(vnet_epair_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_epair_init, NULL); + +static void +vnet_epair_uninit(const void *unused __unused) +{ + + if_clone_detach(V_epair_cloner); +} +VNET_SYSUNINIT(vnet_epair_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, + vnet_epair_uninit, NULL); + static int epair_modevent(module_t mod, int type, void *data) { @@ -957,13 +984,10 @@ epair_modevent(module_t mod, int type, void *data) if (TUNABLE_INT_FETCH("net.link.epair.netisr_maxqlen", &qlimit)) epair_nh.nh_qlimit = qlimit; netisr_register(&epair_nh); - epair_cloner = if_clone_advanced(epairname, 0, - epair_clone_match, epair_clone_create, epair_clone_destroy); if (bootverbose) printf("%s initialized.\n", epairname); break; case MOD_UNLOAD: - if_clone_detach(epair_cloner); netisr_unregister(&epair_nh); epair_dpcpu_detach(); if (bootverbose) From b3a6b001d088fdca6dc1d6ce5b1243a4eff20998 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 08:35:16 +0000 Subject: [PATCH 003/112] Only build/run hsearch_basic and hsearch_r_basic on NetBSD hdestroy1 is not present on FreeBSD Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c b/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c index 099b3e7948a..3c869c4f0b9 100644 --- a/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c +++ b/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c @@ -75,6 +75,7 @@ __RCSID("$NetBSD: t_hsearch.c,v 1.4 2014/07/20 20:17:21 christos Exp $"); #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) +#if defined(__NetBSD__) ATF_TC(hsearch_basic); ATF_TC_HEAD(hsearch_basic, tc) { @@ -123,6 +124,7 @@ ATF_TC_BODY(hsearch_basic, tc) hdestroy1(free, NULL); } +#endif ATF_TC(hsearch_duplicate); ATF_TC_HEAD(hsearch_duplicate, tc) @@ -229,6 +231,7 @@ ATF_TC_BODY(hsearch_two, tc) hdestroy(); } +#if defined(__NetBSD__) ATF_TC(hsearch_r_basic); ATF_TC_HEAD(hsearch_r_basic, tc) { @@ -276,6 +279,7 @@ ATF_TC_BODY(hsearch_r_basic, tc) hdestroy1_r(&t, free, NULL); } +#endif ATF_TC(hsearch_r_duplicate); ATF_TC_HEAD(hsearch_r_duplicate, tc) @@ -385,12 +389,16 @@ ATF_TC_BODY(hsearch_r_two, tc) ATF_TP_ADD_TCS(tp) { +#if defined(__NetBSD__) ATF_TP_ADD_TC(tp, hsearch_basic); +#endif ATF_TP_ADD_TC(tp, hsearch_duplicate); ATF_TP_ADD_TC(tp, hsearch_nonexistent); ATF_TP_ADD_TC(tp, hsearch_two); +#if defined(__NetBSD__) ATF_TP_ADD_TC(tp, hsearch_r_basic); +#endif ATF_TP_ADD_TC(tp, hsearch_r_duplicate); ATF_TP_ADD_TC(tp, hsearch_r_nonexistent); ATF_TP_ADD_TC(tp, hsearch_r_two); From ac2a1d3d71f2db398d84a4fcd5bad2c736ed39f1 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 08:57:55 +0000 Subject: [PATCH 004/112] Expect SIGSEGV in lib/libc/stdlib/t_getenv:setenv_basic See bin/189805 for more details In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c b/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c index 35d687445bb..3b0b8850b58 100644 --- a/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c +++ b/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c @@ -40,6 +40,9 @@ __RCSID("$NetBSD: t_getenv.c,v 1.2 2011/07/15 13:54:31 jruoho Exp $"); #include #include #include +#if defined(__FreeBSD__) +#include +#endif extern char **environ; @@ -152,6 +155,15 @@ ATF_TC_BODY(setenv_basic, tc) ATF_CHECK_ERRNO(EINVAL, setenv(NULL, "val", 1) == -1); ATF_CHECK_ERRNO(EINVAL, setenv("", "val", 1) == -1); ATF_CHECK_ERRNO(EINVAL, setenv("v=r", "val", 1) == -1); +#if defined(__FreeBSD__) + /* + Both FreeBSD and OS/X does not validate the second + argument to setenv(3) + */ + atf_tc_expect_signal(SIGSEGV, "FreeBSD does not validate the second " + "argument to setenv(3); see bin/189805"); +#endif + ATF_CHECK_ERRNO(EINVAL, setenv("var", NULL, 1) == -1); ATF_CHECK(setenv("var", "=val", 1) == 0); From 0ca2fdeca2f4540080bc17fda4ab39323289f81e Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 10 Oct 2014 12:38:53 +0000 Subject: [PATCH 005/112] Store persistent reservation keys as uint64_t instead of uint8_t[8]. This allows to simplify the code and save 512KB of RAM per LUN (8%) by removing no longer needed "registered" keys flags. --- sys/cam/ctl/ctl.c | 205 +++++++++++--------------------------- sys/cam/ctl/ctl_private.h | 7 +- 2 files changed, 61 insertions(+), 151 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 4ed6a5a628d..7edf582534a 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -2990,12 +2990,11 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, for (j = 0; j < (CTL_MAX_PORTS * 2); j++) { for (k = 0; k < CTL_MAX_INIT_PER_PORT; k++){ idx = j * CTL_MAX_INIT_PER_PORT + k; - if (lun->per_res[idx].registered == 0) + if (lun->pr_keys[idx] == 0) continue; printf(" LUN %d port %d iid %d key " "%#jx\n", i, j, k, - (uintmax_t)scsi_8btou64( - lun->per_res[idx].res_key.key)); + (uintmax_t)lun->pr_keys[idx]); } } } @@ -5536,7 +5535,7 @@ ctl_start_stop(struct ctl_scsiio *ctsio) uint32_t residx; residx = ctl_get_resindex(&ctsio->io_hdr.nexus); - if (!lun->per_res[residx].registered + if (lun->pr_keys[residx] == 0 || (lun->pr_res_idx!=residx && lun->res_type < 4)) { ctl_set_reservation_conflict(ctsio); @@ -5827,7 +5826,7 @@ ctl_read_buffer(struct ctl_scsiio *ctsio) && residx != lun->pr_res_idx) || ((lun->res_type == SPR_TYPE_EX_AC_RO || lun->res_type == SPR_TYPE_EX_AC_AR) - && !lun->per_res[residx].registered)) { + && lun->pr_keys[residx] == 0)) { ctl_set_reservation_conflict(ctsio); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); @@ -6882,7 +6881,7 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) && residx != lun->pr_res_idx) || ((lun->res_type == SPR_TYPE_EX_AC_RO || lun->res_type == SPR_TYPE_EX_AC_AR) - && !lun->per_res[residx].registered)) { + && lun->pr_keys[residx] == 0)) { ctl_set_reservation_conflict(ctsio); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); @@ -7825,7 +7824,7 @@ retry: lun->pr_key_count, res_keys->header.length); for (i = 0, key_count = 0; i < 2*CTL_MAX_INITIATORS; i++) { - if (!lun->per_res[i].registered) + if (lun->pr_keys[i] == 0) continue; /* @@ -7851,10 +7850,8 @@ retry: key_count++; continue; } - memcpy(res_keys->keys[key_count].key, - lun->per_res[i].res_key.key, - ctl_min(sizeof(res_keys->keys[key_count].key), - sizeof(lun->per_res[i].res_key))); + scsi_u64to8b(lun->pr_keys[i], + res_keys->keys[key_count].key); key_count++; } break; @@ -7905,9 +7902,8 @@ retry: * is 0, since it doesn't really matter. */ if (lun->pr_res_idx != CTL_PR_ALL_REGISTRANTS) { - memcpy(res->data.reservation, - &lun->per_res[lun->pr_res_idx].res_key, - sizeof(struct scsi_per_res_key)); + scsi_u64to8b(lun->pr_keys[lun->pr_res_idx], + res->data.reservation); } res->data.scopetype = lun->res_type; break; @@ -7958,11 +7954,10 @@ retry: res_desc = &res_status->desc[0]; for (i = 0; i < 2*CTL_MAX_INITIATORS; i++) { - if (!lun->per_res[i].registered) + if (lun->pr_keys[i] == 0) continue; - memcpy(&res_desc->res_key, &lun->per_res[i].res_key.key, - sizeof(res_desc->res_key)); + scsi_u64to8b(lun->pr_keys[i], res_desc->res_key.key); if ((lun->flags & CTL_LUN_PR_RESERVED) && (lun->pr_res_idx == i || lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS)) { @@ -8055,15 +8050,12 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, return (1); } - /* temporarily unregister this nexus */ - lun->per_res[residx].registered = 0; - /* * Unregister everybody else and build UA for * them */ for(i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i].registered == 0) + if (i == residx || lun->pr_keys[i] == 0) continue; if (!persis_offset @@ -8074,11 +8066,8 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, && i >= persis_offset) lun->pending_ua[i-persis_offset] |= CTL_UA_REG_PREEMPT; - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); + lun->pr_keys[i] = 0; } - lun->per_res[residx].registered = 1; lun->pr_key_count = 1; lun->res_type = type; if (lun->res_type != SPR_TYPE_WR_EX_AR @@ -8142,16 +8131,11 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, } for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i].registered - && memcmp(param->serv_act_res_key, - lun->per_res[i].res_key.key, - sizeof(struct scsi_per_res_key)) != 0) + if (lun->pr_keys[i] != sa_res_key) continue; found = 1; - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); + lun->pr_keys[i] = 0; lun->pr_key_count--; if (!persis_offset && i < CTL_MAX_INITIATORS) @@ -8185,9 +8169,7 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, } else { /* Reserved but not all registrants */ /* sa_res_key is res holder */ - if (memcmp(param->serv_act_res_key, - lun->per_res[lun->pr_res_idx].res_key.key, - sizeof(struct scsi_per_res_key)) == 0) { + if (sa_res_key == lun->pr_keys[lun->pr_res_idx]) { /* validate scope and type */ if ((cdb->scope_type & SPR_SCOPE_MASK) != SPR_LU_SCOPE) { @@ -8228,22 +8210,12 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, * except don't unregister the res holder. */ - /* - * Temporarily unregister so it won't get - * removed or UA generated - */ - lun->per_res[residx].registered = 0; for(i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i].registered == 0) + if (i == residx || lun->pr_keys[i] == 0) continue; - if (memcmp(param->serv_act_res_key, - lun->per_res[i].res_key.key, - sizeof(struct scsi_per_res_key)) == 0) { - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, - 0, - sizeof(struct scsi_per_res_key)); + if (sa_res_key == lun->pr_keys[i]) { + lun->pr_keys[i] = 0; lun->pr_key_count--; if (!persis_offset @@ -8268,7 +8240,6 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, CTL_UA_RES_RELEASE; } } - lun->per_res[residx].registered = 1; lun->res_type = type; if (lun->res_type != SPR_TYPE_WR_EX_AR && lun->res_type != SPR_TYPE_EX_AC_AR) @@ -8299,15 +8270,11 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, int found=0; for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (memcmp(param->serv_act_res_key, - lun->per_res[i].res_key.key, - sizeof(struct scsi_per_res_key)) != 0) + if (sa_res_key != lun->pr_keys[i]) continue; found = 1; - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); + lun->pr_keys[i] = 0; lun->pr_key_count--; if (!persis_offset @@ -8354,26 +8321,22 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key, static void ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg) { + uint64_t sa_res_key; int i; + sa_res_key = scsi_8btou64(msg->pr.pr_info.sa_res_key); + if (lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS || lun->pr_res_idx == CTL_PR_NO_RESERVATION - || memcmp(&lun->per_res[lun->pr_res_idx].res_key, - msg->pr.pr_info.sa_res_key, - sizeof(struct scsi_per_res_key)) != 0) { - uint64_t sa_res_key; - sa_res_key = scsi_8btou64(msg->pr.pr_info.sa_res_key); - + || sa_res_key != lun->pr_keys[lun->pr_res_idx]) { if (sa_res_key == 0) { - /* temporarily unregister this nexus */ - lun->per_res[msg->pr.pr_info.residx].registered = 0; - /* * Unregister everybody else and build UA for * them */ for(i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i].registered == 0) + if (i == msg->pr.pr_info.residx || + lun->pr_keys[i] == 0) continue; if (!persis_offset @@ -8383,12 +8346,9 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg) else if (persis_offset && i >= persis_offset) lun->pending_ua[i - persis_offset] |= CTL_UA_REG_PREEMPT; - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); + lun->pr_keys[i] = 0; } - lun->per_res[msg->pr.pr_info.residx].registered = 1; lun->pr_key_count = 1; lun->res_type = msg->pr.pr_info.res_type; if (lun->res_type != SPR_TYPE_WR_EX_AR @@ -8396,14 +8356,10 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg) lun->pr_res_idx = msg->pr.pr_info.residx; } else { for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (memcmp(msg->pr.pr_info.sa_res_key, - lun->per_res[i].res_key.key, - sizeof(struct scsi_per_res_key)) != 0) + if (sa_res_key == lun->pr_keys[i]) continue; - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); + lun->pr_keys[i] = 0; lun->pr_key_count--; if (!persis_offset @@ -8417,21 +8373,13 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg) } } } else { - /* - * Temporarily unregister so it won't get removed - * or UA generated - */ - lun->per_res[msg->pr.pr_info.residx].registered = 0; for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i].registered == 0) + if (i == msg->pr.pr_info.residx || + lun->pr_keys[i] == 0) continue; - if (memcmp(msg->pr.pr_info.sa_res_key, - lun->per_res[i].res_key.key, - sizeof(struct scsi_per_res_key)) == 0) { - lun->per_res[i].registered = 0; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); + if (sa_res_key == lun->pr_keys[i]) { + lun->pr_keys[i] = 0; lun->pr_key_count--; if (!persis_offset && i < CTL_MAX_INITIATORS) @@ -8454,7 +8402,6 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg) CTL_UA_RES_RELEASE; } } - lun->per_res[msg->pr.pr_info.residx].registered = 1; lun->res_type = msg->pr.pr_info.res_type; if (lun->res_type != SPR_TYPE_WR_EX_AR && lun->res_type != SPR_TYPE_EX_AC_AR) @@ -8552,11 +8499,8 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) */ if ((cdb->action & SPRO_ACTION_MASK) != SPRO_REG_IGNO) { mtx_lock(&lun->lun_lock); - if (lun->per_res[residx].registered) { - if (memcmp(param->res_key.key, - lun->per_res[residx].res_key.key, - ctl_min(sizeof(param->res_key), - sizeof(lun->per_res[residx].res_key))) != 0) { + if (lun->pr_keys[residx] != 0) { + if (res_key != lun->pr_keys[residx]) { /* * The current key passed in doesn't match * the one the initiator previously @@ -8637,14 +8581,12 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) if ((res_key == 0 && (cdb->action & SPRO_ACTION_MASK) == SPRO_REGISTER) || ((cdb->action & SPRO_ACTION_MASK) == SPRO_REG_IGNO - && !lun->per_res[residx].registered)) { + && lun->pr_keys[residx] == 0)) { mtx_unlock(&lun->lun_lock); goto done; } - lun->per_res[residx].registered = 0; - memset(&lun->per_res[residx].res_key, - 0, sizeof(lun->per_res[residx].res_key)); + lun->pr_keys[residx] = 0; lun->pr_key_count--; if (residx == lun->pr_res_idx) { @@ -8663,9 +8605,8 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) */ for (i = 0; i < CTL_MAX_INITIATORS;i++){ - if (lun->per_res[ - i+persis_offset].registered - == 0) + if (lun->pr_keys[ + i + persis_offset] == 0) continue; lun->pending_ua[i] |= CTL_UA_RES_RELEASE; @@ -8695,15 +8636,9 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) * If we aren't registered currently then increment * the key count and set the registered flag. */ - if (!lun->per_res[residx].registered) { + if (lun->pr_keys[residx] == 0) lun->pr_key_count++; - lun->per_res[residx].registered = 1; - } - - memcpy(&lun->per_res[residx].res_key, - param->serv_act_res_key, - ctl_min(sizeof(param->serv_act_res_key), - sizeof(lun->per_res[residx].res_key))); + lun->pr_keys[residx] = sa_res_key; persis_io.hdr.nexus = ctsio->io_hdr.nexus; persis_io.hdr.msg_type = CTL_MSG_PERS_ACTION; @@ -8816,20 +8751,12 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) */ if (type != SPR_TYPE_EX_AC && type != SPR_TYPE_WR_EX) { - /* - * temporarily unregister so we don't generate UA - */ - lun->per_res[residx].registered = 0; - for (i = 0; i < CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i+persis_offset].registered - == 0) + if (i == residx || + lun->pr_keys[i + persis_offset] == 0) continue; - lun->pending_ua[i] |= - CTL_UA_RES_RELEASE; + lun->pending_ua[i] |= CTL_UA_RES_RELEASE; } - - lun->per_res[residx].registered = 1; } mtx_unlock(&lun->lun_lock); /* Send msg to other side */ @@ -8852,13 +8779,10 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) lun->pr_key_count = 0; lun->pr_res_idx = CTL_PR_NO_RESERVATION; - - memset(&lun->per_res[residx].res_key, - 0, sizeof(lun->per_res[residx].res_key)); - lun->per_res[residx].registered = 0; + lun->pr_keys[residx] = 0; for (i=0; i < 2*CTL_MAX_INITIATORS; i++) - if (lun->per_res[i].registered) { + if (lun->pr_keys[i] != 0) { if (!persis_offset && i < CTL_MAX_INITIATORS) lun->pending_ua[i] |= CTL_UA_RES_PREEMPT; @@ -8866,9 +8790,7 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) lun->pending_ua[i-persis_offset] |= CTL_UA_RES_PREEMPT; - memset(&lun->per_res[i].res_key, - 0, sizeof(struct scsi_per_res_key)); - lun->per_res[i].registered = 0; + lun->pr_keys[i] = 0; } lun->PRGeneration++; mtx_unlock(&lun->lun_lock); @@ -8924,20 +8846,15 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg) mtx_lock(&lun->lun_lock); switch(msg->pr.pr_info.action) { case CTL_PR_REG_KEY: - if (!lun->per_res[msg->pr.pr_info.residx].registered) { - lun->per_res[msg->pr.pr_info.residx].registered = 1; + if (lun->pr_keys[msg->pr.pr_info.residx] == 0) lun->pr_key_count++; - } + lun->pr_keys[msg->pr.pr_info.residx] = + scsi_8btou64(msg->pr.pr_info.sa_res_key); lun->PRGeneration++; - memcpy(&lun->per_res[msg->pr.pr_info.residx].res_key, - msg->pr.pr_info.sa_res_key, - sizeof(struct scsi_per_res_key)); break; case CTL_PR_UNREG_KEY: - lun->per_res[msg->pr.pr_info.residx].registered = 0; - memset(&lun->per_res[msg->pr.pr_info.residx].res_key, - 0, sizeof(struct scsi_per_res_key)); + lun->pr_keys[msg->pr.pr_info.residx] = 0; lun->pr_key_count--; /* XXX Need to see if the reservation has been released */ @@ -8958,8 +8875,8 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg) */ for (i = 0; i < CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i+ - persis_offset].registered == 0) + if (lun->pr_keys[i+ + persis_offset] == 0) continue; lun->pending_ua[i] |= @@ -8992,7 +8909,7 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg) if (lun->res_type != SPR_TYPE_EX_AC && lun->res_type != SPR_TYPE_WR_EX) { for (i = 0; i < CTL_MAX_INITIATORS; i++) - if (lun->per_res[i+persis_offset].registered) + if (lun->pr_keys[i+persis_offset] != 0) lun->pending_ua[i] |= CTL_UA_RES_RELEASE; } @@ -9012,7 +8929,7 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg) lun->pr_res_idx = CTL_PR_NO_RESERVATION; for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { - if (lun->per_res[i].registered == 0) + if (lun->pr_keys[i] == 0) continue; if (!persis_offset && i < CTL_MAX_INITIATORS) @@ -9021,9 +8938,7 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg) && i >= persis_offset) lun->pending_ua[i-persis_offset] |= CTL_UA_RES_PREEMPT; - memset(&lun->per_res[i].res_key, 0, - sizeof(struct scsi_per_res_key)); - lun->per_res[i].registered = 0; + lun->pr_keys[i] = 0; } lun->PRGeneration++; break; @@ -9062,7 +8977,7 @@ ctl_read_write(struct ctl_scsiio *ctsio) && residx != lun->pr_res_idx) || ((lun->res_type == SPR_TYPE_EX_AC_RO || lun->res_type == SPR_TYPE_EX_AC_AR) - && !lun->per_res[residx].registered)) { + && lun->pr_keys[residx] == 0)) { ctl_set_reservation_conflict(ctsio); ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); @@ -11379,7 +11294,7 @@ ctl_scsiio_lun_check(struct ctl_softc *ctl_softc, struct ctl_lun *lun, * type reservations are checked in the particular command * for a conflict. Read and SSU are the only ones. */ - if (!lun->per_res[residx].registered + if (lun->pr_keys[residx] == 0 || (residx != lun->pr_res_idx && lun->res_type < 4)) { ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT; ctsio->io_hdr.status = CTL_SCSI_ERROR; diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h index 4f22250e374..aeea63d785a 100644 --- a/sys/cam/ctl/ctl_private.h +++ b/sys/cam/ctl/ctl_private.h @@ -353,11 +353,6 @@ typedef enum { CTL_PR_FLAG_ACTIVE_RES = 0x02 } ctl_per_res_flags; -struct ctl_per_res_info { - struct scsi_per_res_key res_key; - uint8_t registered; -}; - #define CTL_PR_ALL_REGISTRANTS 0xFFFFFFFF #define CTL_PR_NO_RESERVATION 0xFFFFFFF0 @@ -398,8 +393,8 @@ struct ctl_lun { struct ctl_mode_pages mode_pages; struct ctl_lun_io_stats stats; uint32_t res_idx; - struct ctl_per_res_info per_res[2*CTL_MAX_INITIATORS]; unsigned int PRGeneration; + uint64_t pr_keys[2*CTL_MAX_INITIATORS]; int pr_key_count; uint32_t pr_res_idx; uint8_t res_type; From 277c7d7b98cbe2923970811d5b2021f83c95ddde Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 10 Oct 2014 14:17:42 +0000 Subject: [PATCH 006/112] Use FreeBSD-bit-checking-style This appease gcc 4.9 issuing warnings about parentheses Differential Revision: https://reviews.freebsd.org/D933 Reviewed by: marius --- sys/dev/mc146818/mc146818.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/mc146818/mc146818.c b/sys/dev/mc146818/mc146818.c index 108ee5ae41b..fae24487cdb 100644 --- a/sys/dev/mc146818/mc146818.c +++ b/sys/dev/mc146818/mc146818.c @@ -77,7 +77,7 @@ mc146818_attach(device_t dev) } mtx_lock_spin(&sc->sc_mtx); - if (!(*sc->sc_mcread)(dev, MC_REGD) & MC_REGD_VRT) { + if (((*sc->sc_mcread)(dev, MC_REGD) & MC_REGD_VRT) == 0) { mtx_unlock_spin(&sc->sc_mtx); device_printf(dev, "%s: battery low\n", __func__); return (ENXIO); @@ -118,7 +118,7 @@ mc146818_gettime(device_t dev, struct timespec *ts) */ for (;;) { mtx_lock_spin(&sc->sc_mtx); - if (!((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP)) + if (((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP) == 0) break; mtx_unlock_spin(&sc->sc_mtx); if (--timeout < 0) { @@ -164,7 +164,7 @@ mc146818_getsecs(device_t dev, int *secp) for (;;) { mtx_lock_spin(&sc->sc_mtx); - if (!((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP)) { + if (((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP) == 0) { sec = FROMREG((*sc->sc_mcread)(dev, MC_SEC)); mtx_unlock_spin(&sc->sc_mtx); break; From dbacd6692819e9d535553d570c967299eb46f89d Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 10 Oct 2014 14:18:33 +0000 Subject: [PATCH 007/112] Fix typo revealed by using newer binutils Differential Revision: https://reviews.freebsd.org/D933 Reviewed by: marius --- sys/sparc64/sparc64/support.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sparc64/sparc64/support.S b/sys/sparc64/sparc64/support.S index 57219547d42..d6468cf4f4f 100644 --- a/sys/sparc64/sparc64/support.S +++ b/sys/sparc64/sparc64/support.S @@ -517,7 +517,7 @@ fs_nofault_end: ENTRY(fs_fault) retl mov -1, %o0 -END(fsfault) +END(fs_fault) .globl fas_nofault_begin fas_nofault_begin: From d4d630aebe86e530637689f5e0624e3ef2ecf9a7 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Fri, 10 Oct 2014 14:35:51 +0000 Subject: [PATCH 008/112] o Add machine-dependent SMP part o Enable SMP Sponsored by: DARPA, AFRL --- sys/arm/altera/socfpga/files.socfpga | 1 + sys/arm/altera/socfpga/socfpga_machdep.c | 3 + sys/arm/altera/socfpga/socfpga_mp.c | 180 +++++++++++++++++++++++ sys/arm/conf/SOCKIT | 2 +- sys/boot/fdt/dts/arm/socfpga-sockit.dts | 3 + 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 sys/arm/altera/socfpga/socfpga_mp.c diff --git a/sys/arm/altera/socfpga/files.socfpga b/sys/arm/altera/socfpga/files.socfpga index df92bff78dc..81917bb2778 100644 --- a/sys/arm/altera/socfpga/files.socfpga +++ b/sys/arm/altera/socfpga/files.socfpga @@ -17,6 +17,7 @@ arm/altera/socfpga/socfpga_common.c standard arm/altera/socfpga/socfpga_machdep.c standard arm/altera/socfpga/socfpga_manager.c standard arm/altera/socfpga/socfpga_rstmgr.c standard +arm/altera/socfpga/socfpga_mp.c optional smp dev/dwc/if_dwc.c optional dwc dev/mmc/host/dwmmc.c optional dwmmc diff --git a/sys/arm/altera/socfpga/socfpga_machdep.c b/sys/arm/altera/socfpga/socfpga_machdep.c index 703c88a04a9..428a9985d5d 100644 --- a/sys/arm/altera/socfpga/socfpga_machdep.c +++ b/sys/arm/altera/socfpga/socfpga_machdep.c @@ -92,6 +92,9 @@ platform_devmap_init(void) /* dwmmc */ arm_devmap_add_entry(0xff700000, 0x100000); + /* scu */ + arm_devmap_add_entry(0xfff00000, 0x100000); + return (0); } diff --git a/sys/arm/altera/socfpga/socfpga_mp.c b/sys/arm/altera/socfpga/socfpga_mp.c new file mode 100644 index 00000000000..37a009ce909 --- /dev/null +++ b/sys/arm/altera/socfpga/socfpga_mp.c @@ -0,0 +1,180 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define SCU_PHYSBASE 0xFFFEC000 +#define SCU_SIZE 0x100 + +#define SCU_CONTROL_REG 0x00 +#define SCU_CONTROL_ENABLE (1 << 0) +#define SCU_CONFIG_REG 0x04 +#define SCU_CONFIG_REG_NCPU_MASK 0x03 +#define SCU_CPUPOWER_REG 0x08 +#define SCU_INV_TAGS_REG 0x0c +#define SCU_DIAG_CONTROL 0x30 +#define SCU_DIAG_DISABLE_MIGBIT (1 << 0) +#define SCU_FILTER_START_REG 0x40 +#define SCU_FILTER_END_REG 0x44 +#define SCU_SECURE_ACCESS_REG 0x50 +#define SCU_NONSECURE_ACCESS_REG 0x54 + +#define RSTMGR_PHYSBASE 0xFFD05000 +#define RSTMGR_SIZE 0x100 +#define MPUMODRST 0x10 +#define MPUMODRST_CPU1 (1 << 1) + +#define RAM_PHYSBASE 0x0 +#define RAM_SIZE 0x1000 + +extern char *mpentry_addr; +static void socfpga_trampoline(void); + +static void +socfpga_trampoline(void) +{ + + __asm __volatile( + "ldr pc, 1f\n" + ".globl mpentry_addr\n" + "mpentry_addr:\n" + "1: .space 4\n"); +} + +void +platform_mp_init_secondary(void) +{ + + gic_init_secondary(); +} + +void +platform_mp_setmaxid(void) +{ + int hwcpu, ncpu; + + /* If we've already set this don't bother to do it again. */ + if (mp_ncpus != 0) + return; + + hwcpu = 2; + + ncpu = hwcpu; + TUNABLE_INT_FETCH("hw.ncpu", &ncpu); + if (ncpu < 1 || ncpu > hwcpu) + ncpu = hwcpu; + + mp_ncpus = ncpu; + mp_maxid = ncpu - 1; +} + +int +platform_mp_probe(void) +{ + + if (mp_ncpus == 0) + platform_mp_setmaxid(); + + return (mp_ncpus > 1); +} + +void +platform_mp_start_ap(void) +{ + bus_space_handle_t scu, rst, ram; + int reg; + + if (bus_space_map(fdtbus_bs_tag, SCU_PHYSBASE, + SCU_SIZE, 0, &scu) != 0) + panic("Couldn't map the SCU\n"); + if (bus_space_map(fdtbus_bs_tag, RSTMGR_PHYSBASE, + RSTMGR_SIZE, 0, &rst) != 0) + panic("Couldn't map the reset manager (RSTMGR)\n"); + if (bus_space_map(fdtbus_bs_tag, RAM_PHYSBASE, + RAM_SIZE, 0, &ram) != 0) + panic("Couldn't map the first physram page\n"); + + /* Invalidate SCU cache tags */ + bus_space_write_4(fdtbus_bs_tag, scu, + SCU_INV_TAGS_REG, 0x0000ffff); + + /* + * Erratum ARM/MP: 764369 (problems with cache maintenance). + * Setting the "disable-migratory bit" in the undocumented SCU + * Diagnostic Control Register helps work around the problem. + */ + reg = bus_space_read_4(fdtbus_bs_tag, scu, SCU_DIAG_CONTROL); + reg |= (SCU_DIAG_DISABLE_MIGBIT); + bus_space_write_4(fdtbus_bs_tag, scu, SCU_DIAG_CONTROL, reg); + + /* Put CPU1 to reset state */ + bus_space_write_4(fdtbus_bs_tag, rst, MPUMODRST, MPUMODRST_CPU1); + + /* Enable the SCU, then clean the cache on this core */ + reg = bus_space_read_4(fdtbus_bs_tag, scu, SCU_CONTROL_REG); + reg |= (SCU_CONTROL_ENABLE); + bus_space_write_4(fdtbus_bs_tag, scu, SCU_CONTROL_REG, reg); + + /* Set up trampoline code */ + mpentry_addr = (char *)pmap_kextract((vm_offset_t)mpentry); + bus_space_write_region_4(fdtbus_bs_tag, ram, 0, + (uint32_t *)&socfpga_trampoline, 8); + + cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); + + /* Put CPU1 out from reset */ + bus_space_write_4(fdtbus_bs_tag, rst, MPUMODRST, 0); + + armv7_sev(); + + bus_space_unmap(fdtbus_bs_tag, scu, SCU_SIZE); + bus_space_unmap(fdtbus_bs_tag, rst, RSTMGR_SIZE); + bus_space_unmap(fdtbus_bs_tag, ram, RAM_SIZE); +} + +void +platform_ipi_send(cpuset_t cpus, u_int ipi) +{ + + pic_ipi_send(cpus, ipi); +} diff --git a/sys/arm/conf/SOCKIT b/sys/arm/conf/SOCKIT index a7c6a87ab78..ee1fc659851 100644 --- a/sys/arm/conf/SOCKIT +++ b/sys/arm/conf/SOCKIT @@ -53,7 +53,7 @@ options PREEMPTION options FREEBSD_BOOT_LOADER options VFP # vfp/neon -#options SMP +options SMP # Debugging makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols diff --git a/sys/boot/fdt/dts/arm/socfpga-sockit.dts b/sys/boot/fdt/dts/arm/socfpga-sockit.dts index 058b95766af..629a4deec83 100644 --- a/sys/boot/fdt/dts/arm/socfpga-sockit.dts +++ b/sys/boot/fdt/dts/arm/socfpga-sockit.dts @@ -38,6 +38,9 @@ model = "Terasic SoCKit"; compatible = "altr,socfpga-cyclone5", "altr,socfpga"; + /* Reserve first page for secondary CPU trampoline code */ + memreserve = < 0x00000000 0x1000 >; + memory { device_type = "memory"; reg = < 0x00000000 0x40000000 >; /* 1G RAM */ From 8423f42aa8e8dd6fe50ee6053676478659718699 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 10 Oct 2014 16:36:25 +0000 Subject: [PATCH 009/112] Various fixes to stats: - Read the counts of received, dropped, and transmitted management packets and add sysctl nodes for them. - Fix the total octets received/transmitted to read all 64 bits of the counters. - Add missing sysctl nodes for rlec, tncrs, fcruc, tor, and tot. - Remove spurious spaces. Reviewed by: Eric Joyner @ Intel MFC after: 1 week --- sys/dev/e1000/if_igb.c | 44 +++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index c8cb5d4ea8e..0e6d16138a6 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -5649,8 +5649,14 @@ igb_update_stats_counters(struct adapter *adapter) stats->roc += E1000_READ_REG(hw, E1000_ROC); stats->rjc += E1000_READ_REG(hw, E1000_RJC); - stats->tor += E1000_READ_REG(hw, E1000_TORH); - stats->tot += E1000_READ_REG(hw, E1000_TOTH); + stats->mgprc += E1000_READ_REG(hw, E1000_MGTPRC); + stats->mgpdc += E1000_READ_REG(hw, E1000_MGTPDC); + stats->mgptc += E1000_READ_REG(hw, E1000_MGTPTC); + + stats->tor += E1000_READ_REG(hw, E1000_TORL) + + ((u64)E1000_READ_REG(hw, E1000_TORH) << 32); + stats->tot += E1000_READ_REG(hw, E1000_TOTL) + + ((u64)E1000_READ_REG(hw, E1000_TOTH) << 32); stats->tpr += E1000_READ_REG(hw, E1000_TPR); stats->tpt += E1000_READ_REG(hw, E1000_TPT); @@ -5965,6 +5971,9 @@ igb_add_hw_stats(struct adapter *adapter) SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "missed_packets", CTLFLAG_RD, &stats->mpc, "Missed Packets"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "recv_length_errors", + CTLFLAG_RD, &stats->rlec, + "Receive Length Errors"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "recv_no_buff", CTLFLAG_RD, &stats->rnbc, "Receive No Buffers"); @@ -5973,7 +5982,7 @@ igb_add_hw_stats(struct adapter *adapter) "Receive Undersize"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "recv_fragmented", CTLFLAG_RD, &stats->rfc, - "Fragmented Packets Received "); + "Fragmented Packets Received"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "recv_oversize", CTLFLAG_RD, &stats->roc, "Oversized Packets Received"); @@ -5989,6 +5998,9 @@ igb_add_hw_stats(struct adapter *adapter) SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "alignment_errs", CTLFLAG_RD, &stats->algnerrc, "Alignment Errors"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "tx_no_crs", + CTLFLAG_RD, &stats->tncrs, + "Transmit with No CRS"); /* On 82575 these are collision counts */ SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "coll_ext_errs", CTLFLAG_RD, &stats->cexterr, @@ -6005,10 +6017,22 @@ igb_add_hw_stats(struct adapter *adapter) SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "xoff_txd", CTLFLAG_RD, &stats->xofftxc, "XOFF Transmitted"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "unsupported_fc_recvd", + CTLFLAG_RD, &stats->fcruc, + "Unsupported Flow Control Received"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "mgmt_pkts_recvd", + CTLFLAG_RD, &stats->mgprc, + "Management Packets Received"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "mgmt_pkts_drop", + CTLFLAG_RD, &stats->mgpdc, + "Management Packets Dropped"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "mgmt_pkts_txd", + CTLFLAG_RD, &stats->mgptc, + "Management Packets Transmitted"); /* Packet Reception Stats */ SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "total_pkts_recvd", CTLFLAG_RD, &stats->tpr, - "Total Packets Received "); + "Total Packets Received"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "good_pkts_recvd", CTLFLAG_RD, &stats->gprc, "Good Packets Received"); @@ -6020,7 +6044,7 @@ igb_add_hw_stats(struct adapter *adapter) "Multicast Packets Received"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "rx_frames_64", CTLFLAG_RD, &stats->prc64, - "64 byte frames received "); + "64 byte frames received"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "rx_frames_65_127", CTLFLAG_RD, &stats->prc127, "65-127 byte frames received"); @@ -6038,12 +6062,18 @@ igb_add_hw_stats(struct adapter *adapter) "1023-1522 byte frames received"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "good_octets_recvd", CTLFLAG_RD, &stats->gorc, - "Good Octets Received"); + "Good Octets Received"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "total_octets_recvd", + CTLFLAG_RD, &stats->tor, + "Total Octets Received"); /* Packet Transmission Stats */ SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "good_octets_txd", CTLFLAG_RD, &stats->gotc, "Good Octets Transmitted"); + SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "total_octets_txd", + CTLFLAG_RD, &stats->tot, + "Total Octets Transmitted"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "total_pkts_txd", CTLFLAG_RD, &stats->tpt, "Total Packets Transmitted"); @@ -6058,7 +6088,7 @@ igb_add_hw_stats(struct adapter *adapter) "Multicast Packets Transmitted"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "tx_frames_64", CTLFLAG_RD, &stats->ptc64, - "64 byte frames transmitted "); + "64 byte frames transmitted"); SYSCTL_ADD_QUAD(ctx, stat_list, OID_AUTO, "tx_frames_65_127", CTLFLAG_RD, &stats->ptc127, "65-127 byte frames transmitted"); From 9fe15d06124fb36157e496363d74b1c306bfc8a0 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Fri, 10 Oct 2014 17:24:56 +0000 Subject: [PATCH 010/112] Partially fix build on !amd64 Pointed by: bz --- sbin/ipfw/ipfw2.c | 2 +- sbin/ipfw/tables.c | 4 +- sys/netpfil/ipfw/ip_fw_table_algo.c | 213 ++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+), 3 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index 19c1d40949b..6b6424c9981 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -2580,7 +2580,7 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo, list_static_range(co, fo, &bp, rbase, rcnt); if (co->do_dynamic && dynsz > 0) { - printf("## Dynamic rules (%d %lu):\n", fo->dcnt, dynsz); + printf("## Dynamic rules (%d %zu):\n", fo->dcnt, dynsz); list_dyn_range(co, fo, &bp, dynbase, dynsz); } diff --git a/sbin/ipfw/tables.c b/sbin/ipfw/tables.c index a94e182ab47..a92737318c8 100644 --- a/sbin/ipfw/tables.c +++ b/sbin/ipfw/tables.c @@ -13,7 +13,7 @@ * * in-kernel ipfw tables support. * - * $FreeBSD: projects/ipfw/sbin/ipfw/ipfw2.c 267467 2014-06-14 10:58:39Z melifaro $ + * $FreeBSD$ */ @@ -1908,7 +1908,7 @@ ipfw_list_values(int ac, char *av[]) for (i = 0; i < olh->count; i++) { table_show_value(buf, sizeof(buf), (ipfw_table_value *)v, vmask, 0); - printf("[%u] refs=%lu %s\n", v->spare1, v->refcnt, buf); + printf("[%u] refs=%ju %s\n", v->spare1, v->refcnt, buf); v = (struct _table_value *)((caddr_t)v + olh->objsize); } diff --git a/sys/netpfil/ipfw/ip_fw_table_algo.c b/sys/netpfil/ipfw/ip_fw_table_algo.c index 14fd6727b9e..c640f1ab37e 100644 --- a/sys/netpfil/ipfw/ip_fw_table_algo.c +++ b/sys/netpfil/ipfw/ip_fw_table_algo.c @@ -366,6 +366,36 @@ struct ta_buf_radix } addr; }; +static int ta_lookup_radix(struct table_info *ti, void *key, uint32_t keylen, + uint32_t *val); +static int ta_init_radix(struct ip_fw_chain *ch, void **ta_state, + struct table_info *ti, char *data, uint8_t tflags); +static int flush_radix_entry(struct radix_node *rn, void *arg); +static void ta_destroy_radix(void *ta_state, struct table_info *ti); +static void ta_dump_radix_tinfo(void *ta_state, struct table_info *ti, + ipfw_ta_tinfo *tinfo); +static int ta_dump_radix_tentry(void *ta_state, struct table_info *ti, + void *e, ipfw_obj_tentry *tent); +static int ta_find_radix_tentry(void *ta_state, struct table_info *ti, + ipfw_obj_tentry *tent); +static void ta_foreach_radix(void *ta_state, struct table_info *ti, + ta_foreach_f *f, void *arg); +static inline void ipv6_writemask(struct in6_addr *addr6, uint8_t mask); +static void tei_to_sockaddr_ent(struct tentry_info *tei, struct sockaddr *sa, + struct sockaddr *ma, int *set_mask); +static int ta_prepare_add_radix(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_add_radix(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static int ta_prepare_del_radix(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_del_radix(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static void ta_flush_radix_entry(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_need_modify_radix(void *ta_state, struct table_info *ti, + uint32_t count, uint64_t *pflags); + static int ta_lookup_radix(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val) @@ -479,7 +509,9 @@ ta_dump_radix_tentry(void *ta_state, struct table_info *ti, void *e, ipfw_obj_tentry *tent) { struct radix_addr_entry *n; +#ifdef INET6 struct radix_addr_xentry *xn; +#endif n = (struct radix_addr_entry *)e; @@ -563,8 +595,12 @@ tei_to_sockaddr_ent(struct tentry_info *tei, struct sockaddr *sa, struct sockaddr *ma, int *set_mask) { int mlen; +#ifdef INET struct sockaddr_in *addr, *mask; +#endif +#ifdef INET6 struct sa_in6 *addr6, *mask6; +#endif in_addr_t a4; mlen = tei->masklen; @@ -895,6 +931,56 @@ struct ta_buf_chash struct chashentry ent; }; +static __inline uint32_t hash_ip(uint32_t addr, int hsize); +static __inline uint32_t hash_ip6(struct in6_addr *addr6, int hsize); +static __inline uint16_t hash_ip64(struct in6_addr *addr6, int hsize); +static __inline uint32_t hash_ip6_slow(struct in6_addr *addr6, void *key, + int mask, int hsize); +static __inline uint32_t hash_ip6_al(struct in6_addr *addr6, void *key, int mask, + int hsize); +static int ta_lookup_chash_slow(struct table_info *ti, void *key, uint32_t keylen, + uint32_t *val); +static int ta_lookup_chash_aligned(struct table_info *ti, void *key, + uint32_t keylen, uint32_t *val); +static int ta_lookup_chash_64(struct table_info *ti, void *key, uint32_t keylen, + uint32_t *val); +static int chash_parse_opts(struct chash_cfg *cfg, char *data); +static void ta_print_chash_config(void *ta_state, struct table_info *ti, + char *buf, size_t bufsize); +static int log2(uint32_t v); +static int ta_init_chash(struct ip_fw_chain *ch, void **ta_state, + struct table_info *ti, char *data, uint8_t tflags); +static void ta_destroy_chash(void *ta_state, struct table_info *ti); +static void ta_dump_chash_tinfo(void *ta_state, struct table_info *ti, + ipfw_ta_tinfo *tinfo); +static int ta_dump_chash_tentry(void *ta_state, struct table_info *ti, + void *e, ipfw_obj_tentry *tent); +static uint32_t hash_ent(struct chashentry *ent, int af, int mlen, + uint32_t size); +static int tei_to_chash_ent(struct tentry_info *tei, struct chashentry *ent); +static int ta_find_chash_tentry(void *ta_state, struct table_info *ti, + ipfw_obj_tentry *tent); +static void ta_foreach_chash(void *ta_state, struct table_info *ti, + ta_foreach_f *f, void *arg); +static int ta_prepare_add_chash(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_add_chash(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static int ta_prepare_del_chash(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_del_chash(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static void ta_flush_chash_entry(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_need_modify_chash(void *ta_state, struct table_info *ti, + uint32_t count, uint64_t *pflags); +static int ta_prepare_mod_chash(void *ta_buf, uint64_t *pflags); +static int ta_fill_mod_chash(void *ta_state, struct table_info *ti, void *ta_buf, + uint64_t *pflags); +static void ta_modify_chash(void *ta_state, struct table_info *ti, void *ta_buf, + uint64_t pflags); +static void ta_flush_mod_chash(void *ta_buf); + static __inline uint32_t hash_ip(uint32_t addr, int hsize) @@ -1816,6 +1902,44 @@ struct ta_buf_ifidx int compare_ifidx(const void *k, const void *v); static void if_notifier(struct ip_fw_chain *ch, void *cbdata, uint16_t ifindex); +static struct ifidx * ifidx_find(struct table_info *ti, void *key); +static int ta_lookup_ifidx(struct table_info *ti, void *key, uint32_t keylen, + uint32_t *val); +static int ta_init_ifidx(struct ip_fw_chain *ch, void **ta_state, + struct table_info *ti, char *data, uint8_t tflags); +static void ta_change_ti_ifidx(void *ta_state, struct table_info *ti); +static void destroy_ifidx_locked(struct namedobj_instance *ii, + struct named_object *no, void *arg); +static void ta_destroy_ifidx(void *ta_state, struct table_info *ti); +static void ta_dump_ifidx_tinfo(void *ta_state, struct table_info *ti, + ipfw_ta_tinfo *tinfo); +static int ta_prepare_add_ifidx(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_add_ifidx(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static int ta_prepare_del_ifidx(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_del_ifidx(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static void ta_flush_ifidx_entry(struct ip_fw_chain *ch, + struct tentry_info *tei, void *ta_buf); +static void if_notifier(struct ip_fw_chain *ch, void *cbdata, uint16_t ifindex); +static int ta_need_modify_ifidx(void *ta_state, struct table_info *ti, + uint32_t count, uint64_t *pflags); +static int ta_prepare_mod_ifidx(void *ta_buf, uint64_t *pflags); +static int ta_fill_mod_ifidx(void *ta_state, struct table_info *ti, + void *ta_buf, uint64_t *pflags); +static void ta_modify_ifidx(void *ta_state, struct table_info *ti, void *ta_buf, + uint64_t pflags); +static void ta_flush_mod_ifidx(void *ta_buf); +static int ta_dump_ifidx_tentry(void *ta_state, struct table_info *ti, void *e, + ipfw_obj_tentry *tent); +static int ta_find_ifidx_tentry(void *ta_state, struct table_info *ti, + ipfw_obj_tentry *tent); +static void foreach_ifidx(struct namedobj_instance *ii, struct named_object *no, + void *arg); +static void ta_foreach_ifidx(void *ta_state, struct table_info *ti, + ta_foreach_f *f, void *arg); int compare_ifidx(const void *k, const void *v) @@ -2483,6 +2607,36 @@ struct ta_buf_numarray }; int compare_numarray(const void *k, const void *v); +static struct numarray *numarray_find(struct table_info *ti, void *key); +static int ta_lookup_numarray(struct table_info *ti, void *key, + uint32_t keylen, uint32_t *val); +static int ta_init_numarray(struct ip_fw_chain *ch, void **ta_state, + struct table_info *ti, char *data, uint8_t tflags); +static void ta_destroy_numarray(void *ta_state, struct table_info *ti); +static void ta_dump_numarray_tinfo(void *ta_state, struct table_info *ti, + ipfw_ta_tinfo *tinfo); +static int ta_prepare_add_numarray(struct ip_fw_chain *ch, + struct tentry_info *tei, void *ta_buf); +static int ta_add_numarray(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static int ta_del_numarray(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static void ta_flush_numarray_entry(struct ip_fw_chain *ch, + struct tentry_info *tei, void *ta_buf); +static int ta_need_modify_numarray(void *ta_state, struct table_info *ti, + uint32_t count, uint64_t *pflags); +static int ta_prepare_mod_numarray(void *ta_buf, uint64_t *pflags); +static int ta_fill_mod_numarray(void *ta_state, struct table_info *ti, + void *ta_buf, uint64_t *pflags); +static void ta_modify_numarray(void *ta_state, struct table_info *ti, + void *ta_buf, uint64_t pflags); +static void ta_flush_mod_numarray(void *ta_buf); +static int ta_dump_numarray_tentry(void *ta_state, struct table_info *ti, + void *e, ipfw_obj_tentry *tent); +static int ta_find_numarray_tentry(void *ta_state, struct table_info *ti, + ipfw_obj_tentry *tent); +static void ta_foreach_numarray(void *ta_state, struct table_info *ti, + ta_foreach_f *f, void *arg); int compare_numarray(const void *k, const void *v) @@ -2915,6 +3069,44 @@ struct ta_buf_fhash { struct fhashentry6 fe6; }; +static __inline int cmp_flow_ent(struct fhashentry *a, + struct fhashentry *b, size_t sz); +static __inline uint32_t hash_flow4(struct fhashentry4 *f, int hsize); +static __inline uint32_t hash_flow6(struct fhashentry6 *f, int hsize); +static uint32_t hash_flow_ent(struct fhashentry *ent, uint32_t size); +static int ta_lookup_fhash(struct table_info *ti, void *key, uint32_t keylen, + uint32_t *val); +static int ta_init_fhash(struct ip_fw_chain *ch, void **ta_state, +struct table_info *ti, char *data, uint8_t tflags); +static void ta_destroy_fhash(void *ta_state, struct table_info *ti); +static void ta_dump_fhash_tinfo(void *ta_state, struct table_info *ti, + ipfw_ta_tinfo *tinfo); +static int ta_dump_fhash_tentry(void *ta_state, struct table_info *ti, + void *e, ipfw_obj_tentry *tent); +static int tei_to_fhash_ent(struct tentry_info *tei, struct fhashentry *ent); +static int ta_find_fhash_tentry(void *ta_state, struct table_info *ti, + ipfw_obj_tentry *tent); +static void ta_foreach_fhash(void *ta_state, struct table_info *ti, + ta_foreach_f *f, void *arg); +static int ta_prepare_add_fhash(struct ip_fw_chain *ch, + struct tentry_info *tei, void *ta_buf); +static int ta_add_fhash(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static int ta_prepare_del_fhash(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_del_fhash(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf, uint32_t *pnum); +static void ta_flush_fhash_entry(struct ip_fw_chain *ch, struct tentry_info *tei, + void *ta_buf); +static int ta_need_modify_fhash(void *ta_state, struct table_info *ti, + uint32_t count, uint64_t *pflags); +static int ta_prepare_mod_fhash(void *ta_buf, uint64_t *pflags); +static int ta_fill_mod_fhash(void *ta_state, struct table_info *ti, + void *ta_buf, uint64_t *pflags); +static void ta_modify_fhash(void *ta_state, struct table_info *ti, void *ta_buf, + uint64_t pflags); +static void ta_flush_mod_fhash(void *ta_buf); + static __inline int cmp_flow_ent(struct fhashentry *a, struct fhashentry *b, size_t sz) { @@ -3129,7 +3321,9 @@ ta_dump_fhash_tentry(void *ta_state, struct table_info *ti, void *e, struct fhash_cfg *cfg; struct fhashentry *ent; struct fhashentry4 *fe4; +#ifdef INET6 struct fhashentry6 *fe6; +#endif struct tflow_entry *tfe; cfg = (struct fhash_cfg *)ta_state; @@ -3549,6 +3743,25 @@ struct table_algo flow_hash = { * */ +static struct rtentry *lookup_kfib(void *key, int keylen, int fib); +static int ta_lookup_kfib(struct table_info *ti, void *key, uint32_t keylen, + uint32_t *val); +static int kfib_parse_opts(int *pfib, char *data); +static void ta_print_kfib_config(void *ta_state, struct table_info *ti, + char *buf, size_t bufsize); +static int ta_init_kfib(struct ip_fw_chain *ch, void **ta_state, + struct table_info *ti, char *data, uint8_t tflags); +static void ta_destroy_kfib(void *ta_state, struct table_info *ti); +static void ta_dump_kfib_tinfo(void *ta_state, struct table_info *ti, + ipfw_ta_tinfo *tinfo); +static int contigmask(uint8_t *p, int len); +static int ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, + ipfw_obj_tentry *tent); +static int ta_find_kfib_tentry(void *ta_state, struct table_info *ti, + ipfw_obj_tentry *tent); +static void ta_foreach_kfib(void *ta_state, struct table_info *ti, + ta_foreach_f *f, void *arg); + static struct rtentry * lookup_kfib(void *key, int keylen, int fib) { From d699ee2dc9ef853570276d7107967d2a4ca01034 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Fri, 10 Oct 2014 18:31:35 +0000 Subject: [PATCH 011/112] Fix NOINET6 build for ipfw. --- sys/netpfil/ipfw/ip_fw_table_algo.c | 52 ++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw_table_algo.c b/sys/netpfil/ipfw/ip_fw_table_algo.c index c640f1ab37e..f5cfd2571aa 100644 --- a/sys/netpfil/ipfw/ip_fw_table_algo.c +++ b/sys/netpfil/ipfw/ip_fw_table_algo.c @@ -380,7 +380,6 @@ static int ta_find_radix_tentry(void *ta_state, struct table_info *ti, ipfw_obj_tentry *tent); static void ta_foreach_radix(void *ta_state, struct table_info *ti, ta_foreach_f *f, void *arg); -static inline void ipv6_writemask(struct in6_addr *addr6, uint8_t mask); static void tei_to_sockaddr_ent(struct tentry_info *tei, struct sockaddr *sa, struct sockaddr *ma, int *set_mask); static int ta_prepare_add_radix(struct ip_fw_chain *ch, struct tentry_info *tei, @@ -579,6 +578,8 @@ ta_foreach_radix(void *ta_state, struct table_info *ti, ta_foreach_f *f, #ifdef INET6 +static inline void ipv6_writemask(struct in6_addr *addr6, uint8_t mask); + static inline void ipv6_writemask(struct in6_addr *addr6, uint8_t mask) { @@ -638,8 +639,8 @@ tei_to_sockaddr_ent(struct tentry_info *tei, struct sockaddr *sa, *set_mask = 1; else *set_mask = 0; - } #endif + } } static int @@ -648,7 +649,9 @@ ta_prepare_add_radix(struct ip_fw_chain *ch, struct tentry_info *tei, { struct ta_buf_radix *tb; struct radix_addr_entry *ent; +#ifdef INET6 struct radix_addr_xentry *xent; +#endif struct sockaddr *addr, *mask; int mlen, set_mask; @@ -931,13 +934,17 @@ struct ta_buf_chash struct chashentry ent; }; +#ifdef INET static __inline uint32_t hash_ip(uint32_t addr, int hsize); +#endif +#ifdef INET6 static __inline uint32_t hash_ip6(struct in6_addr *addr6, int hsize); static __inline uint16_t hash_ip64(struct in6_addr *addr6, int hsize); static __inline uint32_t hash_ip6_slow(struct in6_addr *addr6, void *key, int mask, int hsize); static __inline uint32_t hash_ip6_al(struct in6_addr *addr6, void *key, int mask, int hsize); +#endif static int ta_lookup_chash_slow(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val); static int ta_lookup_chash_aligned(struct table_info *ti, void *key, @@ -982,13 +989,16 @@ static void ta_modify_chash(void *ta_state, struct table_info *ti, void *ta_buf, static void ta_flush_mod_chash(void *ta_buf); +#ifdef INET static __inline uint32_t hash_ip(uint32_t addr, int hsize) { return (addr % (hsize - 1)); } +#endif +#ifdef INET6 static __inline uint32_t hash_ip6(struct in6_addr *addr6, int hsize) { @@ -1034,6 +1044,7 @@ hash_ip6_al(struct in6_addr *addr6, void *key, int mask, int hsize) memcpy(addr6, key, mask); return (hash_ip6(addr6, hsize)); } +#endif static int ta_lookup_chash_slow(struct table_info *ti, void *key, uint32_t keylen, @@ -1045,6 +1056,7 @@ ta_lookup_chash_slow(struct table_info *ti, void *key, uint32_t keylen, uint8_t imask; if (keylen == sizeof(in_addr_t)) { +#ifdef INET head = (struct chashbhead *)ti->state; imask = ti->data >> 24; hsize = 1 << ((ti->data & 0xFFFF) >> 8); @@ -1058,7 +1070,9 @@ ta_lookup_chash_slow(struct table_info *ti, void *key, uint32_t keylen, return (1); } } +#endif } else { +#ifdef INET6 /* IPv6: worst scenario: non-round mask */ struct in6_addr addr6; head = (struct chashbhead *)ti->xstate; @@ -1071,6 +1085,7 @@ ta_lookup_chash_slow(struct table_info *ti, void *key, uint32_t keylen, return (1); } } +#endif } return (0); @@ -1086,6 +1101,7 @@ ta_lookup_chash_aligned(struct table_info *ti, void *key, uint32_t keylen, uint8_t imask; if (keylen == sizeof(in_addr_t)) { +#ifdef INET head = (struct chashbhead *)ti->state; imask = ti->data >> 24; hsize = 1 << ((ti->data & 0xFFFF) >> 8); @@ -1099,7 +1115,9 @@ ta_lookup_chash_aligned(struct table_info *ti, void *key, uint32_t keylen, return (1); } } +#endif } else { +#ifdef INET6 /* IPv6: aligned to 8bit mask */ struct in6_addr addr6; uint64_t *paddr, *ptmp; @@ -1116,6 +1134,7 @@ ta_lookup_chash_aligned(struct table_info *ti, void *key, uint32_t keylen, return (1); } } +#endif } return (0); @@ -1131,6 +1150,7 @@ ta_lookup_chash_64(struct table_info *ti, void *key, uint32_t keylen, uint8_t imask; if (keylen == sizeof(in_addr_t)) { +#ifdef INET head = (struct chashbhead *)ti->state; imask = ti->data >> 24; hsize = 1 << ((ti->data & 0xFFFF) >> 8); @@ -1144,7 +1164,9 @@ ta_lookup_chash_64(struct table_info *ti, void *key, uint32_t keylen, return (1); } } +#endif } else { +#ifdef INET6 /* IPv6: /64 */ uint64_t a6, *paddr; head = (struct chashbhead *)ti->xstate; @@ -1159,6 +1181,7 @@ ta_lookup_chash_64(struct table_info *ti, void *key, uint32_t keylen, return (1); } } +#endif } return (0); @@ -1369,13 +1392,19 @@ hash_ent(struct chashentry *ent, int af, int mlen, uint32_t size) { uint32_t hash; + hash = 0; + if (af == AF_INET) { +#ifdef INET hash = hash_ip(ent->a.a4, size); +#endif } else { +#ifdef INET6 if (mlen == 64) hash = hash_ip64(&ent->a.a6, size); else hash = hash_ip6(&ent->a.a6, size); +#endif } return (hash); @@ -1384,8 +1413,10 @@ hash_ent(struct chashentry *ent, int af, int mlen, uint32_t size) static int tei_to_chash_ent(struct tentry_info *tei, struct chashentry *ent) { - struct in6_addr mask6; int mlen; +#ifdef INET6 + struct in6_addr mask6; +#endif mlen = tei->masklen; @@ -3357,8 +3388,12 @@ ta_dump_fhash_tentry(void *ta_state, struct table_info *ti, void *e, static int tei_to_fhash_ent(struct tentry_info *tei, struct fhashentry *ent) { +#ifdef INET struct fhashentry4 *fe4; +#endif +#ifdef INET6 struct fhashentry6 *fe6; +#endif struct tflow_entry *tfe; tfe = (struct tflow_entry *)tei->paddr; @@ -3905,8 +3940,12 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, ipfw_obj_tentry *tent) { struct rtentry *rte; +#ifdef INET struct sockaddr_in *addr, *mask; +#endif +#ifdef INET6 struct sockaddr_in6 *addr6, *mask6; +#endif int len; rte = (struct rtentry *)e; @@ -3915,6 +3954,7 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, len = 0; /* Guess IPv4/IPv6 radix by sockaddr family */ +#ifdef INET if (addr->sin_family == AF_INET) { tent->k.addr.s_addr = addr->sin_addr.s_addr; len = 32; @@ -3925,8 +3965,10 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, tent->masklen = len; tent->subtype = AF_INET; tent->v.kidx = 0; /* Do we need to put GW here? */ + } +#endif #ifdef INET6 - } else if (addr->sin_family == AF_INET6) { + if (addr->sin_family == AF_INET6) { addr6 = (struct sockaddr_in6 *)addr; mask6 = (struct sockaddr_in6 *)mask; memcpy(&tent->k, &addr6->sin6_addr, sizeof(struct in6_addr)); @@ -3938,8 +3980,8 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e, tent->masklen = len; tent->subtype = AF_INET6; tent->v.kidx = 0; -#endif } +#endif return (0); } From 5f8ad2bd82262ba190810fc0fd42af42dcbb290d Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Fri, 10 Oct 2014 18:57:12 +0000 Subject: [PATCH 012/112] Fix KASSERT argument type. --- sys/netpfil/ipfw/ip_fw_sockopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index bde85080ba2..048ad933c6a 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -3185,7 +3185,7 @@ ipfw_objhash_bitmap_alloc(uint32_t items, void **idx, int *pblocks) u_long *idx_mask; KASSERT((items % BLOCK_ITEMS) == 0, - ("bitmask size needs to power of 2 and greater or equal to %lu", + ("bitmask size needs to power of 2 and greater or equal to %zu", BLOCK_ITEMS)); max_blocks = items / BLOCK_ITEMS; From 6cf117d780dd50c8308832de4b80947374a34175 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 18:57:39 +0000 Subject: [PATCH 013/112] Disable tests that don't pass on FreeBSD due to missing support in humanize_number(3). Bringing in additional revisions from NetBSD's humanize_number(3) will fix the tests Account for the fact that util.h on NetBSD is libutil.h on FreeBSD Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c index 1af579e61c0..eec2d103332 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c @@ -34,7 +34,11 @@ #include #include #include +#if defined(__FreeBSD__) +#include +#else #include +#endif const struct hnopts { size_t ho_len; @@ -78,6 +82,7 @@ const struct hnopts { /* * Truncated output. Rev. 1.7 produces "1.0 K". */ +#if !defined(__FreeBSD__) { 6, 1000, "A", HN_AUTOSCALE, HN_DECIMAL, -1, "" }, /* @@ -90,6 +95,7 @@ const struct hnopts { /* Similar case it prints 1000 where it shouldn't */ { 5, 1023488, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" }, +#endif { 5, 1023999, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" }, }; From e6a6a5c5d3538e1c9d693db59aed7667fe5d617d Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 18:59:18 +0000 Subject: [PATCH 014/112] Add missing #include for gettimeofday Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_time.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_time.c b/contrib/netbsd-tests/lib/libc/gen/t_time.c index bfbdc73d5db..21e625ffcf2 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_time.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_time.c @@ -31,6 +31,9 @@ #include __RCSID("$NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $"); +#if defined(__FreeBSD__) +#include +#endif #include #include #include From bd735ec199f3435b560df0ad8d53ec2bf61cab3c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 19:02:02 +0000 Subject: [PATCH 015/112] FreeBSD returns ENOTTY instead of EBADF in ttyname_r; mark it as an expected failure PR: 191936 In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_ttyname.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c index 0c10c249644..80f5c17c1cb 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c @@ -107,6 +107,9 @@ ATF_TC_BODY(ttyname_r_err, tc) ATF_REQUIRE(rv == ERANGE); } +#if defined(__FreeBSD__) + atf_tc_expect_fail("FreeBSD returns ENOTTY instead of EBADF; see bin/191936"); +#endif rv = ttyname_r(-1, buf, ttymax); ATF_REQUIRE(rv == EBADF); From 97dc3d98cbeb598bd49dd3603cde75e0dc8d128b Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 10 Oct 2014 19:12:04 +0000 Subject: [PATCH 016/112] Don't pass RF_ALLOCATED to bus_alloc_resource(). --- sys/dev/ctau/if_ct.c | 3 +-- sys/dev/cx/if_cx.c | 3 +-- sys/dev/digi/digi_isa.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c index 397c3ac49b2..d0b68bcf477 100644 --- a/sys/dev/ctau/if_ct.c +++ b/sys/dev/ctau/if_ct.c @@ -323,8 +323,7 @@ static int ct_is_free_res (device_t dev, int rid, int type, u_long start, { struct resource *res; - if (!(res = bus_alloc_resource (dev, type, &rid, start, end, count, - RF_ALLOCATED))) + if (!(res = bus_alloc_resource (dev, type, &rid, start, end, count, 0))) return 0; bus_release_resource (dev, type, rid, res); diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c index 360e1f689fa..23274031cb5 100644 --- a/sys/dev/cx/if_cx.c +++ b/sys/dev/cx/if_cx.c @@ -410,8 +410,7 @@ static int cx_is_free_res (device_t dev, int rid, int type, u_long start, { struct resource *res; - if (!(res = bus_alloc_resource (dev, type, &rid, start, end, count, - RF_ALLOCATED))) + if (!(res = bus_alloc_resource (dev, type, &rid, start, end, count, 0))) return 0; bus_release_resource (dev, type, rid, res); diff --git a/sys/dev/digi/digi_isa.c b/sys/dev/digi/digi_isa.c index 0a0a2a0ed92..d0741ac7439 100644 --- a/sys/dev/digi/digi_isa.c +++ b/sys/dev/digi/digi_isa.c @@ -292,7 +292,7 @@ digi_isa_probe(device_t dev) /* Temporarily map our memory */ sc->res.mrid = 0; sc->res.mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->res.mrid, - 0ul, ~0ul, sc->win_size, RF_ALLOCATED); + 0ul, ~0ul, sc->win_size, 0); if (sc->res.mem == NULL) { device_printf(dev, "0x%lx: Memory range is in use\n", sc->pmem); bus_release_resource(dev, SYS_RES_IOPORT, sc->res.iorid, From 4cf97cc9d2d73dddc11b1915f4eb12a4906c9f41 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 19:18:52 +0000 Subject: [PATCH 017/112] FreeBSD doesn't support strings greater than MAXHOSTNAMELEN-1 in {get,set}{domain,host}name. Adjust the tests to not exceed that value when testing out the code Add a positive and negative test for MAXHOSTNAMELEN-1 and MAXHOSTNAMELEN, respectively PR: 181127 In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- .../netbsd-tests/lib/libc/gen/t_setdomainname.c | 16 ++++++++++++++++ .../netbsd-tests/lib/libc/gen/t_sethostname.c | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c b/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c index 89818f08308..a93083a17f6 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c @@ -63,8 +63,20 @@ ATF_TC_BODY(setdomainname_basic, tc) (void)memset(name, 0, sizeof(name)); +#if defined(__FreeBSD__) + /* + * Sanity checks to ensure that the wrong invariant isn't being + * tested for per PR # 181127 + */ + ATF_REQUIRE_EQ(sizeof(domains[i]), MAXHOSTNAMELEN); + ATF_REQUIRE_EQ(sizeof(name), MAXHOSTNAMELEN); + + ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i]) - 1) == 0); + ATF_REQUIRE(getdomainname(name, sizeof(name) - 1) == 0); +#else ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i])) == 0); ATF_REQUIRE(getdomainname(name, sizeof(name)) == 0); +#endif ATF_REQUIRE(strcmp(domains[i], name) == 0); } @@ -89,6 +101,10 @@ ATF_TC_BODY(setdomainname_limit, tc) (void)memset(name, 0, sizeof(name)); +#if defined(__FreeBSD__) + ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN - 1 ) == 0); + ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN) == -1); +#endif ATF_REQUIRE(setdomainname(name, sizeof(name)) == -1); } diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c b/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c index a753ac7b033..9c5abac32a3 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_sethostname.c @@ -63,8 +63,20 @@ ATF_TC_BODY(sethostname_basic, tc) (void)memset(name, 0, sizeof(name)); +#if defined(__FreeBSD__) + /* + * Sanity checks to ensure that the wrong invariant isn't being + * tested for per PR # 181127 + */ + ATF_REQUIRE_EQ(sizeof(hosts[i]), MAXHOSTNAMELEN); + ATF_REQUIRE_EQ(sizeof(name), MAXHOSTNAMELEN); + + ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i]) - 1) == 0); + ATF_REQUIRE(gethostname(name, sizeof(name) - 1) == 0); +#else ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i])) == 0); ATF_REQUIRE(gethostname(name, sizeof(name)) == 0); +#endif ATF_REQUIRE(strcmp(hosts[i], name) == 0); } @@ -94,6 +106,10 @@ ATF_TC_BODY(sethostname_limit, tc) ATF_TC_CLEANUP(sethostname_limit, tc) { +#if defined(__FreeBSD__) + ATF_REQUIRE(sethostname(host, MAXHOSTNAMELEN - 1 ) == 0); + ATF_REQUIRE(sethostname(host, MAXHOSTNAMELEN) == -1); +#endif (void)sethostname(host, sizeof(host)); } From 1d2baefc132ed7c8526f8045409ad0bfa05d03f9 Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Fri, 10 Oct 2014 19:26:26 +0000 Subject: [PATCH 018/112] Change the PF hash from Jenkins to Murmur3. In forwarding tests this showed a conservative 3% incrase in PPS. Differential Revision: https://reviews.freebsd.org/D461 Submitted by: des Reviewed by: emaste MFC after: 1 month --- sys/conf/files | 1 + sys/libkern/murmur3_32.c | 74 ++++++++++++++++++++++++++++++++++++++++ sys/netpfil/pf/pf.c | 14 ++++---- sys/sys/hash.h | 3 ++ 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 sys/libkern/murmur3_32.c diff --git a/sys/conf/files b/sys/conf/files index 0a59317776c..9d2a787ab6b 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3175,6 +3175,7 @@ libkern/inet_ntoa.c standard libkern/inet_ntop.c standard libkern/inet_pton.c standard libkern/jenkins_hash.c standard +libkern/murmur3_32.c standard libkern/mcount.c optional profiling-routine libkern/memcchr.c standard libkern/memchr.c optional fdt | gdb diff --git a/sys/libkern/murmur3_32.c b/sys/libkern/murmur3_32.c new file mode 100644 index 00000000000..05ce2c59d01 --- /dev/null +++ b/sys/libkern/murmur3_32.c @@ -0,0 +1,74 @@ +/*- + * Copyright (c) 2014 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#define rol32(i32, n) ((i32) << (n) | (i32) >> (32 - (n))) + +/* + * $FreeBSD$ + * Simple implementation of the Murmur3-32 hash function optimized for + * aligned sequences of 32-bit words. If len is not a multiple of 4, it + * will be rounded down, droping trailer bytes. + */ +uint32_t +murmur3_aligned_32(const void *data, size_t len, uint32_t seed) +{ + const uint32_t *data32; + uint32_t hash, k; + size_t res; + + /* initialize */ + len -= len % sizeof(*data32); + res = len; + data32 = data; + hash = seed; + + /* iterate */ + for (res = 0; res < len; res += sizeof(*data32), data32++) { + k = le32toh(*data32); + k *= 0xcc9e2d51; + k = rol32(k, 15); + k *= 0x1b873593; + hash ^= k; + hash = rol32(hash, 13); + hash *= 5; + hash += 0xe6546b64; + } + + /* finalize */ + hash ^= (uint32_t)len; + hash ^= hash >> 16; + hash *= 0x85ebca6b; + hash ^= hash >> 13; + hash *= 0xc2b2ae35; + hash ^= hash >> 16; + return (hash); +} + diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 7e90b61cb30..ac4a154ac34 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -374,9 +374,9 @@ pf_hashkey(struct pf_state_key *sk) { uint32_t h; - h = jenkins_hash32((uint32_t *)sk, - sizeof(struct pf_state_key_cmp)/sizeof(uint32_t), - V_pf_hashseed); + h = murmur3_aligned_32((uint32_t *)sk, + sizeof(struct pf_state_key_cmp), + V_pf_hashseed); return (h & pf_hashmask); } @@ -388,12 +388,12 @@ pf_hashsrc(struct pf_addr *addr, sa_family_t af) switch (af) { case AF_INET: - h = jenkins_hash32((uint32_t *)&addr->v4, - sizeof(addr->v4)/sizeof(uint32_t), V_pf_hashseed); + h = murmur3_aligned_32((uint32_t *)&addr->v4, + sizeof(addr->v4), V_pf_hashseed); break; case AF_INET6: - h = jenkins_hash32((uint32_t *)&addr->v6, - sizeof(addr->v6)/sizeof(uint32_t), V_pf_hashseed); + h = murmur3_aligned_32((uint32_t *)&addr->v6, + sizeof(addr->v6), V_pf_hashseed); break; default: panic("%s: unknown address family %u", __func__, af); diff --git a/sys/sys/hash.h b/sys/sys/hash.h index ca9cc6789f0..e2e008bfa85 100644 --- a/sys/sys/hash.h +++ b/sys/sys/hash.h @@ -125,6 +125,9 @@ hash32_strne(const void *buf, size_t len, int end, const char **ep, */ uint32_t jenkins_hash(const void *, size_t, uint32_t); uint32_t jenkins_hash32(const uint32_t *, size_t, uint32_t); + +uint32_t murmur3_aligned_32(const void *data, size_t len, uint32_t seed); + #endif /* _KERNEL */ #endif /* !_SYS_HASH_H_ */ From a36f55322c71692896ccd8891ff852fc0dd87697 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 10 Oct 2014 19:27:36 +0000 Subject: [PATCH 019/112] Make MAP_NOSYNC handling in the vm_fault() read-locked object path compatible with write-locked path. Test for MAP_ENTRY_NOSYNC and set VPO_NOSYNC for pages with dirty mask zero (this does not exclude a possibility that the page is dirty, e.g. due to read fault on writeable mapping and consequent write; the same issue exists in the slow path). Use helper vm_fault_dirty() to unify fast and slow path handling of VPO_NOSYNC and setting the dirty mask. Reviewed by: alc Sponsored by: The FreeBSD Foundation --- sys/vm/vm_fault.c | 108 ++++++++++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 30b0456d478..944b4793f6d 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -174,6 +174,70 @@ unlock_and_deallocate(struct faultstate *fs) } } +static void +vm_fault_dirty(vm_map_entry_t entry, vm_page_t m, vm_prot_t prot, + vm_prot_t fault_type, int fault_flags, boolean_t set_wd) +{ + boolean_t need_dirty; + + if (((prot & VM_PROT_WRITE) == 0 && + (fault_flags & VM_FAULT_DIRTY) == 0) || + (m->oflags & VPO_UNMANAGED) != 0) + return; + + VM_OBJECT_ASSERT_LOCKED(m->object); + + need_dirty = ((fault_type & VM_PROT_WRITE) != 0 && + (fault_flags & VM_FAULT_CHANGE_WIRING) == 0) || + (fault_flags & VM_FAULT_DIRTY) != 0; + + if (set_wd) + vm_object_set_writeable_dirty(m->object); + else + /* + * If two callers of vm_fault_dirty() with set_wd == + * FALSE, one for the map entry with MAP_ENTRY_NOSYNC + * flag set, other with flag clear, race, it is + * possible for the no-NOSYNC thread to see m->dirty + * != 0 and not clear VPO_NOSYNC. Take vm_page lock + * around manipulation of VPO_NOSYNC and + * vm_page_dirty() call, to avoid the race and keep + * m->oflags consistent. + */ + vm_page_lock(m); + + /* + * If this is a NOSYNC mmap we do not want to set VPO_NOSYNC + * if the page is already dirty to prevent data written with + * the expectation of being synced from not being synced. + * Likewise if this entry does not request NOSYNC then make + * sure the page isn't marked NOSYNC. Applications sharing + * data should use the same flags to avoid ping ponging. + */ + if ((entry->eflags & MAP_ENTRY_NOSYNC) != 0) { + if (m->dirty == 0) { + m->oflags |= VPO_NOSYNC; + } + } else { + m->oflags &= ~VPO_NOSYNC; + } + + /* + * If the fault is a write, we know that this page is being + * written NOW so dirty it explicitly to save on + * pmap_is_modified() calls later. + * + * Also tell the backing pager, if any, that it should remove + * any swap backing since the page is now dirty. + */ + if (need_dirty) + vm_page_dirty(m); + if (!set_wd) + vm_page_unlock(m); + if (need_dirty) + vm_pager_page_unswapped(m); +} + /* * TRYPAGER - used by vm_fault to calculate whether the pager for the * current object *might* contain the page. @@ -321,11 +385,8 @@ RetryFault:; vm_page_hold(m); vm_page_unlock(m); } - if ((fault_type & VM_PROT_WRITE) != 0 && - (m->oflags & VPO_UNMANAGED) == 0) { - vm_page_dirty(m); - vm_pager_page_unswapped(m); - } + vm_fault_dirty(fs.entry, m, prot, fault_type, fault_flags, + FALSE); VM_OBJECT_RUNLOCK(fs.first_object); if (!wired) vm_fault_prefault(&fs, vaddr, 0, 0); @@ -898,42 +959,7 @@ vnode_locked: if (hardfault) fs.entry->next_read = fs.pindex + faultcount - reqpage; - if (((prot & VM_PROT_WRITE) != 0 || - (fault_flags & VM_FAULT_DIRTY) != 0) && - (fs.m->oflags & VPO_UNMANAGED) == 0) { - vm_object_set_writeable_dirty(fs.object); - - /* - * If this is a NOSYNC mmap we do not want to set VPO_NOSYNC - * if the page is already dirty to prevent data written with - * the expectation of being synced from not being synced. - * Likewise if this entry does not request NOSYNC then make - * sure the page isn't marked NOSYNC. Applications sharing - * data should use the same flags to avoid ping ponging. - */ - if (fs.entry->eflags & MAP_ENTRY_NOSYNC) { - if (fs.m->dirty == 0) - fs.m->oflags |= VPO_NOSYNC; - } else { - fs.m->oflags &= ~VPO_NOSYNC; - } - - /* - * If the fault is a write, we know that this page is being - * written NOW so dirty it explicitly to save on - * pmap_is_modified() calls later. - * - * Also tell the backing pager, if any, that it should remove - * any swap backing since the page is now dirty. - */ - if (((fault_type & VM_PROT_WRITE) != 0 && - (fault_flags & VM_FAULT_CHANGE_WIRING) == 0) || - (fault_flags & VM_FAULT_DIRTY) != 0) { - vm_page_dirty(fs.m); - vm_pager_page_unswapped(fs.m); - } - } - + vm_fault_dirty(fs.entry, fs.m, prot, fault_type, fault_flags, TRUE); vm_page_assert_xbusied(fs.m); /* From 9ae31714cf56f9e62c6611bb6c8617af99d0a379 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 19:28:57 +0000 Subject: [PATCH 020/112] Disable the invalid pointer test on FreeBSD FreeBSD segfaults on invalid pointers passed to getcwd because it throbs the address passed in in libc, whereas NetBSD just passes the information off to the syscall, which allows the kernel to return EFAULT on bad pointers. In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_getcwd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_getcwd.c b/contrib/netbsd-tests/lib/libc/gen/t_getcwd.c index 76c287aca52..bb3baf01342 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_getcwd.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_getcwd.c @@ -56,10 +56,12 @@ ATF_TC_BODY(getcwd_err, tc) ATF_REQUIRE(getcwd(buf, 0) == NULL); ATF_REQUIRE(errno == EINVAL); +#if defined(__NetBSD__) errno = 0; ATF_REQUIRE(getcwd((void *)-1, sizeof(buf)) == NULL); ATF_REQUIRE(errno == EFAULT); +#endif } ATF_TC(getcwd_fts); From 6fc3b00f80ad83fe9287157d7b6dc693d3cb3b27 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 19:32:53 +0000 Subject: [PATCH 021/112] Handle getting/setting niceness/priority correctly on FreeBSD vs NetBSD This might be fallout from PR: 189821 Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_nice.c | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_nice.c b/contrib/netbsd-tests/lib/libc/gen/t_nice.c index f4a62e9ac75..67a0bf5507e 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_nice.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_nice.c @@ -93,7 +93,11 @@ ATF_TC_HEAD(nice_priority, tc) ATF_TC_BODY(nice_priority, tc) { +#if defined(__FreeBSD__) + int i, pri, pri2, nic; +#else int i, pri, nic; +#endif pid_t pid; int sta; @@ -106,8 +110,10 @@ ATF_TC_BODY(nice_priority, tc) pri = getpriority(PRIO_PROCESS, 0); ATF_REQUIRE(errno == 0); +#if defined(__NetBSD__) if (nic != pri) atf_tc_fail("nice(3) and getpriority(2) conflict"); +#endif /* * Also verify that the nice(3) values @@ -119,10 +125,18 @@ ATF_TC_BODY(nice_priority, tc) if (pid == 0) { errno = 0; +#if defined(__FreeBSD__) pri = getpriority(PRIO_PROCESS, 0); +#else + pri2 = getpriority(PRIO_PROCESS, 0); +#endif ATF_REQUIRE(errno == 0); +#if defined(__FreeBSD__) + if (pri != pri2) +#else if (nic != pri) +#endif _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); @@ -161,7 +175,11 @@ ATF_TC_HEAD(nice_thread, tc) ATF_TC_BODY(nice_thread, tc) { pthread_t tid[5]; +#if defined(__FreeBSD__) + int pri, rv, val; +#else int rv, val; +#endif size_t i; /* @@ -173,7 +191,12 @@ ATF_TC_BODY(nice_thread, tc) val = nice(i); ATF_REQUIRE(val != -1); +#if defined(__FreeBSD__) + pri = getpriority(PRIO_PROCESS, 0); + rv = pthread_create(&tid[i], NULL, threadfunc, &pri); +#else rv = pthread_create(&tid[i], NULL, threadfunc, &val); +#endif ATF_REQUIRE(rv == 0); rv = pthread_join(tid[i], NULL); From e33dfddd037c2a84f69facb426cee2b03ba5479b Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 19:34:19 +0000 Subject: [PATCH 022/112] SIGPWR does not exist on FreeBSD Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_raise.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_raise.c b/contrib/netbsd-tests/lib/libc/gen/t_raise.c index adc032fdd98..120981f8466 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_raise.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_raise.c @@ -43,7 +43,11 @@ static int count; static void handler_err(int); static void handler_ret(int); static void handler_stress(int); +#if defined(__FreeBSD__) +static int sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2 }; +#else static int sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2, SIGPWR }; +#endif static void handler_stress(int signo) From 19720f4113964e8a7e1c122471d469b9c02322db Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 10 Oct 2014 19:41:09 +0000 Subject: [PATCH 023/112] Make ctld start even if some LUNs are unable to open backing storage. Such LUNs will be visible to initiators, but return "not ready" status on media access commands. If backing storage become available later, `ctladm modify ...` or `service ctld reload` can trigger its reopen. --- sys/cam/ctl/ctl.c | 3 + sys/cam/ctl/ctl_backend.h | 5 +- sys/cam/ctl/ctl_backend_block.c | 160 +++++++++++++++----------------- sys/cam/ctl/ctl_cmd_table.c | 22 +++++ sys/cam/ctl/ctl_ioctl.h | 3 +- usr.sbin/ctladm/ctladm.c | 50 ++++++---- usr.sbin/ctld/kernel.c | 52 ++++++----- 7 files changed, 168 insertions(+), 127 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 7edf582534a..622aeee9c2f 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -4599,6 +4599,9 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun, be_lun->ctl_lun = lun; be_lun->lun_id = lun_number; atomic_add_int(&be_lun->be->num_luns, 1); + if (be_lun->flags & CTL_LUN_FLAG_OFFLINE) + lun->flags |= CTL_LUN_OFFLINE; + if (be_lun->flags & CTL_LUN_FLAG_POWERED_OFF) lun->flags |= CTL_LUN_STOPPED; diff --git a/sys/cam/ctl/ctl_backend.h b/sys/cam/ctl/ctl_backend.h index d8e78ab477a..fab34adb47f 100644 --- a/sys/cam/ctl/ctl_backend.h +++ b/sys/cam/ctl/ctl_backend.h @@ -73,6 +73,8 @@ * The DEV_TYPE flag tells us that the device_type field is filled in. * * The UNMAP flag tells us that this LUN supports UNMAP. + * + * The OFFLINE flag tells us that this LUN can not access backing store. */ typedef enum { CTL_LUN_FLAG_ID_REQ = 0x01, @@ -82,7 +84,8 @@ typedef enum { CTL_LUN_FLAG_SERIAL_NUM = 0x10, CTL_LUN_FLAG_DEVID = 0x20, CTL_LUN_FLAG_DEV_TYPE = 0x40, - CTL_LUN_FLAG_UNMAP = 0x80 + CTL_LUN_FLAG_UNMAP = 0x80, + CTL_LUN_FLAG_OFFLINE = 0x100 } ctl_backend_lun_flags; #ifdef _KERNEL diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index eb16474a247..e9852348513 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -151,6 +151,7 @@ typedef void (*cbb_dispatch_t)(struct ctl_be_block_lun *be_lun, * and a backend block LUN, and between a backend block LUN and a CTL LUN. */ struct ctl_be_block_lun { + struct ctl_lun_create_params params; struct ctl_block_disk *disk; char lunname[32]; char *dev_path; @@ -1521,7 +1522,7 @@ ctl_be_block_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, default: lun_req->status = CTL_LUN_ERROR; snprintf(lun_req->error_str, sizeof(lun_req->error_str), - "%s: invalid LUN request type %d", __func__, + "invalid LUN request type %d", lun_req->reqtype); break; } @@ -1545,7 +1546,7 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) error = 0; file_data = &be_lun->backend.file; - params = &req->reqdata.create; + params = &be_lun->params; be_lun->dev_type = CTL_BE_BLOCK_FILE; be_lun->dispatch = ctl_be_block_dispatch_file; @@ -1628,7 +1629,7 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) int error; off_t ps, pss, po, pos; - params = &req->reqdata.create; + params = &be_lun->params; be_lun->dev_type = CTL_BE_BLOCK_DEV; be_lun->backend.dev.cdev = be_lun->vn->v_rdev; @@ -1646,8 +1647,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED); if (error) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error getting vnode attributes for device %s", - __func__, be_lun->dev_path); + "error getting vnode attributes for device %s", + be_lun->dev_path); return (error); } @@ -1655,7 +1656,7 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) devsw = dev->si_devsw; if (!devsw->d_ioctl) { snprintf(req->error_str, sizeof(req->error_str), - "%s: no d_ioctl for device %s!", __func__, + "no d_ioctl for device %s!", be_lun->dev_path); return (ENODEV); } @@ -1665,8 +1666,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) curthread); if (error) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error %d returned for DIOCGSECTORSIZE ioctl " - "on %s!", __func__, error, be_lun->dev_path); + "error %d returned for DIOCGSECTORSIZE ioctl " + "on %s!", error, be_lun->dev_path); return (error); } @@ -1688,9 +1689,9 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) be_lun->blocksize = params->blocksize_bytes; } else { snprintf(req->error_str, sizeof(req->error_str), - "%s: requested blocksize %u is not an even " + "requested blocksize %u is not an even " "multiple of backing device blocksize %u", - __func__, params->blocksize_bytes, + params->blocksize_bytes, be_lun->blocksize); return (EINVAL); @@ -1698,8 +1699,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) } else if ((params->blocksize_bytes != 0) && (params->blocksize_bytes != be_lun->blocksize)) { snprintf(req->error_str, sizeof(req->error_str), - "%s: requested blocksize %u < backing device " - "blocksize %u", __func__, params->blocksize_bytes, + "requested blocksize %u < backing device " + "blocksize %u", params->blocksize_bytes, be_lun->blocksize); return (EINVAL); } @@ -1709,8 +1710,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) curthread); if (error) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error %d returned for DIOCGMEDIASIZE " - " ioctl on %s!", __func__, error, + "error %d returned for DIOCGMEDIASIZE " + " ioctl on %s!", error, be_lun->dev_path); return (error); } @@ -1718,8 +1719,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) if (params->lun_size_bytes != 0) { if (params->lun_size_bytes > be_lun->size_bytes) { snprintf(req->error_str, sizeof(req->error_str), - "%s: requested LUN size %ju > backing device " - "size %ju", __func__, + "requested LUN size %ju > backing device " + "size %ju", (uintmax_t)params->lun_size_bytes, (uintmax_t)be_lun->size_bytes); return (EINVAL); @@ -1792,6 +1793,7 @@ ctl_be_block_close(struct ctl_be_block_lun *be_lun) panic("Unexpected backend type."); break; } + be_lun->dev_type = CTL_BE_BLOCK_NONE; } PICKUP_GIANT(); @@ -1814,7 +1816,7 @@ ctl_be_block_open(struct ctl_be_block_softc *softc, if (rootvnode == NULL) { snprintf(req->error_str, sizeof(req->error_str), - "%s: Root filesystem is not mounted", __func__); + "Root filesystem is not mounted"); return (1); } @@ -1858,7 +1860,7 @@ ctl_be_block_open(struct ctl_be_block_softc *softc, } } snprintf(req->error_str, sizeof(req->error_str), - "%s: error opening %s", __func__, be_lun->dev_path); + "error opening %s: %d", be_lun->dev_path, error); return (error); } @@ -1902,11 +1904,13 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) params = &req->reqdata.create; retval = 0; + req->status = CTL_LUN_OK; num_threads = cbb_num_threads; be_lun = malloc(sizeof(*be_lun), M_CTLBLK, M_ZERO | M_WAITOK); + be_lun->params = req->reqdata.create; be_lun->softc = softc; STAILQ_INIT(&be_lun->input_queue); STAILQ_INIT(&be_lun->config_write_queue); @@ -1922,7 +1926,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (be_lun->lun_zone == NULL) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error allocating UMA zone", __func__); + "error allocating UMA zone"); goto bailout_error; } @@ -1935,26 +1939,18 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) value = ctl_get_opt(&be_lun->ctl_be_lun.options, "file"); if (value == NULL) { snprintf(req->error_str, sizeof(req->error_str), - "%s: no file argument specified", __func__); + "no file argument specified"); goto bailout_error; } be_lun->dev_path = strdup(value, M_CTLBLK); + be_lun->blocksize = 512; + be_lun->blocksize_shift = fls(be_lun->blocksize) - 1; retval = ctl_be_block_open(softc, be_lun, req); if (retval != 0) { retval = 0; - goto bailout_error; + req->status = CTL_LUN_WARNING; } - - /* - * Tell the user the size of the file/device. - */ - params->lun_size_bytes = be_lun->size_bytes; - - /* - * The maximum LBA is the size - 1. - */ - be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; } else { /* * For processor devices, we don't have any size. @@ -1965,7 +1961,6 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) be_lun->size_blocks = 0; be_lun->size_bytes = 0; be_lun->ctl_be_lun.maxlba = 0; - params->lun_size_bytes = 0; /* * Default to just 1 thread for processor devices. @@ -1988,8 +1983,8 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) */ if (tmp_num_threads < 1) { snprintf(req->error_str, sizeof(req->error_str), - "%s: invalid number of threads %s", - __func__, num_thread_str); + "invalid number of threads %s", + num_thread_str); goto bailout_error; } num_threads = tmp_num_threads; @@ -2001,16 +1996,22 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) be_lun->flags = CTL_BE_BLOCK_LUN_UNCONFIGURED; be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; + if (be_lun->vn == NULL) + be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_OFFLINE; if (unmap) be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP; - if (be_lun->dispatch == ctl_be_block_dispatch_zvol) - be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE / - be_lun->blocksize; be_lun->ctl_be_lun.be_lun = be_lun; + be_lun->ctl_be_lun.maxlba = (be_lun->size_blocks == 0) ? + 0 : (be_lun->size_blocks - 1); be_lun->ctl_be_lun.blocksize = be_lun->blocksize; be_lun->ctl_be_lun.pblockexp = be_lun->pblockexp; be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff; + if (be_lun->dispatch == ctl_be_block_dispatch_zvol && + be_lun->blocksize != 0) + be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE / + be_lun->blocksize; /* Tell the user the blocksize we ended up using */ + params->lun_size_bytes = be_lun->size_bytes; params->blocksize_bytes = be_lun->blocksize; if (params->flags & CTL_LUN_FLAG_ID_REQ) { be_lun->ctl_be_lun.req_lun_id = params->req_lun_id; @@ -2062,7 +2063,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (be_lun->io_taskqueue == NULL) { snprintf(req->error_str, sizeof(req->error_str), - "%s: Unable to create taskqueue", __func__); + "unable to create taskqueue"); goto bailout_error; } @@ -2105,8 +2106,8 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) softc->num_luns--; mtx_unlock(&softc->lock); snprintf(req->error_str, sizeof(req->error_str), - "%s: ctl_add_lun() returned error %d, see dmesg for " - "details", __func__, retval); + "ctl_add_lun() returned error %d, see dmesg for " + "details", retval); retval = 0; goto bailout_error; } @@ -2128,8 +2129,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (be_lun->flags & CTL_BE_BLOCK_LUN_CONFIG_ERR) { snprintf(req->error_str, sizeof(req->error_str), - "%s: LUN configuration error, see dmesg for details", - __func__); + "LUN configuration error, see dmesg for details"); STAILQ_REMOVE(&softc->lun_list, be_lun, ctl_be_block_lun, links); softc->num_luns--; @@ -2148,9 +2148,6 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) | DEVSTAT_TYPE_IF_OTHER, DEVSTAT_PRIORITY_OTHER); - - req->status = CTL_LUN_OK; - return (retval); bailout_error: @@ -2192,8 +2189,8 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (be_lun == NULL) { snprintf(req->error_str, sizeof(req->error_str), - "%s: LUN %u is not managed by the block backend", - __func__, params->lun_id); + "LUN %u is not managed by the block backend", + params->lun_id); goto bailout_error; } @@ -2201,8 +2198,8 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (retval != 0) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error %d returned from ctl_disable_lun() for " - "LUN %d", __func__, retval, params->lun_id); + "error %d returned from ctl_disable_lun() for " + "LUN %d", retval, params->lun_id); goto bailout_error; } @@ -2210,8 +2207,8 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) retval = ctl_invalidate_lun(&be_lun->ctl_be_lun); if (retval != 0) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error %d returned from ctl_invalidate_lun() for " - "LUN %d", __func__, retval, params->lun_id); + "error %d returned from ctl_invalidate_lun() for " + "LUN %d", retval, params->lun_id); goto bailout_error; } @@ -2229,8 +2226,7 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if ((be_lun->flags & CTL_BE_BLOCK_LUN_UNCONFIGURED) == 0) { snprintf(req->error_str, sizeof(req->error_str), - "%s: interrupted waiting for LUN to be freed", - __func__); + "interrupted waiting for LUN to be freed"); mtx_unlock(&softc->lock); goto bailout_error; } @@ -2274,9 +2270,7 @@ ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun, { struct vattr vattr; int error; - struct ctl_lun_modify_params *params; - - params = &req->reqdata.modify; + struct ctl_lun_create_params *params = &be_lun->params; if (params->lun_size_bytes != 0) { be_lun->size_bytes = params->lun_size_bytes; @@ -2303,16 +2297,13 @@ ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun, { struct ctl_be_block_devdata *dev_data; int error; - struct ctl_lun_modify_params *params; + struct ctl_lun_create_params *params = &be_lun->params; uint64_t size_bytes; - params = &req->reqdata.modify; - dev_data = &be_lun->backend.dev; if (!dev_data->csw->d_ioctl) { snprintf(req->error_str, sizeof(req->error_str), - "%s: no d_ioctl for device %s!", __func__, - be_lun->dev_path); + "no d_ioctl for device %s!", be_lun->dev_path); return (ENODEV); } @@ -2321,16 +2312,16 @@ ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun, curthread); if (error) { snprintf(req->error_str, sizeof(req->error_str), - "%s: error %d returned for DIOCGMEDIASIZE ioctl " - "on %s!", __func__, error, be_lun->dev_path); + "error %d returned for DIOCGMEDIASIZE ioctl " + "on %s!", error, be_lun->dev_path); return (error); } if (params->lun_size_bytes != 0) { if (params->lun_size_bytes > size_bytes) { snprintf(req->error_str, sizeof(req->error_str), - "%s: requested LUN size %ju > backing device " - "size %ju", __func__, + "requested LUN size %ju > backing device " + "size %ju", (uintmax_t)params->lun_size_bytes, (uintmax_t)size_bytes); return (EINVAL); @@ -2355,9 +2346,7 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) params = &req->reqdata.modify; mtx_lock(&softc->lock); - be_lun = NULL; - STAILQ_FOREACH(be_lun, &softc->lun_list, links) { if (be_lun->ctl_be_lun.lun_id == params->lun_id) break; @@ -2366,29 +2355,22 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (be_lun == NULL) { snprintf(req->error_str, sizeof(req->error_str), - "%s: LUN %u is not managed by the block backend", - __func__, params->lun_id); + "LUN %u is not managed by the block backend", + params->lun_id); goto bailout_error; } - if (params->lun_size_bytes != 0) { - if (params->lun_size_bytes < be_lun->blocksize) { - snprintf(req->error_str, sizeof(req->error_str), - "%s: LUN size %ju < blocksize %u", __func__, - params->lun_size_bytes, be_lun->blocksize); - goto bailout_error; - } - } + be_lun->params.lun_size_bytes = params->lun_size_bytes; - oldsize = be_lun->size_bytes; - if (be_lun->vn->v_type == VREG) + oldsize = be_lun->size_blocks; + if (be_lun->vn == NULL) + error = ctl_be_block_open(softc, be_lun, req); + else if (be_lun->vn->v_type == VREG) error = ctl_be_block_modify_file(be_lun, req); else error = ctl_be_block_modify_dev(be_lun, req); - if (error != 0) - goto bailout_error; - if (be_lun->size_bytes != oldsize) { + if (error == 0 && be_lun->size_blocks != oldsize) { be_lun->size_blocks = be_lun->size_bytes >> be_lun->blocksize_shift; @@ -2398,14 +2380,24 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) * XXX: Note that this field is being updated without locking, * which might cause problems on 32-bit architectures. */ - be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; + be_lun->ctl_be_lun.maxlba = (be_lun->size_blocks == 0) ? + 0 : (be_lun->size_blocks - 1); + be_lun->ctl_be_lun.blocksize = be_lun->blocksize; + be_lun->ctl_be_lun.pblockexp = be_lun->pblockexp; + be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff; + if (be_lun->dispatch == ctl_be_block_dispatch_zvol && + be_lun->blocksize != 0) + be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE / + be_lun->blocksize; ctl_lun_capacity_changed(&be_lun->ctl_be_lun); + if (oldsize == 0 && be_lun->size_blocks != 0) + ctl_lun_online(&be_lun->ctl_be_lun); } /* Tell the user the exact size we ended up using */ params->lun_size_bytes = be_lun->size_bytes; - req->status = CTL_LUN_OK; + req->status = error ? CTL_LUN_WARNING : CTL_LUN_OK; return (0); diff --git a/sys/cam/ctl/ctl_cmd_table.c b/sys/cam/ctl/ctl_cmd_table.c index e2323a2cb34..f1093005d28 100644 --- a/sys/cam/ctl/ctl_cmd_table.c +++ b/sys/cam/ctl/ctl_cmd_table.c @@ -70,6 +70,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -81,6 +82,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -92,6 +94,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -103,6 +106,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -120,6 +124,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -131,6 +136,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -142,6 +148,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -153,6 +160,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -164,6 +172,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -178,6 +187,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -460,6 +470,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] = {ctl_report_tagret_port_groups, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN, CTL_LUN_PAT_NONE, @@ -472,6 +483,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] = {ctl_report_supported_opcodes, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -482,6 +494,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] = {ctl_report_supported_tmf, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -495,6 +508,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] = {ctl_report_timestamp, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN, CTL_LUN_PAT_NONE, @@ -601,6 +615,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_mode_select, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT, CTL_LUN_PAT_NONE, 6, {0x11, 0, 0, 0xff, 0x07}}, @@ -610,6 +625,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT, CTL_LUN_PAT_NONE, 6, {0, 0, 0, 0, 0x07}}, @@ -619,6 +635,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_NONE, CTL_LUN_PAT_NONE, 6, {0, 0, 0, 0, 0x07}}, @@ -633,6 +650,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_mode_sense, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, @@ -855,6 +873,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_mode_select, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT, CTL_LUN_PAT_NONE, 10, {0x11, 0, 0, 0, 0, 0, 0xff, 0xff, 0x07} }, @@ -864,6 +883,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT, CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} }, @@ -873,6 +893,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_OUT, CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} }, @@ -887,6 +908,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {ctl_mode_sense, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | + CTL_CMD_FLAG_OK_ON_OFFLINE | CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_FLAG_DATA_IN | CTL_CMD_FLAG_ALLOW_ON_PR_RESV, diff --git a/sys/cam/ctl/ctl_ioctl.h b/sys/cam/ctl/ctl_ioctl.h index a90475b8fcf..7640313a61f 100644 --- a/sys/cam/ctl/ctl_ioctl.h +++ b/sys/cam/ctl/ctl_ioctl.h @@ -363,7 +363,8 @@ struct ctl_port_list { typedef enum { CTL_LUN_NOSTATUS, CTL_LUN_OK, - CTL_LUN_ERROR + CTL_LUN_ERROR, + CTL_LUN_WARNING } ctl_lun_status; #define CTL_ERROR_STR_LEN 160 diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c index c362f5cb83e..29fdd501057 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -3174,14 +3174,18 @@ cctl_create_lun(int fd, int argc, char **argv, char *combinedopt) goto bailout; } - if (req.status == CTL_LUN_ERROR) { - warnx("%s: error returned from LUN creation request:\n%s", - __func__, req.error_str); + switch (req.status) { + case CTL_LUN_ERROR: + warnx("LUN creation error: %s", req.error_str); retval = 1; goto bailout; - } else if (req.status != CTL_LUN_OK) { - warnx("%s: unknown LUN creation request status %d", - __func__, req.status); + case CTL_LUN_WARNING: + warnx("LUN creation warning: %s", req.error_str); + break; + case CTL_LUN_OK: + break; + default: + warnx("unknown LUN creation status: %d", req.status); retval = 1; goto bailout; } @@ -3320,19 +3324,23 @@ cctl_rm_lun(int fd, int argc, char **argv, char *combinedopt) goto bailout; } - if (req.status == CTL_LUN_ERROR) { - warnx("%s: error returned from LUN removal request:\n%s", - __func__, req.error_str); + switch (req.status) { + case CTL_LUN_ERROR: + warnx("LUN removal error: %s", req.error_str); retval = 1; goto bailout; - } else if (req.status != CTL_LUN_OK) { - warnx("%s: unknown LUN removal request status %d", - __func__, req.status); + case CTL_LUN_WARNING: + warnx("LUN removal warning: %s", req.error_str); + break; + case CTL_LUN_OK: + break; + default: + warnx("unknown LUN removal status: %d", req.status); retval = 1; goto bailout; } - printf("LUN %d deleted successfully\n", lun_id); + printf("LUN %d removed successfully\n", lun_id); bailout: return (retval); @@ -3397,14 +3405,18 @@ cctl_modify_lun(int fd, int argc, char **argv, char *combinedopt) goto bailout; } - if (req.status == CTL_LUN_ERROR) { - warnx("%s: error returned from LUN modification request:\n%s", - __func__, req.error_str); + switch (req.status) { + case CTL_LUN_ERROR: + warnx("LUN modification error: %s", req.error_str); retval = 1; goto bailout; - } else if (req.status != CTL_LUN_OK) { - warnx("%s: unknown LUN modification request status %d", - __func__, req.status); + case CTL_LUN_WARNING: + warnx("LUN modification warning: %s", req.error_str); + break; + case CTL_LUN_OK: + break; + default: + warnx("unknown LUN modification status: %d", req.status); retval = 1; goto bailout; } diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c index c942685ef8e..030ca1ef810 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.c @@ -700,20 +700,22 @@ kernel_lun_add(struct lun *lun) return (1); } - if (req.status == CTL_LUN_ERROR) { - log_warnx("error returned from LUN creation request: %s", - req.error_str); + switch (req.status) { + case CTL_LUN_ERROR: + log_warnx("LUN creation error: %s", req.error_str); return (1); - } - - if (req.status != CTL_LUN_OK) { - log_warnx("unknown LUN creation request status %d", + case CTL_LUN_WARNING: + log_warnx("LUN creation warning: %s", req.error_str); + break; + case CTL_LUN_OK: + break; + default: + log_warnx("unknown LUN creation status: %d", req.status); return (1); } lun_set_ctl_lun(lun, req.reqdata.create.req_lun_id); - return (0); } @@ -735,14 +737,17 @@ kernel_lun_resize(struct lun *lun) return (1); } - if (req.status == CTL_LUN_ERROR) { - log_warnx("error returned from LUN modification request: %s", - req.error_str); + switch (req.status) { + case CTL_LUN_ERROR: + log_warnx("LUN modification error: %s", req.error_str); return (1); - } - - if (req.status != CTL_LUN_OK) { - log_warnx("unknown LUN modification request status %d", + case CTL_LUN_WARNING: + log_warnx("LUN modification warning: %s", req.error_str); + break; + case CTL_LUN_OK: + break; + default: + log_warnx("unknown LUN modification status: %d", req.status); return (1); } @@ -767,14 +772,17 @@ kernel_lun_remove(struct lun *lun) return (1); } - if (req.status == CTL_LUN_ERROR) { - log_warnx("error returned from LUN removal request: %s", - req.error_str); + switch (req.status) { + case CTL_LUN_ERROR: + log_warnx("LUN removal error: %s", req.error_str); return (1); - } - - if (req.status != CTL_LUN_OK) { - log_warnx("unknown LUN removal request status %d", req.status); + case CTL_LUN_WARNING: + log_warnx("LUN removal warning: %s", req.error_str); + break; + case CTL_LUN_OK: + break; + default: + log_warnx("unknown LUN removal status: %d", req.status); return (1); } From 3fd16a3a724bda084023f5f4d428c0777a28bd08 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Fri, 10 Oct 2014 20:37:06 +0000 Subject: [PATCH 024/112] Remove redundant if_notifier declaration. --- sys/netpfil/ipfw/ip_fw_table_algo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/netpfil/ipfw/ip_fw_table_algo.c b/sys/netpfil/ipfw/ip_fw_table_algo.c index f5cfd2571aa..ec2d472fea6 100644 --- a/sys/netpfil/ipfw/ip_fw_table_algo.c +++ b/sys/netpfil/ipfw/ip_fw_table_algo.c @@ -1932,7 +1932,6 @@ struct ta_buf_ifidx }; int compare_ifidx(const void *k, const void *v); -static void if_notifier(struct ip_fw_chain *ch, void *cbdata, uint16_t ifindex); static struct ifidx * ifidx_find(struct table_info *ti, void *key); static int ta_lookup_ifidx(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val); From 1068aa420151ff338c189bfe6f3ed858b937495d Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 21:19:17 +0000 Subject: [PATCH 025/112] Skip over t_spawn_open_nonexistent_diag because it requires NetBSD specific additions to posix_spawn Sponsored by: EMC / Isilon Storage Division --- .../netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c index 1cf643365c3..e9982495694 100644 --- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c +++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c @@ -31,6 +31,9 @@ */ +#if defined(__FreeBSD__) +#include +#endif #include #include #include @@ -248,6 +251,7 @@ ATF_TC_BODY(t_spawn_open_nonexistent, tc) posix_spawn_file_actions_destroy(&fa); } +#if defined(__NetBSD__) ATF_TC(t_spawn_open_nonexistent_diag); ATF_TC_HEAD(t_spawn_open_nonexistent_diag, tc) @@ -283,6 +287,7 @@ ATF_TC_BODY(t_spawn_open_nonexistent_diag, tc) posix_spawn_file_actions_destroy(&fa); posix_spawnattr_destroy(&attr); } +#endif ATF_TC(t_spawn_fileactions); @@ -376,7 +381,9 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_spawn_fileactions); ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent); +#if defined(__NetBSD__) ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent_diag); +#endif ATF_TP_ADD_TC(tp, t_spawn_reopen); ATF_TP_ADD_TC(tp, t_spawn_openmode); ATF_TP_ADD_TC(tp, t_spawn_empty_fileactions); From 8b8647bf30cad3e0a0ddcc61f747220d30f99cfd Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 21:22:25 +0000 Subject: [PATCH 026/112] Port the testcase to FreeBSD - Make #include path to h_macros.h a non-relative path - __gl_stat_t is synonymous with struct stat on FreeBSD - FreeBSD doesn't have _DIRENT_RECLEN - Skip over glob_star on FreeBSD (testcase doesn't pass) In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_glob.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_glob.c b/contrib/netbsd-tests/lib/libc/gen/t_glob.c index ff62b638e12..1611bfa0264 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_glob.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_glob.c @@ -46,7 +46,13 @@ __RCSID("$NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $"); #include #include +#if defined(__FreeBSD__) +#include "h_macros.h" +#define __gl_stat_t struct stat +#define _S_IFDIR S_IFDIR +#else #include "../../../h_macros.h" +#endif #ifdef DEBUG @@ -132,7 +138,11 @@ gl_readdir(void *v) dir.d_ino = dd->pos; dir.d_type = f->dir ? DT_DIR : DT_REG; DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type)); +#if defined(__FreeBSD__) + dir.d_reclen = -1; /* Does not have _DIRENT_RECLEN */ +#else dir.d_reclen = _DIRENT_RECLEN(&dir, dir.d_namlen); +#endif return &dir; } return NULL; @@ -213,6 +223,7 @@ run(const char *p, int flags, const char **res, size_t len) } +#if !defined(__FreeBSD__) ATF_TC(glob_star); ATF_TC_HEAD(glob_star, tc) { @@ -224,6 +235,7 @@ ATF_TC_BODY(glob_star, tc) { run("a/**", GLOB_STAR, glob_star, __arraycount(glob_star)); } +#endif ATF_TC(glob_star_not); ATF_TC_HEAD(glob_star_not, tc) @@ -260,7 +272,9 @@ ATF_TC_BODY(glob_nocheck, tc) ATF_TP_ADD_TCS(tp) { +#if !defined(__FreeBSD__) ATF_TP_ADD_TC(tp, glob_star); +#endif ATF_TP_ADD_TC(tp, glob_star_not); /* * Remove this test for now - the GLOB_NOCHECK return value has been From c57b274d49a62ed6d346c6d43d9ee5d6cc66aded Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 10 Oct 2014 22:18:09 +0000 Subject: [PATCH 027/112] Add LDFLAGS to PROG_VARS so it can be overridden on a per-PROG basis MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- share/mk/bsd.progs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk index 5ca1e458026..7a7c08620cb 100644 --- a/share/mk/bsd.progs.mk +++ b/share/mk/bsd.progs.mk @@ -43,7 +43,7 @@ PROG ?= $t .if defined(PROG) # just one of many PROG_OVERRIDE_VARS += BINDIR MAN SRCS -PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD ${PROG_OVERRIDE_VARS} +PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LDFLAGS ${PROG_OVERRIDE_VARS} .for v in ${PROG_VARS:O:u} .if empty(${PROG_OVERRIDE_VARS:M$v}) .if defined(${v}.${PROG}) From 90a5222f14e0c4939ca42f96eb046c0827ab53e2 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sat, 11 Oct 2014 02:02:58 +0000 Subject: [PATCH 028/112] Turn WITNESS_COUNT into a tunable and sysctl. This allows adjusting the value without recompiling the kernel. This is useful when recompiling is not possible as an immediate solution. When we run out of witness objects, witness is completely disabled. Not having an immediate solution can therefore be problematic. Submitted by: Sreekanth Rupavatharam Obtained from: Juniper Networks, Inc. --- sys/kern/subr_witness.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 309f2e23ce6..93961cc0385 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -135,7 +135,6 @@ __FBSDID("$FreeBSD$"); #ifndef WITNESS_COUNT #define WITNESS_COUNT 1536 #endif -#define WITNESS_CHILDCOUNT (WITNESS_COUNT * 4) #define WITNESS_HASH_SIZE 251 /* Prime, gives load factor < 2 */ #define WITNESS_PENDLIST (1024 + MAXCPU) @@ -155,7 +154,6 @@ __FBSDID("$FreeBSD$"); #define MAX_W_NAME 64 -#define BADSTACK_SBUF_SIZE (256 * WITNESS_COUNT) #define FULLGRAPH_SBUF_SIZE 512 /* @@ -184,7 +182,7 @@ __FBSDID("$FreeBSD$"); #define WITNESS_ATOD(x) (((x) & WITNESS_RELATED_MASK) << 2) #define WITNESS_INDEX_ASSERT(i) \ - MPASS((i) > 0 && (i) <= w_max_used_index && (i) < WITNESS_COUNT) + MPASS((i) > 0 && (i) <= w_max_used_index && (i) < witness_count) static MALLOC_DEFINE(M_WITNESS, "Witness", "Witness"); @@ -416,6 +414,13 @@ int witness_skipspin = 0; #endif SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, 0, ""); +/* tunable for Witness count */ +int witness_count = WITNESS_COUNT; +int badstack_sbuf_size = WITNESS_COUNT * 256; + +SYSCTL_INT(_debug_witness, OID_AUTO, witness_count, CTLFLAG_RDTUN, + &witness_count, 0, ""); + /* * Call this to print out the relations between locks. */ @@ -450,7 +455,7 @@ SYSCTL_INT(_debug_witness, OID_AUTO, sleep_cnt, CTLFLAG_RD, &w_sleep_cnt, 0, ""); static struct witness *w_data; -static uint8_t w_rmatrix[WITNESS_COUNT+1][WITNESS_COUNT+1]; +static uint8_t **w_rmatrix; static struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT]; static struct witness_hash w_hash; /* The witness hash table. */ @@ -726,9 +731,18 @@ witness_initialize(void *dummy __unused) struct witness *w, *w1; int i; - w_data = malloc(sizeof (struct witness) * WITNESS_COUNT, M_WITNESS, + w_data = malloc(sizeof (struct witness) * witness_count, M_WITNESS, M_NOWAIT | M_ZERO); + w_rmatrix = malloc(sizeof(uint8_t *) * (witness_count+1), + M_WITNESS, M_NOWAIT | M_ZERO); + + for(i = 0; i < witness_count+1; i++) { + w_rmatrix[i] = malloc(sizeof(uint8_t) * (witness_count + 1), + M_WITNESS, M_NOWAIT | M_ZERO); + } + badstack_sbuf_size = witness_count * 256; + /* * We have to release Giant before initializing its witness * structure so that WITNESS doesn't get confused. @@ -739,7 +753,7 @@ witness_initialize(void *dummy __unused) CTR1(KTR_WITNESS, "%s: initializing witness", __func__); mtx_init(&w_mtx, "witness lock", NULL, MTX_SPIN | MTX_QUIET | MTX_NOWITNESS | MTX_NOPROFILE); - for (i = WITNESS_COUNT - 1; i >= 0; i--) { + for (i = witness_count - 1; i >= 0; i--) { w = &w_data[i]; memset(w, 0, sizeof(*w)); w_data[i].w_index = i; /* Witness index never changes. */ @@ -752,8 +766,10 @@ witness_initialize(void *dummy __unused) STAILQ_REMOVE_HEAD(&w_free, w_list); w_free_cnt--; - memset(w_rmatrix, 0, - (sizeof(**w_rmatrix) * (WITNESS_COUNT+1) * (WITNESS_COUNT+1))); + for(i = 0; i < witness_count; i++) { + memset(w_rmatrix[i], 0, sizeof(uint8_t) * + (witness_count + 1)); + } for (i = 0; i < LOCK_CHILDCOUNT; i++) witness_lock_list_free(&w_locklistdata[i]); @@ -1196,7 +1212,7 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file, for (j = 0, lle = lock_list; lle != NULL; lle = lle->ll_next) { for (i = lle->ll_count - 1; i >= 0; i--, j++) { - MPASS(j < WITNESS_COUNT); + MPASS(j < witness_count); lock1 = &lle->ll_children[i]; /* @@ -2057,7 +2073,7 @@ witness_get(void) w_free_cnt--; index = w->w_index; MPASS(index > 0 && index == w_max_used_index+1 && - index < WITNESS_COUNT); + index < witness_count); bzero(w, sizeof(*w)); w->w_index = index; if (index > w_max_used_index) @@ -2482,7 +2498,7 @@ sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS) return (error); } error = 0; - sb = sbuf_new(NULL, NULL, BADSTACK_SBUF_SIZE, SBUF_AUTOEXTEND); + sb = sbuf_new(NULL, NULL, badstack_sbuf_size, SBUF_AUTOEXTEND); if (sb == NULL) return (ENOMEM); From 3e4adf76c4aa146c723a291e69f05c3b0a3caaa7 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Sat, 11 Oct 2014 05:11:23 +0000 Subject: [PATCH 029/112] Add assertion to catch duplicated notes. Sponsored by: The FreeBSD Foundation --- sys/fs/autofs/autofs_vnops.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/fs/autofs/autofs_vnops.c b/sys/fs/autofs/autofs_vnops.c index a3ae3a989ce..550c5146beb 100644 --- a/sys/fs/autofs/autofs_vnops.c +++ b/sys/fs/autofs/autofs_vnops.c @@ -504,9 +504,13 @@ autofs_node_new(struct autofs_node *parent, struct autofs_mount *amp, { struct autofs_node *anp; - if (parent != NULL) + if (parent != NULL) { AUTOFS_ASSERT_XLOCKED(parent->an_mount); + KASSERT(autofs_node_find(parent, name, namelen, NULL) == ENOENT, + ("node \"%s\" already exists", name)); + } + anp = uma_zalloc(autofs_node_zone, M_WAITOK | M_ZERO); if (namelen >= 0) anp->an_name = strndup(name, namelen, M_AUTOFS); From d32789d95cfbfa4e78b99602677e504231a7a495 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Sat, 11 Oct 2014 05:18:22 +0000 Subject: [PATCH 030/112] Mark iscontrol(8) and iscsi_initiator(4) obsolete. Differential Revision: https://reviews.freebsd.org/D931 Reviewed by: wblock@ MFC after: 3 days Sponsored by: The FreeBSD Foundation --- sbin/iscontrol/iscontrol.8 | 11 ++++++++++- share/man/man4/iscsi_initiator.4 | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sbin/iscontrol/iscontrol.8 b/sbin/iscontrol/iscontrol.8 index 860b35ab625..eee877653a1 100644 --- a/sbin/iscontrol/iscontrol.8 +++ b/sbin/iscontrol/iscontrol.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 9, 2010 +.Dd October 9, 2014 .Dt ISCONTROL 8 .Os .Sh NAME @@ -41,6 +41,15 @@ .Op Fl t Ar target .Op Ar variable Ns = Ns Ar value .Sh DESCRIPTION +.Bf -symbolic +This command, along with its kernel counterpart +.Xr iscsi_initiator 4 , +is obsolete. +Users are advised to use +.Xr iscsictl 8 +instead. +.Ef +.Pp Internet SCSI (iSCSI) is a network protocol standard, that allows the use of the SCSI protocol over TCP/IP networks, the diff --git a/share/man/man4/iscsi_initiator.4 b/share/man/man4/iscsi_initiator.4 index d48a7572f06..f710a64eae3 100644 --- a/share/man/man4/iscsi_initiator.4 +++ b/share/man/man4/iscsi_initiator.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 3, 2010 +.Dd October 9, 2014 .Dt ISCSI_INITIATOR 4 .Os .Sh NAME @@ -45,6 +45,16 @@ module at boot time, place the following line in iscsi_initiator_load="YES" .Ed .Sh DESCRIPTION +.Bf -symbolic +This driver, along with its userspace counterpart +.Xr iscontrol 8 , +is obsolete. +Users are advised to use +.Xr iscsi 4 +instead. +.Ef +.Pp + The .Nm implements the kernel side of the Internet SCSI (iSCSI) network From dc5362fde923f61500cd0073ed985c68aa86d89f Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 11 Oct 2014 07:49:27 +0000 Subject: [PATCH 031/112] Mark CTL frontend's CAM driver as CAM_PERIPH_DRV_EARLY. Target mode operation does not depend on the initiator mode scan process. This change allows the target driver to attach earlier and receive some async events (like AC_CONTRACT) that could be lost otherwise. MFC after: 1 week --- sys/cam/ctl/scsi_ctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index 9347ed13729..fee5f4ccbc2 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -224,7 +224,8 @@ static void ctlfe_dump(void); static struct periph_driver ctlfe_driver = { ctlfeperiphinit, "ctl", - TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0 + TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0, + CAM_PERIPH_DRV_EARLY }; static struct ctl_frontend ctlfe_frontend = From 829485ba7e664de826966dbd2b411a240311fa06 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 11 Oct 2014 07:59:15 +0000 Subject: [PATCH 032/112] Update isp_tgt_map and send new arrival notification if target that departed earlier has returned. Previously that code worked only once, confusing CTL. MFC after: 1 month --- sys/dev/isp/isp_library.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/isp/isp_library.c b/sys/dev/isp/isp_library.c index 9d7cfe25d68..0dd72a5ecda 100644 --- a/sys/dev/isp/isp_library.c +++ b/sys/dev/isp/isp_library.c @@ -2540,6 +2540,10 @@ isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3 isp_prt(isp, ISP_LOGWARN, "Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x reentered", chan, (unsigned long long) lp->port_wwn, lp->handle, lp->portid); } + if (fcp->isp_tgt_map[nphdl] == 0) { + fcp->isp_tgt_map[nphdl] = i + 1; + goto notify; + } return; } @@ -2573,6 +2577,7 @@ isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3 isp_prt(isp, ISP_LOGTINFO, "Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x vtgt %d %s added", chan, (unsigned long long) ini, nphdl, s_id, fcp->isp_tgt_map[nphdl] - 1, buf); +notify: ISP_MEMZERO(&nt, sizeof (nt)); nt.nt_hba = isp; nt.nt_wwn = ini; From bb829be5085b1a3ae5770c59022d8f9b4ff8cb2c Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 11 Oct 2014 08:50:19 +0000 Subject: [PATCH 033/112] Fix r272936 build with old GCC. MFC after: 1 week --- sys/dev/isp/isp_library.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/isp/isp_library.c b/sys/dev/isp/isp_library.c index 0dd72a5ecda..b6d59451554 100644 --- a/sys/dev/isp/isp_library.c +++ b/sys/dev/isp/isp_library.c @@ -2472,7 +2472,8 @@ isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint3 lp = NULL; if (fcp->isp_tgt_map[nphdl]) { - lp = &fcp->portdb[fcp->isp_tgt_map[nphdl] - 1]; + i = fcp->isp_tgt_map[nphdl] - 1; + lp = &fcp->portdb[i]; } else { /* * Make sure the addition of a new target mode entry doesn't duplicate entries From 7d9cb4d9ab4ad1dac9e3719842c00ff27c9cf760 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 11 Oct 2014 10:19:37 +0000 Subject: [PATCH 034/112] Filter out duplicate AC_PATH_REGISTERED async events. Queued async events handling in CAM opened race, that may lead to duplicate AC_PATH_REGISTERED events delivery during boot. That was not happening before r272935 because the driver was initialized later. After that change it started create duplicate ports in CTL. --- sys/cam/ctl/scsi_ctl.c | 84 ++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 45 deletions(-) diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index fee5f4ccbc2..1dac651321a 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -271,11 +271,19 @@ ctlfeperiphinit(void) static void ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) { + struct ctlfe_softc *softc; #ifdef CTLFEDEBUG printf("%s: entered\n", __func__); #endif + mtx_lock(&ctlfe_list_mtx); + STAILQ_FOREACH(softc, &ctlfe_softc_list, links) { + if (softc->path_id == xpt_path_path_id(path)) + break; + } + mtx_unlock(&ctlfe_list_mtx); + /* * When a new path gets registered, and it is capable of target * mode, go ahead and attach. Later on, we may need to be more @@ -284,7 +292,6 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) switch (code) { case AC_PATH_REGISTERED: { struct ctl_port *port; - struct ctlfe_softc *bus_softc; struct ccb_pathinq *cpi; int retval; @@ -299,6 +306,14 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) break; } + if (softc != NULL) { +#ifdef CTLFEDEBUG + printf("%s: CTL port for CAM path %u already exists\n", + __func__, xpt_path_path_id(path)); +#endif + break; + } + #ifdef CTLFE_INIT_ENABLE if (ctlfe_num_targets >= ctlfe_max_targets) { union ccb *ccb; @@ -347,25 +362,23 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) * use M_NOWAIT. Of course this means trouble if we * can't allocate memory. */ - bus_softc = malloc(sizeof(*bus_softc), M_CTLFE, - M_NOWAIT | M_ZERO); - if (bus_softc == NULL) { + softc = malloc(sizeof(*softc), M_CTLFE, M_NOWAIT | M_ZERO); + if (softc == NULL) { printf("%s: unable to malloc %zd bytes for softc\n", - __func__, sizeof(*bus_softc)); + __func__, sizeof(*softc)); return; } - bus_softc->path_id = cpi->ccb_h.path_id; - bus_softc->sim = xpt_path_sim(path); + softc->path_id = cpi->ccb_h.path_id; + softc->sim = xpt_path_sim(path); if (cpi->maxio != 0) - bus_softc->maxio = cpi->maxio; + softc->maxio = cpi->maxio; else - bus_softc->maxio = DFLTPHYS; - mtx_init(&bus_softc->lun_softc_mtx, "LUN softc mtx", NULL, - MTX_DEF); - STAILQ_INIT(&bus_softc->lun_softc_list); + softc->maxio = DFLTPHYS; + mtx_init(&softc->lun_softc_mtx, "LUN softc mtx", NULL, MTX_DEF); + STAILQ_INIT(&softc->lun_softc_list); - port = &bus_softc->port; + port = &softc->port; port->frontend = &ctlfe_frontend; /* @@ -380,21 +393,21 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) /* XXX KDM what should the real number be here? */ port->num_requested_ctl_io = 4096; - snprintf(bus_softc->port_name, sizeof(bus_softc->port_name), + snprintf(softc->port_name, sizeof(softc->port_name), "%s%d", cpi->dev_name, cpi->unit_number); /* * XXX KDM it would be nice to allocate storage in the * frontend structure itself. */ - port->port_name = bus_softc->port_name; + port->port_name = softc->port_name; port->physical_port = cpi->unit_number; port->virtual_port = cpi->bus_id; port->port_online = ctlfe_online; port->port_offline = ctlfe_offline; - port->onoff_arg = bus_softc; + port->onoff_arg = softc; port->lun_enable = ctlfe_lun_enable; port->lun_disable = ctlfe_lun_disable; - port->targ_lun_arg = bus_softc; + port->targ_lun_arg = softc; port->fe_datamove = ctlfe_datamove_done; port->fe_done = ctlfe_datamove_done; /* @@ -416,35 +429,28 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) if (retval != 0) { printf("%s: ctl_port_register() failed with " "error %d!\n", __func__, retval); - mtx_destroy(&bus_softc->lun_softc_mtx); - free(bus_softc, M_CTLFE); + mtx_destroy(&softc->lun_softc_mtx); + free(softc, M_CTLFE); break; } else { mtx_lock(&ctlfe_list_mtx); - STAILQ_INSERT_TAIL(&ctlfe_softc_list, bus_softc, links); + STAILQ_INSERT_TAIL(&ctlfe_softc_list, softc, links); mtx_unlock(&ctlfe_list_mtx); } break; } case AC_PATH_DEREGISTERED: { - struct ctlfe_softc *softc = NULL; - - mtx_lock(&ctlfe_list_mtx); - STAILQ_FOREACH(softc, &ctlfe_softc_list, links) { - if (softc->path_id == xpt_path_path_id(path)) { - STAILQ_REMOVE(&ctlfe_softc_list, softc, - ctlfe_softc, links); - break; - } - } - mtx_unlock(&ctlfe_list_mtx); if (softc != NULL) { /* * XXX KDM are we certain at this point that there * are no outstanding commands for this frontend? */ + mtx_lock(&ctlfe_list_mtx); + STAILQ_REMOVE(&ctlfe_softc_list, softc, ctlfe_softc, + links); + mtx_unlock(&ctlfe_list_mtx); ctl_port_deregister(&softc->port); mtx_destroy(&softc->lun_softc_mtx); free(softc, M_CTLFE); @@ -459,8 +465,7 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) switch (ac->contract_number) { case AC_CONTRACT_DEV_CHG: { struct ac_device_changed *dev_chg; - struct ctlfe_softc *softc; - int retval, found; + int retval; dev_chg = (struct ac_device_changed *)ac->contract_data; @@ -469,18 +474,7 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) xpt_path_path_id(path), dev_chg->target, (dev_chg->arrived == 0) ? "left" : "arrived"); - found = 0; - - mtx_lock(&ctlfe_list_mtx); - STAILQ_FOREACH(softc, &ctlfe_softc_list, links) { - if (softc->path_id == xpt_path_path_id(path)) { - found = 1; - break; - } - } - mtx_unlock(&ctlfe_list_mtx); - - if (found == 0) { + if (softc == NULL) { printf("%s: CTL port for CAM path %u not " "found!\n", __func__, xpt_path_path_id(path)); From 5c8dcc113149db446c38a70782c3a3604cfcec4c Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 11 Oct 2014 12:56:49 +0000 Subject: [PATCH 035/112] Shorten frontend name. --- sys/cam/ctl/scsi_ctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index 1dac651321a..6059494a1f4 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -230,7 +230,7 @@ static struct periph_driver ctlfe_driver = static struct ctl_frontend ctlfe_frontend = { - .name = "camtarget", + .name = "camtgt", .init = ctlfeinitialize, .fe_dump = ctlfe_dump, .shutdown = ctlfeshutdown, From 956f6d3a3c3cb20cf6c03e72130ebe438f1f5353 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 11 Oct 2014 15:04:50 +0000 Subject: [PATCH 036/112] Fix KASSERT typo. --- sys/netpfil/ipfw/ip_fw_table_value.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw_table_value.c b/sys/netpfil/ipfw/ip_fw_table_value.c index 1e780a4df76..9d68901b3e4 100644 --- a/sys/netpfil/ipfw/ip_fw_table_value.c +++ b/sys/netpfil/ipfw/ip_fw_table_value.c @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c 270407 2014-08-23 12:41:39Z melifaro $"); +__FBSDID("$FreeBSD$"); /* * Multi-field value support for ipfw tables. @@ -557,7 +557,7 @@ ipfw_link_table_values(struct ip_fw_chain *ch, struct tableop_state *ts) return (0); } - KASSERT(pval == ch->tablestate, ("resize_storage() notify failure")); + KASSERT(pval == ch->valuestate, ("resize_storage() notify failure")); /* Let's try to link values */ for (i = 0; i < count; i++) { From 585a4290ab47e74f26e854a87a86c9c29db8388c Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sat, 11 Oct 2014 16:08:54 +0000 Subject: [PATCH 037/112] Update ip_divert.ko to depend on version 3 of ipfw. --- sys/netinet/ip_divert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 97fb191af5f..3e3bc942df9 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -836,5 +836,5 @@ static moduledata_t ipdivertmod = { }; DECLARE_MODULE(ipdivert, ipdivertmod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); -MODULE_DEPEND(ipdivert, ipfw, 2, 2, 2); +MODULE_DEPEND(ipdivert, ipfw, 3, 3, 3); MODULE_VERSION(ipdivert, 1); From 36f6ca401253908eefb743922f47d8e5b86b39e7 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 11 Oct 2014 16:17:49 +0000 Subject: [PATCH 038/112] MFi386 r272761. Noted by: Holger Hans Peter Freyther Sponsored by: The FreeBSD Foundation MFC after: 10 days --- sys/i386/xen/pmap.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index 2f7f027d8e0..1dc50b2a0a1 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -888,15 +888,19 @@ pmap_invalidate_cache(void) #define PMAP_CLFLUSH_THRESHOLD (2 * 1024 * 1024) void -pmap_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva) +pmap_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva, boolean_t force) { - KASSERT((sva & PAGE_MASK) == 0, - ("pmap_invalidate_cache_range: sva not page-aligned")); - KASSERT((eva & PAGE_MASK) == 0, - ("pmap_invalidate_cache_range: eva not page-aligned")); + if (force) { + sva &= ~(vm_offset_t)cpu_clflush_line_size; + } else { + KASSERT((sva & PAGE_MASK) == 0, + ("pmap_invalidate_cache_range: sva not page-aligned")); + KASSERT((eva & PAGE_MASK) == 0, + ("pmap_invalidate_cache_range: eva not page-aligned")); + } - if (cpu_feature & CPUID_SS) + if ((cpu_feature & CPUID_SS) != 0 && !force) ; /* If "Self Snoop" is supported, do nothing. */ else if ((cpu_feature & CPUID_CLFSH) != 0 && eva - sva < PMAP_CLFLUSH_THRESHOLD) { @@ -4073,7 +4077,7 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, int mode) for (tmpsize = 0; tmpsize < size; tmpsize += PAGE_SIZE) pmap_kenter_attr(va + tmpsize, pa + tmpsize, mode); pmap_invalidate_range(kernel_pmap, va, va + tmpsize); - pmap_invalidate_cache_range(va, va + size); + pmap_invalidate_cache_range(va, va + size, FALSE); return ((void *)(va + offset)); } @@ -4241,7 +4245,7 @@ pmap_change_attr(vm_offset_t va, vm_size_t size, int mode) */ if (changed) { pmap_invalidate_range(kernel_pmap, base, tmpva); - pmap_invalidate_cache_range(base, tmpva); + pmap_invalidate_cache_range(base, tmpva, FALSE); } return (0); } From ddbe5b951f5dd29a3c8c373f5a1dbc538421c17a Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sat, 11 Oct 2014 16:34:01 +0000 Subject: [PATCH 039/112] Fix nits in previous commit: 1. Remove initializer for badstack_sbuf_size; it gets set unconditionally. 2. Remove meaningless comment. 3. Group witness_count and its sysctl together. 4. Fix spacing in for statements (space after for and within condition). 5. Change *all* M_NOWAIT usages in witness_initialize() to M_WAITOK; not just those that were newly introduced -- the allocation is assumed to succeed for all allocations. 6. Avoid using uint8_t as the base type in sizeof() expressions; Use the variable name (w_rmatrix) as much as possible. Pointed out by: jhb@ (thanks!) --- sys/kern/subr_witness.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 93961cc0385..1bbb3dc0d5e 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -414,10 +414,9 @@ int witness_skipspin = 0; #endif SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, 0, ""); -/* tunable for Witness count */ -int witness_count = WITNESS_COUNT; -int badstack_sbuf_size = WITNESS_COUNT * 256; +int badstack_sbuf_size; +int witness_count = WITNESS_COUNT; SYSCTL_INT(_debug_witness, OID_AUTO, witness_count, CTLFLAG_RDTUN, &witness_count, 0, ""); @@ -732,17 +731,17 @@ witness_initialize(void *dummy __unused) int i; w_data = malloc(sizeof (struct witness) * witness_count, M_WITNESS, - M_NOWAIT | M_ZERO); + M_WAITOK | M_ZERO); - w_rmatrix = malloc(sizeof(uint8_t *) * (witness_count+1), - M_WITNESS, M_NOWAIT | M_ZERO); + w_rmatrix = malloc(sizeof(*w_rmatrix) * (witness_count + 1), + M_WITNESS, M_WAITOK | M_ZERO); - for(i = 0; i < witness_count+1; i++) { - w_rmatrix[i] = malloc(sizeof(uint8_t) * (witness_count + 1), - M_WITNESS, M_NOWAIT | M_ZERO); + for (i = 0; i < witness_count + 1; i++) { + w_rmatrix[i] = malloc(sizeof(*w_rmatrix[i]) * + (witness_count + 1), M_WITNESS, M_WAITOK | M_ZERO); } badstack_sbuf_size = witness_count * 256; - + /* * We have to release Giant before initializing its witness * structure so that WITNESS doesn't get confused. @@ -766,8 +765,8 @@ witness_initialize(void *dummy __unused) STAILQ_REMOVE_HEAD(&w_free, w_list); w_free_cnt--; - for(i = 0; i < witness_count; i++) { - memset(w_rmatrix[i], 0, sizeof(uint8_t) * + for (i = 0; i < witness_count; i++) { + memset(w_rmatrix[i], 0, sizeof(*w_rmatrix[i]) * (witness_count + 1)); } From 9045dbb21cac70de5dae858c743f47258679d575 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 11 Oct 2014 17:52:54 +0000 Subject: [PATCH 040/112] Give physical and virtual ports numbers some more meaning. --- sys/cam/ctl/ctl_frontend_iscsi.c | 8 ++++++-- sys/cam/ctl/ctl_frontend_iscsi.h | 2 ++ sys/cam/ctl/scsi_ctl.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 448cc731834..719e28ec8ec 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -1996,7 +1996,8 @@ cfiscsi_ioctl_port_create(struct ctl_req *req) /* XXX KDM what should the real number be here? */ port->num_requested_ctl_io = 4096; port->port_name = "iscsi"; - port->virtual_port = strtoul(tag, NULL, 0); + port->physical_port = strtoul(tag, NULL, 0); + port->virtual_port = ct->ct_target_id; port->port_online = cfiscsi_online; port->port_offline = cfiscsi_offline; port->port_info = cfiscsi_info; @@ -2029,7 +2030,7 @@ cfiscsi_ioctl_port_create(struct ctl_req *req) SVPD_ID_TYPE_SCSI_NAME; desc->length = idlen; snprintf(desc->identifier, idlen, "%s,t,0x%4.4x", - target, port->virtual_port); + target, port->physical_port); /* Generate Target ID. */ idlen = strlen(target) + 1; @@ -2257,6 +2258,9 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name, strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias)); refcount_init(&newct->ct_refcount, 1); newct->ct_softc = softc; + if (TAILQ_EMPTY(&softc->targets)) + softc->last_target_id = 0; + newct->ct_target_id = ++softc->last_target_id; TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next); mtx_unlock(&softc->lock); diff --git a/sys/cam/ctl/ctl_frontend_iscsi.h b/sys/cam/ctl/ctl_frontend_iscsi.h index af4de878c30..1efe24565b5 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.h +++ b/sys/cam/ctl/ctl_frontend_iscsi.h @@ -45,6 +45,7 @@ struct cfiscsi_target { char ct_alias[CTL_ISCSI_ALIAS_LEN]; int ct_state; int ct_online; + int ct_target_id; struct ctl_port ct_port; }; @@ -110,6 +111,7 @@ struct cfiscsi_softc { struct mtx lock; char port_name[32]; int online; + int last_target_id; unsigned int last_session_id; TAILQ_HEAD(, cfiscsi_target) targets; TAILQ_HEAD(, cfiscsi_session) sessions; diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index 6059494a1f4..b8b93091a10 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -400,8 +400,8 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) * frontend structure itself. */ port->port_name = softc->port_name; - port->physical_port = cpi->unit_number; - port->virtual_port = cpi->bus_id; + port->physical_port = cpi->bus_id; + port->virtual_port = 0; port->port_online = ctlfe_online; port->port_offline = ctlfe_offline; port->onoff_arg = softc; From b1f8be4004a6ef2b2011b3d8f71a06b6a49773f7 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sat, 11 Oct 2014 18:34:10 +0000 Subject: [PATCH 041/112] tcpd: complete function prototypes. This clears up at least a build issues on mysql-server ports. While here also replace some spaces with tabs in our headers. PR: 42336 MFC after: 2 weeks --- contrib/tcp_wrappers/inetcf.h | 6 +-- contrib/tcp_wrappers/mystdarg.h | 12 ++--- contrib/tcp_wrappers/tcpd.h | 74 +++++++++++++++--------------- contrib/tcp_wrappers/tli-sequent.h | 4 +- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/contrib/tcp_wrappers/inetcf.h b/contrib/tcp_wrappers/inetcf.h index 0f1d77cb3d7..d430d069203 100644 --- a/contrib/tcp_wrappers/inetcf.h +++ b/contrib/tcp_wrappers/inetcf.h @@ -8,7 +8,7 @@ extern char *inet_cfg(); /* read inetd.conf file */ extern void inet_set(); /* remember internet service */ extern int inet_get(); /* look up internet service */ -#define WR_UNKNOWN (-1) /* service unknown */ -#define WR_NOT 1 /* may not be wrapped */ -#define WR_MAYBE 2 /* may be wrapped */ +#define WR_UNKNOWN (-1) /* service unknown */ +#define WR_NOT 1 /* may not be wrapped */ +#define WR_MAYBE 2 /* may be wrapped */ #define WR_YES 3 /* service is wrapped */ diff --git a/contrib/tcp_wrappers/mystdarg.h b/contrib/tcp_wrappers/mystdarg.h index 36bdf696f1a..1ccbbdc7957 100644 --- a/contrib/tcp_wrappers/mystdarg.h +++ b/contrib/tcp_wrappers/mystdarg.h @@ -6,14 +6,14 @@ #ifdef __STDC__ #include -#define VARARGS(func,type,arg) func(type arg, ...) -#define VASTART(ap,type,name) va_start(ap,name) -#define VAEND(ap) va_end(ap) +#define VARARGS(func,type,arg) func(type arg, ...) +#define VASTART(ap,type,name) va_start(ap,name) +#define VAEND(ap) va_end(ap) #else #include -#define VARARGS(func,type,arg) func(va_alist) va_dcl -#define VASTART(ap,type,name) {type name; va_start(ap); name = va_arg(ap, type) -#define VAEND(ap) va_end(ap);} +#define VARARGS(func,type,arg) func(va_alist) va_dcl +#define VASTART(ap,type,name) {type name; va_start(ap); name = va_arg(ap, type) +#define VAEND(ap) va_end(ap);} #endif extern char *percent_m(); diff --git a/contrib/tcp_wrappers/tcpd.h b/contrib/tcp_wrappers/tcpd.h index fec20a262ba..07eaff824b0 100644 --- a/contrib/tcp_wrappers/tcpd.h +++ b/contrib/tcp_wrappers/tcpd.h @@ -8,7 +8,7 @@ /* Structure to describe one communications endpoint. */ -#define STRING_LENGTH 128 /* hosts, users, processes */ +#define STRING_LENGTH 128 /* hosts, users, processes */ struct host_info { char name[STRING_LENGTH]; /* access via eval_hostname(host) */ @@ -31,21 +31,21 @@ struct request_info { char pid[10]; /* access via eval_pid(request) */ struct host_info client[1]; /* client endpoint info */ struct host_info server[1]; /* server endpoint info */ - void (*sink) (); /* datagram sink function or 0 */ - void (*hostname) (); /* address to printable hostname */ - void (*hostaddr) (); /* address to printable address */ - void (*cleanup) (); /* cleanup function or 0 */ + void (*sink) (int); /* datagram sink function or 0 */ + void (*hostname) (struct host_info *); /* address to printable hostname */ + void (*hostaddr) (struct host_info *); /* address to printable address */ + void (*cleanup) (struct request_info *); /* cleanup function or 0 */ struct netconfig *config; /* netdir handle */ }; /* Common string operations. Less clutter should be more readable. */ -#define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; } +#define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; } -#define STRN_EQ(x,y,l) (strncasecmp((x),(y),(l)) == 0) -#define STRN_NE(x,y,l) (strncasecmp((x),(y),(l)) != 0) -#define STR_EQ(x,y) (strcasecmp((x),(y)) == 0) -#define STR_NE(x,y) (strcasecmp((x),(y)) != 0) +#define STRN_EQ(x,y,l) (strncasecmp((x),(y),(l)) == 0) +#define STRN_NE(x,y,l) (strncasecmp((x),(y),(l)) != 0) +#define STR_EQ(x,y) (strcasecmp((x),(y)) == 0) +#define STR_NE(x,y) (strcasecmp((x),(y)) != 0) /* * Initially, all above strings have the empty value. Information that @@ -54,22 +54,22 @@ struct request_info { * that we do not believe in is set to "paranoid". */ -#define STRING_UNKNOWN "unknown" /* lookup failed */ -#define STRING_PARANOID "paranoid" /* hostname conflict */ +#define STRING_UNKNOWN "unknown" /* lookup failed */ +#define STRING_PARANOID "paranoid" /* hostname conflict */ extern char unknown[]; extern char paranoid[]; -#define HOSTNAME_KNOWN(s) (STR_NE((s),unknown) && STR_NE((s),paranoid)) +#define HOSTNAME_KNOWN(s) (STR_NE((s),unknown) && STR_NE((s),paranoid)) -#define NOT_INADDR(s) (s[strspn(s,"01234567890./")] != 0) +#define NOT_INADDR(s) (s[strspn(s,"01234567890./")] != 0) /* Global functions. */ #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) extern void fromhost(); /* get/validate client host info */ #else -#define fromhost sock_host /* no TLI support needed */ +#define fromhost sock_host /* no TLI support needed */ #endif extern int hosts_access(); /* access control */ @@ -105,15 +105,15 @@ extern struct request_info *request_init(); /* initialize request */ extern struct request_info *request_set(); /* update request structure */ #endif -#define RQ_FILE 1 /* file descriptor */ -#define RQ_DAEMON 2 /* server process (argv[0]) */ -#define RQ_USER 3 /* client user name */ -#define RQ_CLIENT_NAME 4 /* client host name */ -#define RQ_CLIENT_ADDR 5 /* client host address */ -#define RQ_CLIENT_SIN 6 /* client endpoint (internal) */ -#define RQ_SERVER_NAME 7 /* server host name */ -#define RQ_SERVER_ADDR 8 /* server host address */ -#define RQ_SERVER_SIN 9 /* server endpoint (internal) */ +#define RQ_FILE 1 /* file descriptor */ +#define RQ_DAEMON 2 /* server process (argv[0]) */ +#define RQ_USER 3 /* client user name */ +#define RQ_CLIENT_NAME 4 /* client host name */ +#define RQ_CLIENT_ADDR 5 /* client host address */ +#define RQ_CLIENT_SIN 6 /* client endpoint (internal) */ +#define RQ_SERVER_NAME 7 /* server host name */ +#define RQ_SERVER_ADDR 8 /* server host address */ +#define RQ_SERVER_SIN 9 /* server endpoint (internal) */ /* * Routines for delayed evaluation of request attributes. Each attribute @@ -129,15 +129,15 @@ extern char *eval_hostaddr(); /* printable host address */ extern char *eval_hostinfo(); /* host name or address */ extern char *eval_client(); /* whatever is available */ extern char *eval_server(); /* whatever is available */ -#define eval_daemon(r) ((r)->daemon) /* daemon process name */ -#define eval_pid(r) ((r)->pid) /* process id */ +#define eval_daemon(r) ((r)->daemon) /* daemon process name */ +#define eval_pid(r) ((r)->pid) /* process id */ /* Socket-specific methods, including DNS hostname lookups. */ extern void sock_host(); /* look up endpoint addresses */ extern void sock_hostname(); /* translate address to hostname */ extern void sock_hostaddr(); /* address to printable address */ -#define sock_methods(r) \ +#define sock_methods(r) \ { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; } /* The System V Transport-Level Interface (TLI) interface. */ @@ -173,9 +173,9 @@ extern struct tcpd_context tcpd_context; * (-1) returns are here because zero is already taken by longjmp(). */ -#define AC_PERMIT 1 /* permit access */ -#define AC_DENY (-1) /* deny_access */ -#define AC_ERROR AC_DENY /* XXX */ +#define AC_PERMIT 1 /* permit access */ +#define AC_DENY (-1) /* deny_access */ +#define AC_ERROR AC_DENY /* XXX */ /* * In verification mode an option function should just say what it would do, @@ -190,36 +190,36 @@ extern int dry_run; /* verification flag */ /* Bug workarounds. */ #ifdef INET_ADDR_BUG /* inet_addr() returns struct */ -#define inet_addr fix_inet_addr +#define inet_addr fix_inet_addr extern long fix_inet_addr(); #endif #ifdef BROKEN_FGETS /* partial reads from sockets */ -#define fgets fix_fgets +#define fgets fix_fgets extern char *fix_fgets(); #endif #ifdef RECVFROM_BUG /* no address family info */ -#define recvfrom fix_recvfrom +#define recvfrom fix_recvfrom extern int fix_recvfrom(); #endif #ifdef GETPEERNAME_BUG /* claims success with UDP */ -#define getpeername fix_getpeername +#define getpeername fix_getpeername extern int fix_getpeername(); #endif #ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */ -#define gethostbyname fix_gethostbyname +#define gethostbyname fix_gethostbyname extern struct hostent *fix_gethostbyname(); #endif #ifdef USE_STRSEP /* libc calls strtok() */ -#define strtok fix_strtok +#define strtok fix_strtok extern char *fix_strtok(); #endif #ifdef LIBC_CALLS_STRTOK /* libc calls strtok() */ -#define strtok my_strtok +#define strtok my_strtok extern char *my_strtok(); #endif diff --git a/contrib/tcp_wrappers/tli-sequent.h b/contrib/tcp_wrappers/tli-sequent.h index 4474d3cdb6f..d6222efb0f2 100644 --- a/contrib/tcp_wrappers/tli-sequent.h +++ b/contrib/tcp_wrappers/tli-sequent.h @@ -1,7 +1,7 @@ #ifdef __STDC__ -#define __P(X) X +#define __P(X) X #else -#define __P(X) () +#define __P(X) () #endif extern int t_sync __P((int)); From eb4e1f805953fa9321c10ff73eb0fb2e2a8c184e Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sat, 11 Oct 2014 18:54:37 +0000 Subject: [PATCH 042/112] tcpd.h: add prototype for hosts_ctl According the hosts_access(3) man page the hosts_ctl() prototype should be in tcpd.h. For now, follow other declarations and don't add the arguments in the prototype. Reference: https://www.illumos.org/issues/4385 PR: 32808 MFC after: 2 weeks --- contrib/tcp_wrappers/tcpd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/tcp_wrappers/tcpd.h b/contrib/tcp_wrappers/tcpd.h index 07eaff824b0..af17c076ca3 100644 --- a/contrib/tcp_wrappers/tcpd.h +++ b/contrib/tcp_wrappers/tcpd.h @@ -73,6 +73,7 @@ extern void fromhost(); /* get/validate client host info */ #endif extern int hosts_access(); /* access control */ +extern int hosts_ctl(); /* wrapper around request_init() */ extern void shell_cmd(); /* execute shell command */ extern char *percent_x(); /* do % expansion */ extern void rfc931(); /* client name from RFC 931 daemon */ From 9dc641f2d30c58ed657cd11561d8f1d52321e576 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sat, 11 Oct 2014 18:58:58 +0000 Subject: [PATCH 043/112] Bump FreeBSD_version due to cleanup of tcp wrapper header. Due to revisions r272949 and r272950 which should affect positively some ports. --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index eabc134010d..e9d86858526 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100037 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100038 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From df5c9c04119c562db9cc259b6ea10570f841fc20 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 11 Oct 2014 19:09:56 +0000 Subject: [PATCH 044/112] Do not set IN_ACCESS flag for read-only mounts. The IN_ACCESS survives remount in rw, also it is set for vnodes on rootfs before noatime can be set or clock is adjusted. All conditions result in wrong atime for accessed vnodes. Submitted by: bde MFC after: 1 week --- sys/fs/ext2fs/ext2_vnops.c | 2 +- sys/fs/msdosfs/msdosfs_vnops.c | 2 +- sys/ufs/ffs/ffs_vnops.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 0972ec7400d..06173b1060e 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -1762,7 +1762,7 @@ ext2_ind_read(struct vop_read_args *ap) } if ((error == 0 || uio->uio_resid != orig_resid) && - (vp->v_mount->mnt_flag & MNT_NOATIME) == 0) + (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) ip->i_flag |= IN_ACCESS; return (error); } diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 622917f5563..a60fa1337bc 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -642,7 +642,7 @@ msdosfs_read(ap) brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); if (!isadir && (error == 0 || uio->uio_resid != orig_resid) && - (vp->v_mount->mnt_flag & MNT_NOATIME) == 0) + (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) dep->de_flag |= DE_ACCESS; return (error); } diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 0dd4d1691c0..84d25d17727 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -627,7 +627,7 @@ ffs_read(ap) } if ((error == 0 || uio->uio_resid != orig_resid) && - (vp->v_mount->mnt_flag & MNT_NOATIME) == 0 && + (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0 && (ip->i_flag & IN_ACCESS) == 0) { VI_LOCK(vp); ip->i_flag |= IN_ACCESS; From d0d8c133c7f1963a3543d5b7d50ae525c9ea03c8 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sat, 11 Oct 2014 19:36:59 +0000 Subject: [PATCH 045/112] Add locking and mark MPSAFE. - Add a mutex to protect the softc. - Use callout(9) instead of timeout(9). - Consolidate duplicated detach routines into a bus-independent detach routine. - Add an extra sleep lock flag (MSESC_READING) to prevent other readers from reading while the first reader is copying data out of sc_bytes[] via uiomove(). - Use bus_*() instead of bus_space_*(). Tested by: nyan --- sys/dev/mse/mse.c | 186 ++++++++++++++++++++++++++++------------- sys/dev/mse/mse_cbus.c | 87 +++++++------------ sys/dev/mse/mse_isa.c | 125 +++++++++++---------------- sys/dev/mse/msevar.h | 30 +++---- 4 files changed, 220 insertions(+), 208 deletions(-) diff --git a/sys/dev/mse/mse.c b/sys/dev/mse/mse.c index a4472989e44..0cf66868023 100644 --- a/sys/dev/mse/mse.c +++ b/sys/dev/mse/mse.c @@ -99,7 +99,6 @@ static d_poll_t msepoll; static struct cdevsw mse_cdevsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, .d_open = mseopen, .d_close = mseclose, .d_read = mseread, @@ -109,9 +108,10 @@ static struct cdevsw mse_cdevsw = { }; static void mseintr(void *); -static timeout_t msetimeout; +static void mseintr_locked(mse_softc_t *sc); +static void msetimeout(void *); -#define MSE_NBLOCKIO(dev) dev2unit(dev) +#define MSE_NBLOCKIO(dev) (dev2unit(dev) != 0) #define MSEPRI (PZERO + 3) @@ -123,32 +123,68 @@ mse_common_attach(device_t dev) sc = device_get_softc(dev); unit = device_get_unit(dev); + mtx_init(&sc->sc_lock, "mse", NULL, MTX_DEF); + callout_init_mtx(&sc->sc_callout, &sc->sc_lock, 0); rid = 0; sc->sc_intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->sc_intr == NULL) { bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); + mtx_destroy(&sc->sc_lock); return ENXIO; } - if (bus_setup_intr(dev, sc->sc_intr, - INTR_TYPE_TTY, NULL, mseintr, sc, &sc->sc_ih)) { + if (bus_setup_intr(dev, sc->sc_intr, INTR_TYPE_TTY | INTR_MPSAFE, + NULL, mseintr, sc, &sc->sc_ih)) { bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); bus_release_resource(dev, SYS_RES_IRQ, rid, sc->sc_intr); + mtx_destroy(&sc->sc_lock); return ENXIO; } flags = device_get_flags(dev); sc->mode.accelfactor = (flags & MSE_CONFIG_ACCEL) >> 4; - callout_handle_init(&sc->sc_callout); - sc->sc_dev = make_dev(&mse_cdevsw, 0, 0, 0, 0600, "mse%d", unit); + sc->sc_dev = make_dev(&mse_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, + "mse%d", unit); sc->sc_dev->si_drv1 = sc; - sc->sc_ndev = make_dev(&mse_cdevsw, 1, 0, 0, 0600, "nmse%d", unit); + sc->sc_ndev = make_dev(&mse_cdevsw, 1, UID_ROOT, GID_WHEEL, 0600, + "nmse%d", unit); sc->sc_ndev->si_drv1 = sc; return 0; } +int +mse_detach(device_t dev) +{ + mse_softc_t *sc; + int rid; + + sc = device_get_softc(dev); + MSE_LOCK(sc); + if (sc->sc_flags & MSESC_OPEN) { + MSE_UNLOCK(sc); + return EBUSY; + } + + /* Sabotage subsequent opens. */ + sc->sc_mousetype = MSE_NONE; + MSE_UNLOCK(sc); + + destroy_dev(sc->sc_dev); + destroy_dev(sc->sc_ndev); + + rid = 0; + bus_teardown_intr(dev, sc->sc_intr, sc->sc_ih); + bus_release_resource(dev, SYS_RES_IRQ, rid, sc->sc_intr); + bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); + + callout_drain(&sc->sc_callout); + mtx_destroy(&sc->sc_lock); + + return 0; +} + /* * Exclusive open the mouse, initialize it and enable interrupts. */ @@ -156,18 +192,22 @@ static int mseopen(struct cdev *dev, int flags, int fmt, struct thread *td) { mse_softc_t *sc = dev->si_drv1; - int s; - if (sc->sc_mousetype == MSE_NONE) + MSE_LOCK(sc); + if (sc->sc_mousetype == MSE_NONE) { + MSE_UNLOCK(sc); return (ENXIO); - if (sc->sc_flags & MSESC_OPEN) + } + if (sc->sc_flags & MSESC_OPEN) { + MSE_UNLOCK(sc); return (EBUSY); + } sc->sc_flags |= MSESC_OPEN; sc->sc_obuttons = sc->sc_buttons = MOUSE_MSC_BUTTONS; sc->sc_deltax = sc->sc_deltay = 0; sc->sc_bytesread = sc->mode.packetsize = MOUSE_MSC_PACKETSIZE; sc->sc_watchdog = FALSE; - sc->sc_callout = timeout(msetimeout, dev, hz*2); + callout_reset(&sc->sc_callout, hz * 2, msetimeout, dev); sc->mode.level = 0; sc->status.flags = 0; sc->status.button = sc->status.obutton = 0; @@ -176,9 +216,8 @@ mseopen(struct cdev *dev, int flags, int fmt, struct thread *td) /* * Initialize mouse interface and enable interrupts. */ - s = spltty(); - (*sc->sc_enablemouse)(sc->sc_iot, sc->sc_ioh); - splx(s); + (*sc->sc_enablemouse)(sc->sc_port); + MSE_UNLOCK(sc); return (0); } @@ -189,14 +228,12 @@ static int mseclose(struct cdev *dev, int flags, int fmt, struct thread *td) { mse_softc_t *sc = dev->si_drv1; - int s; - untimeout(msetimeout, dev, sc->sc_callout); - callout_handle_init(&sc->sc_callout); - s = spltty(); - (*sc->sc_disablemouse)(sc->sc_iot, sc->sc_ioh); + MSE_LOCK(sc); + callout_stop(&sc->sc_callout); + (*sc->sc_disablemouse)(sc->sc_port); sc->sc_flags &= ~MSESC_OPEN; - splx(s); + MSE_UNLOCK(sc); return(0); } @@ -209,27 +246,38 @@ static int mseread(struct cdev *dev, struct uio *uio, int ioflag) { mse_softc_t *sc = dev->si_drv1; - int xfer, s, error; + int xfer, error; /* * If there are no protocol bytes to be read, set up a new protocol * packet. */ - s = spltty(); /* XXX Should be its own spl, but where is imlXX() */ + MSE_LOCK(sc); + while (sc->sc_flags & MSESC_READING) { + if (MSE_NBLOCKIO(dev)) { + MSE_UNLOCK(sc); + return (0); + } + sc->sc_flags |= MSESC_WANT; + error = mtx_sleep(sc, &sc->sc_lock, MSEPRI | PCATCH, "mseread", + 0); + if (error) { + MSE_UNLOCK(sc); + return (error); + } + } + sc->sc_flags |= MSESC_READING; + xfer = 0; if (sc->sc_bytesread >= sc->mode.packetsize) { while (sc->sc_deltax == 0 && sc->sc_deltay == 0 && (sc->sc_obuttons ^ sc->sc_buttons) == 0) { - if (MSE_NBLOCKIO(dev)) { - splx(s); - return (0); - } + if (MSE_NBLOCKIO(dev)) + goto out; sc->sc_flags |= MSESC_WANT; - error = tsleep(sc, MSEPRI | PCATCH, + error = mtx_sleep(sc, &sc->sc_lock, MSEPRI | PCATCH, "mseread", 0); - if (error) { - splx(s); - return (error); - } + if (error) + goto out; } /* @@ -257,13 +305,21 @@ mseread(struct cdev *dev, struct uio *uio, int ioflag) sc->sc_deltax = sc->sc_deltay = 0; sc->sc_bytesread = 0; } - splx(s); xfer = min(uio->uio_resid, sc->mode.packetsize - sc->sc_bytesread); + MSE_UNLOCK(sc); error = uiomove(&sc->sc_bytes[sc->sc_bytesread], xfer, uio); - if (error) - return (error); - sc->sc_bytesread += xfer; - return(0); + MSE_LOCK(sc); +out: + sc->sc_flags &= ~MSESC_READING; + if (error == 0) + sc->sc_bytesread += xfer; + if (sc->sc_flags & MSESC_WANT) { + sc->sc_flags &= ~MSESC_WANT; + MSE_UNLOCK(sc); + wakeup(sc); + } else + MSE_UNLOCK(sc); + return (error); } /* @@ -275,20 +331,19 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td mse_softc_t *sc = dev->si_drv1; mousestatus_t status; int err = 0; - int s; switch (cmd) { case MOUSE_GETHWINFO: - s = spltty(); + MSE_LOCK(sc); *(mousehw_t *)addr = sc->hw; if (sc->mode.level == 0) ((mousehw_t *)addr)->model = MOUSE_MODEL_GENERIC; - splx(s); + MSE_UNLOCK(sc); break; case MOUSE_GETMODE: - s = spltty(); + MSE_LOCK(sc); *(mousemode_t *)addr = sc->mode; switch (sc->mode.level) { case 0: @@ -299,7 +354,7 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td ((mousemode_t *)addr)->syncmask[1] = MOUSE_SYS_SYNC; break; } - splx(s); + MSE_UNLOCK(sc); break; case MOUSE_SETMODE: @@ -310,9 +365,11 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td default: return (EINVAL); } - if (((mousemode_t *)addr)->accelfactor < -1) + MSE_LOCK(sc); + if (((mousemode_t *)addr)->accelfactor < -1) { + MSE_UNLOCK(sc); return (EINVAL); - else if (((mousemode_t *)addr)->accelfactor >= 0) + } else if (((mousemode_t *)addr)->accelfactor >= 0) sc->mode.accelfactor = ((mousemode_t *)addr)->accelfactor; sc->mode.level = ((mousemode_t *)addr)->level; @@ -326,23 +383,30 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td = MOUSE_SYS_PACKETSIZE; break; } + MSE_UNLOCK(sc); break; case MOUSE_GETLEVEL: + MSE_LOCK(sc); *(int *)addr = sc->mode.level; + MSE_UNLOCK(sc); break; case MOUSE_SETLEVEL: switch (*(int *)addr) { case 0: + MSE_LOCK(sc); sc->mode.level = *(int *)addr; sc->sc_bytesread = sc->mode.packetsize = MOUSE_MSC_PACKETSIZE; + MSE_UNLOCK(sc); break; case 1: + MSE_LOCK(sc); sc->mode.level = *(int *)addr; sc->sc_bytesread = sc->mode.packetsize = MOUSE_SYS_PACKETSIZE; + MSE_UNLOCK(sc); break; default: return (EINVAL); @@ -350,7 +414,7 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td break; case MOUSE_GETSTATUS: - s = spltty(); + MSE_LOCK(sc); status = sc->status; sc->status.flags = 0; sc->status.obutton = sc->status.button; @@ -358,7 +422,7 @@ mseioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td sc->status.dx = 0; sc->status.dy = 0; sc->status.dz = 0; - splx(s); + MSE_UNLOCK(sc); *(mousestatus_t *)addr = status; break; @@ -385,24 +449,18 @@ static int msepoll(struct cdev *dev, int events, struct thread *td) { mse_softc_t *sc = dev->si_drv1; - int s; int revents = 0; - s = spltty(); + MSE_LOCK(sc); if (events & (POLLIN | POLLRDNORM)) { if (sc->sc_bytesread != sc->mode.packetsize || sc->sc_deltax != 0 || sc->sc_deltay != 0 || (sc->sc_obuttons ^ sc->sc_buttons) != 0) revents |= events & (POLLIN | POLLRDNORM); - else { - /* - * Since this is an exclusive open device, any previous - * proc pointer is trash now, so we can just assign it. - */ + else selrecord(td, &sc->sc_selp); - } } - splx(s); + MSE_UNLOCK(sc); return (revents); } @@ -417,13 +475,14 @@ msetimeout(void *arg) dev = (struct cdev *)arg; sc = dev->si_drv1; + MSE_ASSERT_LOCKED(sc); if (sc->sc_watchdog) { if (bootverbose) printf("%s: lost interrupt?\n", devtoname(dev)); - mseintr(sc); + mseintr_locked(sc); } sc->sc_watchdog = TRUE; - sc->sc_callout = timeout(msetimeout, dev, hz); + callout_schedule(&sc->sc_callout, hz); } /* @@ -431,6 +490,16 @@ msetimeout(void *arg) */ static void mseintr(void *arg) +{ + mse_softc_t *sc = arg; + + MSE_LOCK(sc); + mseintr_locked(sc); + MSE_UNLOCK(sc); +} + +static void +mseintr_locked(mse_softc_t *sc) { /* * the table to turn MouseSystem button bits (MOUSE_MSC_BUTTON?UP) @@ -446,7 +515,6 @@ mseintr(void *arg) MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN, MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN }; - mse_softc_t *sc = arg; int dx, dy, but; int sign; @@ -458,7 +526,7 @@ mseintr(void *arg) if ((sc->sc_flags & MSESC_OPEN) == 0) return; - (*sc->sc_getmouse)(sc->sc_iot, sc->sc_ioh, &dx, &dy, &but); + (*sc->sc_getmouse)(sc->sc_port, &dx, &dy, &but); if (sc->mode.accelfactor > 0) { sign = (dx < 0); dx = dx * dx / sc->mode.accelfactor; diff --git a/sys/dev/mse/mse_cbus.c b/sys/dev/mse/mse_cbus.c index 75a72ddec2c..21924b60b9e 100644 --- a/sys/dev/mse/mse_cbus.c +++ b/sys/dev/mse/mse_cbus.c @@ -91,12 +91,11 @@ static int mse_cbus_probe(device_t dev); static int mse_cbus_attach(device_t dev); -static int mse_cbus_detach(device_t dev); static device_method_t mse_methods[] = { DEVMETHOD(device_probe, mse_cbus_probe), DEVMETHOD(device_attach, mse_cbus_attach), - DEVMETHOD(device_detach, mse_cbus_detach), + DEVMETHOD(device_detach, mse_detach), { 0, 0 } }; @@ -136,10 +135,10 @@ static struct isa_pnp_id mse_ids[] = { static bus_addr_t mse_port[] = {0, 2, 4, 6}; static int mse_probe98m(device_t dev, mse_softc_t *sc); -static void mse_disable98m(bus_space_tag_t t, bus_space_handle_t h); -static void mse_get98m(bus_space_tag_t t, bus_space_handle_t h, +static void mse_disable98m(struct resource *port); +static void mse_get98m(struct resource *port, int *dx, int *dy, int *but); -static void mse_enable98m(bus_space_tag_t t, bus_space_handle_t h); +static void mse_enable98m(struct resource *port); static struct mse_types mse_types[] = { { MSE_98BUSMOUSE, @@ -173,8 +172,6 @@ mse_cbus_probe(device_t dev) bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); return ENXIO; } - sc->sc_iot = rman_get_bustag(sc->sc_port); - sc->sc_ioh = rman_get_bushandle(sc->sc_port); /* * Check for each mouse type in the table. @@ -216,33 +213,10 @@ mse_cbus_attach(device_t dev) bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); return ENXIO; } - sc->sc_iot = rman_get_bustag(sc->sc_port); - sc->sc_ioh = rman_get_bushandle(sc->sc_port); return (mse_common_attach(dev)); } -static int -mse_cbus_detach(device_t dev) -{ - mse_softc_t *sc; - int rid; - - sc = device_get_softc(dev); - if (sc->sc_flags & MSESC_OPEN) - return EBUSY; - - rid = 0; - BUS_TEARDOWN_INTR(device_get_parent(dev), dev, sc->sc_intr, sc->sc_ih); - bus_release_resource(dev, SYS_RES_IRQ, rid, sc->sc_intr); - bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); - - destroy_dev(sc->sc_dev); - destroy_dev(sc->sc_ndev); - - return 0; -} - /* * Routines for the PC98 bus mouse. */ @@ -255,15 +229,15 @@ static int mse_probe98m(device_t dev, mse_softc_t *sc) { /* mode set */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MODE, 0x93); + bus_write_1(sc->sc_port, MODE, 0x93); /* initialize */ /* INT disable */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, INT, INT_DISABLE); + bus_write_1(sc->sc_port, INT, INT_DISABLE); /* HC = 0 */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, HC, HC_NO_CLEAR); + bus_write_1(sc->sc_port, HC, HC_NO_CLEAR); /* HC = 1 */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, HC, HC_CLEAR); + bus_write_1(sc->sc_port, HC, HC_CLEAR); return (1); } @@ -272,57 +246,56 @@ mse_probe98m(device_t dev, mse_softc_t *sc) * Initialize PC98 bus mouse and enable interrupts. */ static void -mse_enable98m(bus_space_tag_t tag, bus_space_handle_t handle) +mse_enable98m(struct resource *port) { - bus_space_write_1(tag, handle, INT, INT_ENABLE); /* INT enable */ - bus_space_write_1(tag, handle, HC, HC_NO_CLEAR); /* HC = 0 */ - bus_space_write_1(tag, handle, HC, HC_CLEAR); /* HC = 1 */ + bus_write_1(port, INT, INT_ENABLE); /* INT enable */ + bus_write_1(port, HC, HC_NO_CLEAR); /* HC = 0 */ + bus_write_1(port, HC, HC_CLEAR); /* HC = 1 */ } /* * Disable interrupts for PC98 Bus mouse. */ static void -mse_disable98m(bus_space_tag_t tag, bus_space_handle_t handle) +mse_disable98m(struct resource *port) { - bus_space_write_1(tag, handle, INT, INT_DISABLE); /* INT disable */ - bus_space_write_1(tag, handle, HC, HC_NO_CLEAR); /* HC = 0 */ - bus_space_write_1(tag, handle, HC, HC_CLEAR); /* HC = 1 */ + bus_write_1(port, INT, INT_DISABLE); /* INT disable */ + bus_write_1(port, HC, HC_NO_CLEAR); /* HC = 0 */ + bus_write_1(port, HC, HC_CLEAR); /* HC = 1 */ } /* * Get current dx, dy and up/down button state. */ static void -mse_get98m(bus_space_tag_t tag, bus_space_handle_t handle, int *dx, int *dy, - int *but) +mse_get98m(struct resource *port, int *dx, int *dy, int *but) { register char x, y; - bus_space_write_1(tag, handle, INT, INT_DISABLE); /* INT disable */ + bus_write_1(port, INT, INT_DISABLE); /* INT disable */ - bus_space_write_1(tag, handle, HC, HC_CLEAR); /* HC = 1 */ + bus_write_1(port, HC, HC_CLEAR); /* HC = 1 */ /* X low */ - bus_space_write_1(tag, handle, MSE_PORTC, 0x90 | XL); - x = bus_space_read_1(tag, handle, MSE_PORTA) & 0x0f; + bus_write_1(port, MSE_PORTC, 0x90 | XL); + x = bus_read_1(port, MSE_PORTA) & 0x0f; /* X high */ - bus_space_write_1(tag, handle, MSE_PORTC, 0x90 | XH); - x |= ((bus_space_read_1(tag, handle, MSE_PORTA) & 0x0f) << 4); + bus_write_1(port, MSE_PORTC, 0x90 | XH); + x |= ((bus_read_1(port, MSE_PORTA) & 0x0f) << 4); /* Y low */ - bus_space_write_1(tag, handle, MSE_PORTC, 0x90 | YL); - y = (bus_space_read_1(tag, handle, MSE_PORTA) & 0x0f); + bus_write_1(port, MSE_PORTC, 0x90 | YL); + y = (bus_read_1(port, MSE_PORTA) & 0x0f); /* Y high */ - bus_space_write_1(tag, handle, MSE_PORTC, 0x90 | YH); - y |= ((bus_space_read_1(tag, handle, MSE_PORTA) & 0x0f) << 4); + bus_write_1(port, MSE_PORTC, 0x90 | YH); + y |= ((bus_read_1(port, MSE_PORTA) & 0x0f) << 4); - *but = (bus_space_read_1(tag, handle, MSE_PORTA) >> 5) & 7; + *but = (bus_read_1(port, MSE_PORTA) >> 5) & 7; *dx = x; *dy = y; - bus_space_write_1(tag, handle, HC, HC_NO_CLEAR); /* HC = 0 */ + bus_write_1(port, HC, HC_NO_CLEAR); /* HC = 0 */ - bus_space_write_1(tag, handle, INT, INT_ENABLE); /* INT enable */ + bus_write_1(port, INT, INT_ENABLE); /* INT enable */ } diff --git a/sys/dev/mse/mse_isa.c b/sys/dev/mse/mse_isa.c index 517d678936c..c18759d2856 100644 --- a/sys/dev/mse/mse_isa.c +++ b/sys/dev/mse/mse_isa.c @@ -91,12 +91,11 @@ static int mse_isa_probe(device_t dev); static int mse_isa_attach(device_t dev); -static int mse_isa_detach(device_t dev); static device_method_t mse_methods[] = { DEVMETHOD(device_probe, mse_isa_probe), DEVMETHOD(device_attach, mse_isa_attach), - DEVMETHOD(device_detach, mse_isa_detach), + DEVMETHOD(device_detach, mse_detach), { 0, 0 } }; @@ -156,12 +155,10 @@ static struct isa_pnp_id mse_ids[] = { #define MSE_INTREN 0x00 static int mse_probelogi(device_t dev, mse_softc_t *sc); -static void mse_disablelogi(bus_space_tag_t t, - bus_space_handle_t h); -static void mse_getlogi(bus_space_tag_t t, bus_space_handle_t h, - int *dx, int *dy, int *but); -static void mse_enablelogi(bus_space_tag_t t, - bus_space_handle_t h); +static void mse_disablelogi(struct resource *port); +static void mse_getlogi(struct resource *port, int *dx, int *dy, + int *but); +static void mse_enablelogi(struct resource *port); /* * ATI Inport mouse definitions @@ -175,10 +172,10 @@ static void mse_enablelogi(bus_space_tag_t t, #define MSE_INPORT_INTREN 0x09 static int mse_probeati(device_t dev, mse_softc_t *sc); -static void mse_enableati(bus_space_tag_t t, bus_space_handle_t h); -static void mse_disableati(bus_space_tag_t t, bus_space_handle_t h); -static void mse_getati(bus_space_tag_t t, bus_space_handle_t h, - int *dx, int *dy, int *but); +static void mse_enableati(struct resource *port); +static void mse_disableati(struct resource *port); +static void mse_getati(struct resource *port, int *dx, int *dy, + int *but); static struct mse_types mse_types[] = { { MSE_ATIINPORT, @@ -213,8 +210,6 @@ mse_isa_probe(device_t dev) MSE_IOSIZE, RF_ACTIVE); if (sc->sc_port == NULL) return ENXIO; - sc->sc_iot = rman_get_bustag(sc->sc_port); - sc->sc_ioh = rman_get_bushandle(sc->sc_port); /* * Check for each mouse type in the table. @@ -252,33 +247,10 @@ mse_isa_attach(device_t dev) MSE_IOSIZE, RF_ACTIVE); if (sc->sc_port == NULL) return ENXIO; - sc->sc_iot = rman_get_bustag(sc->sc_port); - sc->sc_ioh = rman_get_bushandle(sc->sc_port); return (mse_common_attach(dev)); } -static int -mse_isa_detach(device_t dev) -{ - mse_softc_t *sc; - int rid; - - sc = device_get_softc(dev); - if (sc->sc_flags & MSESC_OPEN) - return EBUSY; - - rid = 0; - BUS_TEARDOWN_INTR(device_get_parent(dev), dev, sc->sc_intr, sc->sc_ih); - bus_release_resource(dev, SYS_RES_IRQ, rid, sc->sc_intr); - bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); - - destroy_dev(sc->sc_dev); - destroy_dev(sc->sc_ndev); - - return 0; -} - /* * Routines for the Logitech mouse. */ @@ -293,15 +265,14 @@ mse_probelogi(device_t dev, mse_softc_t *sc) int sig; - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSE_PORTD, MSE_SETUP); + bus_write_1(sc->sc_port, MSE_PORTD, MSE_SETUP); /* set the signature port */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSE_PORTB, MSE_LOGI_SIG); + bus_write_1(sc->sc_port, MSE_PORTB, MSE_LOGI_SIG); DELAY(30000); /* 30 ms delay */ - sig = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MSE_PORTB) & 0xFF; + sig = bus_read_1(sc->sc_port, MSE_PORTB) & 0xFF; if (sig == MSE_LOGI_SIG) { - bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSE_PORTC, - MSE_DISINTR); + bus_write_1(sc->sc_port, MSE_PORTC, MSE_DISINTR); return(1); } else { if (bootverbose) @@ -314,46 +285,45 @@ mse_probelogi(device_t dev, mse_softc_t *sc) * Initialize Logitech mouse and enable interrupts. */ static void -mse_enablelogi(bus_space_tag_t tag, bus_space_handle_t handle) +mse_enablelogi(struct resource *port) { int dx, dy, but; - bus_space_write_1(tag, handle, MSE_PORTD, MSE_SETUP); - mse_getlogi(tag, handle, &dx, &dy, &but); + bus_write_1(port, MSE_PORTD, MSE_SETUP); + mse_getlogi(port, &dx, &dy, &but); } /* * Disable interrupts for Logitech mouse. */ static void -mse_disablelogi(bus_space_tag_t tag, bus_space_handle_t handle) +mse_disablelogi(struct resource *port) { - bus_space_write_1(tag, handle, MSE_PORTC, MSE_DISINTR); + bus_write_1(port, MSE_PORTC, MSE_DISINTR); } /* * Get the current dx, dy and button up/down state. */ static void -mse_getlogi(bus_space_tag_t tag, bus_space_handle_t handle, int *dx, int *dy, - int *but) +mse_getlogi(struct resource *port, int *dx, int *dy, int *but) { register char x, y; - bus_space_write_1(tag, handle, MSE_PORTC, MSE_HOLD | MSE_RXLOW); - x = bus_space_read_1(tag, handle, MSE_PORTA); + bus_write_1(port, MSE_PORTC, MSE_HOLD | MSE_RXLOW); + x = bus_read_1(port, MSE_PORTA); *but = (x >> 5) & MOUSE_MSC_BUTTONS; x &= 0xf; - bus_space_write_1(tag, handle, MSE_PORTC, MSE_HOLD | MSE_RXHIGH); - x |= (bus_space_read_1(tag, handle, MSE_PORTA) << 4); - bus_space_write_1(tag, handle, MSE_PORTC, MSE_HOLD | MSE_RYLOW); - y = (bus_space_read_1(tag, handle, MSE_PORTA) & 0xf); - bus_space_write_1(tag, handle, MSE_PORTC, MSE_HOLD | MSE_RYHIGH); - y |= (bus_space_read_1(tag, handle, MSE_PORTA) << 4); + bus_write_1(port, MSE_PORTC, MSE_HOLD | MSE_RXHIGH); + x |= (bus_read_1(port, MSE_PORTA) << 4); + bus_write_1(port, MSE_PORTC, MSE_HOLD | MSE_RYLOW); + y = (bus_read_1(port, MSE_PORTA) & 0xf); + bus_write_1(port, MSE_PORTC, MSE_HOLD | MSE_RYHIGH); + y |= (bus_read_1(port, MSE_PORTA) << 4); *dx = x; *dy = y; - bus_space_write_1(tag, handle, MSE_PORTC, MSE_INTREN); + bus_write_1(port, MSE_PORTC, MSE_INTREN); } /* @@ -369,7 +339,7 @@ mse_probeati(device_t dev, mse_softc_t *sc) int i; for (i = 0; i < 2; i++) - if (bus_space_read_1(sc->sc_iot, sc->sc_ioh, MSE_PORTC) == 0xde) + if (bus_read_1(sc->sc_port, MSE_PORTC) == 0xde) return (1); return (0); } @@ -378,44 +348,43 @@ mse_probeati(device_t dev, mse_softc_t *sc) * Initialize ATI Inport mouse and enable interrupts. */ static void -mse_enableati(bus_space_tag_t tag, bus_space_handle_t handle) +mse_enableati(struct resource *port) { - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_RESET); - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_MODE); - bus_space_write_1(tag, handle, MSE_PORTB, MSE_INPORT_INTREN); + bus_write_1(port, MSE_PORTA, MSE_INPORT_RESET); + bus_write_1(port, MSE_PORTA, MSE_INPORT_MODE); + bus_write_1(port, MSE_PORTB, MSE_INPORT_INTREN); } /* * Disable interrupts for ATI Inport mouse. */ static void -mse_disableati(bus_space_tag_t tag, bus_space_handle_t handle) +mse_disableati(struct resource *port) { - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_MODE); - bus_space_write_1(tag, handle, MSE_PORTB, 0); + bus_write_1(port, MSE_PORTA, MSE_INPORT_MODE); + bus_write_1(port, MSE_PORTB, 0); } /* * Get current dx, dy and up/down button state. */ static void -mse_getati(bus_space_tag_t tag, bus_space_handle_t handle, int *dx, int *dy, - int *but) +mse_getati(struct resource *port, int *dx, int *dy, int *but) { char byte; - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_MODE); - bus_space_write_1(tag, handle, MSE_PORTB, MSE_INPORT_HOLD); - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_STATUS); - *but = ~bus_space_read_1(tag, handle, MSE_PORTB) & MOUSE_MSC_BUTTONS; - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_DX); - byte = bus_space_read_1(tag, handle, MSE_PORTB); + bus_write_1(port, MSE_PORTA, MSE_INPORT_MODE); + bus_write_1(port, MSE_PORTB, MSE_INPORT_HOLD); + bus_write_1(port, MSE_PORTA, MSE_INPORT_STATUS); + *but = ~bus_read_1(port, MSE_PORTB) & MOUSE_MSC_BUTTONS; + bus_write_1(port, MSE_PORTA, MSE_INPORT_DX); + byte = bus_read_1(port, MSE_PORTB); *dx = byte; - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_DY); - byte = bus_space_read_1(tag, handle, MSE_PORTB); + bus_write_1(port, MSE_PORTA, MSE_INPORT_DY); + byte = bus_read_1(port, MSE_PORTB); *dy = byte; - bus_space_write_1(tag, handle, MSE_PORTA, MSE_INPORT_MODE); - bus_space_write_1(tag, handle, MSE_PORTB, MSE_INPORT_INTREN); + bus_write_1(port, MSE_PORTA, MSE_INPORT_MODE); + bus_write_1(port, MSE_PORTB, MSE_INPORT_INTREN); } diff --git a/sys/dev/mse/msevar.h b/sys/dev/mse/msevar.h index 2c2b856c442..74a393f0ef0 100644 --- a/sys/dev/mse/msevar.h +++ b/sys/dev/mse/msevar.h @@ -46,7 +46,7 @@ /* * Software control structure for mouse. The sc_enablemouse(), - * sc_disablemouse() and sc_getmouse() routines must be called spl'd(). + * sc_disablemouse() and sc_getmouse() routines must be called locked. */ typedef struct mse_softc { int sc_flags; @@ -54,22 +54,19 @@ typedef struct mse_softc { struct selinfo sc_selp; struct resource *sc_port; struct resource *sc_intr; - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; void *sc_ih; - void (*sc_enablemouse)(bus_space_tag_t t, - bus_space_handle_t h); - void (*sc_disablemouse)(bus_space_tag_t t, - bus_space_handle_t h); - void (*sc_getmouse)(bus_space_tag_t t, bus_space_handle_t h, - int *dx, int *dy, int *but); + void (*sc_enablemouse)(struct resource *port); + void (*sc_disablemouse)(struct resource *port); + void (*sc_getmouse)(struct resource *port, int *dx, int *dy, + int *but); int sc_deltax; int sc_deltay; int sc_obuttons; int sc_buttons; int sc_bytesread; u_char sc_bytes[MOUSE_SYS_PACKETSIZE]; - struct callout_handle sc_callout; + struct callout sc_callout; + struct mtx sc_lock; int sc_watchdog; struct cdev *sc_dev; struct cdev *sc_ndev; @@ -78,9 +75,14 @@ typedef struct mse_softc { mousestatus_t status; } mse_softc_t; +#define MSE_LOCK(sc) mtx_lock(&(sc)->sc_lock) +#define MSE_UNLOCK(sc) mtx_unlock(&(sc)->sc_lock) +#define MSE_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_lock, MA_OWNED) + /* Flags */ #define MSESC_OPEN 0x1 #define MSESC_WANT 0x2 +#define MSESC_READING 0x4 /* and Mouse Types */ #define MSE_NONE 0 /* don't move this! */ @@ -110,12 +112,11 @@ struct mse_types { int m_type; /* Type of bus mouse */ int (*m_probe)(device_t dev, mse_softc_t *sc); /* Probe routine to test for it */ - void (*m_enable)(bus_space_tag_t t, bus_space_handle_t h); + void (*m_enable)(struct resource *port); /* Start routine */ - void (*m_disable)(bus_space_tag_t t, bus_space_handle_t h); + void (*m_disable)(struct resource *port); /* Disable interrupts routine */ - void (*m_get)(bus_space_tag_t t, bus_space_handle_t h, int *dx, - int *dy, int *but); + void (*m_get)(struct resource *port, int *dx, int *dy, int *but); /* and get mouse status */ mousehw_t m_hw; /* buttons iftype type model hwid */ mousemode_t m_mode; /* proto rate res accel level size mask */ @@ -123,3 +124,4 @@ struct mse_types { extern devclass_t mse_devclass; int mse_common_attach(device_t); +int mse_detach(device_t); From 1549fb22e69a7c5bd24f160f9990755a33e6fe54 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sat, 11 Oct 2014 20:25:19 +0000 Subject: [PATCH 046/112] ddb: space/tab fixes. No functional change. MFC after: 3 days --- sys/ddb/db_break.c | 6 +++--- sys/ddb/db_command.c | 2 +- sys/ddb/db_output.h | 2 +- sys/ddb/db_print.c | 2 +- sys/ddb/db_ps.c | 4 ++-- sys/ddb/db_run.c | 2 +- sys/ddb/db_sym.h | 2 +- sys/ddb/db_textdump.c | 6 +++--- sys/ddb/db_variables.h | 2 +- sys/ddb/db_watch.c | 8 ++++---- sys/ddb/db_watch.h | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/ddb/db_break.c b/sys/ddb/db_break.c index 02833ec0a82..772fd9f3414 100644 --- a/sys/ddb/db_break.c +++ b/sys/ddb/db_break.c @@ -161,13 +161,13 @@ db_breakpoint_t db_find_breakpoint_here(addr) db_addr_t addr; { - return db_find_breakpoint(db_map_addr(addr), addr); + return db_find_breakpoint(db_map_addr(addr), addr); } static boolean_t db_breakpoints_inserted = TRUE; #ifndef BKPT_WRITE -#define BKPT_WRITE(addr, storage) \ +#define BKPT_WRITE(addr, storage) \ do { \ *storage = db_get_value(addr, BKPT_SIZE, FALSE); \ db_put_value(addr, BKPT_SIZE, BKPT_SET(*storage)); \ @@ -175,7 +175,7 @@ do { \ #endif #ifndef BKPT_CLEAR -#define BKPT_CLEAR(addr, storage) \ +#define BKPT_CLEAR(addr, storage) \ db_put_value(addr, BKPT_SIZE, *storage) #endif diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index e890a178a23..dd9faef974d 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -648,7 +648,7 @@ db_kill(dummy1, dummy2, dummy3, dummy4) db_expr_t old_radix, pid, sig; struct proc *p; -#define DB_ERROR(f) do { db_printf f; db_flush_lex(); goto out; } while (0) +#define DB_ERROR(f) do { db_printf f; db_flush_lex(); goto out; } while (0) /* * PIDs and signal numbers are typically represented in base diff --git a/sys/ddb/db_output.h b/sys/ddb/db_output.h index cbf9f0e3d68..795719fce6e 100644 --- a/sys/ddb/db_output.h +++ b/sys/ddb/db_output.h @@ -30,7 +30,7 @@ #define _DDB_DB_OUTPUT_H_ /* - * Author: David B. Golub, Carnegie Mellon University + * Author: David B. Golub, Carnegie Mellon University * Date: 8/90 */ diff --git a/sys/ddb/db_print.c b/sys/ddb/db_print.c index 6cffd6d8b63..9e454565144 100644 --- a/sys/ddb/db_print.c +++ b/sys/ddb/db_print.c @@ -25,7 +25,7 @@ * */ /* - * Author: David B. Golub, Carnegie Mellon University + * Author: David B. Golub, Carnegie Mellon University * Date: 7/90 */ diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index 81e141e6dad..d28a0609931 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -155,7 +155,7 @@ db_ps(db_expr_t addr, boolean_t hasaddr, db_expr_t count, char *modif) else if (wflag) state[0] = 'W'; else - state[0] = '?'; + state[0] = '?'; } break; case PRS_NEW: @@ -211,7 +211,7 @@ db_ps(db_expr_t addr, boolean_t hasaddr, db_expr_t count, char *modif) p = LIST_NEXT(p, p_list); if (p == NULL && np > 0) p = LIST_FIRST(&zombproc); - } + } } static void diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c index 897dc3d5744..ce6704b3933 100644 --- a/sys/ddb/db_run.c +++ b/sys/ddb/db_run.c @@ -54,7 +54,7 @@ static int db_run_mode; #define STEP_RETURN 2 #define STEP_CALLT 3 #define STEP_CONTINUE 4 -#define STEP_INVISIBLE 5 +#define STEP_INVISIBLE 5 #define STEP_COUNT 6 static boolean_t db_sstep_print; diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h index e68be1fd5fe..1d9d462d693 100644 --- a/sys/ddb/db_sym.h +++ b/sys/ddb/db_sym.h @@ -30,7 +30,7 @@ #define _DDB_DB_SYM_H_ /* - * Author: Alessandro Forin, Carnegie Mellon University + * Author: Alessandro Forin, Carnegie Mellon University * Date: 8/90 */ diff --git a/sys/ddb/db_textdump.c b/sys/ddb/db_textdump.c index e6648702404..b4b040b8750 100644 --- a/sys/ddb/db_textdump.c +++ b/sys/ddb/db_textdump.c @@ -348,8 +348,8 @@ textdump_dump_msgbuf(struct dumperinfo *di) */ total_len = 0; offset = 0; - msgbuf_peekbytes(msgbufp, NULL, 0, &seq); - while ((len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq)) > 0) { + msgbuf_peekbytes(msgbufp, NULL, 0, &seq); + while ((len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq)) > 0) { for (i = 0; i < len; i++) { if (buf[i] == '\0') continue; @@ -362,7 +362,7 @@ textdump_dump_msgbuf(struct dumperinfo *di) total_len += offset; offset = 0; } - } + } total_len += offset; /* Without the zero-padding. */ if (offset != 0) { bzero(textdump_block_buffer + offset, diff --git a/sys/ddb/db_variables.h b/sys/ddb/db_variables.h index 2866cd0488d..1cbc481a1a7 100644 --- a/sys/ddb/db_variables.h +++ b/sys/ddb/db_variables.h @@ -27,7 +27,7 @@ */ /* - * Author: David B. Golub, Carnegie Mellon University + * Author: David B. Golub, Carnegie Mellon University * Date: 7/90 */ diff --git a/sys/ddb/db_watch.c b/sys/ddb/db_watch.c index b2be970715a..44ca191f72c 100644 --- a/sys/ddb/db_watch.c +++ b/sys/ddb/db_watch.c @@ -303,8 +303,8 @@ db_deletehwatch_cmd(addr, have_addr, count, modif) { int rc; - if (count < 0) - count = 4; + if (count < 0) + count = 4; rc = db_md_clr_watchpoint(addr, count); if (rc < 0) @@ -322,8 +322,8 @@ db_hwatchpoint_cmd(addr, have_addr, count, modif) { int rc; - if (count < 0) - count = 4; + if (count < 0) + count = 4; rc = db_md_set_watchpoint(addr, count); if (rc < 0) diff --git a/sys/ddb/db_watch.h b/sys/ddb/db_watch.h index 7c48ce8af1b..d4fdfc855bd 100644 --- a/sys/ddb/db_watch.h +++ b/sys/ddb/db_watch.h @@ -27,7 +27,7 @@ */ /* - * Author: David B. Golub, Carnegie Mellon University + * Author: David B. Golub, Carnegie Mellon University * Date: 10/90 */ From 37c7d4443c025122954a6c6447c88e21297c7a40 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 11 Oct 2014 20:28:04 +0000 Subject: [PATCH 047/112] Rename s/network/netif/ and set netif_enable for namespace consistency. --- etc/defaults/rc.conf | 1 + etc/rc.d/netif | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index b24e869cdd4..18989fafffb 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -110,6 +110,7 @@ synchronous_dhclient="NO" # Start dhclient directly on configured # interfaces during startup. defaultroute_delay="30" # Time to wait for a default route on a DHCP interface. defaultroute_carrier_delay="5" # Time to wait for carrier while waiting for a default route. +netif_enable="YES" # Set to YES to initialize network interfaces netif_ipexpand_max="2048" # Maximum number of IP addrs in a range spec. wpa_supplicant_program="/usr/sbin/wpa_supplicant" wpa_supplicant_flags="-s" # Extra flags to pass to wpa_supplicant diff --git a/etc/rc.d/netif b/etc/rc.d/netif index 154f1ce704e..dd0dde21bd2 100755 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -33,9 +33,10 @@ . /etc/rc.subr . /etc/network.subr -name="network" -start_cmd="network_start" -stop_cmd="network_stop" +name="netif" +rcvar="${name}_enable" +start_cmd="netif_start" +stop_cmd="netif_stop" cloneup_cmd="clone_up" clonedown_cmd="clone_down" clear_cmd="doclear" @@ -47,7 +48,7 @@ cmdifn= set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces set_rcvar_obsolete ipv6_prefer -network_start() +netif_start() { local _if @@ -71,7 +72,7 @@ network_start() ifnet_rename $cmdifn # Configure the interface(s). - network_common ifn_start $cmdifn + netif_common ifn_start $cmdifn if [ -f /etc/rc.d/ipfilter ] ; then # Resync ipfilter @@ -87,19 +88,19 @@ network_start() fi } -network_stop() +netif_stop() { _clone_down=1 - network_stop0 $* + netif_stop0 $* } doclear() { _clone_down= - network_stop0 $* + netif_stop0 $* } -network_stop0() +netif_stop0() { local _if @@ -108,7 +109,7 @@ network_stop0() cmdifn=$* # Deconfigure the interface(s) - network_common ifn_stop $cmdifn + netif_common ifn_stop $cmdifn # Destroy cloned interfaces if [ -n "$_clone_down" ]; then @@ -126,28 +127,28 @@ vnet_up() { cmdifn=$* - network_common ifn_vnetup $cmdifn + netif_common ifn_vnetup $cmdifn } vnet_down() { cmdifn=$* - network_common ifn_vnetdown $cmdifn + netif_common ifn_vnetdown $cmdifn } -# network_common routine +# netif_common routine # Common configuration subroutine for network interfaces. This # routine takes all the preparatory steps needed for configuriing # an interface and then calls $routine. -network_common() +netif_common() { local _cooked_list _tmp_list _fail _func _ok _str _cmdifn _func= if [ -z "$1" ]; then - err 1 "network_common(): No function name specified." + err 1 "netif_common(): No function name specified." else _func="$1" shift From e58fde506cbd72593e9aa1956118e32058e8978c Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 11 Oct 2014 20:46:06 +0000 Subject: [PATCH 048/112] Fix buffer overrun. MFC after: 1 day --- usr.sbin/rtsold/rtsol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c index c9b3d44158a..118206a4bfc 100644 --- a/usr.sbin/rtsold/rtsol.c +++ b/usr.sbin/rtsold/rtsol.c @@ -933,7 +933,8 @@ dname_labeldec(char *dst, size_t dlen, const char *src) dst_origin = dst; memset(dst, '\0', dlen); while (src && (len = (uint8_t)(*src++) & 0x3f) && - (src + len) <= src_last) { + (src + len) <= src_last && + (dst - dst_origin < (ssize_t)dlen)) { if (dst != dst_origin) *dst++ = '.'; warnmsg(LOG_DEBUG, __func__, "labellen = %zd", len); From f284c7376ae25d38c429ec37d06215a6b946582c Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Sat, 11 Oct 2014 21:43:05 +0000 Subject: [PATCH 049/112] Add a new option, -P, to pkt-gen which reads a single packet from a stored pcap file and transmits it instead of the default UDP packet. Reviewed by: luigi MFC after: 2 weeks --- tools/tools/netmap/pkt-gen.c | 45 +++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index c7cd8740b05..6063f0470eb 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -202,6 +202,7 @@ struct glob_arg { int dummy_send; int virt_header; /* send also the virt_header */ int extra_bufs; /* goes in nr_arg3 */ + char *packet_file; /* -P option */ }; enum dev_type { DEV_NONE, DEV_NETMAP, DEV_PCAP, DEV_TAP }; @@ -224,6 +225,7 @@ struct targ { int affinity; struct pkt pkt; + void *frame; }; @@ -613,6 +615,28 @@ initialize_packet(struct targ *targ) indirect_payload : default_payload; int i, l0 = strlen(payload); + char errbuf[PCAP_ERRBUF_SIZE]; + pcap_t *file; + struct pcap_pkthdr *header; + const unsigned char *packet; + + /* Read a packet from a PCAP file if asked. */ + if (targ->g->packet_file != NULL) { + if ((file = pcap_open_offline(targ->g->packet_file, + errbuf)) == NULL) + D("failed to open pcap file %s", + targ->g->packet_file); + if (pcap_next_ex(file, &header, &packet) < 0) + D("failed to read packet from %s", + targ->g->packet_file); + if ((targ->frame = malloc(header->caplen)) == NULL) + D("out of memory"); + bcopy(packet, (unsigned char *)targ->frame, header->caplen); + targ->g->pkt_size = header->caplen; + pcap_close(file); + return; + } + /* create a nice NUL-terminated string */ for (i = 0; i < paylen; i += l0) { if (l0 > paylen - i) @@ -783,7 +807,6 @@ pinger_body(void *data) frame += sizeof(targ->pkt.vh) - targ->g->virt_header; size = targ->g->pkt_size + targ->g->virt_header; - if (targ->g->nthreads > 1) { D("can only ping with 1 thread"); return NULL; @@ -1038,10 +1061,15 @@ sender_body(void *data) void *frame; int size; - frame = pkt; - frame += sizeof(pkt->vh) - targ->g->virt_header; - size = targ->g->pkt_size + targ->g->virt_header; - + if (targ->frame == NULL) { + frame = pkt; + frame += sizeof(pkt->vh) - targ->g->virt_header; + size = targ->g->pkt_size + targ->g->virt_header; + } else { + frame = targ->frame; + size = targ->g->pkt_size; + } + D("start, fd %d main_fd %d", targ->fd, targ->g->main_fd); if (setaffinity(targ->thread, targ->affinity)) goto quit; @@ -1366,6 +1394,7 @@ usage(void) "\t-R rate in packets per second\n" "\t-X dump payload\n" "\t-H len add empty virtio-net-header with size 'len'\n" + "\t-P file load packet from pcap file" "", cmd); @@ -1638,7 +1667,7 @@ main(int arc, char **argv) g.virt_header = 0; while ( (ch = getopt(arc, argv, - "a:f:F:n:i:Il:d:s:D:S:b:c:o:p:T:w:WvR:XC:H:e:m:")) != -1) { + "a:f:F:n:i:Il:d:s:D:S:b:c:o:p:T:w:WvR:XC:H:e:m:P:")) != -1) { struct sf *fn; switch(ch) { @@ -1781,7 +1810,11 @@ main(int arc, char **argv) D("unrecognized monitor mode %s", optarg); } break; + case 'P': + g.packet_file = strdup(optarg); + break; } + } if (g.ifname == NULL) { From 3e83ac2bfa98e6f5636c980045b5821230ed6fc3 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 11 Oct 2014 21:53:06 +0000 Subject: [PATCH 050/112] pstat(8): Correct description of the SESS column in pstat -t. MFC after: 1 week --- usr.sbin/pstat/pstat.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8 index 5e3760cecb7..cd1399422f0 100644 --- a/usr.sbin/pstat/pstat.8 +++ b/usr.sbin/pstat/pstat.8 @@ -35,7 +35,7 @@ .\" @(#)pstat.8 8.5 (Berkeley) 5/13/94 .\" $FreeBSD$ .\" -.Dd August 20, 2008 +.Dd October 11, 2014 .Dt PSTAT 8 .Os .Sh NAME @@ -170,7 +170,7 @@ Low water mark for output. .It COL Calculated column position of terminal. .It SESS -Kernel address of the session structure. +Process ID of the session leader. .It PGID Process group for which this is the controlling terminal. .It STATE From 0546aa1b97c50f1598be549123d1dcbf8f7b230a Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 11 Oct 2014 23:08:00 +0000 Subject: [PATCH 051/112] Fix off-by-one. MFC after: 1 day --- usr.sbin/rtadvd/advcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rtadvd/advcap.c b/usr.sbin/rtadvd/advcap.c index 7280f4097d6..542e06649f9 100644 --- a/usr.sbin/rtadvd/advcap.c +++ b/usr.sbin/rtadvd/advcap.c @@ -149,9 +149,9 @@ getent(char *bp, char *name, const char *cfile) } break; } - if (cp >= bp + BUFSIZ) { + if (cp >= bp + BUFSIZ - 1) { write(STDERR_FILENO, "Remcap entry too long\n", - 23); + 22); break; } else *cp++ = c; From e72e4280cfab1aa03d5b1f4e7484ec562c488763 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 11 Oct 2014 23:24:09 +0000 Subject: [PATCH 052/112] Check buffer length more strictly. MFC after: 1 day --- usr.sbin/rtadvd/config.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c index f0e11a34608..5c9d778e961 100644 --- a/usr.sbin/rtadvd/config.c +++ b/usr.sbin/rtadvd/config.c @@ -77,10 +77,10 @@ static time_t prefix_timo = (60 * 120); /* 2 hours. static struct rtadvd_timer *prefix_timeout(void *); static void makeentry(char *, size_t, int, const char *); -static size_t dname_labelenc(char *, const char *); +static ssize_t dname_labelenc(char *, const char *); /* Encode domain name label encoding in RFC 1035 Section 3.1 */ -static size_t +static ssize_t dname_labelenc(char *dst, const char *src) { char *dst_origin; @@ -90,6 +90,8 @@ dname_labelenc(char *dst, const char *src) dst_origin = dst; len = strlen(src); + if (len + len / 64 + 1 + 1 > DNAME_LABELENC_MAXLEN) + return (-1); /* Length fields per 63 octets + '\0' (<= DNAME_LABELENC_MAXLEN) */ memset(dst, 0, len + len / 64 + 1 + 1); @@ -98,9 +100,13 @@ dname_labelenc(char *dst, const char *src) /* Put a length field with 63 octet limitation first. */ p = strchr(src, '.'); if (p == NULL) - *dst++ = len = MIN(63, len); + *dst = len = MIN(63, len); else - *dst++ = len = MIN(63, p - src); + *dst = len = MIN(63, p - src); + if (dst + 1 + len < dst_origin + DNAME_LABELENC_MAXLEN) + dst++; + else + return (-1); /* Copy 63 octets at most. */ memcpy(dst, src, len); dst += len; @@ -866,6 +872,11 @@ getconfig_free_rdn: abuf[c] = '\0'; ELM_MALLOC(dnsa, goto getconfig_free_dns); dnsa->da_len = dname_labelenc(dnsa->da_dom, abuf); + if (dnsa->da_len < 0) { + syslog(LOG_ERR, "Invalid dnssl entry: %s", + abuf); + goto getconfig_free_dns; + } syslog(LOG_DEBUG, "<%s>: dnsa->da_len = %d", __func__, dnsa->da_len); TAILQ_INSERT_TAIL(&dns->dn_list, dnsa, da_next); From 61a8e8491886d0acd492dc4cbca0690f07b132c6 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 11 Oct 2014 23:49:27 +0000 Subject: [PATCH 053/112] Add ${name}_env and ${name}_prepend. ${name}_env is an argument list which will be passed to env(1). ${name}_prepend is simply prepended to the command line for $command. --- etc/rc.subr | 12 +++++++++++- share/man/man8/rc.subr.8 | 26 +++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/etc/rc.subr b/etc/rc.subr index 4b3fddf5d92..387b909848e 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -749,6 +749,8 @@ check_startmsgs() # NOTE: $flags from the parent environment # can be used to override this. # +# ${name}_env n Environment variables to run ${command} with. +# # ${name}_fib n Routing table number to run ${command} with. # # ${name}_nice n Nice level to run ${command} at. @@ -764,6 +766,8 @@ check_startmsgs() # to run the chrooted ${command} with. # Requires /usr to be mounted. # +# ${name}_prepend n Command added before ${command}. +# # ${rc_arg}_cmd n If set, use this as the method when invoked; # Otherwise, use default command (see below) # @@ -937,7 +941,8 @@ run_rc_command() eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ _nice=\$${name}_nice _user=\$${name}_user \ _group=\$${name}_group _groups=\$${name}_groups \ - _fib=\$${name}_fib + _fib=\$${name}_fib _env=\$${name}_env \ + _prepend=\$${name}_prepend if [ -n "$_user" ]; then # unset $_user if running as that user if [ "$_user" = "$(eval $IDCMD)" ]; then @@ -1022,12 +1027,14 @@ run_rc_command() _doit="\ ${_nice:+nice -n $_nice }\ ${_fib:+setfib -F $_fib }\ +${_env:+env $_env }\ chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ $_chroot $command $rc_flags $command_args" else _doit="\ ${_chdir:+cd $_chdir && }\ ${_fib:+setfib -F $_fib }\ +${_env:+env $_env }\ $command $rc_flags $command_args" if [ -n "$_user" ]; then _doit="su -m $_user -c 'sh -c \"$_doit\"'" @@ -1038,6 +1045,9 @@ $command $rc_flags $command_args" fi _doit="nice -n $_nice $_doit" fi + if [ -n "$_prepend" ]; then + _doit="$_prepend $_doit" + fi fi # run the full command diff --git a/share/man/man8/rc.subr.8 b/share/man/man8/rc.subr.8 index 7c3b654229d..47457ead904 100644 --- a/share/man/man8/rc.subr.8 +++ b/share/man/man8/rc.subr.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 23, 2012 +.Dd October 12, 2014 .Dt RC.SUBR 8 .Os .Sh NAME @@ -568,6 +568,22 @@ to before running Only supported after .Pa /usr is mounted. +.It Va ${name}_env +A list of environment variables to run +.Va command +with. +This will be passed as arguments to +.Xr env 1 +utility. +.It Va ${name}_fib +FIB +.Pa Routing Table +number to run +.Va command +with. +See +.Xr setfib 1 +for more details. .It Va ${name}_flags Arguments to call .Va command @@ -622,6 +638,14 @@ as. Comma separated list of supplementary groups to run the chrooted .Va command with. +.It Va ${name}_prepend +Commands to be prepended to +.Va command . +This is a generic version of +.Va ${name}_env , +.Va ${name}_fib , +or +.Va ${name}_nice . .It Ar argument Ns Va _cmd Shell commands which override the default method for .Ar argument . From 2869fca8b0f3fa55ca1b79c7446320d87dab6502 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sun, 12 Oct 2014 02:42:36 +0000 Subject: [PATCH 054/112] Add env and prepend to _rc_namevarlist. --- etc/rc.subr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.subr b/etc/rc.subr index 387b909848e..6534f6858f6 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -2050,7 +2050,7 @@ check_kern_features() # check_namevarlist var # Return "0" if ${name}_var is reserved in rc.subr. -_rc_namevarlist="program chroot chdir flags fib nice user group groups" +_rc_namevarlist="program chroot chdir env flags fib nice user group groups prepend" check_namevarlist() { local _v From 555e99a3bfb24d3086dbd30a1540fb0359ce28ab Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 12 Oct 2014 06:55:34 +0000 Subject: [PATCH 055/112] Improve and document `ctladm portlist` subcommand. Make this subcommand less FC-specific, reporting target and port addresses in more generic way. Also make it report list of connected initiators in unified way, working for both FC and iSCSI, and potentially others. MFC after: 1 week --- sys/cam/ctl/ctl.c | 76 +++++++++++++++++++++++++++++++++++----- usr.sbin/ctladm/ctladm.8 | 26 +++++++++++++- usr.sbin/ctladm/ctladm.c | 70 ++++++++++++++++++++++++++---------- 3 files changed, 144 insertions(+), 28 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 622aeee9c2f..66e00f9cf63 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -2237,6 +2237,43 @@ ctl_sbuf_printf_esc(struct sbuf *sb, char *str) return (retval); } +static void +ctl_id_sbuf(struct ctl_devid *id, struct sbuf *sb) +{ + struct scsi_vpd_id_descriptor *desc; + int i; + + if (id == NULL || id->len < 4) + return; + desc = (struct scsi_vpd_id_descriptor *)id->data; + switch (desc->id_type & SVPD_ID_TYPE_MASK) { + case SVPD_ID_TYPE_T10: + sbuf_printf(sb, "t10."); + break; + case SVPD_ID_TYPE_EUI64: + sbuf_printf(sb, "eui."); + break; + case SVPD_ID_TYPE_NAA: + sbuf_printf(sb, "naa."); + break; + case SVPD_ID_TYPE_SCSI_NAME: + break; + } + switch (desc->proto_codeset & SVPD_ID_CODESET_MASK) { + case SVPD_ID_CODESET_BINARY: + for (i = 0; i < desc->length; i++) + sbuf_printf(sb, "%02x", desc->identifier[i]); + break; + case SVPD_ID_CODESET_ASCII: + sbuf_printf(sb, "%.*s", (int)desc->length, + (char *)desc->identifier); + break; + case SVPD_ID_CODESET_UTF8: + sbuf_printf(sb, "%s", (char *)desc->identifier); + break; + } +} + static int ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) @@ -3288,6 +3325,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct ctl_port *port; struct ctl_lun_list *list; struct ctl_option *opt; + int j; list = (struct ctl_lun_list *)addr; @@ -3344,15 +3382,17 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, if (retval != 0) break; - retval = sbuf_printf(sb, "\t%#jx\n", - (uintmax_t)port->wwnn); - if (retval != 0) - break; + if (port->target_devid != NULL) { + sbuf_printf(sb, "\t"); + ctl_id_sbuf(port->target_devid, sb); + sbuf_printf(sb, "\n"); + } - retval = sbuf_printf(sb, "\t%#jx\n", - (uintmax_t)port->wwpn); - if (retval != 0) - break; + if (port->port_devid != NULL) { + sbuf_printf(sb, "\t"); + ctl_id_sbuf(port->port_devid, sb); + sbuf_printf(sb, "\n"); + } if (port->port_info != NULL) { retval = port->port_info(port->onoff_arg, sb); @@ -3366,6 +3406,26 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, break; } + for (j = 0; j < CTL_MAX_INIT_PER_PORT; j++) { + if (port->wwpn_iid[j].in_use == 0 || + (port->wwpn_iid[j].wwpn == 0 && + port->wwpn_iid[j].name == NULL)) + continue; + + if (port->wwpn_iid[j].name != NULL) + retval = sbuf_printf(sb, + "\t%u %s\n", + j, port->wwpn_iid[j].name); + else + retval = sbuf_printf(sb, + "\t%u naa.%08jx\n", + j, port->wwpn_iid[j].wwpn); + if (retval != 0) + break; + } + if (retval != 0) + break; + retval = sbuf_printf(sb, "\n"); if (retval != 0) break; diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8 index 19ee806fd83..5e69dd25402 100644 --- a/usr.sbin/ctladm/ctladm.8 +++ b/usr.sbin/ctladm/ctladm.8 @@ -34,7 +34,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd October 8, 2014 +.Dd October 12, 2014 .Dt CTLADM 8 .Os .Sh NAME @@ -193,6 +193,14 @@ .Op Fl q .Op Fl x .Nm +.Ic portlist +.Op Fl f Ar frontend +.Op Fl i +.Op Fl p Ar targ_port +.Op Fl q +.Op Fl v +.Op Fl x +.Nm .Ic dumpooa .Nm .Ic dumpstructs @@ -768,6 +776,22 @@ As a general rule, the WWPN must be different for every port in the system. .It Fl x Output the port list in XML format. .El +.It Ic portlist +List CTL frontend ports. +.Bl -tag -width 12n +.It Fl f Ar frontend +Specify the frontend type. +.It Fl i +Report target and connected initiators addresses +.It Fl p Ar targ_port +Specify the frontend port number. +.It Fl q +Omit the header in the port list output. +.It Fl v +Enable verbose output (report all port options). +.It Fl x +Output the port list in XML format. +.El .It Ic dumpooa Dump the OOA (Order Of Arrival) queue for each LUN registered with CTL. .It Ic dumpstructs diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c index 29fdd501057..731c7d81160 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -191,7 +191,7 @@ static struct ctladm_opts option_table[] = { {"modesense", CTLADM_CMD_MODESENSE, CTLADM_ARG_NEED_TL, "P:S:dlm:c:"}, {"modify", CTLADM_CMD_MODIFY, CTLADM_ARG_NONE, "b:l:s:"}, {"port", CTLADM_CMD_PORT, CTLADM_ARG_NONE, "lo:p:qt:w:W:x"}, - {"portlist", CTLADM_CMD_PORTLIST, CTLADM_ARG_NONE, "f:vx"}, + {"portlist", CTLADM_CMD_PORTLIST, CTLADM_ARG_NONE, "f:ip:qvx"}, {"prin", CTLADM_CMD_PRES_IN, CTLADM_ARG_NEED_TL, "a:"}, {"prout", CTLADM_CMD_PRES_OUT, CTLADM_ARG_NEED_TL, "a:k:r:s:"}, {"read", CTLADM_CMD_READ, CTLADM_ARG_NEED_TL, rw_opts}, @@ -4100,7 +4100,8 @@ struct cctl_port { char *frontend_type; char *name; int pp, vp; - char *wwnn, *wwpn; + char *target, *port; + STAILQ_HEAD(,cctl_lun_nv) init_list; STAILQ_HEAD(,cctl_lun_nv) attr_list; STAILQ_ENTRY(cctl_port) links; }; @@ -4144,6 +4145,7 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr) portlist->num_ports++; portlist->cur_port = cur_port; + STAILQ_INIT(&cur_port->init_list); STAILQ_INIT(&cur_port->attr_list); STAILQ_INSERT_TAIL(&portlist->port_list, cur_port, links); @@ -4205,11 +4207,11 @@ cctl_end_pelement(void *user_data, const char *name) cur_port->pp = strtoull(str, NULL, 0); } else if (strcmp(name, "virtual_port") == 0) { cur_port->vp = strtoull(str, NULL, 0); - } else if (strcmp(name, "wwnn") == 0) { - cur_port->wwnn = str; + } else if (strcmp(name, "target") == 0) { + cur_port->target = str; str = NULL; - } else if (strcmp(name, "wwpn") == 0) { - cur_port->wwpn = str; + } else if (strcmp(name, "port") == 0) { + cur_port->port = str; str = NULL; } else if (strcmp(name, "targ_port") == 0) { portlist->cur_port = NULL; @@ -4230,7 +4232,10 @@ cctl_end_pelement(void *user_data, const char *name) nv->value = str; str = NULL; - STAILQ_INSERT_TAIL(&cur_port->attr_list, nv, links); + if (strcmp(name, "initiator") == 0) + STAILQ_INSERT_TAIL(&cur_port->init_list, nv, links); + else + STAILQ_INSERT_TAIL(&cur_port->attr_list, nv, links); } free(str); @@ -4258,7 +4263,8 @@ cctl_portlist(int fd, int argc, char **argv, char *combinedopt) int dump_xml = 0; int retval, c; char *frontend = NULL; - int verbose = 0; + uint64_t portarg = UINT64_MAX; + int verbose = 0, init = 0, quiet = 0; retval = 0; port_len = 4096; @@ -4271,6 +4277,15 @@ cctl_portlist(int fd, int argc, char **argv, char *combinedopt) case 'f': frontend = strdup(optarg); break; + case 'i': + init++; + break; + case 'p': + portarg = strtoll(optarg, NULL, 0); + break; + case 'q': + quiet++; + break; case 'v': verbose++; break; @@ -4327,8 +4342,8 @@ retry: goto bailout; } - printf("Port Online Frontend %-12s pp vp %-18s %-18s\n", - "Name", "WWNN", "WWPN"); + if (quiet == 0) + printf("Port Online Frontend Name pp vp\n"); STAILQ_FOREACH(port, &portlist.port_list, links) { struct cctl_lun_nv *nv; @@ -4336,16 +4351,26 @@ retry: && (strcmp(port->frontend_type, frontend) != 0)) continue; - printf("%-4ju %-6s %-8s %-12s %-2d %-2d %-18s %-18s\n", - (uintmax_t)port->port_id, port->online, - port->frontend_type, port->name, port->pp, port->vp, - port->wwnn, port->wwpn); - - if (verbose == 0) + if ((portarg != UINT64_MAX) && (portarg != port->port_id)) continue; - STAILQ_FOREACH(nv, &port->attr_list, links) { - printf(" %s=%s\n", nv->name, nv->value); + printf("%-4ju %-6s %-8s %-8s %-2d %-2d %s\n", + (uintmax_t)port->port_id, port->online, + port->frontend_type, port->name, port->pp, port->vp, + port->port ? port->port : ""); + + if (init || verbose) { + if (port->target) + printf(" Target: %s\n", port->target); + STAILQ_FOREACH(nv, &port->init_list, links) { + printf(" Initiator: %s\n", nv->value); + } + } + + if (verbose) { + STAILQ_FOREACH(nv, &port->attr_list, links) { + printf(" %s=%s\n", nv->name, nv->value); + } } } bailout: @@ -4401,7 +4426,7 @@ usage(int error) " [-s len fmt [args]] [-c] [-d delete_id]\n" " ctladm port <-l | -o | [-w wwnn][-W wwpn]>\n" " [-p targ_port] [-t port_type] [-q] [-x]\n" -" ctladm portlist [-f frontend] [-v] [-x]\n" +" ctladm portlist [-f frontend] [-i] [-p targ_port] [-q] [-v] [-x]\n" " ctladm islist [-v | -x]\n" " ctladm islogout <-a | -c connection-id | -i name | -p portal>\n" " ctladm isterminate <-a | -c connection-id | -i name | -p portal>\n" @@ -4487,6 +4512,13 @@ usage(int error) "-p targ_port : specify target port number\n" "-q : omit header in list output\n" "-x : output port list in XML format\n" +"portlist options:\n" +"-f fronetnd : specify frontend type\n" +"-i : report target and initiators addresses\n" +"-p targ_port : specify target port number\n" +"-q : omit header in list output\n" +"-v : verbose output (report all port options)\n" +"-x : output port list in XML format\n" "bbrread options:\n" "-l lba : starting LBA\n" "-d datalen : length, in bytes, to read\n", From 5bd73b51076b5cb5a2c9810f76c1d7ed20c4460e Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 12 Oct 2014 10:04:59 +0000 Subject: [PATCH 056/112] Only #include on NetBSD Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/tls/dso/h_tls_dlopen.c | 2 ++ contrib/netbsd-tests/lib/libc/tls/t_tls_dlopen.c | 2 ++ contrib/netbsd-tests/lib/libc/tls/t_tls_dynamic.c | 2 ++ contrib/netbsd-tests/lib/libc/tls/t_tls_static.c | 2 ++ contrib/netbsd-tests/lib/libc/tls/t_tls_static_helper.c | 2 ++ contrib/netbsd-tests/lib/libc/tls_dso/h_tls_dynamic.c | 2 ++ 6 files changed, 12 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/tls/dso/h_tls_dlopen.c b/contrib/netbsd-tests/lib/libc/tls/dso/h_tls_dlopen.c index c455d33cec2..373528beef8 100644 --- a/contrib/netbsd-tests/lib/libc/tls/dso/h_tls_dlopen.c +++ b/contrib/netbsd-tests/lib/libc/tls/dso/h_tls_dlopen.c @@ -36,7 +36,9 @@ __RCSID("$NetBSD: h_tls_dlopen.c,v 1.5 2013/10/21 19:14:16 joerg Exp $"); #include #include +#if defined(__NetBSD__) #include +#endif #ifdef __HAVE_NO___THREAD #define __thread diff --git a/contrib/netbsd-tests/lib/libc/tls/t_tls_dlopen.c b/contrib/netbsd-tests/lib/libc/tls/t_tls_dlopen.c index 591823ea2b0..1ebbe7dfe21 100644 --- a/contrib/netbsd-tests/lib/libc/tls/t_tls_dlopen.c +++ b/contrib/netbsd-tests/lib/libc/tls/t_tls_dlopen.c @@ -39,7 +39,9 @@ __RCSID("$NetBSD: t_tls_dlopen.c,v 1.3 2012/01/17 20:34:57 joerg Exp $"); #include #include +#if defined(__NetBSD__) #include +#endif #ifdef __HAVE_NO___THREAD #define __thread diff --git a/contrib/netbsd-tests/lib/libc/tls/t_tls_dynamic.c b/contrib/netbsd-tests/lib/libc/tls/t_tls_dynamic.c index 9d242aeddc8..b5d1728b64e 100644 --- a/contrib/netbsd-tests/lib/libc/tls/t_tls_dynamic.c +++ b/contrib/netbsd-tests/lib/libc/tls/t_tls_dynamic.c @@ -38,7 +38,9 @@ __RCSID("$NetBSD: t_tls_dynamic.c,v 1.3 2012/01/17 20:34:57 joerg Exp $"); #include #include +#if defined(__NetBSD__) #include +#endif #ifdef __HAVE_NO___THREAD #define __thread diff --git a/contrib/netbsd-tests/lib/libc/tls/t_tls_static.c b/contrib/netbsd-tests/lib/libc/tls/t_tls_static.c index 7751a163fd0..028f398fdae 100644 --- a/contrib/netbsd-tests/lib/libc/tls/t_tls_static.c +++ b/contrib/netbsd-tests/lib/libc/tls/t_tls_static.c @@ -37,7 +37,9 @@ __RCSID("$NetBSD: t_tls_static.c,v 1.2 2012/01/17 20:34:57 joerg Exp $"); #include #include +#if defined(__NetBSD__) #include +#endif #ifdef __HAVE_NO___THREAD #define __thread diff --git a/contrib/netbsd-tests/lib/libc/tls/t_tls_static_helper.c b/contrib/netbsd-tests/lib/libc/tls/t_tls_static_helper.c index da3b6f06e6b..a85ce9b7215 100644 --- a/contrib/netbsd-tests/lib/libc/tls/t_tls_static_helper.c +++ b/contrib/netbsd-tests/lib/libc/tls/t_tls_static_helper.c @@ -34,7 +34,9 @@ #include __RCSID("$NetBSD: t_tls_static_helper.c,v 1.2 2012/01/17 20:34:57 joerg Exp $"); +#if defined(__NetBSD__) #include +#endif #ifdef __HAVE_NO___THREAD #define __thread diff --git a/contrib/netbsd-tests/lib/libc/tls_dso/h_tls_dynamic.c b/contrib/netbsd-tests/lib/libc/tls_dso/h_tls_dynamic.c index a12e07a78da..8a82689221b 100644 --- a/contrib/netbsd-tests/lib/libc/tls_dso/h_tls_dynamic.c +++ b/contrib/netbsd-tests/lib/libc/tls_dso/h_tls_dynamic.c @@ -35,7 +35,9 @@ __RCSID("$NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $"); #include +#if defined(__NetBSD__) #include +#endif #ifdef __HAVE_NO___THREAD #define __thread From 387dcafe06d4512cb0c674012b909eec5b9f63ca Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 12 Oct 2014 10:07:26 +0000 Subject: [PATCH 057/112] #include libutil.h for fparseln on FreeBSD Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c b/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c index 17258f5fef9..f5ded273de4 100644 --- a/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c +++ b/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c @@ -36,6 +36,9 @@ #include #include #include +#if defined(__FreeBSD__) +#include +#endif #define SKIPWS(p) while (isspace((int)(*p))) p++ #define WS "\t\n " From 75e1716807730619eddd56dbd59b9b34003e40e3 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 12 Oct 2014 13:12:06 +0000 Subject: [PATCH 058/112] sh: Fix break/continue/return in multiline eval. Example: eval $'return\necho bad' --- bin/sh/eval.c | 2 ++ bin/sh/tests/builtins/Makefile | 2 ++ bin/sh/tests/builtins/eval7.0 | 9 +++++++++ bin/sh/tests/builtins/eval8.7 | 7 +++++++ 4 files changed, 20 insertions(+) create mode 100644 bin/sh/tests/builtins/eval7.0 create mode 100644 bin/sh/tests/builtins/eval8.7 diff --git a/bin/sh/eval.c b/bin/sh/eval.c index ea2d2641e7e..38e227c7d74 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -168,6 +168,8 @@ evalstring(char *s, int flags) else evaltree(n, flags); any = 1; + if (evalskip) + break; } popstackmark(&smark); setstackmark(&smark); diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index d5d96b58a48..5f5da4a8907 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -72,6 +72,8 @@ FILES+= eval3.0 FILES+= eval4.0 FILES+= eval5.0 FILES+= eval6.0 +FILES+= eval7.0 +FILES+= eval8.7 FILES+= exec1.0 FILES+= exec2.0 FILES+= exit1.0 diff --git a/bin/sh/tests/builtins/eval7.0 b/bin/sh/tests/builtins/eval7.0 new file mode 100644 index 00000000000..a309c917b10 --- /dev/null +++ b/bin/sh/tests/builtins/eval7.0 @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Assumes that break can break out of a loop outside eval. + +while :; do + eval "break +echo bad1" + echo bad2 + exit 3 +done diff --git a/bin/sh/tests/builtins/eval8.7 b/bin/sh/tests/builtins/eval8.7 new file mode 100644 index 00000000000..af6064c388d --- /dev/null +++ b/bin/sh/tests/builtins/eval8.7 @@ -0,0 +1,7 @@ +# $FreeBSD$ + +f() { + eval "return 7 +echo bad2" +} +f From f0cace5d9450d59fc537cab49df449d632a394b2 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sun, 12 Oct 2014 15:49:52 +0000 Subject: [PATCH 059/112] When deciding whether to call m_pullup() even though there is adequate data in an mbuf, use M_WRITABLE() instead of a direct test of M_EXT; the latter both unnecessarily exposes mbuf-allocator internals in the protocol stack and is also insufficient to catch all cases of non-writability. (NB: m_pullup() does not actually guarantee that a writable mbuf is returned, so further refinement of all of these code paths continues to be required.) Reviewed by: bz MFC after: 3 days Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D900 --- sys/netinet/igmp.c | 4 ++-- sys/netinet/ip_mroute.c | 7 +++---- sys/netinet/ip_output.c | 2 +- sys/netinet6/icmp6.c | 4 +++- sys/netinet6/ip6_mroute.c | 9 +++------ sys/netinet6/ip6_output.c | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index a13260fd345..529d0ab2cc9 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -1466,7 +1466,7 @@ igmp_input(struct mbuf **mp, int *offp, int proto) minlen += IGMP_V3_QUERY_MINLEN; else minlen += IGMP_MINLEN; - if ((m->m_flags & M_EXT || m->m_len < minlen) && + if ((!M_WRITABLE(m) || m->m_len < minlen) && (m = m_pullup(m, minlen)) == 0) { IGMPSTAT_INC(igps_rcv_tooshort); return (IPPROTO_DONE); @@ -1557,7 +1557,7 @@ igmp_input(struct mbuf **mp, int *offp, int proto) */ igmpv3len = iphlen + IGMP_V3_QUERY_MINLEN + srclen; - if ((m->m_flags & M_EXT || + if ((!M_WRITABLE(m) || m->m_len < igmpv3len) && (m = m_pullup(m, igmpv3len)) == NULL) { IGMPSTAT_INC(igps_rcv_tooshort); diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 05605a810c6..7239946ba27 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -121,7 +121,6 @@ __FBSDID("$FreeBSD$"); #endif #define VIFI_INVALID ((vifi_t) -1) -#define M_HASCL(m) ((m)->m_flags & M_EXT) static VNET_DEFINE(uint32_t, last_tv_sec); /* last time we processed this */ #define V_last_tv_sec VNET(last_tv_sec) @@ -1304,7 +1303,7 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, } mb0 = m_copypacket(m, M_NOWAIT); - if (mb0 && (M_HASCL(mb0) || mb0->m_len < hlen)) + if (mb0 && (!M_WRITABLE(mb0) || mb0->m_len < hlen)) mb0 = m_pullup(mb0, hlen); if (mb0 == NULL) { free(rte, M_MRTABLE); @@ -1544,7 +1543,7 @@ ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif) int hlen = ip->ip_hl << 2; struct mbuf *mm = m_copy(m, 0, hlen); - if (mm && (M_HASCL(mm) || mm->m_len < hlen)) + if (mm && (!M_WRITABLE(mm) || mm->m_len < hlen)) mm = m_pullup(mm, hlen); if (mm == NULL) return ENOBUFS; @@ -1665,7 +1664,7 @@ phyint_send(struct ip *ip, struct vif *vifp, struct mbuf *m) * so that ip_output() only scribbles on the copy. */ mb_copy = m_copypacket(m, M_NOWAIT); - if (mb_copy && (M_HASCL(mb_copy) || mb_copy->m_len < hlen)) + if (mb_copy && (!M_WRITABLE(mb_copy) || mb_copy->m_len < hlen)) mb_copy = m_pullup(mb_copy, hlen); if (mb_copy == NULL) return; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 827d25af34b..25e7cceaf98 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1365,7 +1365,7 @@ ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst, * modify the pack in order to generate checksums. */ copym = m_dup(m, M_NOWAIT); - if (copym != NULL && (copym->m_flags & M_EXT || copym->m_len < hlen)) + if (copym != NULL && (!M_WRITABLE(copym) || copym->m_len < hlen)) copym = m_pullup(copym, hlen); if (copym != NULL) { /* If needed, compute the checksum and mark it as valid. */ diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index a50b5cfd7cc..acebe162a25 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -63,6 +63,8 @@ #include __FBSDID("$FreeBSD$"); +#define MBUF_PRIVATE /* XXXRW: Optimisation tries to avoid M_EXT mbufs */ + #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" @@ -581,7 +583,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) /* Give up remote */ break; } - if ((n->m_flags & M_EXT) != 0 + if (!M_WRITABLE(n) || n->m_len < off + sizeof(struct icmp6_hdr)) { struct mbuf *n0 = n; int n0len; diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index daf43f66875..3976b081b37 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -126,9 +126,6 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_MRTABLE6, "mf6c", "multicast forwarding cache entry"); -/* XXX: this is a very common idiom; move to ? */ -#define M_HASCL(m) ((m)->m_flags & M_EXT) - static int ip6_mdq(struct mbuf *, struct ifnet *, struct mf6c *); static void phyint_send(struct ip6_hdr *, struct mif6 *, struct mbuf *); static int register_send(struct ip6_hdr *, struct mif6 *, struct mbuf *); @@ -1128,7 +1125,7 @@ X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m) * Pullup packet header if needed before storing it, * as other references may modify it in the meantime. */ - if (mb0 && (M_HASCL(mb0) || mb0->m_len < sizeof(struct ip6_hdr))) + if (mb0 && (!M_WRITABLE(mb0) || mb0->m_len < sizeof(struct ip6_hdr))) mb0 = m_pullup(mb0, sizeof(struct ip6_hdr)); if (mb0 == NULL) { free(rte, M_MRTABLE6); @@ -1397,7 +1394,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) mm = m_copy(m, 0, sizeof(struct ip6_hdr)); if (mm && - (M_HASCL(mm) || + (!M_WRITABLE(mm) || mm->m_len < sizeof(struct ip6_hdr))) mm = m_pullup(mm, sizeof(struct ip6_hdr)); if (mm == NULL) @@ -1527,7 +1524,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) */ mb_copy = m_copy(m, 0, M_COPYALL); if (mb_copy && - (M_HASCL(mb_copy) || mb_copy->m_len < sizeof(struct ip6_hdr))) + (!M_WRITABLE(mb_copy) || mb_copy->m_len < sizeof(struct ip6_hdr))) mb_copy = m_pullup(mb_copy, sizeof(struct ip6_hdr)); if (mb_copy == NULL) { return; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 298a0d3bd07..f574fb22c86 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1196,7 +1196,7 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int hlen, for (mlast = n; mlast->m_next; mlast = mlast->m_next) ; - if ((mlast->m_flags & M_EXT) == 0 && + if (M_WRITABLE(mlast) && M_TRAILINGSPACE(mlast) >= sizeof(struct ip6_frag)) { /* use the trailing space of the last mbuf for the fragment hdr */ *frghdrp = (struct ip6_frag *)(mtod(mlast, caddr_t) + @@ -2918,7 +2918,7 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst) * is in an mbuf cluster, so that we can safely override the IPv6 * header portion later. */ - if ((copym->m_flags & M_EXT) != 0 || + if (!M_WRITABLE(copym) || copym->m_len < sizeof(struct ip6_hdr)) { copym = m_pullup(copym, sizeof(struct ip6_hdr)); if (copym == NULL) From be01d6e9f2c9e42ed7558cb31b463c4aceb88c82 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 12 Oct 2014 17:50:25 +0000 Subject: [PATCH 060/112] Centralize determination of boot firmware (UEFI vs. BIOS/CSM) into a function x86_bootmethod() and fix deviations from style(9). --- usr.sbin/bsdinstall/partedit/partedit_x86.c | 67 +++++++++++---------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index bd98ac55cf3..8bd4027b583 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -32,8 +32,21 @@ #include "partedit.h" -static char platform[255] = ""; -static const char *platform_sysctl = "machdep.bootmethod"; +static const char * +x86_bootmethod(void) +{ + static char fw[255] = ""; + size_t len = sizeof(fw); + int error; + + if (strlen(fw) == 0) { + error = sysctlbyname("machdep.bootmethod", fw, &len, NULL, -1); + if (error != 0) + return ("BIOS"); + } + + return (fw); +} const char * default_scheme(void) { @@ -41,14 +54,12 @@ default_scheme(void) { } int -is_scheme_bootable(const char *part_type) { - size_t platlen = sizeof(platform); - if (strlen(platform) == 0) - sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); +is_scheme_bootable(const char *part_type) +{ if (strcmp(part_type, "GPT") == 0) return (1); - if (strcmp(platform, "BIOS") == 0) { + if (strcmp(x86_bootmethod(), "BIOS") == 0) { if (strcmp(part_type, "BSD") == 0) return (1); if (strcmp(part_type, "MBR") == 0) @@ -59,31 +70,28 @@ is_scheme_bootable(const char *part_type) { } int -is_fs_bootable(const char *part_type, const char *fs) { - size_t platlen = sizeof(platform); - if (strlen(platform) == 0) - sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); +is_fs_bootable(const char *part_type, const char *fs) +{ if (strcmp(fs, "freebsd-ufs") == 0) return (1); - if (strcmp(fs, "freebsd-zfs") == 0 && strcmp(platform, "BIOS") == 0) + if (strcmp(fs, "freebsd-zfs") == 0 && + strcmp(x86_bootmethod(), "BIOS") == 0) return (1); return (0); } size_t -bootpart_size(const char *scheme) { - size_t platlen = sizeof(platform); - if (strlen(platform) == 0) - sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); +bootpart_size(const char *scheme) +{ /* No partcode except for GPT */ if (strcmp(scheme, "GPT") != 0) return (0); - if (strcmp(platform, "BIOS") == 0) + if (strcmp(x86_bootmethod(), "BIOS") == 0) return (512*1024); else return (800*1024); @@ -92,23 +100,20 @@ bootpart_size(const char *scheme) { } const char * -bootpart_type(const char *scheme) { - size_t platlen = sizeof(platform); - if (strlen(platform) == 0) - sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); +bootpart_type(const char *scheme) +{ - if (strcmp(platform, "UEFI") == 0) + if (strcmp(x86_bootmethod(), "UEFI") == 0) return ("efi"); return ("freebsd-boot"); } const char * -bootcode_path(const char *part_type) { - size_t platlen = sizeof(platform); - if (strlen(platform) == 0) - sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); - if (strcmp(platform, "UEFI") == 0) +bootcode_path(const char *part_type) +{ + + if (strcmp(x86_bootmethod(), "UEFI") == 0) return (NULL); if (strcmp(part_type, "GPT") == 0) @@ -122,13 +127,11 @@ bootcode_path(const char *part_type) { } const char * -partcode_path(const char *part_type, const char *fs_type) { - size_t platlen = sizeof(platform); - if (strlen(platform) == 0) - sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); +partcode_path(const char *part_type, const char *fs_type) +{ if (strcmp(part_type, "GPT") == 0) { - if (strcmp(platform, "UEFI") == 0) + if (strcmp(x86_bootmethod(), "UEFI") == 0) return ("/boot/boot1.efifat"); else if (strcmp(fs_type, "zfs") == 0) return ("/boot/gptzfsboot"); From 0dc54d18b29bfd0a501385dd95bbe42b535caf00 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 12 Oct 2014 17:56:02 +0000 Subject: [PATCH 061/112] Use the FIFOs in the imx5/imx6 uart hardware instead of interrupting on each byte sent or received. --- sys/dev/uart/uart_dev_imx.c | 106 +++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/sys/dev/uart/uart_dev_imx.c b/sys/dev/uart/uart_dev_imx.c index 2def18cbdbd..2f5fc064a80 100644 --- a/sys/dev/uart/uart_dev_imx.c +++ b/sys/dev/uart/uart_dev_imx.c @@ -48,6 +48,17 @@ __FBSDID("$FreeBSD$"); #include +/* + * The hardare FIFOs are 32 bytes. We want an interrupt when there are 24 bytes + * available to read or space for 24 more bytes to write. While 8 bytes of + * slack before over/underrun might seem excessive, the hardware can run at + * 5mbps, which means 2uS per char, so at full speed 8 bytes provides only 16uS + * to get into the interrupt handler and service the fifo. + */ +#define IMX_FIFOSZ 32 +#define IMX_RXFIFO_LEVEL 24 +#define IMX_TXFIFO_LEVEL 24 + /* * Low-level UART interface. */ @@ -187,6 +198,17 @@ imx_uart_init(struct uart_bas *bas, int baudrate, int databits, SETREG(bas, REG(UBIR), 15); SETREG(bas, REG(UBMR), (baseclk / baudrate) - 1); } + + /* + * Program the tx lowater and rx hiwater levels at which fifo-service + * interrupts are signaled. The tx value is interpetted as "when there + * are only this many bytes remaining" (not "this many free"). + */ + reg = GETREG(bas, REG(UFCR)); + reg &= ~(IMXUART_UFCR_TXTL_MASK | IMXUART_UFCR_RXTL_MASK); + reg |= (IMX_FIFOSZ - IMX_TXFIFO_LEVEL) << IMXUART_UFCR_TXTL_SHIFT; + reg |= IMX_RXFIFO_LEVEL << IMXUART_UFCR_RXTL_SHIFT; + SETREG(bas, REG(UFCR), reg); } static void @@ -199,7 +221,7 @@ static void imx_uart_putc(struct uart_bas *bas, int c) { - while (!(IS(bas, USR2, TXFE))) + while (!(IS(bas, USR1, TRDY))) ; SETREG(bas, REG(UTXD), c); } @@ -302,11 +324,15 @@ imx_uart_bus_attach(struct uart_softc *sc) (void)imx_uart_bus_getsig(sc); - ENA(bas, UCR4, DREN); - DIS(bas, UCR1, RRDYEN); + /* Clear all pending interrupts. */ + SETREG(bas, REG(USR1), 0xffff); + SETREG(bas, REG(USR2), 0xffff); + + DIS(bas, UCR4, DREN); + ENA(bas, UCR1, RRDYEN); DIS(bas, UCR1, IDEN); DIS(bas, UCR3, RXDSEN); - DIS(bas, UCR2, ATEN); + ENA(bas, UCR2, ATEN); DIS(bas, UCR1, TXMPTYEN); DIS(bas, UCR1, TRDYEN); DIS(bas, UCR4, TCEN); @@ -330,9 +356,6 @@ imx_uart_bus_attach(struct uart_softc *sc) ENA(bas, UCR2, IRTS); ENA(bas, UCR3, RXDMUXSEL); - /* ACK all interrupts */ - SETREG(bas, REG(USR1), 0xffff); - SETREG(bas, REG(USR2), 0xffff); return (0); } @@ -404,7 +427,7 @@ imx_uart_bus_ipend(struct uart_softc *sc) struct uart_bas *bas; int ipend; uint32_t usr1, usr2; - uint32_t ucr1, ucr4; + uint32_t ucr1, ucr2, ucr4; bas = &sc->sc_bas; ipend = 0; @@ -419,18 +442,28 @@ imx_uart_bus_ipend(struct uart_softc *sc) SETREG(bas, REG(USR2), usr2); ucr1 = GETREG(bas, REG(UCR1)); + ucr2 = GETREG(bas, REG(UCR2)); ucr4 = GETREG(bas, REG(UCR4)); - if ((usr2 & FLD(USR2, TXFE)) && (ucr1 & FLD(UCR1, TXMPTYEN))) { - DIS(bas, UCR1, TXMPTYEN); - /* Continue TXing */ + /* If we have reached tx low-water, we can tx some more now. */ + if ((usr1 & FLD(USR1, TRDY)) && (ucr1 & FLD(UCR1, TRDYEN))) { + DIS(bas, UCR1, TRDYEN); ipend |= SER_INT_TXIDLE; } - if ((usr2 & FLD(USR2, RDR)) && (ucr4 & FLD(UCR4, DREN))) { - DIS(bas, UCR4, DREN); - /* Wow, new char on input */ + + /* + * If we have reached the rx high-water, or if there are bytes in the rx + * fifo and no new data has arrived for 8 character periods (aging + * timer), we have input data to process. + */ + if (((usr1 & FLD(USR1, RRDY)) && (ucr1 & FLD(UCR1, RRDYEN))) || + ((usr1 & FLD(USR1, AGTIM)) && (ucr2 & FLD(UCR2, ATEN)))) { + DIS(bas, UCR1, RRDYEN); + DIS(bas, UCR2, ATEN); ipend |= SER_INT_RXREADY; } + + /* A break can come in at any time, it never gets disabled. */ if ((usr2 & FLD(USR2, BRCD)) && (ucr4 & FLD(UCR4, BKEN))) ipend |= SER_INT_BREAK; @@ -459,8 +492,14 @@ imx_uart_bus_probe(struct uart_softc *sc) if (error) return (error); - sc->sc_rxfifosz = 1; - sc->sc_txfifosz = 1; + /* + * On input we can read up to the full fifo size at once. On output, we + * want to write only as much as the programmed tx low water level, + * because that's all we can be certain we have room for in the fifo + * when we get a tx-ready interrupt. + */ + sc->sc_rxfifosz = IMX_FIFOSZ; + sc->sc_txfifosz = IMX_TXFIFO_LEVEL; device_set_desc(sc->sc_dev, "Freescale i.MX UART"); return (0); @@ -475,20 +514,20 @@ imx_uart_bus_receive(struct uart_softc *sc) bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); - /* Read while we have anything in FIFO */ + /* + * Empty the rx fifo. We get the RRDY interrupt when IMX_RXFIFO_LEVEL + * (the rx high-water level) is reached, but we set sc_rxfifosz to the + * full hardware fifo size, so we can safely process however much is + * there, not just the highwater size. + */ while (IS(bas, USR2, RDR)) { if (uart_rx_full(sc)) { /* No space left in input buffer */ sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN; break; } - out = 0; xc = GETREG(bas, REG(URXD)); - - /* We have valid char */ - if (xc & FLD(URXD, CHARRDY)) - out = xc & 0x000000ff; - + out = xc & 0x000000ff; if (xc & FLD(URXD, FRMERR)) out |= UART_STAT_FRAMERR; if (xc & FLD(URXD, PRERR)) @@ -500,8 +539,8 @@ imx_uart_bus_receive(struct uart_softc *sc) uart_rx_put(sc, out); } - /* Reenable Data Ready interrupt */ - ENA(bas, UCR4, DREN); + ENA(bas, UCR1, RRDYEN); + ENA(bas, UCR2, ATEN); uart_unlock(sc->sc_hwmtx); return (0); @@ -523,14 +562,17 @@ imx_uart_bus_transmit(struct uart_softc *sc) bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); - /* Fill TX FIFO */ + /* + * Fill the tx fifo. The uart core puts at most IMX_TXFIFO_LEVEL bytes + * into the txbuf (because that's what sc_txfifosz is set to), and + * because we got the TRDY (low-water reached) interrupt we know at + * least that much space is available in the fifo. + */ for (i = 0; i < sc->sc_txdatasz; i++) { SETREG(bas, REG(UTXD), sc->sc_txbuf[i] & 0xff); } - sc->sc_txbusy = 1; - /* Call me when ready */ - ENA(bas, UCR1, TXMPTYEN); + ENA(bas, UCR1, TRDYEN); uart_unlock(sc->sc_hwmtx); @@ -544,7 +586,8 @@ imx_uart_bus_grab(struct uart_softc *sc) bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); - DIS(bas, UCR4, DREN); + DIS(bas, UCR1, RRDYEN); + DIS(bas, UCR2, ATEN); uart_unlock(sc->sc_hwmtx); } @@ -555,6 +598,7 @@ imx_uart_bus_ungrab(struct uart_softc *sc) bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); - ENA(bas, UCR4, DREN); + ENA(bas, UCR1, RRDYEN); + ENA(bas, UCR2, ATEN); uart_unlock(sc->sc_hwmtx); } From 403a3c8c82dd71e9a0beb7cc8ff9b1ba0a414061 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 12 Oct 2014 17:59:31 +0000 Subject: [PATCH 062/112] Only allow ZFS boot on GPT; the MBR ZFS bootblocks cannot be installed using gpart bootcode as /boot/zfsboot needs to be split into multiple pieces by hand and copied to different areas of the partition. --- usr.sbin/bsdinstall/partedit/partedit_x86.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index 8bd4027b583..cc6a5713f94 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -49,7 +49,8 @@ x86_bootmethod(void) } const char * -default_scheme(void) { +default_scheme(void) +{ return ("GPT"); } @@ -77,6 +78,7 @@ is_fs_bootable(const char *part_type, const char *fs) return (1); if (strcmp(fs, "freebsd-zfs") == 0 && + strcmp(part_type, "GPT") == 0 && strcmp(x86_bootmethod(), "BIOS") == 0) return (1); From a41dd0319c532919c2f5ac2ba161d0157375e2fc Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sun, 12 Oct 2014 18:01:52 +0000 Subject: [PATCH 063/112] ddb: ANSI-fy function declarations. MFC after: 5 days --- sys/ddb/db_access.c | 10 ++----- sys/ddb/db_break.c | 62 +++++++++++++----------------------------- sys/ddb/db_command.c | 46 ++++++++----------------------- sys/ddb/db_examine.c | 39 +++++++------------------- sys/ddb/db_input.c | 2 +- sys/ddb/db_lex.c | 8 +++--- sys/ddb/db_output.c | 4 +-- sys/ddb/db_run.c | 27 ++++++------------ sys/ddb/db_sym.c | 58 +++++++++------------------------------ sys/ddb/db_watch.c | 53 +++++++++++------------------------- sys/ddb/db_write_cmd.c | 7 ++--- 11 files changed, 89 insertions(+), 227 deletions(-) diff --git a/sys/ddb/db_access.c b/sys/ddb/db_access.c index 2f4d049ee60..415faa1c080 100644 --- a/sys/ddb/db_access.c +++ b/sys/ddb/db_access.c @@ -54,10 +54,7 @@ static unsigned db_extend[] = { /* table for sign-extending */ #endif db_expr_t -db_get_value(addr, size, is_signed) - db_addr_t addr; - register int size; - boolean_t is_signed; +db_get_value(db_addr_t addr, int size, boolean_t is_signed) { char data[sizeof(u_int64_t)]; register db_expr_t value; @@ -87,10 +84,7 @@ db_get_value(addr, size, is_signed) } void -db_put_value(addr, size, value) - db_addr_t addr; - register int size; - register db_expr_t value; +db_put_value(db_addr_t addr, int size, db_expr_t value) { char data[sizeof(int)]; register int i; diff --git a/sys/ddb/db_break.c b/sys/ddb/db_break.c index 772fd9f3414..f4c27aa986c 100644 --- a/sys/ddb/db_break.c +++ b/sys/ddb/db_break.c @@ -59,7 +59,7 @@ static void db_list_breakpoints(void); static void db_set_breakpoint(vm_map_t map, db_addr_t addr, int count); static db_breakpoint_t -db_breakpoint_alloc() +db_breakpoint_alloc(void) { register db_breakpoint_t bkpt; @@ -78,18 +78,14 @@ db_breakpoint_alloc() } static void -db_breakpoint_free(bkpt) - register db_breakpoint_t bkpt; +db_breakpoint_free(db_breakpoint_t bkpt) { bkpt->link = db_free_breakpoints; db_free_breakpoints = bkpt; } static void -db_set_breakpoint(map, addr, count) - vm_map_t map; - db_addr_t addr; - int count; +db_set_breakpoint(vm_map_t map, db_addr_t addr, int count) { register db_breakpoint_t bkpt; @@ -115,9 +111,7 @@ db_set_breakpoint(map, addr, count) } static void -db_delete_breakpoint(map, addr) - vm_map_t map; - db_addr_t addr; +db_delete_breakpoint(vm_map_t map, db_addr_t addr) { register db_breakpoint_t bkpt; register db_breakpoint_t *prev; @@ -140,9 +134,7 @@ db_delete_breakpoint(map, addr) } static db_breakpoint_t -db_find_breakpoint(map, addr) - vm_map_t map; - db_addr_t addr; +db_find_breakpoint(vm_map_t map, db_addr_t addr) { register db_breakpoint_t bkpt; @@ -158,8 +150,7 @@ db_find_breakpoint(map, addr) } db_breakpoint_t -db_find_breakpoint_here(addr) - db_addr_t addr; +db_find_breakpoint_here(db_addr_t addr) { return db_find_breakpoint(db_map_addr(addr), addr); } @@ -180,7 +171,7 @@ do { \ #endif void -db_set_breakpoints() +db_set_breakpoints(void) { register db_breakpoint_t bkpt; @@ -197,7 +188,7 @@ db_set_breakpoints() } void -db_clear_breakpoints() +db_clear_breakpoints(void) { register db_breakpoint_t bkpt; @@ -220,8 +211,7 @@ db_clear_breakpoints() * so the breakpoint does not have to be on the breakpoint list. */ db_breakpoint_t -db_set_temp_breakpoint(addr) - db_addr_t addr; +db_set_temp_breakpoint(db_addr_t addr) { register db_breakpoint_t bkpt; @@ -242,8 +232,7 @@ db_set_temp_breakpoint(addr) } void -db_delete_temp_breakpoint(bkpt) - db_breakpoint_t bkpt; +db_delete_temp_breakpoint(db_breakpoint_t bkpt) { BKPT_CLEAR(bkpt->address, &bkpt->bkpt_inst); db_breakpoint_free(bkpt); @@ -254,7 +243,7 @@ db_delete_temp_breakpoint(bkpt) * List breakpoints. */ static void -db_list_breakpoints() +db_list_breakpoints(void) { register db_breakpoint_t bkpt; @@ -278,11 +267,7 @@ db_list_breakpoints() /* Delete breakpoint */ /*ARGSUSED*/ void -db_delete_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_delete_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif) { db_delete_breakpoint(db_map_addr(addr), (db_addr_t)addr); } @@ -290,11 +275,8 @@ db_delete_cmd(addr, have_addr, count, modif) /* Set breakpoint with skip count */ /*ARGSUSED*/ void -db_breakpoint_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_breakpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { if (count == -1) count = 1; @@ -304,11 +286,8 @@ db_breakpoint_cmd(addr, have_addr, count, modif) /* list breakpoints */ void -db_listbreak_cmd(dummy1, dummy2, dummy3, dummy4) - db_expr_t dummy1; - boolean_t dummy2; - db_expr_t dummy3; - char * dummy4; +db_listbreak_cmd(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, + char *dummy4) { db_list_breakpoints(); } @@ -320,8 +299,7 @@ db_listbreak_cmd(dummy1, dummy2, dummy3, dummy4) */ boolean_t -db_map_equal(map1, map2) - vm_map_t map1, map2; +db_map_equal(vm_map_t map1, vm_map_t map2) { return ((map1 == map2) || ((map1 == NULL) && (map2 == kernel_map)) || @@ -329,8 +307,7 @@ db_map_equal(map1, map2) } boolean_t -db_map_current(map) - vm_map_t map; +db_map_current(vm_map_t map) { #if 0 thread_t thread; @@ -345,8 +322,7 @@ db_map_current(map) } vm_map_t -db_map_addr(addr) - vm_offset_t addr; +db_map_addr(vm_offset_t addr) { #if 0 thread_t thread; diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index dd9faef974d..7bed8ae27ee 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -157,7 +157,7 @@ static boolean_t db_ed_style = TRUE; * Utility routine - discard tokens through end-of-line. */ void -db_skip_to_eol() +db_skip_to_eol(void) { int t; do { @@ -252,11 +252,8 @@ db_command_unregister(struct command_table *list, struct command *cmd) * Helper function to match a single command. */ static void -db_cmd_match(name, cmd, cmdp, resultp) - char * name; - struct command *cmd; - struct command **cmdp; /* out */ - int * resultp; +db_cmd_match(char *name, struct command *cmd, struct command **cmdp, + int *resultp) { char *lp, *rp; int c; @@ -291,10 +288,7 @@ db_cmd_match(name, cmd, cmdp, resultp) * Search for command prefix. */ static int -db_cmd_search(name, table, cmdp) - char * name; - struct command_table *table; - struct command **cmdp; /* out */ +db_cmd_search(char *name, struct command_table *table, struct command **cmdp) { struct command *cmd; int result = CMD_NONE; @@ -315,8 +309,7 @@ db_cmd_search(name, table, cmdp) } static void -db_cmd_list(table) - struct command_table *table; +db_cmd_list(struct command_table *table) { register struct command *cmd; @@ -327,10 +320,8 @@ db_cmd_list(table) } static void -db_command(last_cmdp, cmd_table, dopager) - struct command **last_cmdp; /* IN_OUT */ - struct command_table *cmd_table; - int dopager; +db_command(struct command **last_cmdp, struct command_table *cmd_table, + int dopager) { struct command *cmd = NULL; int t; @@ -483,7 +474,7 @@ DB_COMMAND(panic, db_panic) } void -db_command_loop() +db_command_loop(void) { /* * Initialize 'prev' and 'next' to dot. @@ -521,8 +512,7 @@ db_command_script(const char *command) } void -db_error(s) - const char *s; +db_error(const char *s) { if (s) db_printf("%s", s); @@ -581,11 +571,7 @@ db_fncall_generic(db_expr_t addr, db_expr_t *rv, int nargs, db_expr_t args[]) } static void -db_fncall(dummy1, dummy2, dummy3, dummy4) - db_expr_t dummy1; - boolean_t dummy2; - db_expr_t dummy3; - char * dummy4; +db_fncall(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4) { db_expr_t fn_addr; db_expr_t args[DB_MAXARGS]; @@ -639,11 +625,7 @@ db_halt(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4) } static void -db_kill(dummy1, dummy2, dummy3, dummy4) - db_expr_t dummy1; - boolean_t dummy2; - db_expr_t dummy3; - char * dummy4; +db_kill(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4) { db_expr_t old_radix, pid, sig; struct proc *p; @@ -732,11 +714,7 @@ db_reset(db_expr_t addr, boolean_t have_addr, db_expr_t count __unused, } static void -db_watchdog(dummy1, dummy2, dummy3, dummy4) - db_expr_t dummy1; - boolean_t dummy2; - db_expr_t dummy3; - char * dummy4; +db_watchdog(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4) { db_expr_t old_radix, tout; int err, i; diff --git a/sys/ddb/db_examine.c b/sys/ddb/db_examine.c index fc4f47285f0..f10df12928a 100644 --- a/sys/ddb/db_examine.c +++ b/sys/ddb/db_examine.c @@ -52,11 +52,8 @@ static void db_search(db_addr_t, int, db_expr_t, db_expr_t, u_int); */ /*ARGSUSED*/ void -db_examine_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_examine_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { if (modif[0] != '\0') db_strcpy(db_examine_format, modif); @@ -68,11 +65,7 @@ db_examine_cmd(addr, have_addr, count, modif) } static void -db_examine(addr, fmt, count) - register - db_addr_t addr; - char * fmt; /* format string */ - int count; /* repeat count */ +db_examine(db_addr_t addr, char *fmt, int count) { int c; db_expr_t value; @@ -197,11 +190,8 @@ static char db_print_format = 'x'; /*ARGSUSED*/ void -db_print_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_print_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { db_expr_t value; @@ -242,8 +232,7 @@ db_print_cmd(addr, have_addr, count, modif) } void -db_print_loc_and_inst(loc) - db_addr_t loc; +db_print_loc_and_inst(db_addr_t loc) { db_printsym(loc, DB_STGY_PROC); db_printf(":\t"); @@ -255,11 +244,8 @@ db_print_loc_and_inst(loc) * Syntax: search [/bhl] addr value [mask] [,count] */ void -db_search_cmd(dummy1, dummy2, dummy3, dummy4) - db_expr_t dummy1; - boolean_t dummy2; - db_expr_t dummy3; - char * dummy4; +db_search_cmd(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, + char *dummy4) { int t; db_addr_t addr; @@ -323,13 +309,8 @@ db_search_cmd(dummy1, dummy2, dummy3, dummy4) } static void -db_search(addr, size, value, mask, count) - register - db_addr_t addr; - int size; - db_expr_t value; - db_expr_t mask; - unsigned int count; +db_search(db_addr_t addr, int size, db_expr_t value, db_expr_t mask, + unsigned int count) { while (count-- != 0) { db_prev = addr; diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c index 171b3dac0a3..327f4903cd8 100644 --- a/sys/ddb/db_input.c +++ b/sys/ddb/db_input.c @@ -346,7 +346,7 @@ db_readline(lstart, lsize) } void -db_check_interrupt() +db_check_interrupt(void) { register int c; diff --git a/sys/ddb/db_lex.c b/sys/ddb/db_lex.c index 1c8151e5371..8a81046579a 100644 --- a/sys/ddb/db_lex.c +++ b/sys/ddb/db_lex.c @@ -49,7 +49,7 @@ static int db_read_char(void); static void db_unread_char(int); int -db_read_line() +db_read_line(void) { int i; @@ -97,7 +97,7 @@ db_flush_line() static int db_look_char = 0; static int -db_read_char() +db_read_char(void) { int c; @@ -148,7 +148,7 @@ char db_tok_string[TOK_STRING_SIZE]; db_expr_t db_radix = 16; void -db_flush_lex() +db_flush_lex(void) { db_flush_line(); db_look_char = 0; @@ -156,7 +156,7 @@ db_flush_lex() } static int -db_lex() +db_lex(void) { int c; diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index 8390a865d5d..a2afb6aba8e 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -91,7 +91,7 @@ static void db_pager(void); * Force pending whitespace. */ void -db_force_whitespace() +db_force_whitespace(void) { register int last_print, next_tab; @@ -308,7 +308,7 @@ db_pager(void) * Return output position */ int -db_print_position() +db_print_position(void) { return (db_output_position); } diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c index ce6704b3933..406b9ddd309 100644 --- a/sys/ddb/db_run.c +++ b/sys/ddb/db_run.c @@ -78,8 +78,7 @@ db_breakpoint_t db_taken_bkpt = 0; #endif boolean_t -db_stop_at_pc(is_breakpoint) - boolean_t *is_breakpoint; +db_stop_at_pc(boolean_t *is_breakpoint) { register db_addr_t pc; register db_breakpoint_t bkpt; @@ -180,8 +179,7 @@ db_stop_at_pc(is_breakpoint) } void -db_restart_at_pc(watchpt) - boolean_t watchpt; +db_restart_at_pc(boolean_t watchpt) { register db_addr_t pc = PC_REGS(); @@ -328,11 +326,8 @@ db_single_step_cmd(addr, have_addr, count, modif) /* trace and print until call/return */ /*ARGSUSED*/ void -db_trace_until_call_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_trace_until_call_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { boolean_t print = FALSE; @@ -350,11 +345,8 @@ db_trace_until_call_cmd(addr, have_addr, count, modif) /*ARGSUSED*/ void -db_trace_until_matching_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_trace_until_matching_cmd(db_expr_t addr, boolean_t have_addr, + db_expr_t count, char *modif) { boolean_t print = FALSE; @@ -374,11 +366,8 @@ db_trace_until_matching_cmd(addr, have_addr, count, modif) /* continue */ /*ARGSUSED*/ void -db_continue_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_continue_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { if (modif[0] == 'c') db_run_mode = STEP_COUNT; diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index 04af1eba535..ff6889edec9 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -170,11 +170,7 @@ db_var_curvnet(struct db_variable *vp, db_expr_t *valuep, int op) * Add symbol table, with given name, to list of symbol tables. */ void -db_add_symbol_table(start, end, name, ref) - char *start; - char *end; - char *name; - char *ref; +db_add_symbol_table(char *start, char *end, char *name, char *ref) { if (db_nsymtab >= MAXNOSYMTABS) { printf ("No slots left for %s symbol table", name); @@ -195,9 +191,7 @@ db_add_symbol_table(start, end, name, ref) * overwritten by each call... but in practice this seems okay. */ static char * -db_qualify(sym, symtabname) - c_db_sym_t sym; - register char *symtabname; +db_qualify(c_db_sym_t sym, char *symtabname) { const char *symname; static char tmp[256]; @@ -209,10 +203,7 @@ db_qualify(sym, symtabname) boolean_t -db_eqname(src, dst, c) - const char *src; - const char *dst; - int c; +db_eqname(const char *src, const char *dst, int c) { if (!strcmp(src, dst)) return (TRUE); @@ -222,9 +213,7 @@ db_eqname(src, dst, c) } boolean_t -db_value_of_name(name, valuep) - const char *name; - db_expr_t *valuep; +db_value_of_name(const char *name, db_expr_t *valuep) { c_db_sym_t sym; @@ -236,9 +225,7 @@ db_value_of_name(name, valuep) } boolean_t -db_value_of_name_pcpu(name, valuep) - const char *name; - db_expr_t *valuep; +db_value_of_name_pcpu(const char *name, db_expr_t *valuep) { static char tmp[256]; db_expr_t value; @@ -261,9 +248,7 @@ db_value_of_name_pcpu(name, valuep) } boolean_t -db_value_of_name_vnet(name, valuep) - const char *name; - db_expr_t *valuep; +db_value_of_name_vnet(const char *name, db_expr_t *valuep) { #ifdef VIMAGE static char tmp[256]; @@ -296,8 +281,7 @@ db_value_of_name_vnet(name, valuep) * otherwise, all symbol tables will be searched. */ static c_db_sym_t -db_lookup(symstr) - const char *symstr; +db_lookup(const char *symstr) { c_db_sym_t sp; register int i; @@ -354,8 +338,7 @@ static volatile boolean_t db_qualify_ambiguous_names = FALSE; * Used by db_symbol_values to decide whether to qualify a symbol. */ static boolean_t -db_symbol_is_ambiguous(sym) - c_db_sym_t sym; +db_symbol_is_ambiguous(c_db_sym_t sym) { const char *sym_name; register int i; @@ -381,10 +364,7 @@ db_symbol_is_ambiguous(sym) * and the difference between val and the symbol found. */ c_db_sym_t -db_search_symbol( val, strategy, offp) - register db_addr_t val; - db_strategy_t strategy; - db_expr_t *offp; +db_search_symbol(db_addr_t val, db_strategy_t strategy, db_expr_t *offp) { register unsigned int diff; @@ -409,10 +389,7 @@ db_search_symbol( val, strategy, offp) * Return name and value of a symbol */ void -db_symbol_values(sym, namep, valuep) - c_db_sym_t sym; - const char **namep; - db_expr_t *valuep; +db_symbol_values(c_db_sym_t sym, const char **namep, db_expr_t *valuep) { db_expr_t value; @@ -449,9 +426,7 @@ db_symbol_values(sym, namep, valuep) db_expr_t db_maxoff = 0x10000; void -db_printsym(off, strategy) - db_expr_t off; - db_strategy_t strategy; +db_printsym(db_expr_t off, db_strategy_t strategy) { db_expr_t d; char *filename; @@ -486,20 +461,13 @@ db_printsym(off, strategy) } static boolean_t -db_line_at_pc( sym, filename, linenum, pc) - c_db_sym_t sym; - char **filename; - int *linenum; - db_expr_t pc; +db_line_at_pc(c_db_sym_t sym, char **filename, int *linenum, db_expr_t pc) { return X_db_line_at_pc( db_last_symtab, sym, filename, linenum, pc); } int -db_sym_numargs(sym, nargp, argnames) - c_db_sym_t sym; - int *nargp; - char **argnames; +db_sym_numargs(c_db_sym_t sym, int *nargp, char **argnames) { return X_db_sym_numargs(db_last_symtab, sym, nargp, argnames); } diff --git a/sys/ddb/db_watch.c b/sys/ddb/db_watch.c index 44ca191f72c..8debdb797be 100644 --- a/sys/ddb/db_watch.c +++ b/sys/ddb/db_watch.c @@ -67,7 +67,7 @@ static void db_set_watchpoint(vm_map_t map, db_addr_t addr, vm_size_t size); static db_watchpoint_t -db_watchpoint_alloc() +db_watchpoint_alloc(void) { register db_watchpoint_t watch; @@ -86,18 +86,14 @@ db_watchpoint_alloc() } static void -db_watchpoint_free(watch) - register db_watchpoint_t watch; +db_watchpoint_free(db_watchpoint_t watch) { watch->link = db_free_watchpoints; db_free_watchpoints = watch; } static void -db_set_watchpoint(map, addr, size) - vm_map_t map; - db_addr_t addr; - vm_size_t size; +db_set_watchpoint(vm_map_t map, db_addr_t addr, vm_size_t size) { register db_watchpoint_t watch; @@ -137,9 +133,7 @@ db_set_watchpoint(map, addr, size) } static void -db_delete_watchpoint(map, addr) - vm_map_t map; - db_addr_t addr; +db_delete_watchpoint(vm_map_t map, db_addr_t addr) { register db_watchpoint_t watch; register db_watchpoint_t *prev; @@ -159,7 +153,7 @@ db_delete_watchpoint(map, addr) } static void -db_list_watchpoints() +db_list_watchpoints(void) { register db_watchpoint_t watch; @@ -189,11 +183,8 @@ db_list_watchpoints() /* Delete watchpoint */ /*ARGSUSED*/ void -db_deletewatch_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_deletewatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { db_delete_watchpoint(db_map_addr(addr), addr); } @@ -201,11 +192,8 @@ db_deletewatch_cmd(addr, have_addr, count, modif) /* Set watchpoint */ /*ARGSUSED*/ void -db_watchpoint_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_watchpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { vm_size_t size; db_expr_t value; @@ -230,7 +218,7 @@ DB_SHOW_COMMAND(watches, db_listwatch_cmd) } void -db_set_watchpoints() +db_set_watchpoints(void) { register db_watchpoint_t watch; @@ -248,17 +236,14 @@ db_set_watchpoints() } void -db_clear_watchpoints() +db_clear_watchpoints(void) { db_watchpoints_inserted = FALSE; } #ifdef notused static boolean_t -db_find_watchpoint(map, addr, regs) - vm_map_t map; - db_addr_t addr; - db_regs_t *regs; +db_find_watchpoint(vm_map_t map, db_addr_t addr, db_regs_t regs) { register db_watchpoint_t watch; db_watchpoint_t found = 0; @@ -295,11 +280,8 @@ db_find_watchpoint(map, addr, regs) /* Delete hardware watchpoint */ /*ARGSUSED*/ void -db_deletehwatch_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_deletehwatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { int rc; @@ -314,11 +296,8 @@ db_deletehwatch_cmd(addr, have_addr, count, modif) /* Set hardware watchpoint */ /*ARGSUSED*/ void -db_hwatchpoint_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_hwatchpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, + char *modif) { int rc; diff --git a/sys/ddb/db_write_cmd.c b/sys/ddb/db_write_cmd.c index 64d34736487..5cd5c952294 100644 --- a/sys/ddb/db_write_cmd.c +++ b/sys/ddb/db_write_cmd.c @@ -43,11 +43,8 @@ __FBSDID("$FreeBSD$"); */ /*ARGSUSED*/ void -db_write_cmd(address, have_addr, count, modif) - db_expr_t address; - boolean_t have_addr; - db_expr_t count; - char * modif; +db_write_cmd(db_expr_t address, boolean_t have_addr, db_expr_t count, + char * modif) { register db_addr_t addr; From 6461dd5c774d5e1242fddd431a3dedbff90499dd Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 12 Oct 2014 18:57:22 +0000 Subject: [PATCH 064/112] Remove stale comments. --- sys/cam/ctl/scsi_ctl.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index b8b93091a10..fbd20a35390 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -1513,11 +1513,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb) case CAM_MESSAGE_RECV: switch (inot->arg) { case MSG_ABORT_TASK_SET: - /* - * XXX KDM this isn't currently - * supported by CTL. It ends up - * being a no-op. - */ io->taskio.task_action = CTL_TASK_ABORT_TASK_SET; break; @@ -1534,11 +1529,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb) CTL_TASK_LUN_RESET; break; case MSG_CLEAR_TASK_SET: - /* - * XXX KDM this isn't currently - * supported by CTL. It ends up - * being a no-op. - */ io->taskio.task_action = CTL_TASK_CLEAR_TASK_SET; break; From d49c6f029c3aeb62bcea97004159377efb72692c Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Sun, 12 Oct 2014 19:12:48 +0000 Subject: [PATCH 065/112] Add an AC line monitor so power_profile can work Summary: Add a polling loop (1Hz) to monitor the battery and AC status, to notify devd like ACPI does for power monitoring. This allows /etc/rc.d/power_profile to work on PowerPC laptops Test Plan: Tested on a Titanium PowerBook, configuring economy_cpu_freq and performance_cpu_freq, disabling powerd. Reviewers: #powerpc, nwhitehorn Reviewed By: nwhitehorn Subscribers: rpaulo Differential Revision: https://reviews.freebsd.org/D937 --- etc/devd/apple.conf | 8 ++++++- sys/powerpc/powermac/pmu.c | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/etc/devd/apple.conf b/etc/devd/apple.conf index 8518890a5d6..7f066cdf5ad 100644 --- a/etc/devd/apple.conf +++ b/etc/devd/apple.conf @@ -71,4 +71,10 @@ notify 0 { action "camcontrol eject cd0"; }; - +# Equivalent to the ACPI/ACAD notify +notify 10 { + match "system" "PMU"; + match "subsystem" "POWER"; + match "type" "ACLINE"; + action "/etc/rc.d/power_profile $notify"; +} diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c index 913845e59bc..bb3147952d5 100644 --- a/sys/powerpc/powermac/pmu.c +++ b/sys/powerpc/powermac/pmu.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -183,6 +184,9 @@ static int pmu_send(void *cookie, int cmd, int length, uint8_t *in_msg, static uint8_t pmu_read_reg(struct pmu_softc *sc, u_int offset); static void pmu_write_reg(struct pmu_softc *sc, u_int offset, uint8_t value); static int pmu_intr_state(struct pmu_softc *); +static void pmu_battquery_proc(void); +static void pmu_battery_notify(struct pmu_battstate *batt, + struct pmu_battstate *old); /* these values shows that number of data returned after 'send' cmd is sent */ static signed char pm_send_cmd_type[] = { @@ -256,6 +260,13 @@ static signed char pm_receive_cmd_type[] = { -1, -1, -1, -1, -1, -1, -1, -1, }; +static struct proc *pmubattproc; +static struct kproc_desc pmu_batt_kp = { + "pmu_batt", + pmu_battquery_proc, + &pmubattproc +}; + /* We only have one of each device, so globals are safe */ static device_t pmu = NULL; static device_t pmu_extint = NULL; @@ -420,6 +431,8 @@ pmu_attach(device_t dev) struct sysctl_oid *oid, *battroot; char battnum[2]; + /* Only start the battery monitor if we have a battery. */ + kproc_start(&pmu_batt_kp); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "acline", CTLTYPE_INT | CTLFLAG_RD, sc, 0, pmu_acline_state, "I", "AC Line Status"); @@ -914,6 +927,39 @@ pmu_query_battery(struct pmu_softc *sc, int batt, struct pmu_battstate *info) return (0); } +static void +pmu_battery_notify(struct pmu_battstate *batt, struct pmu_battstate *old) +{ + char notify_buf[16]; + int acline; + + acline = (batt->state & PMU_PWR_AC_PRESENT) ? 1 : 0; + if (acline != (old->state & PMU_PWR_AC_PRESENT)) { + snprintf(notify_buf, sizeof(notify_buf), + "notify=0x%02x", acline); + devctl_notify("PMU", "POWER", "ACLINE", notify_buf); + } +} + +static void +pmu_battquery_proc() +{ + struct pmu_softc *sc; + struct pmu_battstate batt; + struct pmu_battstate cur_batt; + int error; + + sc = device_get_softc(pmu); + + error = pmu_query_battery(sc, 0, &cur_batt); + while (1) { + error = pmu_query_battery(sc, 0, &batt); + pmu_battery_notify(&batt, &cur_batt); + cur_batt = batt; + pause("pmu_batt", hz); + } +} + static int pmu_acline_state(SYSCTL_HANDLER_ARGS) { From f12a8d0b052646f62f391dfec0884f2762a52f6a Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 12 Oct 2014 21:53:13 +0000 Subject: [PATCH 066/112] Implement 64MB memory limit for test to ensure that it fails reliably in 600 seconds; it would previously fail inconsistently when run in some virtual machine configurations This patch might need to be reverted or revisited later (see the attached PR for more details) PR: 169302 Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/regex/t_exhaust.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c b/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c index 468492c293a..bc34441fe4c 100644 --- a/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c +++ b/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c @@ -45,6 +45,9 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $"); #include #include #include +#if defined(__FreeBSD__) +#include +#endif #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE 9999 @@ -176,14 +179,25 @@ ATF_TC_HEAD(regcomp_too_big, tc) " crash, but return a proper error code"); // libtre needs it. atf_tc_set_md_var(tc, "timeout", "600"); +#if defined(__FreeBSD__) + atf_tc_set_md_var(tc, "require.memory", "64M"); +#else atf_tc_set_md_var(tc, "require.memory", "120M"); +#endif } ATF_TC_BODY(regcomp_too_big, tc) { regex_t re; +#if defined(__FreeBSD__) + struct rlimit limit; +#endif int e; +#if defined(__FreeBSD__) + limit.rlim_cur = limit.rlim_max = 64 * 1024 * 1024; + ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1); +#endif for (size_t i = 0; i < __arraycount(tests); i++) { char *d = (*tests[i].pattern)(REGEX_MAXSIZE); e = regcomp(&re, d, tests[i].type); From 40187119b6ee4fcadf3b12dd95c37de3c12672df Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 12 Oct 2014 21:54:55 +0000 Subject: [PATCH 067/112] Fix compilation errors with missing wide-type headers and fix compilation warnings with -Wformat In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/regex/debug.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/regex/debug.c b/contrib/netbsd-tests/lib/libc/regex/debug.c index c1528b9e8c9..55655eb8cd9 100644 --- a/contrib/netbsd-tests/lib/libc/regex/debug.c +++ b/contrib/netbsd-tests/lib/libc/regex/debug.c @@ -34,6 +34,10 @@ #include #include +#if defined(__FreeBSD__) +#include +#include +#endif /* Don't sort these! */ #include "utils.h" @@ -50,6 +54,7 @@ static char *regchar(int); void regprint(regex_t *r, FILE *d) { +#if defined(__NetBSD__) struct re_guts *g = r->re_g; int c; int last; @@ -111,6 +116,7 @@ regprint(regex_t *r, FILE *d) } fprintf(d, "\n"); } +#endif } /* @@ -171,6 +177,7 @@ s_print(struct re_guts *g, FILE *d) break; case OANYOF: fprintf(d, "[(%ld)", (long)opnd); +#if defined(__NetBSD__) cs = &g->sets[opnd]; last = -1; for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */ @@ -187,6 +194,7 @@ s_print(struct re_guts *g, FILE *d) last = -1; } } +#endif fprintf(d, "]"); break; case OBACK_: @@ -242,7 +250,11 @@ s_print(struct re_guts *g, FILE *d) fprintf(d, ">"); break; default: +#if defined(__FreeBSD__) + fprintf(d, "!%ld(%ld)!", OP(*s), opnd); +#else fprintf(d, "!%d(%d)!", OP(*s), opnd); +#endif break; } if (!done) From 27d2e83dc4bdbc3a356bcd10fd56e31e871ca29c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 12 Oct 2014 21:59:23 +0000 Subject: [PATCH 068/112] - Add libutil #include for fparseln - Change ATF_REQUIRE_EQ_MSG to ATF_CHECK_EQ_MSG to gather all failing results possible (currently 12 with leftassoc) - Mark leftassoc "atf_tc_expect_fail" on FreeBSD (PR coming soon after further analysis is done on the code) In collaboration with: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/regex/t_regex_att.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c b/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c index beaeb04043b..fb8f2855f98 100644 --- a/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c +++ b/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c @@ -48,6 +48,9 @@ __RCSID("$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $"); #include #include #include +#if defined(__FreeBSD__) +#include +#endif static const char sep[] = "\r\n\t"; static const char delim[3] = "\\\\\0"; @@ -374,7 +377,11 @@ checkmatches(const char *matches, size_t nm, const regmatch_t *pm, " cur=%d, max=%zu", res, l, len - off); off += l; } +#if defined(__FreeBSD__) + ATF_CHECK_STREQ_MSG(res, matches, " at line %zu", lineno); +#else ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno); +#endif free(res); } @@ -572,6 +579,9 @@ ATF_TC_BODY(leftassoc, tc) * disabled this test in a very unconventional way without giving * any explation. Mark as broken here, but I don't know why. */ atf_tc_expect_fail("Reason for breakage unknown"); +#endif +#if defined(__FreeBSD__) + atf_tc_expect_fail("The expected and matched groups are mismatched on FreeBSD"); #endif att_test(tc, "leftassoc"); } From f96f5e21e0545d56ce0ea86cae6b59de3f3095f4 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sun, 12 Oct 2014 22:11:28 +0000 Subject: [PATCH 069/112] s/-/_/ in name. --- etc/rc.d/bgfsck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/bgfsck b/etc/rc.d/bgfsck index 101577ef90e..d15744c9051 100755 --- a/etc/rc.d/bgfsck +++ b/etc/rc.d/bgfsck @@ -9,7 +9,7 @@ . /etc/rc.subr -name="background-fsck" +name="background_fsck" rcvar="background_fsck" start_cmd="bgfsck_start" stop_cmd=":" From 489dcc9262ab468b1bab7cca09cea6fc25c07102 Mon Sep 17 00:00:00 2001 From: Julien Charbon Date: Sun, 12 Oct 2014 23:01:25 +0000 Subject: [PATCH 070/112] A connection in TIME_WAIT state before calling close() actually did not received any RST packet. Do not set error to ECONNRESET in this case. Differential Revision: https://reviews.freebsd.org/D879 Reviewed by: rpaulo, adrian Approved by: jhb (mentor) Sponsored by: Verisign, Inc. --- sys/netinet/tcp_usrreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 22a160ca2b2..17efea44083 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -592,7 +592,9 @@ tcp_usr_disconnect(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_disconnect: inp == NULL")); INP_WLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + if (inp->inp_flags & INP_TIMEWAIT) + goto out; + if (inp->inp_flags & INP_DROPPED) { error = ECONNRESET; goto out; } From 62141a34e7af20c4503c1341e0c2d3dcc4ff29ad Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 12 Oct 2014 23:46:24 +0000 Subject: [PATCH 071/112] Expect nice_err to fail on FreeBSD with unprivileged users PR: 189821 Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/gen/t_nice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_nice.c b/contrib/netbsd-tests/lib/libc/gen/t_nice.c index 67a0bf5507e..a0e912be6fb 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_nice.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_nice.c @@ -72,6 +72,11 @@ ATF_TC_BODY(nice_err, tc) { int i; +#if defined(__FreeBSD__) + atf_tc_expect_fail("nice(incr) with incr < 0 fails with unprivileged " + "users and sets errno == EPERM; see PR # 189821 for more details"); +#endif + /* * The call should fail with EPERM if the * supplied parameter is negative and the From 6ab4d70393cc22b63dccac9a06c98a00e89b5159 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Sun, 12 Oct 2014 23:48:55 +0000 Subject: [PATCH 072/112] Check error return from reading integer part of temperature. There's a very remote, but possible, chance that the integer part read will fail, but the fraction read succeeds, at which point the reported temperature is invalid. Reported by: Matthew Rezny MFC after: 3 weeks --- sys/dev/iicbus/max6690.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/iicbus/max6690.c b/sys/dev/iicbus/max6690.c index 5742e179f13..67bb042b39b 100644 --- a/sys/dev/iicbus/max6690.c +++ b/sys/dev/iicbus/max6690.c @@ -340,6 +340,10 @@ max6690_sensor_read(struct max6690_sensor *sens) } err = max6690_read(sc->sc_dev, sc->sc_addr, reg_int, &integer); + + if (err < 0) + return (-1); + err = max6690_read(sc->sc_dev, sc->sc_addr, reg_ext, &fraction); if (err < 0) From b081e68c536fb1a6aa2a354b4b020d5e0b947224 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 00:33:59 +0000 Subject: [PATCH 073/112] Add #include for printf Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/locale/t_wcstod.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c b/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c index 85b1ee16aaa..ef857772683 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c @@ -66,6 +66,10 @@ __RCSID("$NetBSD: t_wcstod.c,v 1.3 2011/10/01 17:56:11 christos Exp $"); #include +#if defined(__FreeBSD__) +#include +#endif + #define ALT_HUGE_VAL -1 #define ALT_MINUS_HUGE_VAL -2 #define ALT_NAN -3 From 416f6852e3161aa5d9dc6262695bbe695763fab8 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 13 Oct 2014 01:06:40 +0000 Subject: [PATCH 074/112] Remove ALC_LOCK_ASSERT in alc_stop_queue(). This function is now called in device attach without holding a driver lock so it resulted in panic. Reported by: markj --- sys/dev/alc/if_alc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index 6fed1423c21..2db8675b6cc 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -4394,8 +4394,6 @@ alc_stop_queue(struct alc_softc *sc) uint32_t reg; int i; - ALC_LOCK_ASSERT(sc); - /* Disable RxQ. */ reg = CSR_READ_4(sc, ALC_RXQ_CFG); if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { From effc369887f4deae35a52a1da532055000686373 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 01:14:01 +0000 Subject: [PATCH 075/112] Do initial port of contrib/netbsd-tests/lib/libc/locale t_io: - Expect failures potentially related to implementation-specific knowledge of the zh_TW.Big5 locale [*] t_mbrtowc: - Handle unknown locales more gracefully (do not test if the locale doesn't exist) - Expect failure with mbrtowc_internal dealing with Japanese locales (potentially related to implementation detail knowledge of the ja_* locales) [*]. t_mbstowcs, t_mbtowc, t_wctomb: - Handle unknown locales more gracefully (do not test if the locale doesn't exist) t_wcstod: - Treat FreeBSD like NetBSD and Linux in the XXX: FIXME section [*] More investigation is required to determine the root cause of the failures Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/locale/t_io.c | 13 +++++++++++++ contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c | 10 ++++++++++ contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c | 7 +++++++ contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c | 14 ++++++++++++++ contrib/netbsd-tests/lib/libc/locale/t_wcstod.c | 2 +- contrib/netbsd-tests/lib/libc/locale/t_wctomb.c | 7 +++++++ 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/contrib/netbsd-tests/lib/libc/locale/t_io.c b/contrib/netbsd-tests/lib/libc/locale/t_io.c index 782bed8f9e8..7f7293a02e1 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_io.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_io.c @@ -56,6 +56,11 @@ ATF_TC_BODY(bad_big5_wprintf, tc) /* XXX implementation detail knowledge (wchar_t encoding) */ wchar_t ibuf[] = { 0xcf10, 0 }; setlocale(LC_CTYPE, "zh_TW.Big5"); + +#if defined(__FreeBSD__) + atf_tc_expect_fail("does not fail as expected (may be implementation " + "specific issue with the test)"); +#endif ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0); ATF_REQUIRE(ferror(stdout)); } @@ -72,6 +77,11 @@ ATF_TC_BODY(bad_big5_swprintf, tc) wchar_t ibuf[] = { 0xcf10, 0 }; wchar_t obuf[20]; setlocale(LC_CTYPE, "zh_TW.Big5"); + +#if defined(__FreeBSD__) + atf_tc_expect_fail("does not fail as expected (may be implementation " + "specific issue with the test)"); +#endif ATF_REQUIRE_ERRNO(EILSEQ, swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf) < 0); } @@ -161,6 +171,9 @@ ATF_TC_BODY(bad_big5_getwc, tc) ATF_REQUIRE(fp != NULL); setlocale(LC_CTYPE, "zh_TW.Big5"); +#if defined(__FreeBSD__) + atf_tc_expect_fail("does not return WEOF as expected"); +#endif ATF_REQUIRE_EQ(getwc(fp), WEOF); fclose(fp); } diff --git a/contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c b/contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c index b4ad8411aed..7cab9739797 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c @@ -132,7 +132,14 @@ h_ctype2(const struct test *t, bool use_mbstate) size_t n; ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); +#if defined(__NetBSD__) ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL); +#else + if (setlocale(LC_CTYPE, t->locale) == NULL) { + fprintf(stderr, "Locale %s not found.\n", t->locale); + return; + } +#endif (void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL); (void)printf("Checking string: \"%s\"\n", buf); @@ -238,6 +245,9 @@ ATF_TC_BODY(mbrtowc_internal, tc) { struct test *t; +#if defined(__FreeBSD__) + atf_tc_expect_fail("ja_* locale fails"); +#endif for (t = &tests[0]; t->data != NULL; ++t) h_ctype2(t, false); } diff --git a/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c b/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c index ec0672907ab..7395d19bf17 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_mbstowcs.c @@ -150,7 +150,14 @@ ATF_TC_BODY(mbstowcs_basic, tc) int i; ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); +#if defined(__NetBSD__) ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL); +#else + if (setlocale(LC_CTYPE, t->locale) == NULL) { + fprintf(stderr, "Locale %s not found.\n", t->locale); + continue; + } +#endif (void)strvis(visbuf, t->data, VIS_WHITE | VIS_OCTAL); (void)printf("Checking string: \"%s\"\n", visbuf); diff --git a/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c b/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c index 62f62b10d50..bb690607fa0 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c @@ -76,7 +76,14 @@ h_mbtowc(const char *locale, const char *illegal, const char *legal) char *str; ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); +#if defined(__NetBSD__) ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL); +#else + if (setlocale(LC_CTYPE, locale) == NULL) { + fprintf(stderr, "Locale %s not found.\n", locale); + return; + } +#endif ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL); (void)printf("Using locale: %s\n", str); @@ -130,9 +137,16 @@ ATF_TC_BODY(mbtowc, tc) h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B"); h_mbtowc("ja_JP.SJIS", "\202", "\202\240"); h_mbtowc("ja_JP.eucJP", "\244", "\244\242"); +#if !defined(__FreeBSD__) + /* Moved last as it fails */ h_mbtowc("zh_CN.GB18030", "\241", "\241\241"); +#endif h_mbtowc("zh_TW.Big5", "\241", "\241@"); h_mbtowc("zh_TW.eucTW", "\241", "\241\241"); +#if defined(__FreeBSD__) + atf_tc_expect_fail("zh_CN.GB18030"); + h_mbtowc("zh_CN.GB18030", "\241", "\241\241"); +#endif } ATF_TP_ADD_TCS(tp) diff --git a/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c b/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c index ef857772683..fe7b468eb62 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_wcstod.c @@ -238,7 +238,7 @@ static struct test { { L" -0X.", 12, 0, 0 }, #endif /* XXX: FIXME */ -#if defined(__NetBSD__) || defined(__linux__) +#if defined(__NetBSD__) || defined(__linux__) || defined(__FreeBSD__) { L"0X.0", 4, 0, 0 }, { L"+0X.0", 5, 0, 0 }, { L"-0X.0", 5, 0, 0 }, diff --git a/contrib/netbsd-tests/lib/libc/locale/t_wctomb.c b/contrib/netbsd-tests/lib/libc/locale/t_wctomb.c index f553c8c511f..06016bf31f6 100644 --- a/contrib/netbsd-tests/lib/libc/locale/t_wctomb.c +++ b/contrib/netbsd-tests/lib/libc/locale/t_wctomb.c @@ -109,7 +109,14 @@ h_wctomb(const struct test *t, char tc) size_t sz, ret, i; ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); +#if defined(__NetBSD__) ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL); +#else + if (setlocale(LC_CTYPE, t->locale) == NULL) { + fprintf(stderr, "Locale %s not found.\n", t->locale); + return; + } +#endif (void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL); (void)printf("Checking sequence: \"%s\"\n", buf); From 21a9353bfdbd1d4e31e9452e1eb92febe3444b2c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 02:23:24 +0000 Subject: [PATCH 076/112] memmem with NUL length "needle" (aka small) strings on FreeBSD/OSX returns NULL instead of the "haystack" value (aka big) Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/string/t_memmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/string/t_memmem.c b/contrib/netbsd-tests/lib/libc/string/t_memmem.c index 1e87af892bd..8734bc3a955 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_memmem.c +++ b/contrib/netbsd-tests/lib/libc/string/t_memmem.c @@ -75,8 +75,13 @@ ATF_TC_HEAD(memmem_basic, tc) ATF_TC_BODY(memmem_basic, tc) { +#if defined(__darwin__) || defined(__FreeBSD__) + expect(memmem(b2, lb2, p0, lp0) == NULL); + expect(memmem(b0, lb0, p0, lp0) == NULL); +#else expect(memmem(b2, lb2, p0, lp0) == b2); expect(memmem(b0, lb0, p0, lp0) == b0); +#endif expect(memmem(b0, lb0, p1, lp1) == NULL); expect(memmem(b1, lb1, p1, lp1) == NULL); From ea441bc0617c0e026d03aef2586febe3f9b6875b Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 02:27:59 +0000 Subject: [PATCH 077/112] Use 1 as a random seed, as recommended in srandom(3). Adjust the random values accordingly Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/string/t_memcpy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c index 6485a88ae14..c9e52a379a2 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c +++ b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c @@ -51,7 +51,11 @@ unsigned char *start[BLOCKTYPES] = { }; char result[100]; +#if defined(__NetBSD__) const char goodResult[] = "7b405d24bc03195474c70ddae9e1f8fb"; +#else +const char goodResult[] = "217b4fbe456916bf62a2f85df752e4ab"; +#endif static void runTest(unsigned char *b1, unsigned char *b2) @@ -89,7 +93,15 @@ ATF_TC_BODY(memcpy_basic, tc) start[2] = auto1; start[3] = auto2; +#if defined(__NetBSD__) srandom(0L); +#else + /* + * random() shall produce by default a sequence of numbers that can be + * duplicated by calling srandom() with 1 as the seed. + */ + srandom(1); +#endif MD5Init(mc); for (i = 0; i < BLOCKTYPES; ++i) for (j = 0; j < BLOCKTYPES; ++j) From 267693b26960cf68ff09f7df986a1b15518ee700 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 02:29:58 +0000 Subject: [PATCH 078/112] Add #include to get sys_nerr definition Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/string/t_strerror.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/string/t_strerror.c b/contrib/netbsd-tests/lib/libc/string/t_strerror.c index c0e9c06e918..cb008d79ce8 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_strerror.c +++ b/contrib/netbsd-tests/lib/libc/string/t_strerror.c @@ -37,6 +37,10 @@ __RCSID("$NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $"); #include #include +#if defined(__FreeBSD__) +#include +#endif + ATF_TC(strerror_basic); ATF_TC_HEAD(strerror_basic, tc) { From 8a05dd85957b4c63be0344eddfbbfe7c9712b8f4 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 02:32:37 +0000 Subject: [PATCH 079/112] __isnanl is automatically picked according to data type in . There isn't a need for the explicit __isnanl test Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c index d7ebe1b628b..d11e6f0a16b 100644 --- a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c +++ b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c @@ -221,7 +221,9 @@ ATF_TC_BODY(strtold_nan, tc) volatile long double ld = strtold(nan_string, &end); ATF_REQUIRE(isnan(ld) != 0); +#if !defined(__FreeBSD__) ATF_REQUIRE(__isnanl(ld) != 0); +#endif ATF_REQUIRE(strcmp(end, "y") == 0); # else atf_tc_skip("Requires long double support"); From 13727fa5e8e10e51188cd4bcdfc963e46c143ee2 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 02:44:35 +0000 Subject: [PATCH 080/112] Only test the return value in mktime_negyear Testing for the errno is an optional requirement according to POSIX, and FreeBSD doesn't document that errno would be set on failure with mktime Submitted by: pho Sponsored by: EMC / Isilon Storage Division --- contrib/netbsd-tests/lib/libc/time/t_mktime.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/time/t_mktime.c b/contrib/netbsd-tests/lib/libc/time/t_mktime.c index 8092361dbc3..caef9065cc9 100644 --- a/contrib/netbsd-tests/lib/libc/time/t_mktime.c +++ b/contrib/netbsd-tests/lib/libc/time/t_mktime.c @@ -72,7 +72,12 @@ ATF_TC_BODY(mktime_negyear, tc) errno = 0; t = mktime(&tms); +#if defined(__FreeBSD__) + /* Open Group says "and may set errno to indicate the error" */ + ATF_REQUIRE(t == (time_t)-1); +#else ATF_REQUIRE_ERRNO(0, t != (time_t)-1); +#endif } ATF_TC(timegm_epoch); From e58fb51fc761b11efb3f12efde2c44b1e5e0b56c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 13 Oct 2014 03:55:47 +0000 Subject: [PATCH 081/112] Change ATF_REQUIRE_MSG calls to ATF_CHECK_MSG to get as many errors as possible t_strptime:common.. - Expect the testcase body as a whole to fail. Multiple PRs will be filed to track the issues (there are 18 check failures) t_strptime:day.. - %EA and %OA seem to be case insensitive on FreeBSD --- .../netbsd-tests/lib/libc/time/t_strptime.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/time/t_strptime.c b/contrib/netbsd-tests/lib/libc/time/t_strptime.c index c0f9cdf7958..7808891b640 100644 --- a/contrib/netbsd-tests/lib/libc/time/t_strptime.c +++ b/contrib/netbsd-tests/lib/libc/time/t_strptime.c @@ -49,6 +49,17 @@ h_pass(const char *buf, const char *fmt, int len, exp = buf + len; ret = strptime(buf, fmt, &tm); +#if defined(__FreeBSD__) + ATF_CHECK_MSG(ret == exp, + "strptime(\"%s\", \"%s\", tm): incorrect return code: " + "expected: %p, got: %p", buf, fmt, exp, ret); + +#define H_REQUIRE_FIELD(field) \ + ATF_CHECK_MSG(tm.field == field, \ + "strptime(\"%s\", \"%s\", tm): incorrect %s: " \ + "expected: %d, but got: %d", buf, fmt, \ + ___STRING(field), field, tm.field) +#else ATF_REQUIRE_MSG(ret == exp, "strptime(\"%s\", \"%s\", tm): incorrect return code: " "expected: %p, got: %p", buf, fmt, exp, ret); @@ -58,6 +69,7 @@ h_pass(const char *buf, const char *fmt, int len, "strptime(\"%s\", \"%s\", tm): incorrect %s: " \ "expected: %d, but got: %d", buf, fmt, \ ___STRING(field), field, tm.field) +#endif H_REQUIRE_FIELD(tm_sec); H_REQUIRE_FIELD(tm_min); @@ -76,8 +88,13 @@ h_fail(const char *buf, const char *fmt) { struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL }; +#if defined(__FreeBSD__) + ATF_CHECK_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", " + "\"%s\", &tm) should fail, but it didn't", buf, fmt); +#else ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", " "\"%s\", &tm) should fail, but it didn't", buf, fmt); +#endif } ATF_TC(common); @@ -91,6 +108,10 @@ ATF_TC_HEAD(common, tc) ATF_TC_BODY(common, tc) { +#if defined(__FreeBSD__) + atf_tc_expect_fail("There are various issues with strptime on FreeBSD"); +#endif + h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y", 24, 46, 27, 23, 20, 0, 98, 2, -1); h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y", @@ -168,9 +189,17 @@ ATF_TC_BODY(day, tc) h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1); h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1); h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1); +#if defined(__NetBSD__) h_fail("sunday", "%EA"); +#else + h_pass("Sunday", "%EA", 6, -1, -1, -1, -1, -1, -1, 0, -1); +#endif h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1); +#if defined(__NetBSD__) h_fail("SaturDay", "%OA"); +#else + h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1); +#endif } ATF_TC(month); From a4f5b8db9f48c5c7511b3b79ae4853a4526d2c0a Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 13 Oct 2014 05:34:10 +0000 Subject: [PATCH 082/112] Add a tunable for arc_shrink_shift (vfs.zfs.arc_shrink_shift) that controls how much fraction, 1/2^arc_shrink_shift, should be reclaimed when there is memory pressure. Submitted by: Richard Kojedzinszky MFC after: 2 weeks --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index 60d2ff99961..33f308b859a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -217,6 +217,7 @@ SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY, arc_free_target_init, NULL); TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit); +TUNABLE_INT("vfs.zfs.arc_shrink_shift", &zfs_arc_shrink_shift); SYSCTL_DECL(_vfs_zfs); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0, "Maximum ARC size"); @@ -225,6 +226,10 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, &zfs_arc_min, 0, SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_blocksize, CTLFLAG_RDTUN, &zfs_arc_average_blocksize, 0, "ARC average blocksize"); +SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, + &arc_shrink_shift, 0, + "log2(fraction of arc to reclaim)"); + /* * We don't have a tunable for arc_free_target due to the dependency on * pagedaemon initialisation. From 3f52cae506d857e6e6cc61b2eafa0f0af2f946cc Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Mon, 13 Oct 2014 06:50:08 +0000 Subject: [PATCH 083/112] Make sure correct object code is generated at -O0. Submitted by: grehan@ Approved by: so@ (des) MFC after: 1 month --- sys/dev/random/ivy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/random/ivy.c b/sys/dev/random/ivy.c index cb82adc47f7..23fd542e5c1 100644 --- a/sys/dev/random/ivy.c +++ b/sys/dev/random/ivy.c @@ -79,7 +79,7 @@ ivy_rng_store(long *buf) "2:\n\t" "mov %2,%1\n\t" /* *buf = tmp */ "3:" - : "+q" (retry), "=m" (*buf), "=q" (tmp) : : "cc"); + : "+q" (retry), "=m" (*buf), "+q" (tmp) : : "cc"); return (retry); #else /* __GNUCLIKE_ASM */ return (0); From 6ad1954bcb1e83d33892cc77b261fcf292f35c67 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 13 Oct 2014 06:51:40 +0000 Subject: [PATCH 084/112] Eliminate unnecessary checking for M_EXT on mbufs returned by m_getjcl(). Reviewed by: bz, glebius, yongari MFC after: 3 days Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D938 --- sys/dev/msk/if_msk.c | 4 ---- sys/dev/nfe/if_nfe.c | 4 ---- sys/dev/sk/if_sk.c | 4 ---- 3 files changed, 12 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 16e7485a911..90474e4e411 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -962,10 +962,6 @@ msk_jumbo_newbuf(struct msk_if_softc *sc_if, int idx) m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); - return (ENOBUFS); - } m->m_len = m->m_pkthdr.len = MJUM9BYTES; if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) m_adj(m, ETHER_ALIGN); diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index 1675f032bdd..4c7ccb1a619 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -2063,10 +2063,6 @@ nfe_jnewbuf(struct nfe_softc *sc, int idx) m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); - return (ENOBUFS); - } m->m_pkthdr.len = m->m_len = MJUM9BYTES; m_adj(m, ETHER_ALIGN); diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 9898370ad62..2678390eb8e 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1012,10 +1012,6 @@ sk_jumbo_newbuf(sc_if, idx) m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); - return (ENOBUFS); - } m->m_pkthdr.len = m->m_len = MJUM9BYTES; /* * Adjust alignment so packet payload begins on a From 20a28d6cee775cadf1e5a2ecbf02f6ba6f2b424b Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 13 Oct 2014 11:00:58 +0000 Subject: [PATCH 085/112] Report physical block size for file-backed LUNs, using vattr.va_blocksize. MFC after: 1 week --- sys/cam/ctl/ctl_backend_block.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index e9852348513..2d3c368bf83 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -1542,6 +1542,7 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) struct ctl_be_block_filedata *file_data; struct ctl_lun_create_params *params; struct vattr vattr; + off_t pss; int error; error = 0; @@ -1590,21 +1591,21 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req) be_lun->flags |= CTL_BE_BLOCK_LUN_MULTI_THREAD; /* - * XXX KDM vattr.va_blocksize may be larger than 512 bytes here. - * With ZFS, it is 131072 bytes. Block sizes that large don't work - * with disklabel and UFS on FreeBSD at least. Large block sizes - * may not work with other OSes as well. So just export a sector - * size of 512 bytes, which should work with any OS or - * application. Since our backing is a file, any block size will - * work fine for the backing store. + * For files we can use any logical block size. Prefer 512 bytes + * for compatibility reasons. If file's vattr.va_blocksize + * (preferred I/O block size) is bigger and multiple to chosen + * logical block size -- report it as physical block size. */ -#if 0 - be_lun->blocksize= vattr.va_blocksize; -#endif if (params->blocksize_bytes != 0) be_lun->blocksize = params->blocksize_bytes; else be_lun->blocksize = 512; + pss = vattr.va_blocksize / be_lun->blocksize; + if ((pss > 0) && (pss * be_lun->blocksize == vattr.va_blocksize) && + ((pss & (pss - 1)) == 0)) { + be_lun->pblockexp = fls(pss) - 1; + be_lun->pblockoff = 0; + } /* * Sanity check. The media size has to be at least one From 60f485ca9feb648d6e1e98f1054d29ce0c72e307 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Mon, 13 Oct 2014 11:26:17 +0000 Subject: [PATCH 086/112] * Fix zeroing individual entries via ipfw(8). * Report error and return non-zero exit code if zeroing non-matched entries Found by: Oleg Ginzburg --- sbin/ipfw/ipfw2.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index 6b6424c9981..ac79ef8c3d6 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -2111,13 +2111,19 @@ static int do_range_cmd(int cmd, ipfw_range_tlv *rt) { ipfw_range_header rh; + size_t sz; memset(&rh, 0, sizeof(rh)); memcpy(&rh.range, rt, sizeof(*rt)); rh.range.head.length = sizeof(*rt); rh.range.head.type = IPFW_TLV_RANGE; + sz = sizeof(rh); - return (do_set3(cmd, &rh.opheader, sizeof(rh))); + if (do_get3(cmd, &rh.opheader, &sz) != 0) + return (-1); + /* Save number of matched objects */ + rt->new_set = rh.range.new_set; + return (0); } /* @@ -4792,6 +4798,9 @@ ipfw_zero(int ac, char *av[], int optname) warn("rule %u: setsockopt(IP_FW_X%s)", arg, name); failed = EX_UNAVAILABLE; + } else if (rt.new_set == 0) { + printf("Entry %d not found\n", arg); + failed = EX_UNAVAILABLE; } else if (!co.do_quiet) printf("Entry %d %s.\n", arg, optname == IP_FW_XZERO ? @@ -4799,6 +4808,7 @@ ipfw_zero(int ac, char *av[], int optname) } else { errx(EX_USAGE, "invalid rule number ``%s''", *av); } + av++; ac--; } if (failed != EX_OK) exit(failed); From 6ca0dd05f44e2baf9db686957dffca358bceb425 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Mon, 13 Oct 2014 12:49:04 +0000 Subject: [PATCH 087/112] Show error when deleting non-existing rule number. Found by: Oleg Ginzburg --- sbin/ipfw/ipfw2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index ac79ef8c3d6..242451922fd 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -3009,7 +3009,6 @@ fill_flags_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, void ipfw_delete(char *av[]) { - uint32_t rulenum; int i; int exitval = EX_OK; int do_set = 0; @@ -3059,7 +3058,15 @@ ipfw_delete(char *av[]) if (i != 0) { exitval = EX_UNAVAILABLE; warn("rule %u: setsockopt(IP_FW_XDEL)", - rulenum); + rt.start_rule); + } else if (rt.new_set == 0) { + exitval = EX_UNAVAILABLE; + if (rt.start_rule != rt.end_rule) + warnx("no rules rules in %u-%u range", + rt.start_rule, rt.end_rule); + else + warnx("rule %u not found", + rt.start_rule); } } } From 9bfafa105547b490aab3f0cf465485024184e989 Mon Sep 17 00:00:00 2001 From: Christian Brueffer Date: Mon, 13 Oct 2014 13:13:42 +0000 Subject: [PATCH 088/112] Add one more AMD Kaveri APU device ID. Submitted by: Remy Nonnenmacher MFC after: 1 week --- sys/dev/amdtemp/amdtemp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c index 48a4c1d9e48..54f47ce14d8 100644 --- a/sys/dev/amdtemp/amdtemp.c +++ b/sys/dev/amdtemp/amdtemp.c @@ -80,6 +80,7 @@ struct amdtemp_softc { #define DEVICEID_AMD_MISC14 0x1703 #define DEVICEID_AMD_MISC15 0x1603 #define DEVICEID_AMD_MISC16 0x1533 +#define DEVICEID_AMD_MISC17 0x141d static struct amdtemp_product { uint16_t amdtemp_vendorid; @@ -92,6 +93,7 @@ static struct amdtemp_product { { VENDORID_AMD, DEVICEID_AMD_MISC14 }, { VENDORID_AMD, DEVICEID_AMD_MISC15 }, { VENDORID_AMD, DEVICEID_AMD_MISC16 }, + { VENDORID_AMD, DEVICEID_AMD_MISC17 }, { 0, 0 } }; From 2930362fb17c172dd1cadc923badbb65f4851241 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Mon, 13 Oct 2014 13:49:28 +0000 Subject: [PATCH 089/112] Fix matching default rule on clear/show commands. Found by: Oleg Ginzburg --- sys/netinet/ip_fw.h | 5 +++++ sys/netpfil/ipfw/ip_fw_sockopt.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h index ed61b4fe5fe..ab9ec63e626 100644 --- a/sys/netinet/ip_fw.h +++ b/sys/netinet/ip_fw.h @@ -886,6 +886,11 @@ typedef struct _ipfw_range_tlv { #define IPFW_RCFLAG_RANGE 0x01 /* rule range is set */ #define IPFW_RCFLAG_ALL 0x02 /* match ALL rules */ #define IPFW_RCFLAG_SET 0x04 /* match rules in given set */ +/* User-settable flags */ +#define IPFW_RCFLAG_USER (IPFW_RCFLAG_RANGE | IPFW_RCFLAG_ALL | \ + IPFW_RCFLAG_SET) +/* Internally used flags */ +#define IPFW_RCFLAG_DEFAULT 0x0100 /* Do not skip defaul rule */ typedef struct _ipfw_ta_tinfo { uint32_t flags; /* Format flags */ diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index 048ad933c6a..0c0d022dd8b 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -833,8 +833,9 @@ int ipfw_match_range(struct ip_fw *rule, ipfw_range_tlv *rt) { - /* Don't match default rule regardless of query */ - if (rule->rulenum == IPFW_DEFAULT_RULE) + /* Don't match default rule for modification queries */ + if (rule->rulenum == IPFW_DEFAULT_RULE && + (rt->flags & IPFW_RCFLAG_DEFAULT) == 0) return (0); /* Don't match rules in reserved set for flush requests */ @@ -965,7 +966,7 @@ move_range(struct ip_fw_chain *chain, ipfw_range_tlv *rt) } /* XXX: We have to do swap holding WLOCK */ - for (i = 0; i < chain->n_rules - 1; i++) { + for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; if (ipfw_match_range(rule, rt) == 0) continue; @@ -1006,9 +1007,10 @@ clear_range(struct ip_fw_chain *chain, ipfw_range_tlv *rt, int log_only) int i; num = 0; + rt->flags |= IPFW_RCFLAG_DEFAULT; IPFW_UH_WLOCK(chain); /* arbitrate writers */ - for (i = 0; i < chain->n_rules - 1; i++) { + for (i = 0; i < chain->n_rules; i++) { rule = chain->map[i]; if (ipfw_match_range(rule, rt) == 0) continue; @@ -1031,6 +1033,9 @@ check_range_tlv(ipfw_range_tlv *rt) if (rt->set >= IPFW_MAX_SETS || rt->new_set >= IPFW_MAX_SETS) return (1); + if ((rt->flags & IPFW_RCFLAG_USER) != rt->flags) + return (1); + return (0); } @@ -2012,7 +2017,7 @@ dump_config(struct ip_fw_chain *chain, ip_fw3_opheader *op3, da.b = ipfw_find_rule(chain, rnum, 0); rnum = hdr->end_rule; rnum = (rnum < IPFW_DEFAULT_RULE) ? rnum+1 : IPFW_DEFAULT_RULE; - da.e = ipfw_find_rule(chain, rnum, 0); + da.e = ipfw_find_rule(chain, rnum, 0) + 1; } if (hdr->flags & IPFW_CFG_GET_STATIC) { From d70698b372ef9f3b231ba590542889e9c652fc87 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 13 Oct 2014 14:48:49 +0000 Subject: [PATCH 090/112] Add support for READ DEFECT DATA (10/12) commands. SPC-4 r2 allows to return empty defect list if the list is not supported. We don't reallu support defect data lists, but this suppresses some errors. MFC after: 1 week --- sys/cam/ctl/ctl.c | 83 +++++++++++++++++++++++++++++++++++++ sys/cam/ctl/ctl_cmd_table.c | 12 +++++- sys/cam/ctl/ctl_private.h | 1 + sys/cam/scsi/scsi_da.h | 45 ++++++-------------- 4 files changed, 107 insertions(+), 34 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 66e00f9cf63..175cbc98d45 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -7388,6 +7388,89 @@ ctl_read_capacity_16(struct ctl_scsiio *ctsio) return (CTL_RETVAL_COMPLETE); } +int +ctl_read_defect(struct ctl_scsiio *ctsio) +{ + struct scsi_read_defect_data_10 *ccb10; + struct scsi_read_defect_data_12 *ccb12; + struct scsi_read_defect_data_hdr_10 *data10; + struct scsi_read_defect_data_hdr_12 *data12; + struct ctl_lun *lun; + uint32_t alloc_len, data_len; + uint8_t format; + + CTL_DEBUG_PRINT(("ctl_read_defect\n")); + + lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; + if (lun->flags & CTL_LUN_PR_RESERVED) { + uint32_t residx; + + /* + * XXX KDM need a lock here. + */ + residx = ctl_get_resindex(&ctsio->io_hdr.nexus); + if ((lun->res_type == SPR_TYPE_EX_AC + && residx != lun->pr_res_idx) + || ((lun->res_type == SPR_TYPE_EX_AC_RO + || lun->res_type == SPR_TYPE_EX_AC_AR) + && lun->pr_keys[residx] == 0)) { + ctl_set_reservation_conflict(ctsio); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } + } + + if (ctsio->cdb[0] == READ_DEFECT_DATA_10) { + ccb10 = (struct scsi_read_defect_data_10 *)&ctsio->cdb; + format = ccb10->format; + alloc_len = scsi_2btoul(ccb10->alloc_length); + data_len = sizeof(*data10); + } else { + ccb12 = (struct scsi_read_defect_data_12 *)&ctsio->cdb; + format = ccb12->format; + alloc_len = scsi_4btoul(ccb12->alloc_length); + data_len = sizeof(*data12); + } + if (alloc_len == 0) { + ctl_set_success(ctsio); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } + + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); + if (data_len < alloc_len) { + ctsio->residual = alloc_len - data_len; + ctsio->kern_data_len = data_len; + ctsio->kern_total_len = data_len; + } else { + ctsio->residual = 0; + ctsio->kern_data_len = alloc_len; + ctsio->kern_total_len = alloc_len; + } + ctsio->kern_data_resid = 0; + ctsio->kern_rel_offset = 0; + ctsio->kern_sg_entries = 0; + + if (ctsio->cdb[0] == READ_DEFECT_DATA_10) { + data10 = (struct scsi_read_defect_data_hdr_10 *) + ctsio->kern_data_ptr; + data10->format = format; + scsi_ulto2b(0, data10->length); + } else { + data12 = (struct scsi_read_defect_data_hdr_12 *) + ctsio->kern_data_ptr; + data12->format = format; + scsi_ulto2b(0, data12->generation); + scsi_ulto4b(0, data12->length); + } + + ctsio->scsi_status = SCSI_STATUS_OK; + ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; + ctsio->be_move_done = ctl_config_move_done; + ctl_datamove((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); +} + int ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) { diff --git a/sys/cam/ctl/ctl_cmd_table.c b/sys/cam/ctl/ctl_cmd_table.c index f1093005d28..c1c1673fe5a 100644 --- a/sys/cam/ctl/ctl_cmd_table.c +++ b/sys/cam/ctl/ctl_cmd_table.c @@ -768,7 +768,11 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, /* 37 READ DEFECT DATA(10) */ -{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, +{ctl_read_defect, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_SLUN | + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, + CTL_LUN_PAT_NONE, + 10, {0, 0x1f, 0, 0, 0, 0, 0xff, 0xff, 0x07}}, /* 38 MEDIUM SCAN */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, @@ -1247,7 +1251,11 @@ const struct ctl_cmd_entry ctl_cmd_table[256] = {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, /* B7 READ DEFECT DATA(12) */ -{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, +{ctl_read_defect, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_SLUN | + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, + CTL_LUN_PAT_NONE, + 12, {0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}}, /* B8 READ ELEMENT STATUS */ {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h index aeea63d785a..30418dfa96e 100644 --- a/sys/cam/ctl/ctl_private.h +++ b/sys/cam/ctl/ctl_private.h @@ -486,6 +486,7 @@ int ctl_mode_select(struct ctl_scsiio *ctsio); int ctl_mode_sense(struct ctl_scsiio *ctsio); int ctl_read_capacity(struct ctl_scsiio *ctsio); int ctl_read_capacity_16(struct ctl_scsiio *ctsio); +int ctl_read_defect(struct ctl_scsiio *ctsio); int ctl_read_write(struct ctl_scsiio *ctsio); int ctl_cnw(struct ctl_scsiio *ctsio); int ctl_report_luns(struct ctl_scsiio *ctsio); diff --git a/sys/cam/scsi/scsi_da.h b/sys/cam/scsi/scsi_da.h index a27b17325b1..f48d327b35b 100644 --- a/sys/cam/scsi/scsi_da.h +++ b/sys/cam/scsi/scsi_da.h @@ -92,28 +92,19 @@ struct scsi_reassign_blocks struct scsi_read_defect_data_10 { - u_int8_t opcode; - - /* - * The most significant 3 bits are the LUN, the other 5 are - * reserved. - */ -#define SRDD10_LUN_MASK 0xE0 - u_int8_t byte2; + uint8_t opcode; + uint8_t byte2; #define SRDD10_GLIST 0x08 #define SRDD10_PLIST 0x10 #define SRDD10_DLIST_FORMAT_MASK 0x07 #define SRDD10_BLOCK_FORMAT 0x00 #define SRDD10_BYTES_FROM_INDEX_FORMAT 0x04 #define SRDD10_PHYSICAL_SECTOR_FORMAT 0x05 - u_int8_t format; - - u_int8_t reserved[4]; - - u_int8_t alloc_length[2]; + uint8_t format; + uint8_t reserved[4]; + uint8_t alloc_length[2]; #define SRDD10_MAX_LENGTH 0xffff - - u_int8_t control; + uint8_t control; }; struct scsi_sanitize @@ -143,29 +134,18 @@ struct scsi_sanitize_parameter_list struct scsi_read_defect_data_12 { - u_int8_t opcode; - - /* - * The most significant 3 bits are the LUN, the other 5 are - * reserved. - */ -#define SRDD12_LUN_MASK 0xE0 - u_int8_t byte2; - + uint8_t opcode; #define SRDD12_GLIST 0x08 #define SRDD12_PLIST 0x10 #define SRDD12_DLIST_FORMAT_MASK 0x07 #define SRDD12_BLOCK_FORMAT 0x00 #define SRDD12_BYTES_FROM_INDEX_FORMAT 0x04 #define SRDD12_PHYSICAL_SECTOR_FORMAT 0x05 - u_int8_t format; - - u_int8_t reserved[4]; - - u_int8_t alloc_length[4]; - - u_int8_t control; - + uint8_t format; + uint8_t address_descriptor_index[4]; + uint8_t alloc_length[4]; + uint8_t reserved; + uint8_t control; }; @@ -376,6 +356,7 @@ struct scsi_read_defect_data_hdr_12 #define SRDDH12_BYTES_FROM_INDEX_FORMAT 0x04 #define SRDDH12_PHYSICAL_SECTOR_FORMAT 0x05 u_int8_t format; + u_int8_t generation[2]; u_int8_t length[4]; }; From f5fb223710cb6645ec9a3fe309c4ae6138148f02 Mon Sep 17 00:00:00 2001 From: Kashyap D Desai Date: Mon, 13 Oct 2014 15:33:27 +0000 Subject: [PATCH 091/112] Fix for build issue on i386.xen and amd64.xen. This is a duplicate variable reference in mrsas, so now this patch isolate atomic_ variable and relavent function call using prefix mrsas_xx. Issue was introduced in r272737. MFC after: 2 weeks Sponsored by: Avago Technology --- sys/dev/mrsas/mrsas.c | 22 +++++++++++----------- sys/dev/mrsas/mrsas.h | 22 +++++++++++----------- sys/dev/mrsas/mrsas_cam.c | 4 ++-- sys/dev/mrsas/mrsas_fp.c | 6 +++--- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/sys/dev/mrsas/mrsas.c b/sys/dev/mrsas/mrsas.c index ba15848b230..24738ebb7f2 100644 --- a/sys/dev/mrsas/mrsas.c +++ b/sys/dev/mrsas/mrsas.c @@ -850,7 +850,7 @@ mrsas_attach(device_t dev) TAILQ_INIT(&sc->mrsas_mpt_cmd_list_head); TAILQ_INIT(&sc->mrsas_mfi_cmd_list_head); - atomic_set(&sc->fw_outstanding, 0); + mrsas_atomic_set(&sc->fw_outstanding, 0); sc->io_cmds_highwater = 0; @@ -1392,7 +1392,7 @@ mrsas_isr(void *arg) return; } /* If we are resetting, bail */ - if (test_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags)) { + if (mrsas_test_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags)) { printf(" Entered into ISR when OCR is going active. \n"); mrsas_clear_intr(sc); return; @@ -1462,7 +1462,7 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex) lbinfo = &sc->load_balance_info[device_id]; if (cmd_mpt->load_balance == MRSAS_LOAD_BALANCE_FLAG) { arm = lbinfo->raid1DevHandle[0] == scsi_io_req->DevHandle ? 0 : 1; - atomic_dec(&lbinfo->scsi_pending_cmds[arm]); + mrsas_atomic_dec(&lbinfo->scsi_pending_cmds[arm]); cmd_mpt->load_balance &= ~MRSAS_LOAD_BALANCE_FLAG; } /* Fall thru and complete IO */ @@ -1471,7 +1471,7 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex) mrsas_cmd_done(sc, cmd_mpt); scsi_io_req->RaidContext.status = 0; scsi_io_req->RaidContext.exStatus = 0; - atomic_dec(&sc->fw_outstanding); + mrsas_atomic_dec(&sc->fw_outstanding); break; case MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST: /* MFI command */ cmd_mfi = sc->mfi_cmd_list[cmd_mpt->sync_cmd_idx]; @@ -2672,7 +2672,7 @@ mrsas_reset_ctrl(struct mrsas_softc *sc) "mrsas: Hardware critical error, returning FAIL.\n"); return FAIL; } - set_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); + mrsas_set_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); sc->adprecovery = MRSAS_ADPRESET_SM_INFAULT; mrsas_disable_intr(sc); DELAY(1000 * 1000); @@ -2689,7 +2689,7 @@ mrsas_reset_ctrl(struct mrsas_softc *sc) ccb = (union ccb *)(mpt_cmd->ccb_ptr); ccb->ccb_h.status = CAM_SCSI_BUS_RESET; mrsas_cmd_done(sc, mpt_cmd); - atomic_dec(&sc->fw_outstanding); + mrsas_atomic_dec(&sc->fw_outstanding); } } @@ -2787,7 +2787,7 @@ mrsas_reset_ctrl(struct mrsas_softc *sc) mrsas_dprint(sc, MRSAS_OCR, "mrsas_ioc_init() failed!\n"); continue; } - clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); + mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); mrsas_enable_intr(sc); sc->adprecovery = MRSAS_HBA_OPERATIONAL; @@ -2833,12 +2833,12 @@ mrsas_reset_ctrl(struct mrsas_softc *sc) mrsas_kill_hba(sc); retval = FAIL; } else { - clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); + mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); mrsas_enable_intr(sc); sc->adprecovery = MRSAS_HBA_OPERATIONAL; } out: - clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); + mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); mrsas_dprint(sc, MRSAS_OCR, "Reset Exit with %d.\n", retval); return retval; @@ -2890,7 +2890,7 @@ mrsas_wait_for_outstanding(struct mrsas_softc *sc) retval = 1; goto out; } - outstanding = atomic_read(&sc->fw_outstanding); + outstanding = mrsas_atomic_read(&sc->fw_outstanding); if (!outstanding) goto out; @@ -2904,7 +2904,7 @@ mrsas_wait_for_outstanding(struct mrsas_softc *sc) DELAY(1000 * 1000); } - if (atomic_read(&sc->fw_outstanding)) { + if (mrsas_atomic_read(&sc->fw_outstanding)) { mrsas_dprint(sc, MRSAS_OCR, " pending commands remain after waiting," " will reset adapter.\n"); diff --git a/sys/dev/mrsas/mrsas.h b/sys/dev/mrsas/mrsas.h index 87f73a9ffdd..16dc95dfc5a 100644 --- a/sys/dev/mrsas/mrsas.h +++ b/sys/dev/mrsas/mrsas.h @@ -101,7 +101,7 @@ __FBSDID("$FreeBSD$"); */ #define BYTE_ALIGNMENT 1 #define MRSAS_MAX_NAME_LENGTH 32 -#define MRSAS_VERSION "06.705.10.01-fbsd" +#define MRSAS_VERSION "06.705.10.02-fbsd" #define MRSAS_ULONG_MAX 0xFFFFFFFFFFFFFFFF #define MRSAS_DEFAULT_TIMEOUT 0x14 /* Temporarily set */ #define DONE 0 @@ -513,12 +513,12 @@ Mpi2ReplyDescriptorsUnion_t, MPI2_POINTER pMpi2ReplyDescriptorsUnion_t; typedef struct { volatile unsigned int val; -} atomic_t; +} mrsas_atomic_t; -#define atomic_read(v) atomic_load_acq_int(&(v)->val) -#define atomic_set(v,i) atomic_store_rel_int(&(v)->val, i) -#define atomic_dec(v) atomic_fetchadd_int(&(v)->val, -1) -#define atomic_inc(v) atomic_fetchadd_int(&(v)->val, 1) +#define mrsas_atomic_read(v) atomic_load_acq_int(&(v)->val) +#define mrsas_atomic_set(v,i) atomic_store_rel_int(&(v)->val, i) +#define mrsas_atomic_dec(v) atomic_fetchadd_int(&(v)->val, -1) +#define mrsas_atomic_inc(v) atomic_fetchadd_int(&(v)->val, 1) /* IOCInit Request message */ typedef struct _MPI2_IOC_INIT_REQUEST { @@ -813,7 +813,7 @@ typedef struct _LD_LOAD_BALANCE_INFO { u_int8_t loadBalanceFlag; u_int8_t reserved1; u_int16_t raid1DevHandle[2]; - atomic_t scsi_pending_cmds[2]; + mrsas_atomic_t scsi_pending_cmds[2]; u_int64_t last_accessed_block[2]; } LD_LOAD_BALANCE_INFO, *PLD_LOAD_BALANCE_INFO; @@ -2524,7 +2524,7 @@ struct mrsas_softc { bus_addr_t ctlr_info_phys_addr; u_int32_t max_sectors_per_req; u_int8_t disableOnlineCtrlReset; - atomic_t fw_outstanding; + mrsas_atomic_t fw_outstanding; u_int32_t mrsas_debug; u_int32_t mrsas_io_timeout; u_int32_t mrsas_fw_fault_check_delay; @@ -2577,19 +2577,19 @@ struct mrsas_softc { #endif static __inline void -clear_bit(int b, volatile void *p) +mrsas_clear_bit(int b, volatile void *p) { atomic_clear_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f)); } static __inline void -set_bit(int b, volatile void *p) +mrsas_set_bit(int b, volatile void *p) { atomic_set_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f)); } static __inline int -test_bit(int b, volatile void *p) +mrsas_test_bit(int b, volatile void *p) { return ((volatile int *)p)[b >> 5] & (1 << (b & 0x1f)); } diff --git a/sys/dev/mrsas/mrsas_cam.c b/sys/dev/mrsas/mrsas_cam.c index c454f7bb669..b92bb5b3dae 100644 --- a/sys/dev/mrsas/mrsas_cam.c +++ b/sys/dev/mrsas/mrsas_cam.c @@ -532,9 +532,9 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim, */ callout_reset(&cmd->cm_callout, (sc->mrsas_io_timeout * hz) / 1000, mrsas_scsiio_timeout, cmd); - atomic_inc(&sc->fw_outstanding); + mrsas_atomic_inc(&sc->fw_outstanding); - if (atomic_read(&sc->fw_outstanding) > sc->io_cmds_highwater) + if (mrsas_atomic_read(&sc->fw_outstanding) > sc->io_cmds_highwater) sc->io_cmds_highwater++; mrsas_fire_cmd(sc, req_desc->addr.u.low, req_desc->addr.u.high); diff --git a/sys/dev/mrsas/mrsas_fp.c b/sys/dev/mrsas/mrsas_fp.c index 19bb4e428c5..cd0d57f3077 100644 --- a/sys/dev/mrsas/mrsas_fp.c +++ b/sys/dev/mrsas/mrsas_fp.c @@ -1347,8 +1347,8 @@ mrsas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm, u_int8_t bestArm; /* get the pending cmds for the data and mirror arms */ - pend0 = atomic_read(&lbInfo->scsi_pending_cmds[0]); - pend1 = atomic_read(&lbInfo->scsi_pending_cmds[1]); + pend0 = mrsas_atomic_read(&lbInfo->scsi_pending_cmds[0]); + pend1 = mrsas_atomic_read(&lbInfo->scsi_pending_cmds[1]); /* Determine the disk whose head is nearer to the req. block */ diff0 = ABS_DIFF(block, lbInfo->last_accessed_block[0]); @@ -1382,7 +1382,7 @@ mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo, /* get best new arm */ arm = mrsas_get_best_arm(lbInfo, old_arm, io_info->ldStartBlock, io_info->numBlocks); devHandle = lbInfo->raid1DevHandle[arm]; - atomic_inc(&lbInfo->scsi_pending_cmds[arm]); + mrsas_atomic_inc(&lbInfo->scsi_pending_cmds[arm]); return devHandle; } From 56d8b96cbc3bd204e30061ff5c554f0c9acb3662 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 13 Oct 2014 15:35:08 +0000 Subject: [PATCH 092/112] Start removing the omap3 support. In base it was only ever a header and a few changes to drivers, no kernel config was added. As the SoCs are quite old and the code is unmaintained start the process of removing support by deleting the header file and code that depends on it along with the macro SOC_OMAP3. Other Ti SoCs shouldn't be affected, other than for us to have less code to maintain. Differential Revision: https://reviews.freebsd.org/D936 Reviewed by: rpaulo, loos --- sys/arm/ti/omap3/omap3_reg.h | 780 ----------------------------------- sys/arm/ti/ti_cpuid.c | 65 --- sys/arm/ti/ti_cpuid.h | 7 +- sys/arm/ti/ti_gpio.c | 47 +-- sys/arm/ti/ti_i2c.c | 4 - sys/arm/ti/ti_mmchs.c | 4 +- sys/arm/ti/ti_sdhci.c | 4 +- 7 files changed, 5 insertions(+), 906 deletions(-) delete mode 100644 sys/arm/ti/omap3/omap3_reg.h diff --git a/sys/arm/ti/omap3/omap3_reg.h b/sys/arm/ti/omap3/omap3_reg.h deleted file mode 100644 index 3b4e2ea2599..00000000000 --- a/sys/arm/ti/omap3/omap3_reg.h +++ /dev/null @@ -1,780 +0,0 @@ -/*- - * Copyright (c) 2011 - * Ben Gray . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * Texas Instruments - OMAP3xxx series processors - * - * Reference: - * OMAP35x Applications Processor - * Technical Reference Manual - * (omap35xx_techref.pdf) - * - * - * Note: - * The devices are mapped into address above 0xD000_0000 as the kernel space - * memory is at 0xC000_0000 and above. The first 256MB after this is reserved - * for the size of the kernel, everything above that is reserved for SoC - * devices. - * - */ -#ifndef _OMAP35XX_REG_H_ -#define _OMAP35XX_REG_H_ - -#ifndef _LOCORE -#include /* for uint32_t */ -#endif - - - - -#define OMAP35XX_SDRAM0_START 0x80000000UL -#define OMAP35XX_SDRAM1_START 0xA0000000UL -#define OMAP35XX_SDRAM_BANKS 2 -#define OMAP35XX_SDRAM_BANK_SIZE 0x20000000UL - - -/* Physical/Virtual address for SDRAM controller */ - -#define OMAP35XX_SMS_VBASE 0x6C000000UL -#define OMAP35XX_SMS_HWBASE 0x6C000000UL -#define OMAP35XX_SMS_SIZE 0x01000000UL - -#define OMAP35XX_SDRC_VBASE 0x6D000000UL -#define OMAP35XX_SDRC_HWBASE 0x6D000000UL -#define OMAP35XX_SDRC_SIZE 0x01000000UL - - - -/* Physical/Virtual address for I/O space */ - -#define OMAP35XX_L3_VBASE 0xD0000000UL -#define OMAP35XX_L3_HWBASE 0x68000000UL -#define OMAP35XX_L3_SIZE 0x01000000UL - -#define OMAP35XX_L4_CORE_VBASE 0xE8000000UL -#define OMAP35XX_L4_CORE_HWBASE 0x48000000UL -#define OMAP35XX_L4_CORE_SIZE 0x01000000UL - -#define OMAP35XX_L4_WAKEUP_VBASE 0xE8300000UL -#define OMAP35XX_L4_WAKEUP_HWBASE 0x48300000UL -#define OMAP35XX_L4_WAKEUP_SIZE 0x00040000UL - -#define OMAP35XX_L4_PERIPH_VBASE 0xE9000000UL -#define OMAP35XX_L4_PERIPH_HWBASE 0x49000000UL -#define OMAP35XX_L4_PERIPH_SIZE 0x00100000UL - - -/* - * L4-CORE Physical/Virtual addresss offsets - */ -#define OMAP35XX_SCM_OFFSET 0x00002000UL -#define OMAP35XX_CM_OFFSET 0x00004000UL -#define OMAP35XX_SDMA_OFFSET 0x00056000UL -#define OMAP35XX_I2C3_OFFSET 0x00060000UL -#define OMAP35XX_USB_TLL_OFFSET 0x00062000UL -#define OMAP35XX_USB_UHH_OFFSET 0x00064000UL -#define OMAP35XX_USB_EHCI_OFFSET 0x00064800UL - - -#define OMAP35XX_UART1_OFFSET 0x0006A000UL -#define OMAP35XX_UART2_OFFSET 0x0006C000UL -#define OMAP35XX_I2C1_OFFSET 0x00070000UL -#define OMAP35XX_I2C2_OFFSET 0x00072000UL -#define OMAP35XX_MCBSP1_OFFSET 0x00074000UL -#define OMAP35XX_GPTIMER10_OFFSET 0x00086000UL -#define OMAP35XX_GPTIMER11_OFFSET 0x00088000UL -#define OMAP35XX_MCBSP5_OFFSET 0x00096000UL -#define OMAP35XX_MMU1_OFFSET 0x000BD400UL -#define OMAP35XX_INTCPS_OFFSET 0x00200000UL - - -/* - * L4-WAKEUP Physical/Virtual addresss offsets - */ -#define OMAP35XX_PRM_OFFSET 0x00006000UL -#define OMAP35XX_GPIO1_OFFSET 0x00010000UL -#define OMAP35XX_GPTIMER1_OFFSET 0x00018000UL - - - -/* - * L4-PERIPH Physical/Virtual addresss offsets - */ -#define OMAP35XX_UART3_OFFSET 0x00020000UL -#define OMAP35XX_MCBSP2_OFFSET 0x00022000UL -#define OMAP35XX_MCBSP3_OFFSET 0x00024000UL -#define OMAP35XX_MCBSP4_OFFSET 0x00026000UL -#define OMAP35XX_SIDETONE_MCBSP2_OFFSET 0x00028000UL -#define OMAP35XX_SIDETONE_MCBSP3_OFFSET 0x0002A000UL -#define OMAP35XX_GPTIMER2_OFFSET 0x00032000UL -#define OMAP35XX_GPTIMER3_OFFSET 0x00034000UL -#define OMAP35XX_GPTIMER4_OFFSET 0x00036000UL -#define OMAP35XX_GPTIMER5_OFFSET 0x00038000UL -#define OMAP35XX_GPTIMER6_OFFSET 0x0003A000UL -#define OMAP35XX_GPTIMER7_OFFSET 0x0003C000UL -#define OMAP35XX_GPTIMER8_OFFSET 0x0003E000UL -#define OMAP35XX_GPTIMER9_OFFSET 0x00040000UL -#define OMAP35XX_GPIO2_OFFSET 0x00050000UL -#define OMAP35XX_GPIO3_OFFSET 0x00052000UL -#define OMAP35XX_GPIO4_OFFSET 0x00054000UL -#define OMAP35XX_GPIO5_OFFSET 0x00056000UL -#define OMAP35XX_GPIO6_OFFSET 0x00058000UL - - - - - - -/* - * System Control Module - */ -#define OMAP35XX_SCM_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_SCM_OFFSET) -#define OMAP35XX_SCM_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_SCM_OFFSET) -#define OMAP35XX_SCM_SIZE 0x00001000UL - -#define OMAP35XX_SCM_REVISION 0x00000000UL -#define OMAP35XX_SCM_SYSCONFIG 0x00000010UL -#define OMAP35XX_SCM_PADCONFS_BASE 0x00000030UL -#define OMAP35XX_SCM_DEVCONF0 0x00000274UL -#define OMAP35XX_SCM_MEM_DFTRW0 0x00000278UL - - - - -/* - * - */ -#define OMAP35XX_CM_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_CM_OFFSET) -#define OMAP35XX_CM_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_CM_OFFSET) -#define OMAP35XX_CM_SIZE 0x00001500UL - -#define OMAP35XX_CM_CORE_OFFSET 0x00000A00UL -#define OMAP35XX_CM_CORE_SIZE 0x00000100UL -#define OMAP35XX_CM_FCLKEN1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0000UL) -#define OMAP35XX_CM_FCLKEN3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0008UL) -#define OMAP35XX_CM_ICLKEN1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0010UL) -#define OMAP35XX_CM_ICLKEN2_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0014UL) -#define OMAP35XX_CM_ICLKEN3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0018UL) -#define OMAP35XX_CM_IDLEST1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0020UL) -#define OMAP35XX_CM_IDLEST2_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0024UL) -#define OMAP35XX_CM_IDLEST3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0028UL) -#define OMAP35XX_CM_AUTOIDLE1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0030UL) -#define OMAP35XX_CM_AUTOIDLE2_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0034UL) -#define OMAP35XX_CM_AUTOIDLE3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0038UL) -#define OMAP35XX_CM_CLKSEL_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0040UL) -#define OMAP35XX_CM_CLKSTCTRL_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0048UL) -#define OMAP35XX_CM_CLKSTST_CORE (OMAP35XX_CM_CORE_OFFSET + 0x004CUL) - -#define OMAP35XX_CM_WKUP_OFFSET 0x00000C00UL -#define OMAP35XX_CM_WKUP_SIZE 0x00000100UL -#define OMAP35XX_CM_FCLKEN_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0000UL) -#define OMAP35XX_CM_ICLKEN_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0010UL) -#define OMAP35XX_CM_IDLEST_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0020UL) -#define OMAP35XX_CM_AUTOIDLE_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0030UL) -#define OMAP35XX_CM_CLKSEL_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0040UL) - -#define OMAP35XX_CM_PLL_OFFSET 0x00000D00UL -#define OMAP35XX_CM_PLL_SIZE 0x00000100UL -#define OMAP35XX_CM_CLKEN_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0000UL) -#define OMAP35XX_CM_CLKEN2_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0004UL) -#define OMAP35XX_CM_IDLEST_CKGEN (OMAP35XX_CM_PLL_OFFSET + 0x0020UL) -#define OMAP35XX_CM_IDLEST2_CKGEN (OMAP35XX_CM_PLL_OFFSET + 0x0024UL) -#define OMAP35XX_CM_AUTOIDLE_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0030UL) -#define OMAP35XX_CM_AUTOIDLE2_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0034UL) -#define OMAP35XX_CM_CLKSEL1_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0040UL) -#define OMAP35XX_CM_CLKSEL2_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0044UL) -#define OMAP35XX_CM_CLKSEL3_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0048UL) -#define OMAP35XX_CM_CLKSEL4_PLL (OMAP35XX_CM_PLL_OFFSET + 0x004CUL) -#define OMAP35XX_CM_CLKSEL5_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0050UL) -#define OMAP35XX_CM_CLKOUT_CTRL (OMAP35XX_CM_PLL_OFFSET + 0x0070UL) - -#define OMAP35XX_CM_PER_OFFSET 0x00001000UL -#define OMAP35XX_CM_PER_SIZE 0x00000100UL -#define OMAP35XX_CM_FCLKEN_PER (OMAP35XX_CM_PER_OFFSET + 0x0000UL) -#define OMAP35XX_CM_ICLKEN_PER (OMAP35XX_CM_PER_OFFSET + 0x0010UL) -#define OMAP35XX_CM_IDLEST_PER (OMAP35XX_CM_PER_OFFSET + 0x0020UL) -#define OMAP35XX_CM_AUTOIDLE_PER (OMAP35XX_CM_PER_OFFSET + 0x0030UL) -#define OMAP35XX_CM_CLKSEL_PER (OMAP35XX_CM_PER_OFFSET + 0x0040UL) -#define OMAP35XX_CM_SLEEPDEP_PER (OMAP35XX_CM_PER_OFFSET + 0x0044UL) -#define OMAP35XX_CM_CLKSTCTRL_PER (OMAP35XX_CM_PER_OFFSET + 0x0048UL) -#define OMAP35XX_CM_CLKSTST_PER (OMAP35XX_CM_PER_OFFSET + 0x004CUL) - -#define OMAP35XX_CM_USBHOST_OFFSET 0x00001400UL -#define OMAP35XX_CM_USBHOST_SIZE 0x00000100UL -#define OMAP35XX_CM_FCLKEN_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0000UL) -#define OMAP35XX_CM_ICLKEN_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0010UL) -#define OMAP35XX_CM_IDLEST_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0020UL) -#define OMAP35XX_CM_AUTOIDLE_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0030UL) -#define OMAP35XX_CM_SLEEPDEP_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0044UL) -#define OMAP35XX_CM_CLKSTCTRL_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0048UL) -#define OMAP35XX_CM_CLKSTST_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x004CUL) - - - - -/* - * - */ -#define OMAP35XX_PRM_HWBASE (OMAP35XX_L4_WAKEUP_HWBASE + OMAP35XX_PRM_OFFSET) -#define OMAP35XX_PRM_VBASE (OMAP35XX_L4_WAKEUP_VBASE + OMAP35XX_PRM_OFFSET) -#define OMAP35XX_PRM_SIZE 0x00001600UL - -#define OMAP35XX_PRM_CLKCTRL_OFFSET 0x00000D00UL -#define OMAP35XX_PRM_CLKCTRL_SIZE 0x00000100UL -#define OMAP35XX_PRM_CLKSEL (OMAP35XX_PRM_CLKCTRL_OFFSET + 0x0040UL) -#define OMAP35XX_PRM_CLKOUT_CTRL (OMAP35XX_PRM_CLKCTRL_OFFSET + 0x0070UL) - -#define OMAP35XX_PRM_GLOBAL_OFFSET 0x00001200UL -#define OMAP35XX_PRM_GLOBAL_SIZE 0x00000100UL -#define OMAP35XX_PRM_CLKSRC_CTRL (OMAP35XX_PRM_GLOBAL_OFFSET + 0x0070UL) - - - - - -/* - * Uarts - */ -#define OMAP35XX_UART1_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_UART1_OFFSET) -#define OMAP35XX_UART1_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_UART1_OFFSET) -#define OMAP35XX_UART1_SIZE 0x00001000UL - -#define OMAP35XX_UART2_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_UART2_OFFSET) -#define OMAP35XX_UART2_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_UART2_OFFSET) -#define OMAP35XX_UART2_SIZE 0x00001000UL - -#define OMAP35XX_UART3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_UART3_OFFSET) -#define OMAP35XX_UART3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_UART3_OFFSET) -#define OMAP35XX_UART3_SIZE 0x00001000UL - - - - -/* - * I2C Modules - */ -#define OMAP35XX_I2C1_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_I2C1_OFFSET) -#define OMAP35XX_I2C1_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_I2C1_OFFSET) -#define OMAP35XX_I2C1_SIZE 0x00000080UL - -#define OMAP35XX_I2C2_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_I2C2_OFFSET) -#define OMAP35XX_I2C2_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_I2C2_OFFSET) -#define OMAP35XX_I2C2_SIZE 0x00000080UL - -#define OMAP35XX_I2C3_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_I2C3_OFFSET) -#define OMAP35XX_I2C3_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_I2C3_OFFSET) -#define OMAP35XX_I2C3_SIZE 0x00000080UL - -#define OMAP35XX_I2C_IE 0x04 -#define OMAP35XX_I2C_STAT 0x08 -#define OMAP35XX_I2C_WE 0x0C -#define OMAP35XX_I2C_SYSS 0x10 -#define OMAP35XX_I2C_BUF 0x14 -#define OMAP35XX_I2C_CNT 0x18 -#define OMAP35XX_I2C_DATA 0x1C -#define OMAP35XX_I2C_SYSC 0x20 -#define OMAP35XX_I2C_CON 0x24 -#define OMAP35XX_I2C_OA0 0x28 -#define OMAP35XX_I2C_SA 0x2C -#define OMAP35XX_I2C_PSC 0x30 -#define OMAP35XX_I2C_SCLL 0x34 -#define OMAP35XX_I2C_SCLH 0x38 -#define OMAP35XX_I2C_SYSTEST 0x3C -#define OMAP35XX_I2C_BUFSTAT 0x40 -#define OMAP35XX_I2C_OA1 0x44 -#define OMAP35XX_I2C_OA2 0x48 -#define OMAP35XX_I2C_OA3 0x4C -#define OMAP35XX_I2C_ACTOA 0x50 -#define OMAP35XX_I2C_SBLOCK 0x54 - - - -/* - * McBSP Modules - */ -#define OMAP35XX_MCBSP1_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_MCBSP1_OFFSET) -#define OMAP35XX_MCBSP1_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_MCBSP1_OFFSET) -#define OMAP35XX_MCBSP1_SIZE 0x00001000UL - -#define OMAP35XX_MCBSP2_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_MCBSP2_OFFSET) -#define OMAP35XX_MCBSP2_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_MCBSP2_OFFSET) -#define OMAP35XX_MCBSP2_SIZE 0x00001000UL - -#define OMAP35XX_MCBSP3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_MCBSP3_OFFSET) -#define OMAP35XX_MCBSP3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_MCBSP3_OFFSET) -#define OMAP35XX_MCBSP3_SIZE 0x00001000UL - -#define OMAP35XX_MCBSP4_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_MCBSP4_OFFSET) -#define OMAP35XX_MCBSP4_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_MCBSP4_OFFSET) -#define OMAP35XX_MCBSP4_SIZE 0x00001000UL - -#define OMAP35XX_MCBSP5_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_MCBSP5_OFFSET) -#define OMAP35XX_MCBSP5_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_MCBSP5_OFFSET) -#define OMAP35XX_MCBSP5_SIZE 0x00001000UL - -#define OMAP35XX_MCBSP_DRR 0x0000 -#define OMAP35XX_MCBSP_DXR 0x0008 -#define OMAP35XX_MCBSP_SPCR2 0x0010 -#define OMAP35XX_MCBSP_SPCR1 0x0014 -#define OMAP35XX_MCBSP_RCR2 0x0018 -#define OMAP35XX_MCBSP_RCR1 0x001C -#define OMAP35XX_MCBSP_XCR2 0x0020 -#define OMAP35XX_MCBSP_XCR1 0x0024 -#define OMAP35XX_MCBSP_SRGR2 0x0028 -#define OMAP35XX_MCBSP_SRGR1 0x002C -#define OMAP35XX_MCBSP_MCR2 0x0030 -#define OMAP35XX_MCBSP_MCR1 0x0034 -#define OMAP35XX_MCBSP_RCERA 0x0038 -#define OMAP35XX_MCBSP_RCERB 0x003C -#define OMAP35XX_MCBSP_XCERA 0x0040 -#define OMAP35XX_MCBSP_XCERB 0x0044 -#define OMAP35XX_MCBSP_PCR 0x0048 -#define OMAP35XX_MCBSP_RCERC 0x004C -#define OMAP35XX_MCBSP_RCERD 0x0050 -#define OMAP35XX_MCBSP_XCERC 0x0054 -#define OMAP35XX_MCBSP_XCERD 0x0058 -#define OMAP35XX_MCBSP_RCERE 0x005C -#define OMAP35XX_MCBSP_RCERF 0x0060 -#define OMAP35XX_MCBSP_XCERE 0x0064 -#define OMAP35XX_MCBSP_XCERF 0x0068 -#define OMAP35XX_MCBSP_RCERG 0x006C -#define OMAP35XX_MCBSP_RCERH 0x0070 -#define OMAP35XX_MCBSP_XCERG 0x0074 -#define OMAP35XX_MCBSP_XCERH 0x0078 -#define OMAP35XX_MCBSP_RINTCLR 0x0080 -#define OMAP35XX_MCBSP_XINTCLR 0x0084 -#define OMAP35XX_MCBSP_ROVFLCLR 0x0088 -#define OMAP35XX_MCBSP_SYSCONFIG 0x008C -#define OMAP35XX_MCBSP_THRSH2 0x0090 -#define OMAP35XX_MCBSP_THRSH1 0x0094 -#define OMAP35XX_MCBSP_IRQSTATUS 0x00A0 -#define OMAP35XX_MCBSP_IRQENABLE 0x00A4 -#define OMAP35XX_MCBSP_WAKEUPEN 0x00A8 -#define OMAP35XX_MCBSP_XCCR 0x00AC -#define OMAP35XX_MCBSP_RCCR 0x00B0 -#define OMAP35XX_MCBSP_XBUFFSTAT 0x00B4 -#define OMAP35XX_MCBSP_RBUFFSTAT 0x00B8 -#define OMAP35XX_MCBSP_SSELCR 0x00BC -#define OMAP35XX_MCBSP_STATUS 0x00C0 - - - -/* - * USB TTL Module - */ -#define OMAP35XX_USBTLL_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USBTLL_OFFSET) -#define OMAP35XX_USBTLL_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USBTLL_OFFSET) -#define OMAP35XX_USBTLL_SIZE 0x00001000UL - -#define OMAP35XX_USBTLL_REVISION 0x0000 -#define OMAP35XX_USBTLL_SYSCONFIG 0x0010 -#define OMAP35XX_USBTLL_SYSSTATUS 0x0014 -#define OMAP35XX_USBTLL_IRQSTATUS 0x0018 -#define OMAP35XX_USBTLL_IRQENABLE 0x001C -#define OMAP35XX_USBTLL_TLL_SHARED_CONF 0x0030 -#define OMAP35XX_USBTLL_TLL_CHANNEL_CONF(i) (0x0040 + (0x04 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_ID_LO(i) (0x0800 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_ID_HI(i) (0x0801 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_PRODUCT_ID_LO(i) (0x0802 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_PRODUCT_ID_HI(i) (0x0803 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_FUNCTION_CTRL(i) (0x0804 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_FUNCTION_CTRL_SET(i) (0x0805 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_FUNCTION_CTRL_CLR(i) (0x0806 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_INTERFACE_CTRL(i) (0x0807 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_INTERFACE_CTRL_SET(i) (0x0808 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_INTERFACE_CTRL_CLR(i) (0x0809 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_OTG_CTRL(i) (0x080A + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_OTG_CTRL_SET(i) (0x080B + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_OTG_CTRL_CLR(i) (0x080C + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_RISE(i) (0x080D + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_RISE_SET(i) (0x080E + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_RISE_CLR(i) (0x080F + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_FALL(i) (0x0810 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_FALL_SET(i) (0x0811 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_FALL_CLR(i) (0x0812 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_STATUS(i) (0x0813 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_LATCH(i) (0x0814 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_DEBUG(i) (0x0815 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_SCRATCH_REGISTER(i) (0x0816 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_SCRATCH_REGISTER_SET(i) (0x0817 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_SCRATCH_REGISTER_CLR(i) (0x0818 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_EXTENDED_SET_ACCESS(i) (0x082F + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_EN(i) (0x0830 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_EN_SET(i) (0x0831 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_EN_CLR(i) (0x0832 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_STATUS(i) (0x0833 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_LATCH(i) (0x0834 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VSTATUS(i) (0x0835 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VSTATUS_SET(i) (0x0836 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_UTMI_VSTATUS_CLR(i) (0x0837 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_USB_INT_LATCH_NOCLR(i) (0x0838 + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_EN(i) (0x083B + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_EN_SET(i) (0x083C + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_EN_CLR(i) (0x083D + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_STATUS(i) (0x083E + (0x100 * (i))) -#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_LATCH(i) (0x083F + (0x100 * (i))) - - -/* - * USB Host Module - */ -#define OMAP35XX_USB_TLL_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USB_TLL_OFFSET) -#define OMAP35XX_USB_TLL_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USB_TLL_OFFSET) -#define OMAP35XX_USB_TLL_SIZE 0x00001000UL - -#define OMAP35XX_USB_EHCI_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USB_EHCI_OFFSET) -#define OMAP35XX_USB_EHCI_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USB_EHCI_OFFSET) -#define OMAP35XX_USB_EHCI_SIZE 0x00000400UL - -#define OMAP35XX_USB_UHH_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USB_UHH_OFFSET) -#define OMAP35XX_USB_UHH_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USB_UHH_OFFSET) -#define OMAP35XX_USB_UHH_SIZE 0x00000400UL - - - - - -/* - * SDRAM Controler (SDRC) - * PA 0x6D00_0000 - */ - -#define OMAP35XX_SDRC_SYSCONFIG (OMAP35XX_SDRC_VBASE + 0x10) -#define OMAP35XX_SDRC_SYSSTATUS (OMAP35XX_SDRC_VBASE + 0x14) -#define OMAP35XX_SDRC_CS_CFG (OMAP35XX_SDRC_VBASE + 0x40) -#define OMAP35XX_SDRC_SHARING (OMAP35XX_SDRC_VBASE + 0x44) -#define OMAP35XX_SDRC_ERR_ADDR (OMAP35XX_SDRC_VBASE + 0x48) -#define OMAP35XX_SDRC_ERR_TYPE (OMAP35XX_SDRC_VBASE + 0x4C) -#define OMAP35XX_SDRC_DLLA_CTRL (OMAP35XX_SDRC_VBASE + 0x60) -#define OMAP35XX_SDRC_DLLA_STATUS (OMAP35XX_SDRC_VBASE + 0x64) -#define OMAP35XX_SDRC_POWER_REG (OMAP35XX_SDRC_VBASE + 0x70) -#define OMAP35XX_SDRC_MCFG(p) (OMAP35XX_SDRC_VBASE + 0x80 + (0x30 * (p))) -#define OMAP35XX_SDRC_MR(p) (OMAP35XX_SDRC_VBASE + 0x84 + (0x30 * (p))) -#define OMAP35XX_SDRC_EMR2(p) (OMAP35XX_SDRC_VBASE + 0x8C + (0x30 * (p))) -#define OMAP35XX_SDRC_ACTIM_CTRLA(p) (OMAP35XX_SDRC_VBASE + 0x9C + (0x28 * (p))) -#define OMAP35XX_SDRC_ACTIM_CTRLB(p) (OMAP35XX_SDRC_VBASE + 0xA0 + (0x28 * (p))) -#define OMAP35XX_SDRC_RFR_CTRL(p) (OMAP35XX_SDRC_VBASE + 0xA4 + (0x30 * (p))) -#define OMAP35XX_SDRC_MANUAL(p) (OMAP35XX_SDRC_VBASE + 0xA8 + (0x30 * (p))) - - -/* - * SDMA Offset - * PA 0x4805 6000 - */ - -#define OMAP35XX_SDMA_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_SDMA_OFFSET) -#define OMAP35XX_SDMA_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_SDMA_OFFSET) -#define OMAP35XX_SDMA_SIZE 0x00001000UL - - - -/* - * Interrupt Controller Unit. - * PA 0x4820_0000 - */ - -#define OMAP35XX_INTCPS_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_INTCPS_OFFSET) -#define OMAP35XX_INTCPS_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_INTCPS_OFFSET) -#define OMAP35XX_INTCPS_SIZE 0x00001000UL - -#define OMAP35XX_INTCPS_SYSCONFIG (OMAP35XX_INTCPS_VBASE + 0x10) -#define OMAP35XX_INTCPS_SYSSTATUS (OMAP35XX_INTCPS_VBASE + 0x14) -#define OMAP35XX_INTCPS_SIR_IRQ (OMAP35XX_INTCPS_VBASE + 0x40) -#define OMAP35XX_INTCPS_SIR_FIQ (OMAP35XX_INTCPS_VBASE + 0x44) -#define OMAP35XX_INTCPS_CONTROL (OMAP35XX_INTCPS_VBASE + 0x48) -#define OMAP35XX_INTCPS_PROTECTION (OMAP35XX_INTCPS_VBASE + 0x4C) -#define OMAP35XX_INTCPS_IDLE (OMAP35XX_INTCPS_VBASE + 0x50) -#define OMAP35XX_INTCPS_IRQ_PRIORITY (OMAP35XX_INTCPS_VBASE + 0x60) -#define OMAP35XX_INTCPS_FIQ_PRIORITY (OMAP35XX_INTCPS_VBASE + 0x64) -#define OMAP35XX_INTCPS_THRESHOLD (OMAP35XX_INTCPS_VBASE + 0x68) -#define OMAP35XX_INTCPS_ITR(n) (OMAP35XX_INTCPS_VBASE + 0x80 + (0x20 * (n))) -#define OMAP35XX_INTCPS_MIR(n) (OMAP35XX_INTCPS_VBASE + 0x84 + (0x20 * (n))) -#define OMAP35XX_INTCPS_MIR_CLEAR(n) (OMAP35XX_INTCPS_VBASE + 0x88 + (0x20 * (n))) -#define OMAP35XX_INTCPS_MIR_SET(n) (OMAP35XX_INTCPS_VBASE + 0x8C + (0x20 * (n))) -#define OMAP35XX_INTCPS_ISR_SET(n) (OMAP35XX_INTCPS_VBASE + 0x90 + (0x20 * (n))) -#define OMAP35XX_INTCPS_ISR_CLEAR(n) (OMAP35XX_INTCPS_VBASE + 0x94 + (0x20 * (n))) -#define OMAP35XX_INTCPS_PENDING_IRQ(n) (OMAP35XX_INTCPS_VBASE + 0x98 + (0x20 * (n))) -#define OMAP35XX_INTCPS_PENDING_FIQ(n) (OMAP35XX_INTCPS_VBASE + 0x9C + (0x20 * (n))) -#define OMAP35XX_INTCPS_ILR(m) (OMAP35XX_INTCPS_VBASE + 0x100 + (0x4 * (m))) - - -#define OMAP35XX_IRQ_EMUINT 0 /* MPU emulation(2) */ -#define OMAP35XX_IRQ_COMMTX 1 /* MPU emulation(2) */ -#define OMAP35XX_IRQ_COMMRX 2 /* MPU emulation(2) */ -#define OMAP35XX_IRQ_BENCH 3 /* MPU emulation(2) */ -#define OMAP35XX_IRQ_MCBSP2_ST 4 /* Sidetone MCBSP2 overflow */ -#define OMAP35XX_IRQ_MCBSP3_ST 5 /* Sidetone MCBSP3 overflow */ -#define OMAP35XX_IRQ_SSM_ABORT 6 /* MPU subsystem secure state-machine abort (2) */ -#define OMAP35XX_IRQ_SYS_NIRQ 7 /* External source (active low) */ -#define OMAP35XX_IRQ_RESERVED8 8 /* RESERVED */ -#define OMAP35XX_IRQ_SMX_DBG 9 /* SMX error for debug */ -#define OMAP35XX_IRQ_SMX_APP 10 /* SMX error for application */ -#define OMAP35XX_IRQ_PRCM_MPU 11 /* PRCM module IRQ */ -#define OMAP35XX_IRQ_SDMA0 12 /* System DMA request 0(3) */ -#define OMAP35XX_IRQ_SDMA1 13 /* System DMA request 1(3) */ -#define OMAP35XX_IRQ_SDMA2 14 /* System DMA request 2 */ -#define OMAP35XX_IRQ_SDMA3 15 /* System DMA request 3 */ -#define OMAP35XX_IRQ_MCBSP1 16 /* McBSP module 1 IRQ (3) */ -#define OMAP35XX_IRQ_MCBSP2 17 /* McBSP module 2 IRQ (3) */ -#define OMAP35XX_IRQ_SR1 18 /* SmartReflex™ 1 */ -#define OMAP35XX_IRQ_SR2 19 /* SmartReflex™ 2 */ -#define OMAP35XX_IRQ_GPMC 20 /* General-purpose memory controller module */ -#define OMAP35XX_IRQ_SGX 21 /* 2D/3D graphics module */ -#define OMAP35XX_IRQ_MCBSP3 22 /* McBSP module 3(3) */ -#define OMAP35XX_IRQ_MCBSP4 23 /* McBSP module 4(3) */ -#define OMAP35XX_IRQ_CAM0 24 /* Camera interface request 0 */ -#define OMAP35XX_IRQ_DSS 25 /* Display subsystem module(3) */ -#define OMAP35XX_IRQ_MAIL_U0 26 /* Mailbox user 0 request */ -#define OMAP35XX_IRQ_MCBSP5_IRQ1 27 /* McBSP module 5 (3) */ -#define OMAP35XX_IRQ_IVA2_MMU 28 /* IVA2 MMU */ -#define OMAP35XX_IRQ_GPIO1_MPU 29 /* GPIO module 1(3) */ -#define OMAP35XX_IRQ_GPIO2_MPU 30 /* GPIO module 2(3) */ -#define OMAP35XX_IRQ_GPIO3_MPU 31 /* GPIO module 3(3) */ -#define OMAP35XX_IRQ_GPIO4_MPU 32 /* GPIO module 4(3) */ -#define OMAP35XX_IRQ_GPIO5_MPU 33 /* GPIO module 5(3) */ -#define OMAP35XX_IRQ_GPIO6_MPU 34 /* GPIO module 6(3) */ -#define OMAP35XX_IRQ_USIM 35 /* USIM interrupt (HS devices only) (4) */ -#define OMAP35XX_IRQ_WDT3 36 /* Watchdog timer module 3 overflow */ -#define OMAP35XX_IRQ_GPT1 37 /* General-purpose timer module 1 */ -#define OMAP35XX_IRQ_GPT2 38 /* General-purpose timer module 2 */ -#define OMAP35XX_IRQ_GPT3 39 /* General-purpose timer module 3 */ -#define OMAP35XX_IRQ_GPT4 40 /* General-purpose timer module 4 */ -#define OMAP35XX_IRQ_GPT5 41 /* General-purpose timer module 5(3) */ -#define OMAP35XX_IRQ_GPT6 42 /* General-purpose timer module 6(3) */ -#define OMAP35XX_IRQ_GPT7 43 /* General-purpose timer module 7(3) */ -#define OMAP35XX_IRQ_GPT8 44 /* General-purpose timer module 8(3) */ -#define OMAP35XX_IRQ_GPT9 45 /* General-purpose timer module 9 */ -#define OMAP35XX_IRQ_GPT10 46 /* General-purpose timer module 10 */ -#define OMAP35XX_IRQ_GPT11 47 /* General-purpose timer module 11 */ -#define OMAP35XX_IRQ_SPI4 48 /* McSPI module 4 */ -#define OMAP35XX_IRQ_SHA1MD5_2 49 /* SHA-1/MD5 crypto-accelerator 2 (HS devices only)(4) */ -#define OMAP35XX_IRQ_FPKA_IRQREADY_N 50 /* PKA crypto-accelerator (HS devices only) (4) */ -#define OMAP35XX_IRQ_SHA2MD5 51 /* SHA-2/MD5 crypto-accelerator 1 (HS devices only) (4) */ -#define OMAP35XX_IRQ_RNG 52 /* RNG module (HS devices only) (4) */ -#define OMAP35XX_IRQ_MG 53 /* MG function (3) */ -#define OMAP35XX_IRQ_MCBSP4_TX 54 /* McBSP module 4 transmit(3) */ -#define OMAP35XX_IRQ_MCBSP4_RX 55 /* McBSP module 4 receive(3) */ -#define OMAP35XX_IRQ_I2C1 56 /* I2C module 1 */ -#define OMAP35XX_IRQ_I2C2 57 /* I2C module 2 */ -#define OMAP35XX_IRQ_HDQ 58 /* HDQ / One-wire */ -#define OMAP35XX_IRQ_MCBSP1_TX 59 /* McBSP module 1 transmit(3) */ -#define OMAP35XX_IRQ_MCBSP1_RX 60 /* McBSP module 1 receive(3) */ -#define OMAP35XX_IRQ_I2C3 61 /* I2C module 3 */ -#define OMAP35XX_IRQ_McBSP2_TX 62 /* McBSP module 2 transmit(3) */ -#define OMAP35XX_IRQ_McBSP2_RX 63 /* McBSP module 2 receive(3) */ -#define OMAP35XX_IRQ_FPKA_IRQRERROR_N 64 /* PKA crypto-accelerator (HS devices only) (4) */ -#define OMAP35XX_IRQ_SPI1 65 /* McSPI module 1 */ -#define OMAP35XX_IRQ_SPI2 66 /* McSPI module 2 */ -#define OMAP35XX_IRQ_RESERVED67 67 /* RESERVED */ -#define OMAP35XX_IRQ_RESERVED68 68 /* RESERVED */ -#define OMAP35XX_IRQ_RESERVED69 69 /* RESERVED */ -#define OMAP35XX_IRQ_RESERVED70 70 /* RESERVED */ -#define OMAP35XX_IRQ_RESERVED71 71 /* RESERVED */ -#define OMAP35XX_IRQ_UART1 72 /* UART module 1 */ -#define OMAP35XX_IRQ_UART2 73 /* UART module 2 */ -#define OMAP35XX_IRQ_UART3 74 /* UART module 3 (also infrared)(3) */ -#define OMAP35XX_IRQ_PBIAS 75 /* Merged interrupt for PBIASlite1 and 2 */ -#define OMAP35XX_IRQ_OHCI 76 /* OHCI controller HSUSB MP Host Interrupt */ -#define OMAP35XX_IRQ_EHCI 77 /* EHCI controller HSUSB MP Host Interrupt */ -#define OMAP35XX_IRQ_TLL 78 /* HSUSB MP TLL Interrupt */ -#define OMAP35XX_IRQ_PARTHASH 79 /* SHA2/MD5 crypto-accelerator 1 (HS devices only) (4) */ -#define OMAP35XX_IRQ_RESERVED80 80 /* Reserved */ -#define OMAP35XX_IRQ_MCBSP5_TX 81 /* McBSP module 5 transmit(3) */ -#define OMAP35XX_IRQ_MCBSP5_RX 82 /* McBSP module 5 receive(3) */ -#define OMAP35XX_IRQ_MMC1 83 /* MMC/SD module 1 */ -#define OMAP35XX_IRQ_MS 84 /* MS-PRO™ module */ -#define OMAP35XX_IRQ_RESERVED85 85 /* Reserved */ -#define OMAP35XX_IRQ_MMC2 86 /* MMC/SD module 2 */ -#define OMAP35XX_IRQ_MPU_ICR 87 /* MPU ICR */ -#define OMAP35XX_IRQ_RESERVED 88 /* RESERVED */ -#define OMAP35XX_IRQ_MCBSP3_TX 89 /* McBSP module 3 transmit(3) */ -#define OMAP35XX_IRQ_MCBSP3_RX 90 /* McBSP module 3 receive(3) */ -#define OMAP35XX_IRQ_SPI3 91 /* McSPI module 3 */ -#define OMAP35XX_IRQ_HSUSB_MC_NINT 92 /* High-Speed USB OTG controller */ -#define OMAP35XX_IRQ_HSUSB_DMA_NINT 93 /* High-Speed USB OTG DMA controller */ -#define OMAP35XX_IRQ_MMC3 94 /* MMC/SD module 3 */ -#define OMAP35XX_IRQ_GPT12 95 /* General-purpose timer module 12 */ - - - - -/* - * General Purpose Timers - */ -#define OMAP35XX_GPTIMER1_VBASE (OMAP35XX_L4_WAKEUP_VBASE + OMAP35XX_GPTIMER1_OFFSET) -#define OMAP35XX_GPTIMER1_HWBASE (OMAP35XX_L4_WAKEUP_HWBASE + OMAP35XX_GPTIMER1_OFFSET) -#define OMAP35XX_GPTIMER2_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER2_OFFSET) -#define OMAP35XX_GPTIMER2_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER2_OFFSET) -#define OMAP35XX_GPTIMER3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER3_OFFSET) -#define OMAP35XX_GPTIMER3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER3_OFFSET) -#define OMAP35XX_GPTIMER4_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER4_OFFSET) -#define OMAP35XX_GPTIMER4_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER4_OFFSET) -#define OMAP35XX_GPTIMER5_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER5_OFFSET) -#define OMAP35XX_GPTIMER5_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER5_OFFSET) -#define OMAP35XX_GPTIMER6_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER6_OFFSET) -#define OMAP35XX_GPTIMER6_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER6_OFFSET) -#define OMAP35XX_GPTIMER7_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER7_OFFSET) -#define OMAP35XX_GPTIMER7_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER7_OFFSET) -#define OMAP35XX_GPTIMER8_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER8_OFFSET) -#define OMAP35XX_GPTIMER8_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER8_OFFSET) -#define OMAP35XX_GPTIMER9_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER9_OFFSET) -#define OMAP35XX_GPTIMER9_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER9_OFFSET) -#define OMAP35XX_GPTIMER10_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_GPTIMER10_OFFSET) -#define OMAP35XX_GPTIMER10_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_GPTIMER10_OFFSET) -#define OMAP35XX_GPTIMER11_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_GPTIMER11_OFFSET) -#define OMAP35XX_GPTIMER11_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_GPTIMER11_OFFSET) -#define OMAP35XX_GPTIMER12_VBASE 0x48304000UL /* GPTIMER12 */ -#define OMAP35XX_GPTIMER_SIZE 0x00001000UL - - - -/* Timer register offsets */ -#define OMAP35XX_GPTIMER_TIOCP_CFG 0x010 -#define OMAP35XX_GPTIMER_TISTAT 0x014 -#define OMAP35XX_GPTIMER_TISR 0x018 -#define OMAP35XX_GPTIMER_TIER 0x01C -#define OMAP35XX_GPTIMER_TWER 0x020 -#define OMAP35XX_GPTIMER_TCLR 0x024 -#define OMAP35XX_GPTIMER_TCRR 0x028 -#define OMAP35XX_GPTIMER_TLDR 0x02C -#define OMAP35XX_GPTIMER_TTGR 0x030 -#define OMAP35XX_GPTIMER_TWPS 0x034 -#define OMAP35XX_GPTIMER_TMAR 0x038 -#define OMAP35XX_GPTIMER_TCAR1 0x03C -#define OMAP35XX_GPTIMER_TSICR 0x040 -#define OMAP35XX_GPTIMER_TCAR2 0x044 -#define OMAP35XX_GPTIMER_TPIR 0x048 -#define OMAP35XX_GPTIMER_TNIR 0x04C -#define OMAP35XX_GPTIMER_TCVR 0x050 -#define OMAP35XX_GPTIMER_TOCR 0x054 -#define OMAP35XX_GPTIMER_TOWR 0x058 - -/* Bit values */ -#define MAT_IT_FLAG 0x01 -#define OVF_IT_FLAG 0x02 -#define TCAR_IT_FLAG 0x04 - - - -/* - * GPIO - General Purpose IO - */ - -/* Base addresses for the GPIO modules */ -#define OMAP35XX_GPIO1_HWBASE (OMAP35XX_L4_WAKEUP_HWBASE + OMAP35XX_GPIO1_OFFSET) -#define OMAP35XX_GPIO1_VBASE (OMAP35XX_L4_WAKEUP_VBASE + OMAP35XX_GPIO1_OFFSET) -#define OMAP35XX_GPIO1_SIZE 0x00001000UL -#define OMAP35XX_GPIO2_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO2_OFFSET) -#define OMAP35XX_GPIO2_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO2_OFFSET) -#define OMAP35XX_GPIO2_SIZE 0x00001000UL -#define OMAP35XX_GPIO3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO3_OFFSET) -#define OMAP35XX_GPIO3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO3_OFFSET) -#define OMAP35XX_GPIO3_SIZE 0x00001000UL -#define OMAP35XX_GPIO4_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO4_OFFSET) -#define OMAP35XX_GPIO4_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO4_OFFSET) -#define OMAP35XX_GPIO4_SIZE 0x00001000UL -#define OMAP35XX_GPIO5_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO5_OFFSET) -#define OMAP35XX_GPIO5_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO5_OFFSET) -#define OMAP35XX_GPIO5_SIZE 0x00001000UL -#define OMAP35XX_GPIO6_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO6_OFFSET) -#define OMAP35XX_GPIO6_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO6_OFFSET) -#define OMAP35XX_GPIO6_SIZE 0x00001000UL - - - -/* Register offsets within the banks above */ -#define OMAP35XX_GPIO_SYSCONFIG 0x010 -#define OMAP35XX_GPIO_SYSSTATUS 0x014 -#define OMAP35XX_GPIO_IRQSTATUS1 0x018 -#define OMAP35XX_GPIO_IRQENABLE1 0x01C -#define OMAP35XX_GPIO_WAKEUPENABLE 0x020 -#define OMAP35XX_GPIO_IRQSTATUS2 0x028 -#define OMAP35XX_GPIO_IRQENABLE2 0x02C -#define OMAP35XX_GPIO_CTRL 0x030 -#define OMAP35XX_GPIO_OE 0x034 -#define OMAP35XX_GPIO_DATAIN 0x038 -#define OMAP35XX_GPIO_DATAOUT 0x03C -#define OMAP35XX_GPIO_LEVELDETECT0 0x040 -#define OMAP35XX_GPIO_LEVELDETECT1 0x044 -#define OMAP35XX_GPIO_RISINGDETECT 0x048 -#define OMAP35XX_GPIO_FALLINGDETECT 0x04C -#define OMAP35XX_GPIO_DEBOUNCENABLE 0x050 -#define OMAP35XX_GPIO_DEBOUNCINGTIME 0x054 -#define OMAP35XX_GPIO_CLEARIRQENABLE1 0x060 -#define OMAP35XX_GPIO_SETIRQENABLE1 0x064 -#define OMAP35XX_GPIO_CLEARIRQENABLE2 0x070 -#define OMAP35XX_GPIO_SETIRQENABLE2 0x074 -#define OMAP35XX_GPIO_CLEARWKUENA 0x080 -#define OMAP35XX_GPIO_SETWKUENA 0x084 -#define OMAP35XX_GPIO_CLEARDATAOUT 0x090 -#define OMAP35XX_GPIO_SETDATAOUT 0x094 - - -/* - * MMC/SD/SDIO - */ - -/* Base addresses for the MMC/SD/SDIO modules */ -#define OMAP35XX_MMCHS1_HWBASE (OMAP35XX_L4_CORE_HWBASE + 0x0009C000) -#define OMAP35XX_MMCHS1_VBASE (OMAP35XX_L4_CORE_VBASE + 0x0009C000) -#define OMAP35XX_MMCHS2_HWBASE (OMAP35XX_L4_CORE_HWBASE + 0x000B4000) -#define OMAP35XX_MMCHS2_VBASE (OMAP35XX_L4_CORE_VBASE + 0x000B4000) -#define OMAP35XX_MMCHS3_HWBASE (OMAP35XX_L4_CORE_HWBASE + 0x000AD000) -#define OMAP35XX_MMCHS3_VBASE (OMAP35XX_L4_CORE_VBASE + 0x000AD000) -#define OMAP35XX_MMCHS_SIZE 0x00000200UL - -/* Register offsets within each of the MMC/SD/SDIO controllers */ -#define OMAP35XX_MMCHS_SYSCONFIG 0x010 -#define OMAP35XX_MMCHS_SYSSTATUS 0x014 -#define OMAP35XX_MMCHS_CSRE 0x024 -#define OMAP35XX_MMCHS_SYSTEST 0x028 -#define OMAP35XX_MMCHS_CON 0x02C -#define OMAP35XX_MMCHS_PWCNT 0x030 -#define OMAP35XX_MMCHS_BLK 0x104 -#define OMAP35XX_MMCHS_ARG 0x108 -#define OMAP35XX_MMCHS_CMD 0x10C -#define OMAP35XX_MMCHS_RSP10 0x110 -#define OMAP35XX_MMCHS_RSP32 0x114 -#define OMAP35XX_MMCHS_RSP54 0x118 -#define OMAP35XX_MMCHS_RSP76 0x11C -#define OMAP35XX_MMCHS_DATA 0x120 -#define OMAP35XX_MMCHS_PSTATE 0x124 -#define OMAP35XX_MMCHS_HCTL 0x128 -#define OMAP35XX_MMCHS_SYSCTL 0x12C -#define OMAP35XX_MMCHS_STAT 0x130 -#define OMAP35XX_MMCHS_IE 0x134 -#define OMAP35XX_MMCHS_ISE 0x138 -#define OMAP35XX_MMCHS_AC12 0x13C -#define OMAP35XX_MMCHS_CAPA 0x140 -#define OMAP35XX_MMCHS_CUR_CAPA 0x148 -#define OMAP35XX_MMCHS_REV 0x1FC - - - -#endif /* _OMAP35XX_REG_H_ */ diff --git a/sys/arm/ti/ti_cpuid.c b/sys/arm/ti/ti_cpuid.c index 078757d852d..38af285c1ab 100644 --- a/sys/arm/ti/ti_cpuid.c +++ b/sys/arm/ti/ti_cpuid.c @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #define OMAP4_STD_FUSE_DIE_ID_0 0x2200 @@ -198,67 +197,6 @@ omap4_get_revision(void) } } -/** - * omap3_get_revision - determines omap3 revision - * - * Reads the registers to determine the revision of the chip we are currently - * running on. Stores the information in global variables. - * - * WARNING: This function currently only really works for OMAP3530 devices. - * - * - * - */ -static void -omap3_get_revision(void) -{ - uint32_t id_code; - uint32_t revision; - uint32_t hawkeye; - bus_space_handle_t bsh; - - /* The chip revsion is read from the device identification registers and - * the JTAG (?) tap registers, which are located in address 0x4A00_2200 to - * 0x4A00_2218. This is part of the L4_CORE memory range and should have - * been mapped in by the machdep.c code. - * - * CONTROL_IDCODE 0x4830 A204 (this is the only one we need) - * - * - */ - bus_space_map(fdtbus_bs_tag, OMAP35XX_L4_WAKEUP_HWBASE, 0x10000, 0, &bsh); - id_code = bus_space_read_4(fdtbus_bs_tag, bsh, OMAP3_ID_CODE); - bus_space_unmap(fdtbus_bs_tag, bsh, 0x10000); - - hawkeye = ((id_code >> 12) & 0xffff); - revision = ((id_code >> 28) & 0xf); - - switch (hawkeye) { - case 0xB6D6: - chip_revision = OMAP3350_REV_ES1_0; - break; - case 0xB7AE: - if (revision == 1) - chip_revision = OMAP3530_REV_ES2_0; - else if (revision == 2) - chip_revision = OMAP3530_REV_ES2_1; - else if (revision == 3) - chip_revision = OMAP3530_REV_ES3_0; - else if (revision == 4) - chip_revision = OMAP3530_REV_ES3_1; - else if (revision == 7) - chip_revision = OMAP3530_REV_ES3_1_2; - break; - default: - /* Default to the latest revision if we can't determine type */ - chip_revision = OMAP3530_REV_ES3_1_2; - break; - } - printf("Texas Instruments OMAP%04x Processor, Revision ES%u.%u\n", - OMAP_REV_DEVICE(chip_revision), OMAP_REV_MAJOR(chip_revision), - OMAP_REV_MINOR(chip_revision)); -} - static void am335x_get_revision(void) { @@ -313,9 +251,6 @@ static void ti_cpu_ident(void *dummy) { switch(ti_chip()) { - case CHIP_OMAP_3: - omap3_get_revision(); - break; case CHIP_OMAP_4: omap4_get_revision(); break; diff --git a/sys/arm/ti/ti_cpuid.h b/sys/arm/ti/ti_cpuid.h index 6efbf32789c..86ac9828726 100644 --- a/sys/arm/ti/ti_cpuid.h +++ b/sys/arm/ti/ti_cpuid.h @@ -67,16 +67,13 @@ #define AM335X_DEVREV(x) ((x) >> 28) -#define CHIP_OMAP_3 0 -#define CHIP_OMAP_4 1 -#define CHIP_AM335X 2 +#define CHIP_OMAP_4 0 +#define CHIP_AM335X 1 static __inline int ti_chip(void) { #if defined(SOC_OMAP4) return CHIP_OMAP_4; -#elif defined(SOC_OMAP3) - return CHIP_OMAP_3; #elif defined(SOC_TI_AM335X) return CHIP_AM335X; #else diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c index 619d75be0aa..18f14404a45 100644 --- a/sys/arm/ti/ti_gpio.c +++ b/sys/arm/ti/ti_gpio.c @@ -70,32 +70,7 @@ __FBSDID("$FreeBSD$"); /* Register definitions */ #define TI_GPIO_REVISION 0x0000 #define TI_GPIO_SYSCONFIG 0x0010 -#if defined(SOC_OMAP3) -#define TI_GPIO_SYSSTATUS 0x0014 -#define TI_GPIO_IRQSTATUS1 0x0018 -#define TI_GPIO_IRQENABLE1 0x001C -#define TI_GPIO_WAKEUPENABLE 0x0020 -#define TI_GPIO_IRQSTATUS2 0x0028 -#define TI_GPIO_IRQENABLE2 0x002C -#define TI_GPIO_CTRL 0x0030 -#define TI_GPIO_OE 0x0034 -#define TI_GPIO_DATAIN 0x0038 -#define TI_GPIO_DATAOUT 0x003C -#define TI_GPIO_LEVELDETECT0 0x0040 -#define TI_GPIO_LEVELDETECT1 0x0044 -#define TI_GPIO_RISINGDETECT 0x0048 -#define TI_GPIO_FALLINGDETECT 0x004C -#define TI_GPIO_DEBOUNCENABLE 0x0050 -#define TI_GPIO_DEBOUNCINGTIME 0x0054 -#define TI_GPIO_CLEARIRQENABLE1 0x0060 -#define TI_GPIO_SETIRQENABLE1 0x0064 -#define TI_GPIO_CLEARIRQENABLE2 0x0070 -#define TI_GPIO_SETIRQENABLE2 0x0074 -#define TI_GPIO_CLEARWKUENA 0x0080 -#define TI_GPIO_SETWKUENA 0x0084 -#define TI_GPIO_CLEARDATAOUT 0x0090 -#define TI_GPIO_SETDATAOUT 0x0094 -#elif defined(SOC_OMAP4) || defined(SOC_TI_AM335X) +#if defined(SOC_OMAP4) || defined(SOC_TI_AM335X) #define TI_GPIO_IRQSTATUS_RAW_0 0x0024 #define TI_GPIO_IRQSTATUS_RAW_1 0x0028 #define TI_GPIO_IRQSTATUS_0 0x002C @@ -131,10 +106,6 @@ __FBSDID("$FreeBSD$"); #endif /* Other SoC Specific definitions */ -#define OMAP3_MAX_GPIO_BANKS 6 -#define OMAP3_FIRST_GPIO_BANK 1 -#define OMAP3_INTR_PER_BANK 1 -#define OMAP3_GPIO_REV 0x00000025 #define OMAP4_MAX_GPIO_BANKS 6 #define OMAP4_FIRST_GPIO_BANK 1 #define OMAP4_INTR_PER_BANK 1 @@ -152,10 +123,6 @@ static u_int ti_max_gpio_banks(void) { switch(ti_chip()) { -#ifdef SOC_OMAP3 - case CHIP_OMAP_3: - return (OMAP3_MAX_GPIO_BANKS); -#endif #ifdef SOC_OMAP4 case CHIP_OMAP_4: return (OMAP4_MAX_GPIO_BANKS); @@ -172,10 +139,6 @@ static u_int ti_max_gpio_intrs(void) { switch(ti_chip()) { -#ifdef SOC_OMAP3 - case CHIP_OMAP_3: - return (OMAP3_MAX_GPIO_BANKS * OMAP3_INTR_PER_BANK); -#endif #ifdef SOC_OMAP4 case CHIP_OMAP_4: return (OMAP4_MAX_GPIO_BANKS * OMAP4_INTR_PER_BANK); @@ -192,10 +155,6 @@ static u_int ti_first_gpio_bank(void) { switch(ti_chip()) { -#ifdef SOC_OMAP3 - case CHIP_OMAP_3: - return (OMAP3_FIRST_GPIO_BANK); -#endif #ifdef SOC_OMAP4 case CHIP_OMAP_4: return (OMAP4_FIRST_GPIO_BANK); @@ -212,10 +171,6 @@ static uint32_t ti_gpio_rev(void) { switch(ti_chip()) { -#ifdef SOC_OMAP3 - case CHIP_OMAP_3: - return (OMAP3_GPIO_REV); -#endif #ifdef SOC_OMAP4 case CHIP_OMAP_4: return (OMAP4_GPIO_REV); diff --git a/sys/arm/ti/ti_i2c.c b/sys/arm/ti/ti_i2c.c index 3ad5102a87b..80256d0f53d 100644 --- a/sys/arm/ti/ti_i2c.c +++ b/sys/arm/ti/ti_i2c.c @@ -111,10 +111,6 @@ struct ti_i2c_clock_config uint8_t hssclh; /* High Speed mode SCL high time */ }; -#if defined(SOC_OMAP3) -#error "Unsupported SoC" -#endif - #if defined(SOC_OMAP4) static struct ti_i2c_clock_config ti_omap4_i2c_clock_configs[] = { { IIC_UNKNOWN, 100000, 23, 13, 15, 0, 0}, diff --git a/sys/arm/ti/ti_mmchs.c b/sys/arm/ti/ti_mmchs.c index c311da73ed0..141caaee5fb 100644 --- a/sys/arm/ti/ti_mmchs.c +++ b/sys/arm/ti/ti_mmchs.c @@ -1621,9 +1621,7 @@ ti_mmchs_activate(device_t dev) goto errout; /* Set the register offset */ - if (ti_chip() == CHIP_OMAP_3) - sc->sc_reg_off = OMAP3_MMCHS_REG_OFFSET; - else if (ti_chip() == CHIP_OMAP_4) + if (ti_chip() == CHIP_OMAP_4) sc->sc_reg_off = OMAP4_MMCHS_REG_OFFSET; else if (ti_chip() == CHIP_AM335X) sc->sc_reg_off = AM335X_MMCHS_REG_OFFSET; diff --git a/sys/arm/ti/ti_sdhci.c b/sys/arm/ti/ti_sdhci.c index 7befa8c66fb..63aeb9bdf6a 100644 --- a/sys/arm/ti/ti_sdhci.c +++ b/sys/arm/ti/ti_sdhci.c @@ -494,9 +494,7 @@ ti_sdhci_attach(device_t dev) * Set the offset from the device's memory start to the MMCHS registers. * Also for OMAP4 disable high speed mode due to erratum ID i626. */ - if (ti_chip() == CHIP_OMAP_3) - sc->mmchs_reg_off = OMAP3_MMCHS_REG_OFFSET; - else if (ti_chip() == CHIP_OMAP_4) { + if (ti_chip() == CHIP_OMAP_4) { sc->mmchs_reg_off = OMAP4_MMCHS_REG_OFFSET; sc->disable_highspeed = true; } else if (ti_chip() == CHIP_AM335X) From b0d1c7102e5becb3f7ee4c9096269ace246dc89c Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 13 Oct 2014 16:12:28 +0000 Subject: [PATCH 093/112] Sort the files in the am355x directory. --- sys/arm/ti/am335x/files.am335x | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/arm/ti/am335x/files.am335x b/sys/arm/ti/am335x/files.am335x index adc59d63ceb..31ef7471da3 100644 --- a/sys/arm/ti/am335x/files.am335x +++ b/sys/arm/ti/am335x/files.am335x @@ -1,13 +1,15 @@ #$FreeBSD$ arm/ti/aintc.c standard -arm/ti/am335x/am335x_prcm.c standard + arm/ti/am335x/am335x_dmtimer.c standard -arm/ti/am335x/am335x_scm_padconf.c standard arm/ti/am335x/am335x_lcd.c optional sc arm/ti/am335x/am335x_lcd_syscons.c optional sc +arm/ti/am335x/am335x_prcm.c standard arm/ti/am335x/am335x_pwm.c standard +arm/ti/am335x/am335x_scm_padconf.c standard arm/ti/am335x/am335x_usbss.c optional musb fdt + arm/ti/ti_edma3.c standard arm/ti/ti_sdhci.c optional sdhci #arm/ti/ti_mmchs.c optional mmc From 09020352fe1e0eb1921d065d12a2f97583eedcd9 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 13 Oct 2014 16:15:32 +0000 Subject: [PATCH 094/112] Don't confuse frontend with zero length data moves, just return immediately. MFC after: 1 week --- sys/cam/ctl/ctl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 175cbc98d45..7a7fa028c0c 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -10821,15 +10821,9 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio) } ctsio->scsi_status = SCSI_STATUS_OK; - if (ctsio->kern_data_len > 0) { - ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; - ctsio->be_move_done = ctl_config_move_done; - ctl_datamove((union ctl_io *)ctsio); - } else { - ctsio->io_hdr.status = CTL_SUCCESS; - ctl_done((union ctl_io *)ctsio); - } - + ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; + ctsio->be_move_done = ctl_config_move_done; + ctl_datamove((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } @@ -12901,6 +12895,12 @@ ctl_datamove(union ctl_io *io) return; } + /* Don't confuse frontend with zero length data move. */ + if (io->scsiio.kern_data_len == 0) { + io->scsiio.be_move_done(io); + return; + } + /* * If we're in XFER mode and this I/O is from the other shelf * controller, we need to send the DMA to the other side to From 56f4208d56de7417779d1080bb444118373379d0 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 13 Oct 2014 16:16:32 +0000 Subject: [PATCH 095/112] Remove the need for files.beaglebone and std.beaglebone by moving the one option they defined into files.am335x. --- sys/arm/conf/BEAGLEBONE | 2 +- sys/arm/ti/am335x/files.am335x | 1 + sys/arm/ti/am335x/files.beaglebone | 3 --- sys/arm/ti/am335x/std.beaglebone | 4 ---- 4 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 sys/arm/ti/am335x/files.beaglebone delete mode 100644 sys/arm/ti/am335x/std.beaglebone diff --git a/sys/arm/conf/BEAGLEBONE b/sys/arm/conf/BEAGLEBONE index ec515f12e47..f6e0d2e217c 100644 --- a/sys/arm/conf/BEAGLEBONE +++ b/sys/arm/conf/BEAGLEBONE @@ -22,7 +22,7 @@ ident BEAGLEBONE -include "../ti/am335x/std.beaglebone" +include "../ti/am335x/std.am335x" makeoptions WITHOUT_MODULES="ahc" diff --git a/sys/arm/ti/am335x/files.am335x b/sys/arm/ti/am335x/files.am335x index 31ef7471da3..3bb44e3b60c 100644 --- a/sys/arm/ti/am335x/files.am335x +++ b/sys/arm/ti/am335x/files.am335x @@ -5,6 +5,7 @@ arm/ti/aintc.c standard arm/ti/am335x/am335x_dmtimer.c standard arm/ti/am335x/am335x_lcd.c optional sc arm/ti/am335x/am335x_lcd_syscons.c optional sc +arm/ti/am335x/am335x_pmic.c optional am335x_pmic arm/ti/am335x/am335x_prcm.c standard arm/ti/am335x/am335x_pwm.c standard arm/ti/am335x/am335x_scm_padconf.c standard diff --git a/sys/arm/ti/am335x/files.beaglebone b/sys/arm/ti/am335x/files.beaglebone deleted file mode 100644 index ff527ce212d..00000000000 --- a/sys/arm/ti/am335x/files.beaglebone +++ /dev/null @@ -1,3 +0,0 @@ -#$FreeBSD$ - -arm/ti/am335x/am335x_pmic.c optional am335x_pmic diff --git a/sys/arm/ti/am335x/std.beaglebone b/sys/arm/ti/am335x/std.beaglebone deleted file mode 100644 index 299e822532d..00000000000 --- a/sys/arm/ti/am335x/std.beaglebone +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -files "../ti/am335x/files.beaglebone" -include "../ti/am335x/std.am335x" From bb1a2d4aa2bd2f740eebd2069e54a729d568078b Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 13 Oct 2014 16:17:42 +0000 Subject: [PATCH 096/112] Fix most of the warnings in kdump(1). Sponsored by: Norse --- usr.bin/kdump/kdump.c | 47 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 5978a631b1f..ac0e88ba1f6 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -103,9 +103,9 @@ void ktrgenio(struct ktr_genio *, int); void ktrpsig(struct ktr_psig *); void ktrcsw(struct ktr_csw *); void ktrcsw_old(struct ktr_csw_old *); -void ktruser_malloc(unsigned char *); -void ktruser_rtld(int, unsigned char *); -void ktruser(int, unsigned char *); +void ktruser_malloc(void *); +void ktruser_rtld(int, void *); +void ktruser(int, void *); void ktrcaprights(cap_rights_t *); void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); @@ -122,10 +122,13 @@ void ioctlname(unsigned long, int); #define TIMESTAMP_ELAPSED 0x2 #define TIMESTAMP_RELATIVE 0x4 -int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, +extern const char *signames[], *syscallnames[]; +extern int nsyscalls; + +static int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, resolv = 0, abiflag = 0, syscallno = 0; -const char *tracefile = DEF_TRACEFILE; -struct ktr_header ktr_header; +static const char *tracefile = DEF_TRACEFILE; +static struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) @@ -172,7 +175,7 @@ struct proc_info pid_t pid; }; -TAILQ_HEAD(trace_procs, proc_info) trace_procs; +static TAILQ_HEAD(trace_procs, proc_info) trace_procs; #ifdef HAVE_LIBCAPSICUM static cap_channel_t *cappwd, *capgrp; @@ -456,7 +459,7 @@ limitfd(int fd) unsigned long cmd; cap_rights_init(&rights, CAP_FSTAT); - cmd = -1; + cmd = 0; switch (fd) { case STDIN_FILENO: @@ -479,7 +482,7 @@ limitfd(int fd) if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) err(1, "unable to limit rights for descriptor %d", fd); - if (cmd != -1 && cap_ioctls_limit(fd, &cmd, 1) < 0 && errno != ENOSYS) + if (cmd != 0 && cap_ioctls_limit(fd, &cmd, 1) < 0 && errno != ENOSYS) err(1, "unable to limit ioctls for descriptor %d", fd); } @@ -1093,7 +1096,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags) print_number(ip, narg, c); putchar(','); flagsname(ip[0]); - printf(",0%o", ip[1]); + printf(",0%o", (unsigned int)ip[1]); ip += 3; narg -= 3; break; @@ -1515,9 +1518,10 @@ struct utrace_rtld { }; void -ktruser_rtld(int len, unsigned char *p) +ktruser_rtld(int len, void *p) { - struct utrace_rtld *ut = (struct utrace_rtld *)p; + struct utrace_rtld *ut = p; + unsigned char *cp; void *parent; int mode; @@ -1582,14 +1586,15 @@ ktruser_rtld(int len, unsigned char *p) ut->name); break; default: - p += 4; + cp = p; + cp += 4; len -= 4; printf("RTLD: %d ", len); while (len--) if (decimal) - printf(" %d", *p++); + printf(" %d", *cp++); else - printf(" %02x", *p++); + printf(" %02x", *cp++); printf("\n"); } } @@ -1601,9 +1606,9 @@ struct utrace_malloc { }; void -ktruser_malloc(unsigned char *p) +ktruser_malloc(void *p) { - struct utrace_malloc *ut = (struct utrace_malloc *)p; + struct utrace_malloc *ut = p; if (ut->p == (void *)(intptr_t)(-1)) printf("malloc_init()\n"); @@ -1616,8 +1621,9 @@ ktruser_malloc(unsigned char *p) } void -ktruser(int len, unsigned char *p) +ktruser(int len, void *p) { + unsigned char *cp; if (len >= 8 && bcmp(p, "RTLD", 4) == 0) { ktruser_rtld(len, p); @@ -1630,11 +1636,12 @@ ktruser(int len, unsigned char *p) } printf("%d ", len); + cp = p; while (len--) if (decimal) - printf(" %d", *p++); + printf(" %d", *cp++); else - printf(" %02x", *p++); + printf(" %02x", *cp++); printf("\n"); } From 88e1e174518888ba559037dc7fe65c435537e5b8 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 13 Oct 2014 16:20:04 +0000 Subject: [PATCH 097/112] Remove ti_mmchs.c, it has been replaced by ti_sdhci.c. --- sys/arm/ti/am335x/files.am335x | 1 - sys/arm/ti/omap4/files.omap4 | 1 - sys/arm/ti/ti_mmchs.c | 1841 -------------------------------- sys/arm/ti/ti_mmchs.h | 176 --- 4 files changed, 2019 deletions(-) delete mode 100644 sys/arm/ti/ti_mmchs.c delete mode 100644 sys/arm/ti/ti_mmchs.h diff --git a/sys/arm/ti/am335x/files.am335x b/sys/arm/ti/am335x/files.am335x index 3bb44e3b60c..fe2ebb84b9d 100644 --- a/sys/arm/ti/am335x/files.am335x +++ b/sys/arm/ti/am335x/files.am335x @@ -13,5 +13,4 @@ arm/ti/am335x/am335x_usbss.c optional musb fdt arm/ti/ti_edma3.c standard arm/ti/ti_sdhci.c optional sdhci -#arm/ti/ti_mmchs.c optional mmc arm/ti/cpsw/if_cpsw.c optional cpsw diff --git a/sys/arm/ti/omap4/files.omap4 b/sys/arm/ti/omap4/files.omap4 index 8f40095a665..9611c6eded9 100644 --- a/sys/arm/ti/omap4/files.omap4 +++ b/sys/arm/ti/omap4/files.omap4 @@ -7,7 +7,6 @@ arm/ti/ti_smc.S standard arm/ti/usb/omap_ehci.c optional usb ehci arm/ti/ti_sdma.c optional ti_sdma arm/ti/ti_sdhci.c optional sdhci -#arm/ti/ti_mmchs.c optional mmc arm/ti/omap4/omap4_l2cache.c optional pl310 arm/ti/omap4/omap4_prcm_clks.c standard diff --git a/sys/arm/ti/ti_mmchs.c b/sys/arm/ti/ti_mmchs.c deleted file mode 100644 index 141caaee5fb..00000000000 --- a/sys/arm/ti/ti_mmchs.c +++ /dev/null @@ -1,1841 +0,0 @@ -/*- - * Copyright (c) 2011 - * Ben Gray . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/** - * Driver for the MMC/SD/SDIO module on the TI OMAP series of SoCs. - * - * This driver is heavily based on the SD/MMC driver for the AT91 (at91_mci.c). - * - * It's important to realise that the MMC state machine is already in the kernel - * and this driver only exposes the specific interfaces of the controller. - * - * This driver is still very much a work in progress, I've verified that basic - * sector reading can be performed. But I've yet to test it with a file system - * or even writing. In addition I've only tested the driver with an SD card, - * I've no idea if MMC cards work. - * - */ -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "gpio_if.h" - -#include "mmcbr_if.h" -#include "mmcbus_if.h" - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef DEBUG -#define ti_mmchs_dbg(sc, fmt, args...) \ - device_printf((sc)->sc_dev, fmt, ## args); -#else -#define ti_mmchs_dbg(sc, fmt, args...) -#endif - -/** - * Structure that stores the driver context - */ -struct ti_mmchs_softc { - device_t sc_dev; - uint32_t device_id; - struct resource* sc_irq_res; - struct resource* sc_mem_res; - - void* sc_irq_h; - - bus_dma_tag_t sc_dmatag; - bus_dmamap_t sc_dmamap; - int sc_dmamapped; - - unsigned int sc_dmach_rd; - unsigned int sc_dmach_wr; - int dma_rx_trig; - int dma_tx_trig; - - device_t sc_gpio_dev; - int sc_wp_gpio_pin; /* GPIO pin for MMC write protect */ - - device_t sc_vreg_dev; - const char* sc_vreg_name; - - struct mtx sc_mtx; - - struct mmc_host host; - struct mmc_request* req; - struct mmc_command* curcmd; - - int flags; -#define CMD_STARTED 1 -#define STOP_STARTED 2 - - int bus_busy; /* TODO: Needed ? */ - - void* sc_cmd_data_vaddr; - int sc_cmd_data_len; - - /* The offset applied to each of the register base addresses, OMAP4 - * register sets are offset 0x100 from the OMAP3 series. - */ - unsigned long sc_reg_off; - - /* The physical address of the MMCHS_DATA register, used for the DMA xfers */ - unsigned long sc_data_reg_paddr; - - /* The reference clock frequency */ - unsigned int sc_ref_freq; - - enum mmc_power_mode sc_cur_power_mode; -}; - -/** - * Macros for driver mutex locking - */ -#define TI_MMCHS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) -#define TI_MMCHS_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) -#define TI_MMCHS_LOCK_INIT(_sc) \ - mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->sc_dev), \ - "ti_mmchs", MTX_DEF) -#define TI_MMCHS_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); -#define TI_MMCHS_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); -#define TI_MMCHS_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); - -static void ti_mmchs_start(struct ti_mmchs_softc *sc); - -/** - * ti_mmchs_read_4 - reads a 32-bit value from a register - * ti_mmchs_write_4 - writes a 32-bit value to a register - * @sc: pointer to the driver context - * @off: register offset to read from - * @val: the value to write into the register - * - * LOCKING: - * None - * - * RETURNS: - * The 32-bit value read from the register - */ -static inline uint32_t -ti_mmchs_read_4(struct ti_mmchs_softc *sc, bus_size_t off) -{ - return bus_read_4(sc->sc_mem_res, (sc->sc_reg_off + off)); -} - -static inline void -ti_mmchs_write_4(struct ti_mmchs_softc *sc, bus_size_t off, uint32_t val) -{ - bus_write_4(sc->sc_mem_res, (sc->sc_reg_off + off), val); -} - -/** - * ti_mmchs_reset_controller - - * @arg: caller supplied arg - * @segs: array of segments (although in our case should only be one) - * @nsegs: number of segments (in our case should be 1) - * @error: - * - * - * - */ -static void -ti_mmchs_reset_controller(struct ti_mmchs_softc *sc, uint32_t bit) -{ - unsigned long attempts; - uint32_t sysctl; - - ti_mmchs_dbg(sc, "reseting controller - bit 0x%08x\n", bit); - - sysctl = ti_mmchs_read_4(sc, MMCHS_SYSCTL); - ti_mmchs_write_4(sc, MMCHS_SYSCTL, sysctl | bit); - /* - * AM335x and OMAP4 >= ES2 have an updated reset logic. - * Monitor a 0->1 transition first. - */ - if ((ti_chip() == CHIP_AM335X) || - ((ti_chip() == CHIP_OMAP_4) && (ti_revision() > OMAP4430_REV_ES1_0))) { - attempts = 10000; - while (!(ti_mmchs_read_4(sc, MMCHS_SYSCTL) & bit) && (attempts-- > 0)) - continue; - } - - attempts = 10000; - while ((ti_mmchs_read_4(sc, MMCHS_SYSCTL) & bit) && (attempts-- > 0)) - continue; - - if (ti_mmchs_read_4(sc, MMCHS_SYSCTL) & bit) - device_printf(sc->sc_dev, "Error - Timeout waiting on controller reset\n"); -} - -/** - * ti_mmchs_getaddr - called by the DMA function to simply return the phys addr - * @arg: caller supplied arg - * @segs: array of segments (although in our case should only be one) - * @nsegs: number of segments (in our case should be 1) - * @error: - * - * This function is called by bus_dmamap_load() after it has compiled an array - * of segments, each segment is a phsyical chunk of memory. However in our case - * we should only have one segment, because we don't (yet?) support DMA scatter - * gather. To ensure we only have one segment, the DMA tag was created by - * bus_dma_tag_create() (called from ti_mmchs_attach) with nsegments set to 1. - * - */ -static void -ti_mmchs_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) -{ - if (error != 0) - return; - - *(bus_addr_t *)arg = segs[0].ds_addr; -} - -#ifndef SOC_TI_AM335X -/** - * ti_mmchs_dma_intr - interrupt handler for DMA events triggered by the controller - * @ch: the dma channel number - * @status: bit field of the status bytes - * @data: callback data, in this case a pointer to the controller struct - * - * - * LOCKING: - * Called from interrupt context - * - */ -static void -ti_mmchs_dma_intr(unsigned int ch, uint32_t status, void *data) -{ - /* Ignore for now ... we don't need this interrupt as we already have the - * interrupt from the MMC controller. - */ -} -#endif - -/** - * ti_mmchs_intr_xfer_compl - called if a 'transfer complete' IRQ was received - * @sc: pointer to the driver context - * @cmd: the command that was sent previously - * - * This function is simply responsible for syncing up the DMA buffer. - * - * LOCKING: - * Called from interrupt context - * - * RETURNS: - * Return value indicates if the transaction is complete, not done = 0, done != 0 - */ -static int -ti_mmchs_intr_xfer_compl(struct ti_mmchs_softc *sc, struct mmc_command *cmd) -{ - uint32_t cmd_reg; - - /* Read command register to test whether this command was a read or write. */ - cmd_reg = ti_mmchs_read_4(sc, MMCHS_CMD); - - /* Sync-up the DMA buffer so the caller can access the new memory */ - if (cmd_reg & MMCHS_CMD_DDIR) { - bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(sc->sc_dmatag, sc->sc_dmamap); - } - else { - bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->sc_dmatag, sc->sc_dmamap); - } - sc->sc_dmamapped--; - - /* Debugging dump of the data received */ -#if 0 - { - int i; - uint8_t *p = (uint8_t*) sc->sc_cmd_data_vaddr; - for (i=0; isc_cmd_data_len; i++) { - if ((i % 16) == 0) - printf("\n0x%04x : ", i); - printf("%02X ", *p++); - } - printf("\n"); - } -#endif - - /* We are done, transfer complete */ - return 1; -} - -/** - * ti_mmchs_intr_cmd_compl - called if a 'command complete' IRQ was received - * @sc: pointer to the driver context - * @cmd: the command that was sent previously - * - * - * LOCKING: - * Called from interrupt context - * - * RETURNS: - * Return value indicates if the transaction is complete, not done = 0, done != 0 - */ -static int -ti_mmchs_intr_cmd_compl(struct ti_mmchs_softc *sc, struct mmc_command *cmd) -{ - uint32_t cmd_reg; - - /* Copy the response into the request struct ... if a response was - * expected */ - if (cmd != NULL && (cmd->flags & MMC_RSP_PRESENT)) { - if (cmd->flags & MMC_RSP_136) { - cmd->resp[3] = ti_mmchs_read_4(sc, MMCHS_RSP10); - cmd->resp[2] = ti_mmchs_read_4(sc, MMCHS_RSP32); - cmd->resp[1] = ti_mmchs_read_4(sc, MMCHS_RSP54); - cmd->resp[0] = ti_mmchs_read_4(sc, MMCHS_RSP76); - } else { - cmd->resp[0] = ti_mmchs_read_4(sc, MMCHS_RSP10); - } - } - - /* Check if the command was expecting some data transfer, if not - * we are done. */ - cmd_reg = ti_mmchs_read_4(sc, MMCHS_CMD); - return ((cmd_reg & MMCHS_CMD_DP) == 0); -} - -/** - * ti_mmchs_intr_error - handles error interrupts - * @sc: pointer to the driver context - * @cmd: the command that was sent previously - * @stat_reg: the value that was in the status register - * - * - * LOCKING: - * Called from interrupt context - * - * RETURNS: - * Return value indicates if the transaction is complete, not done = 0, done != 0 - */ -static int -ti_mmchs_intr_error(struct ti_mmchs_softc *sc, struct mmc_command *cmd, - uint32_t stat_reg) -{ - ti_mmchs_dbg(sc, "error in xfer - stat 0x%08x\n", stat_reg); - - /* Ignore CRC errors on CMD2 and ACMD47, per relevant standards */ - if ((stat_reg & MMCHS_STAT_CCRC) && (cmd->opcode == MMC_SEND_OP_COND || - cmd->opcode == ACMD_SD_SEND_OP_COND)) - cmd->error = MMC_ERR_NONE; - else if (stat_reg & (MMCHS_STAT_CTO | MMCHS_STAT_DTO)) - cmd->error = MMC_ERR_TIMEOUT; - else if (stat_reg & (MMCHS_STAT_CCRC | MMCHS_STAT_DCRC)) - cmd->error = MMC_ERR_BADCRC; - else - cmd->error = MMC_ERR_FAILED; - - /* If a dma transaction we should also stop the dma transfer */ - if (ti_mmchs_read_4(sc, MMCHS_CMD) & MMCHS_CMD_DE) { - - /* Abort the DMA transfer (DDIR bit tells direction) */ - if (ti_mmchs_read_4(sc, MMCHS_CMD) & MMCHS_CMD_DDIR) -#ifdef SOC_TI_AM335X - printf("%s: DMA unimplemented\n", __func__); -#else - ti_sdma_stop_xfer(sc->sc_dmach_rd); -#endif - else -#ifdef SOC_TI_AM335X - printf("%s: DMA unimplemented\n", __func__); -#else - ti_sdma_stop_xfer(sc->sc_dmach_wr); -#endif - - /* If an error occure abort the DMA operation and free the dma map */ - if ((sc->sc_dmamapped > 0) && (cmd->error != MMC_ERR_NONE)) { - bus_dmamap_unload(sc->sc_dmatag, sc->sc_dmamap); - sc->sc_dmamapped--; - } - } - - /* Command error occured? ... if so issue a soft reset for the cmd fsm */ - if (stat_reg & (MMCHS_STAT_CCRC | MMCHS_STAT_CTO)) { - ti_mmchs_reset_controller(sc, MMCHS_SYSCTL_SRC); - } - - /* Data error occured? ... if so issue a soft reset for the data line */ - if (stat_reg & (MMCHS_STAT_DEB | MMCHS_STAT_DCRC | MMCHS_STAT_DTO)) { - ti_mmchs_reset_controller(sc, MMCHS_SYSCTL_SRD); - } - - /* On any error the command is cancelled ... so we are done */ - return 1; -} - -/** - * ti_mmchs_intr - interrupt handler for MMC/SD/SDIO controller - * @arg: pointer to the driver context - * - * Interrupt handler for the MMC/SD/SDIO controller, responsible for handling - * the IRQ and clearing the status flags. - * - * LOCKING: - * Called from interrupt context - * - * RETURNS: - * nothing - */ -static void -ti_mmchs_intr(void *arg) -{ - struct ti_mmchs_softc *sc = (struct ti_mmchs_softc *) arg; - uint32_t stat_reg; - int done = 0; - - TI_MMCHS_LOCK(sc); - - stat_reg = ti_mmchs_read_4(sc, MMCHS_STAT) & (ti_mmchs_read_4(sc, - MMCHS_IE) | MMCHS_STAT_ERRI); - - if (sc->curcmd == NULL) { - device_printf(sc->sc_dev, "Error: current cmd NULL, already done?\n"); - ti_mmchs_write_4(sc, MMCHS_STAT, stat_reg); - TI_MMCHS_UNLOCK(sc); - return; - } - - if (stat_reg & MMCHS_STAT_ERRI) { - /* An error has been tripped in the status register */ - done = ti_mmchs_intr_error(sc, sc->curcmd, stat_reg); - - } else { - - /* NOTE: This implementation could be a bit inefficent, I don't think - * it is necessary to handle both the 'command complete' and 'transfer - * complete' for data transfers ... presumably just transfer complete - * is enough. - */ - - /* No error */ - sc->curcmd->error = MMC_ERR_NONE; - - /* Check if the command completed */ - if (stat_reg & MMCHS_STAT_CC) { - done = ti_mmchs_intr_cmd_compl(sc, sc->curcmd); - } - - /* Check if the transfer has completed */ - if (stat_reg & MMCHS_STAT_TC) { - done = ti_mmchs_intr_xfer_compl(sc, sc->curcmd); - } - - } - - /* Clear all the interrupt status bits by writing the value back */ - ti_mmchs_write_4(sc, MMCHS_STAT, stat_reg); - - /* This may mark the command as done if there is no stop request */ - /* TODO: This is a bit ugly, needs fix-up */ - if (done) { - ti_mmchs_start(sc); - } - - TI_MMCHS_UNLOCK(sc); -} - -#ifdef SOC_TI_AM335X -static void -ti_mmchs_edma3_rx_xfer_setup(struct ti_mmchs_softc *sc, uint32_t src_paddr, - uint32_t dst_paddr, uint16_t blk_size, uint16_t num_blks) -{ - struct ti_edma3cc_param_set ps; - - bzero(&ps, sizeof(struct ti_edma3cc_param_set)); - ps.src = src_paddr; - ps.dst = dst_paddr; - ps.dstbidx = 4; - ps.dstcidx = blk_size; - ps.acnt = 4; - ps.bcnt = blk_size/4; - ps.ccnt = num_blks; - ps.link = 0xffff; - ps.opt.tcc = sc->dma_rx_trig; - ps.opt.tcinten = 1; - ps.opt.fwid = 2; /* fifo width is 32 */ - ps.opt.sam = 1; - ps.opt.syncdim = 1; - - ti_edma3_param_write(sc->dma_rx_trig, &ps); - ti_edma3_enable_transfer_event(sc->dma_rx_trig); -} - -static void -ti_mmchs_edma3_tx_xfer_setup(struct ti_mmchs_softc *sc, uint32_t src_paddr, - uint32_t dst_paddr, uint16_t blk_size, uint16_t num_blks) -{ - struct ti_edma3cc_param_set ps; - - bzero(&ps, sizeof(struct ti_edma3cc_param_set)); - ps.src = src_paddr; - ps.dst = dst_paddr; - ps.srccidx = blk_size; - ps.bcnt = blk_size/4; - ps.ccnt = num_blks; - ps.srcbidx = 4; - ps.acnt = 0x4; - ps.link = 0xffff; - ps.opt.tcc = sc->dma_tx_trig; - ps.opt.tcinten = 1; - ps.opt.fwid = 2; /* fifo width is 32 */ - ps.opt.dam = 1; - ps.opt.syncdim = 1; - - ti_edma3_param_write(sc->dma_tx_trig, &ps); - ti_edma3_enable_transfer_event(sc->dma_tx_trig); -} -#endif - -/** - * ti_mmchs_start_cmd - starts the given command - * @sc: pointer to the driver context - * @cmd: the command to start - * - * The call tree for this function is - * - ti_mmchs_start_cmd - * - ti_mmchs_start - * - ti_mmchs_request - * - * LOCKING: - * Caller should be holding the OMAP_MMC lock. - * - * RETURNS: - * nothing - */ -static void -ti_mmchs_start_cmd(struct ti_mmchs_softc *sc, struct mmc_command *cmd) -{ - uint32_t cmd_reg, con_reg, ise_reg; - struct mmc_data *data; - struct mmc_request *req; - void *vaddr; - bus_addr_t paddr; -#ifndef SOC_TI_AM335X - uint32_t pktsize; -#endif - sc->curcmd = cmd; - data = cmd->data; - req = cmd->mrq; - - /* Ensure the STR and MIT bits are cleared, these are only used for special - * command types. - */ - con_reg = ti_mmchs_read_4(sc, MMCHS_CON); - con_reg &= ~(MMCHS_CON_STR | MMCHS_CON_MIT); - - /* Load the command into bits 29:24 of the CMD register */ - cmd_reg = (uint32_t)(cmd->opcode & 0x3F) << 24; - - /* Set the default set of interrupts */ - ise_reg = (MMCHS_STAT_CERR | MMCHS_STAT_CTO | MMCHS_STAT_CC | MMCHS_STAT_CEB); - - /* Enable CRC checking if requested */ - if (cmd->flags & MMC_RSP_CRC) - ise_reg |= MMCHS_STAT_CCRC; - - /* Enable reply index checking if the response supports it */ - if (cmd->flags & MMC_RSP_OPCODE) - ise_reg |= MMCHS_STAT_CIE; - - /* Set the expected response length */ - if (MMC_RSP(cmd->flags) == MMC_RSP_NONE) { - cmd_reg |= MMCHS_CMD_RSP_TYPE_NO; - } else { - if (cmd->flags & MMC_RSP_136) - cmd_reg |= MMCHS_CMD_RSP_TYPE_136; - else if (cmd->flags & MMC_RSP_BUSY) - cmd_reg |= MMCHS_CMD_RSP_TYPE_48_BSY; - else - cmd_reg |= MMCHS_CMD_RSP_TYPE_48; - - /* Enable command index/crc checks if necessary expected */ - if (cmd->flags & MMC_RSP_CRC) - cmd_reg |= MMCHS_CMD_CCCE; - if (cmd->flags & MMC_RSP_OPCODE) - cmd_reg |= MMCHS_CMD_CICE; - } - - /* Set the bits for the special commands CMD12 (MMC_STOP_TRANSMISSION) and - * CMD52 (SD_IO_RW_DIRECT) */ - if (cmd->opcode == MMC_STOP_TRANSMISSION) - cmd_reg |= MMCHS_CMD_CMD_TYPE_IO_ABORT; - - /* Check if there is any data to write */ - if (data == NULL) { - /* Clear the block count */ - ti_mmchs_write_4(sc, MMCHS_BLK, 0); - - /* The no data case is fairly simple */ - ti_mmchs_write_4(sc, MMCHS_CON, con_reg); - ti_mmchs_write_4(sc, MMCHS_IE, ise_reg); - ti_mmchs_write_4(sc, MMCHS_ISE, ise_reg); - ti_mmchs_write_4(sc, MMCHS_ARG, cmd->arg); - ti_mmchs_write_4(sc, MMCHS_CMD, cmd_reg); - return; - } - - /* Indicate that data is present */ - cmd_reg |= MMCHS_CMD_DP | MMCHS_CMD_MSBS | MMCHS_CMD_BCE; - - /* Indicate a read operation */ - if (data->flags & MMC_DATA_READ) - cmd_reg |= MMCHS_CMD_DDIR; - - /* Streaming mode */ - if (data->flags & MMC_DATA_STREAM) { - con_reg |= MMCHS_CON_STR; - } - - /* Multi-block mode */ - if (data->flags & MMC_DATA_MULTI) { - cmd_reg |= MMCHS_CMD_MSBS; - } - - /* Enable extra interrupt sources for the transfer */ - ise_reg |= (MMCHS_STAT_TC | MMCHS_STAT_DTO | MMCHS_STAT_DEB | MMCHS_STAT_CEB); - if (cmd->flags & MMC_RSP_CRC) - ise_reg |= MMCHS_STAT_DCRC; - - /* Enable the DMA transfer bit */ - cmd_reg |= MMCHS_CMD_DE; - - /* Set the block size and block count */ - ti_mmchs_write_4(sc, MMCHS_BLK, (1 << 16) | data->len); - - /* Setup the DMA stuff */ - if (data->flags & (MMC_DATA_READ | MMC_DATA_WRITE)) { - - vaddr = data->data; - data->xfer_len = 0; - - /* Map the buffer buf into bus space using the dmamap map. */ - if (bus_dmamap_load(sc->sc_dmatag, sc->sc_dmamap, vaddr, data->len, - ti_mmchs_getaddr, &paddr, 0) != 0) { - - if (req->cmd->flags & STOP_STARTED) - req->stop->error = MMC_ERR_NO_MEMORY; - else - req->cmd->error = MMC_ERR_NO_MEMORY; - sc->req = NULL; - sc->curcmd = NULL; - req->done(req); - return; - } - -#ifndef SOC_TI_AM335X - /* Calculate the packet size, the max packet size is 512 bytes - * (or 128 32-bit elements). - */ - pktsize = min((data->len / 4), (512 / 4)); -#endif - /* Sync the DMA buffer and setup the DMA controller */ - if (data->flags & MMC_DATA_READ) { - bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, BUS_DMASYNC_PREREAD); -#ifdef SOC_TI_AM335X - ti_mmchs_edma3_rx_xfer_setup(sc, sc->sc_data_reg_paddr, - paddr, data->len, 1); -#else - ti_sdma_start_xfer_packet(sc->sc_dmach_rd, sc->sc_data_reg_paddr, - paddr, 1, (data->len / 4), pktsize); -#endif - } else { - bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, BUS_DMASYNC_PREWRITE); -#ifdef SOC_TI_AM335X - ti_mmchs_edma3_tx_xfer_setup(sc, paddr, - sc->sc_data_reg_paddr, data->len, 1); -#else - ti_sdma_start_xfer_packet(sc->sc_dmach_wr, paddr, - sc->sc_data_reg_paddr, 1, (data->len / 4), pktsize); -#endif - } - - /* Increase the mapped count */ - sc->sc_dmamapped++; - - sc->sc_cmd_data_vaddr = vaddr; - sc->sc_cmd_data_len = data->len; - } - - /* Finally kick off the command */ - ti_mmchs_write_4(sc, MMCHS_CON, con_reg); - ti_mmchs_write_4(sc, MMCHS_IE, ise_reg); - ti_mmchs_write_4(sc, MMCHS_ISE, ise_reg); - ti_mmchs_write_4(sc, MMCHS_ARG, cmd->arg); - ti_mmchs_write_4(sc, MMCHS_CMD, cmd_reg); - - /* and we're done */ -} - -/** - * ti_mmchs_start - starts a request stored in the driver context - * @sc: pointer to the driver context - * - * This function is called by ti_mmchs_request() in response to a read/write - * request from the MMC core module. - * - * LOCKING: - * Caller should be holding the OMAP_MMC lock. - * - * RETURNS: - * nothing - */ -static void -ti_mmchs_start(struct ti_mmchs_softc *sc) -{ - struct mmc_request *req; - - /* Sanity check we have a request */ - req = sc->req; - if (req == NULL) - return; - - /* assert locked */ - if (!(sc->flags & CMD_STARTED)) { - sc->flags |= CMD_STARTED; - ti_mmchs_start_cmd(sc, req->cmd); - return; - } - - if (!(sc->flags & STOP_STARTED) && req->stop) { - sc->flags |= STOP_STARTED; - ti_mmchs_start_cmd(sc, req->stop); - return; - } - - /* We must be done -- bad idea to do this while locked? */ - sc->req = NULL; - sc->curcmd = NULL; - req->done(req); -} - -/** - * ti_mmchs_request - entry point for all read/write/cmd requests - * @brdev: mmc bridge device handle - * @reqdev: the device doing the requesting ? - * @req: the action requested - * - * LOCKING: - * None, internally takes the OMAP_MMC lock. - * - * RETURNS: - * 0 on success - * EBUSY if the driver is already performing a request - */ -static int -ti_mmchs_request(device_t brdev, device_t reqdev, struct mmc_request *req) -{ - struct ti_mmchs_softc *sc = device_get_softc(brdev); - - TI_MMCHS_LOCK(sc); - - /* - * XXX do we want to be able to queue up multiple commands? - * XXX sounds like a good idea, but all protocols are sync, so - * XXX maybe the idea is naive... - */ - if (sc->req != NULL) { - TI_MMCHS_UNLOCK(sc); - return (EBUSY); - } - - /* Store the request and start the command */ - sc->req = req; - sc->flags = 0; - ti_mmchs_start(sc); - - TI_MMCHS_UNLOCK(sc); - - return (0); -} - -/** - * ti_mmchs_get_ro - returns the status of the read-only setting - * @brdev: mmc bridge device handle - * @reqdev: device doing the request - * - * This function is relies on hint'ed values to determine which GPIO is used - * to determine if the write protect is enabled. On the BeagleBoard the pin - * is GPIO_23. - * - * LOCKING: - * - - * - * RETURNS: - * 0 if not read-only - * 1 if read only - */ -static int -ti_mmchs_get_ro(device_t brdev, device_t reqdev) -{ - struct ti_mmchs_softc *sc = device_get_softc(brdev); - unsigned int readonly = 0; - - TI_MMCHS_LOCK(sc); - - if ((sc->sc_wp_gpio_pin != -1) && (sc->sc_gpio_dev != NULL)) { - if (GPIO_PIN_GET(sc->sc_gpio_dev, sc->sc_wp_gpio_pin, &readonly) != 0) - readonly = 0; - else - readonly = (readonly == 0) ? 0 : 1; - } - - TI_MMCHS_UNLOCK(sc); - - return (readonly); -} - -/** - * ti_mmchs_send_init_stream - sets bus/controller settings - * @brdev: mmc bridge device handle - * @reqdev: device doing the request - * - * Send init stream sequence to card before sending IDLE command - * - * LOCKING: - * - * - * RETURNS: - * 0 if function succeeded - */ -static void -ti_mmchs_send_init_stream(struct ti_mmchs_softc *sc) -{ - unsigned long timeout; - uint32_t ie, ise, con; - - ti_mmchs_dbg(sc, "Performing init sequence\n"); - - /* Prior to issuing any command, the MMCHS controller has to execute a - * special INIT procedure. The MMCHS controller has to generate a clock - * during 1ms. During the INIT procedure, the MMCHS controller generates 80 - * clock periods. In order to keep the 1ms gap, the MMCHS controller should - * be configured to generate a clock whose frequency is smaller or equal to - * 80 KHz. If the MMCHS controller divider bitfield width doesn't allow to - * choose big values, the MMCHS controller driver should perform the INIT - * procedure twice or three times. Twice is generally enough. - * - * The INIt procedure is executed by setting MMCHS1.MMCHS_CON[1] INIT - * bitfield to 1 and by sending a dummy command, writing 0x00000000 in - * MMCHS1.MMCHS_CMD register. - */ - - /* Disable interrupt status events but enable interrupt generation. - * This doesn't seem right to me, but if the interrupt generation is not - * enabled the CC bit doesn't seem to be set in the STAT register. - */ - - /* Enable interrupt generation */ - ie = ti_mmchs_read_4(sc, MMCHS_IE); - ti_mmchs_write_4(sc, MMCHS_IE, 0x307F0033); - - /* Disable generation of status events (stops interrupt triggering) */ - ise = ti_mmchs_read_4(sc, MMCHS_ISE); - ti_mmchs_write_4(sc, MMCHS_ISE, 0); - - /* Set the initialise stream bit */ - con = ti_mmchs_read_4(sc, MMCHS_CON); - con |= MMCHS_CON_INIT; - ti_mmchs_write_4(sc, MMCHS_CON, con); - - /* Write a dummy command 0x00 */ - ti_mmchs_write_4(sc, MMCHS_CMD, 0x00000000); - - /* Loop waiting for the command to finish */ - timeout = hz; - do { - pause("MMCINIT", 1); - if (timeout-- == 0) { - device_printf(sc->sc_dev, "Error: first stream init timed out\n"); - break; - } - } while (!(ti_mmchs_read_4(sc, MMCHS_STAT) & MMCHS_STAT_CC)); - - /* Clear the command complete status bit */ - ti_mmchs_write_4(sc, MMCHS_STAT, MMCHS_STAT_CC); - - /* Write another dummy command 0x00 */ - ti_mmchs_write_4(sc, MMCHS_CMD, 0x00000000); - - /* Loop waiting for the second command to finish */ - timeout = hz; - do { - pause("MMCINIT", 1); - if (timeout-- == 0) { - device_printf(sc->sc_dev, "Error: second stream init timed out\n"); - break; - } - } while (!(ti_mmchs_read_4(sc, MMCHS_STAT) & MMCHS_STAT_CC)); - - /* Clear the stream init bit */ - con &= ~MMCHS_CON_INIT; - ti_mmchs_write_4(sc, MMCHS_CON, con); - - /* Clear the status register, then restore the IE and ISE registers */ - ti_mmchs_write_4(sc, MMCHS_STAT, 0xffffffff); - ti_mmchs_read_4(sc, MMCHS_STAT); - - ti_mmchs_write_4(sc, MMCHS_ISE, ise); - ti_mmchs_write_4(sc, MMCHS_IE, ie); -} - -/** - * ti_mmchs_update_ios - sets bus/controller settings - * @brdev: mmc bridge device handle - * @reqdev: device doing the request - * - * Called to set the bus and controller settings that need to be applied to - * the actual HW. Currently this function just sets the bus width and the - * clock speed. - * - * LOCKING: - * - * - * RETURNS: - * 0 if function succeeded - */ -static int -ti_mmchs_update_ios(device_t brdev, device_t reqdev) -{ - struct ti_mmchs_softc *sc; - struct mmc_host *host; - struct mmc_ios *ios; - uint32_t clkdiv; - uint32_t hctl_reg; - uint32_t con_reg; - uint32_t sysctl_reg; -#ifndef SOC_TI_AM335X - uint16_t mv; -#endif - unsigned long timeout; - int do_card_init = 0; - - sc = device_get_softc(brdev); - host = &sc->host; - ios = &host->ios; - - /* Read the initial values of the registers */ - hctl_reg = ti_mmchs_read_4(sc, MMCHS_HCTL); - con_reg = ti_mmchs_read_4(sc, MMCHS_CON); - - /* Set the bus width */ - switch (ios->bus_width) { - case bus_width_1: - hctl_reg &= ~MMCHS_HCTL_DTW; - con_reg &= ~MMCHS_CON_DW8; - break; - case bus_width_4: - hctl_reg |= MMCHS_HCTL_DTW; - con_reg &= ~MMCHS_CON_DW8; - break; - case bus_width_8: - con_reg |= MMCHS_CON_DW8; - break; - } - - /* Finally write all these settings back to the registers */ - ti_mmchs_write_4(sc, MMCHS_HCTL, hctl_reg); - ti_mmchs_write_4(sc, MMCHS_CON, con_reg); - - /* Check if we need to change the external voltage regulator */ - if (sc->sc_cur_power_mode != ios->power_mode) { - - if (ios->power_mode == power_up) { - - /* Set the power level */ - hctl_reg = ti_mmchs_read_4(sc, MMCHS_HCTL); - hctl_reg &= ~(MMCHS_HCTL_SDVS_MASK | MMCHS_HCTL_SDBP); - - if ((ios->vdd == -1) || (ios->vdd >= vdd_240)) { -#ifndef SOC_TI_AM335X - mv = 3000; -#endif - hctl_reg |= MMCHS_HCTL_SDVS_V30; - } else { -#ifndef SOC_TI_AM335X - mv = 1800; -#endif - hctl_reg |= MMCHS_HCTL_SDVS_V18; - } - - ti_mmchs_write_4(sc, MMCHS_HCTL, hctl_reg); - -#ifdef SOC_TI_AM335X - printf("%s: TWL unimplemented\n", __func__); -#else - /* Set the desired voltage on the regulator */ - if (sc->sc_vreg_dev && sc->sc_vreg_name) - twl_vreg_set_voltage(sc->sc_vreg_dev, sc->sc_vreg_name, mv); -#endif - /* Enable the bus power */ - ti_mmchs_write_4(sc, MMCHS_HCTL, (hctl_reg | MMCHS_HCTL_SDBP)); - timeout = hz; - while (!(ti_mmchs_read_4(sc, MMCHS_HCTL) & MMCHS_HCTL_SDBP)) { - if (timeout-- == 0) - break; - pause("MMC_PWRON", 1); - } - - } else if (ios->power_mode == power_off) { - /* Disable the bus power */ - hctl_reg = ti_mmchs_read_4(sc, MMCHS_HCTL); - ti_mmchs_write_4(sc, MMCHS_HCTL, (hctl_reg & ~MMCHS_HCTL_SDBP)); - -#ifdef SOC_TI_AM335X - printf("%s: TWL unimplemented\n", __func__); -#else - /* Turn the power off on the voltage regulator */ - if (sc->sc_vreg_dev && sc->sc_vreg_name) - twl_vreg_set_voltage(sc->sc_vreg_dev, sc->sc_vreg_name, 0); -#endif - } else if (ios->power_mode == power_on) { - /* Force a card re-initialisation sequence */ - do_card_init = 1; - } - - /* Save the new power state */ - sc->sc_cur_power_mode = ios->power_mode; - } - - /* need the MMCHS_SYSCTL register */ - sysctl_reg = ti_mmchs_read_4(sc, MMCHS_SYSCTL); - - /* Just in case this hasn't been setup before, set the timeout to the default */ - sysctl_reg &= ~MMCHS_SYSCTL_DTO_MASK; - sysctl_reg |= MMCHS_SYSCTL_DTO(0xe); - - /* Disable the clock output while configuring the new clock */ - sysctl_reg &= ~(MMCHS_SYSCTL_ICE | MMCHS_SYSCTL_CEN); - ti_mmchs_write_4(sc, MMCHS_SYSCTL, sysctl_reg); - - /* bus mode? */ - if (ios->clock == 0) { - clkdiv = 0; - } else { - clkdiv = sc->sc_ref_freq / ios->clock; - if (clkdiv < 1) - clkdiv = 1; - if ((sc->sc_ref_freq / clkdiv) > ios->clock) - clkdiv += 1; - if (clkdiv > 250) - clkdiv = 250; - } - - /* Set the new clock divider */ - sysctl_reg &= ~MMCHS_SYSCTL_CLKD_MASK; - sysctl_reg |= MMCHS_SYSCTL_CLKD(clkdiv); - - /* Write the new settings ... */ - ti_mmchs_write_4(sc, MMCHS_SYSCTL, sysctl_reg); - /* ... write the internal clock enable bit ... */ - ti_mmchs_write_4(sc, MMCHS_SYSCTL, sysctl_reg | MMCHS_SYSCTL_ICE); - /* ... wait for the clock to stablise ... */ - while (((sysctl_reg = ti_mmchs_read_4(sc, MMCHS_SYSCTL)) & - MMCHS_SYSCTL_ICS) == 0) { - continue; - } - /* ... then enable */ - sysctl_reg |= MMCHS_SYSCTL_CEN; - ti_mmchs_write_4(sc, MMCHS_SYSCTL, sysctl_reg); - - /* If the power state has changed to 'power_on' then run the init sequence*/ - if (do_card_init) { - ti_mmchs_send_init_stream(sc); - } - - /* Set the bus mode (opendrain or normal) */ - con_reg = ti_mmchs_read_4(sc, MMCHS_CON); - if (ios->bus_mode == opendrain) - con_reg |= MMCHS_CON_OD; - else - con_reg &= ~MMCHS_CON_OD; - ti_mmchs_write_4(sc, MMCHS_CON, con_reg); - - return (0); -} - -/** - * ti_mmchs_acquire_host - - * @brdev: mmc bridge device handle - * @reqdev: device doing the request - * - * TODO: Is this function needed ? - * - * LOCKING: - * none - * - * RETURNS: - * 0 function succeeded - * - */ -static int -ti_mmchs_acquire_host(device_t brdev, device_t reqdev) -{ - struct ti_mmchs_softc *sc = device_get_softc(brdev); - int err = 0; - - TI_MMCHS_LOCK(sc); - - while (sc->bus_busy) { - msleep(sc, &sc->sc_mtx, PZERO, "mmc", hz / 5); - } - - sc->bus_busy++; - - TI_MMCHS_UNLOCK(sc); - - return (err); -} - -/** - * ti_mmchs_release_host - - * @brdev: mmc bridge device handle - * @reqdev: device doing the request - * - * TODO: Is this function needed ? - * - * LOCKING: - * none - * - * RETURNS: - * 0 function succeeded - * - */ -static int -ti_mmchs_release_host(device_t brdev, device_t reqdev) -{ - struct ti_mmchs_softc *sc = device_get_softc(brdev); - - TI_MMCHS_LOCK(sc); - - sc->bus_busy--; - wakeup(sc); - - TI_MMCHS_UNLOCK(sc); - - return (0); -} - -/** - * ti_mmchs_read_ivar - returns driver conf variables - * @bus: - * @child: - * @which: The variable to get the result for - * @result: Upon return will store the variable value - * - * - * - * LOCKING: - * None, caller must hold locks - * - * RETURNS: - * 0 on success - * EINVAL if the variable requested is invalid - */ -static int -ti_mmchs_read_ivar(device_t bus, device_t child, int which, uintptr_t *result) -{ - struct ti_mmchs_softc *sc = device_get_softc(bus); - - switch (which) { - case MMCBR_IVAR_BUS_MODE: - *(int *)result = sc->host.ios.bus_mode; - break; - case MMCBR_IVAR_BUS_WIDTH: - *(int *)result = sc->host.ios.bus_width; - break; - case MMCBR_IVAR_CHIP_SELECT: - *(int *)result = sc->host.ios.chip_select; - break; - case MMCBR_IVAR_CLOCK: - *(int *)result = sc->host.ios.clock; - break; - case MMCBR_IVAR_F_MIN: - *(int *)result = sc->host.f_min; - break; - case MMCBR_IVAR_F_MAX: - *(int *)result = sc->host.f_max; - break; - case MMCBR_IVAR_HOST_OCR: - *(int *)result = sc->host.host_ocr; - break; - case MMCBR_IVAR_MODE: - *(int *)result = sc->host.mode; - break; - case MMCBR_IVAR_OCR: - *(int *)result = sc->host.ocr; - break; - case MMCBR_IVAR_POWER_MODE: - *(int *)result = sc->host.ios.power_mode; - break; - case MMCBR_IVAR_VDD: - *(int *)result = sc->host.ios.vdd; - break; - case MMCBR_IVAR_CAPS: - *(int *)result = sc->host.caps; - break; - case MMCBR_IVAR_MAX_DATA: - *(int *)result = 1; - break; - default: - return (EINVAL); - } - return (0); -} - -/** - * ti_mmchs_write_ivar - writes a driver conf variables - * @bus: - * @child: - * @which: The variable to set - * @value: The value to write into the variable - * - * - * - * LOCKING: - * None, caller must hold locks - * - * RETURNS: - * 0 on success - * EINVAL if the variable requested is invalid - */ -static int -ti_mmchs_write_ivar(device_t bus, device_t child, int which, uintptr_t value) -{ - struct ti_mmchs_softc *sc = device_get_softc(bus); - - switch (which) { - case MMCBR_IVAR_BUS_MODE: - sc->host.ios.bus_mode = value; - break; - case MMCBR_IVAR_BUS_WIDTH: - sc->host.ios.bus_width = value; - break; - case MMCBR_IVAR_CHIP_SELECT: - sc->host.ios.chip_select = value; - break; - case MMCBR_IVAR_CLOCK: - sc->host.ios.clock = value; - break; - case MMCBR_IVAR_MODE: - sc->host.mode = value; - break; - case MMCBR_IVAR_OCR: - sc->host.ocr = value; - break; - case MMCBR_IVAR_POWER_MODE: - sc->host.ios.power_mode = value; - break; - case MMCBR_IVAR_VDD: - sc->host.ios.vdd = value; - break; - /* These are read-only */ - case MMCBR_IVAR_CAPS: - case MMCBR_IVAR_HOST_OCR: - case MMCBR_IVAR_F_MIN: - case MMCBR_IVAR_F_MAX: - case MMCBR_IVAR_MAX_DATA: - return (EINVAL); - default: - return (EINVAL); - } - return (0); -} - -/** - * ti_mmchs_hw_init - initialises the MMC/SD/SIO controller - * @dev: mmc device handle - * - * Called by the driver attach function during driver initialisation. This - * function is responsibly to setup the controller ready for transactions. - * - * LOCKING: - * No locking, assumed to only be called during initialisation. - * - * RETURNS: - * nothing - */ -static void -ti_mmchs_hw_init(device_t dev) -{ - struct ti_mmchs_softc *sc = device_get_softc(dev); - clk_ident_t clk; - unsigned long timeout; - uint32_t sysctl; - uint32_t capa; - uint32_t con, sysconfig; - - /* 1: Enable the controller and interface/functional clocks */ - clk = MMC0_CLK + sc->device_id; - - if (ti_prcm_clk_enable(clk) != 0) { - device_printf(dev, "Error: failed to enable MMC clock\n"); - return; - } - - /* 1a: Get the frequency of the source clock */ - if (ti_prcm_clk_get_source_freq(clk, &sc->sc_ref_freq) != 0) { - device_printf(dev, "Error: failed to get source clock freq\n"); - return; - } - - /* 2: Issue a softreset to the controller */ - sysconfig = ti_mmchs_read_4(sc, MMCHS_SYSCONFIG); - sysconfig |= MMCHS_SYSCONFIG_SRST; - ti_mmchs_write_4(sc, MMCHS_SYSCONFIG, sysconfig); - timeout = 100; - while ((ti_mmchs_read_4(sc, MMCHS_SYSSTATUS) & 0x01) == 0x0) { - DELAY(1000); - if (timeout-- == 0) { - device_printf(dev, "Error: reset operation timed out\n"); - return; - } - } - - /* 3: Reset both the command and data state machines */ - sysctl = ti_mmchs_read_4(sc, MMCHS_SYSCTL); - ti_mmchs_write_4(sc, MMCHS_SYSCTL, sysctl | MMCHS_SYSCTL_SRA); - timeout = 100; - while ((ti_mmchs_read_4(sc, MMCHS_SYSCTL) & MMCHS_SYSCTL_SRA) != 0x0) { - DELAY(1000); - if (timeout-- == 0) { - device_printf(dev, "Error: reset operation timed out\n"); - return; - } - } - - /* 4: Set initial host configuration (1-bit mode, pwroff) and capabilities */ - ti_mmchs_write_4(sc, MMCHS_HCTL, MMCHS_HCTL_SDVS_V30); - - capa = ti_mmchs_read_4(sc, MMCHS_CAPA); - ti_mmchs_write_4(sc, MMCHS_CAPA, capa | MMCHS_CAPA_VS30 | MMCHS_CAPA_VS18); - - /* 5: Set the initial bus configuration - * 0 CTPL_MMC_SD : Control Power for DAT1 line - * 0 WPP_ACTIVE_HIGH : Write protect polarity - * 0 CDP_ACTIVE_HIGH : Card detect polarity - * 0 CTO_ENABLED : MMC interrupt command - * 0 DW8_DISABLED : 8-bit mode MMC select - * 0 MODE_FUNC : Mode select - * 0 STREAM_DISABLED : Stream command - * 0 HR_DISABLED : Broadcast host response - * 0 INIT_DISABLED : Send initialization stream - * 0 OD_DISABLED : No Open Drain - */ - con = ti_mmchs_read_4(sc, MMCHS_CON) & MMCHS_CON_DVAL_MASK; - ti_mmchs_write_4(sc, MMCHS_CON, con); - -} - -/** - * ti_mmchs_fini - shutdown the MMC/SD/SIO controller - * @dev: mmc device handle - * - * Responsible for shutting done the MMC controller, this function may be - * called as part of a reset sequence. - * - * LOCKING: - * No locking, assumed to be called during tear-down/reset. - * - * RETURNS: - * nothing - */ -static void -ti_mmchs_hw_fini(device_t dev) -{ - struct ti_mmchs_softc *sc = device_get_softc(dev); - - /* Disable all interrupts */ - ti_mmchs_write_4(sc, MMCHS_ISE, 0x00000000); - ti_mmchs_write_4(sc, MMCHS_IE, 0x00000000); - - /* Disable the functional and interface clocks */ - ti_prcm_clk_disable(MMC0_CLK + sc->device_id); -} - -/** - * ti_mmchs_init_dma_channels - initalise the DMA channels - * @sc: driver soft context - * - * Attempts to activate an RX and TX DMA channel for the MMC device. - * - * LOCKING: - * No locking, assumed to be called during tear-down/reset. - * - * RETURNS: - * 0 on success, a negative error code on failure. - */ -static int -ti_mmchs_init_dma_channels(struct ti_mmchs_softc *sc) -{ -#ifdef SOC_TI_AM335X - switch (sc->device_id) { - case 0: - sc->dma_tx_trig = TI_EDMA3_EVENT_SDTXEVT0; - sc->dma_rx_trig = TI_EDMA3_EVENT_SDRXEVT0; - break; - case 1: - sc->dma_tx_trig = TI_EDMA3_EVENT_SDTXEVT1; - sc->dma_rx_trig = TI_EDMA3_EVENT_SDRXEVT1; - break; - default: - return(EINVAL); - } - -#define EVTQNUM 0 - /* TODO EDMA3 have 3 queues, so we need some queue allocation call */ - ti_edma3_init(EVTQNUM); - ti_edma3_request_dma_ch(sc->dma_tx_trig, sc->dma_tx_trig, EVTQNUM); - ti_edma3_request_dma_ch(sc->dma_rx_trig, sc->dma_rx_trig, EVTQNUM); -#else - int err; - uint32_t rev; - - /* Get the current chip revision */ - rev = ti_revision(); - if ((OMAP_REV_DEVICE(rev) != OMAP4430_DEV) && (sc->device_id > 3)) - return(EINVAL); - - /* Get the DMA MMC triggers */ - switch (sc->device_id) { - case 1: - sc->dma_tx_trig = 60; - sc->dma_rx_trig = 61; - break; - case 2: - sc->dma_tx_trig = 46; - sc->dma_rx_trig = 47; - break; - case 3: - sc->dma_tx_trig = 76; - sc->dma_rx_trig = 77; - break; - /* The following are OMAP4 only */ - case 4: - sc->dma_tx_trig = 56; - sc->dma_rx_trig = 57; - break; - case 5: - sc->dma_tx_trig = 58; - sc->dma_rx_trig = 59; - break; - default: - return(EINVAL); - } - - /* Activate a RX channel from the OMAP DMA driver */ - err = ti_sdma_activate_channel(&sc->sc_dmach_rd, ti_mmchs_dma_intr, sc); - if (err != 0) - return(err); - - /* Setup the RX channel for MMC data transfers */ - ti_sdma_set_xfer_burst(sc->sc_dmach_rd, TI_SDMA_BURST_NONE, - TI_SDMA_BURST_64); - ti_sdma_set_xfer_data_type(sc->sc_dmach_rd, TI_SDMA_DATA_32BITS_SCALAR); - ti_sdma_sync_params(sc->sc_dmach_rd, sc->dma_rx_trig, - TI_SDMA_SYNC_PACKET | TI_SDMA_SYNC_TRIG_ON_SRC); - ti_sdma_set_addr_mode(sc->sc_dmach_rd, TI_SDMA_ADDR_CONSTANT, - TI_SDMA_ADDR_POST_INCREMENT); - - /* Activate and configure the TX DMA channel */ - err = ti_sdma_activate_channel(&sc->sc_dmach_wr, ti_mmchs_dma_intr, sc); - if (err != 0) - return(err); - - /* Setup the TX channel for MMC data transfers */ - ti_sdma_set_xfer_burst(sc->sc_dmach_wr, TI_SDMA_BURST_64, - TI_SDMA_BURST_NONE); - ti_sdma_set_xfer_data_type(sc->sc_dmach_wr, TI_SDMA_DATA_32BITS_SCALAR); - ti_sdma_sync_params(sc->sc_dmach_wr, sc->dma_tx_trig, - TI_SDMA_SYNC_PACKET | TI_SDMA_SYNC_TRIG_ON_DST); - ti_sdma_set_addr_mode(sc->sc_dmach_wr, TI_SDMA_ADDR_POST_INCREMENT, - TI_SDMA_ADDR_CONSTANT); -#endif - return(0); -} - -/** - * ti_mmchs_deactivate - deactivates the driver - * @dev: mmc device handle - * - * Unmaps the register set and releases the IRQ resource. - * - * LOCKING: - * None required - * - * RETURNS: - * nothing - */ -static void -ti_mmchs_deactivate(device_t dev) -{ - struct ti_mmchs_softc *sc= device_get_softc(dev); - - /* Remove the IRQ handler */ - if (sc->sc_irq_h != NULL) { - bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_irq_h); - sc->sc_irq_h = NULL; - } - - /* Do the generic detach */ - bus_generic_detach(sc->sc_dev); - -#ifdef SOC_TI_AM335X - printf("%s: DMA unimplemented\n", __func__); -#else - /* Deactivate the DMA channels */ - ti_sdma_deactivate_channel(sc->sc_dmach_rd); - ti_sdma_deactivate_channel(sc->sc_dmach_wr); -#endif - - /* Unmap the MMC controller registers */ - if (sc->sc_mem_res != 0) { - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->sc_irq_res), - sc->sc_mem_res); - sc->sc_mem_res = NULL; - } - - /* Release the IRQ resource */ - if (sc->sc_irq_res != NULL) { - bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->sc_irq_res), - sc->sc_irq_res); - sc->sc_irq_res = NULL; - } - - return; -} - -/** - * ti_mmchs_activate - activates the driver - * @dev: mmc device handle - * - * Maps in the register set and requests an IRQ handler for the MMC controller. - * - * LOCKING: - * None required - * - * RETURNS: - * 0 on sucess - * ENOMEM if failed to map register set - */ -static int -ti_mmchs_activate(device_t dev) -{ - struct ti_mmchs_softc *sc = device_get_softc(dev); - int rid; - int err; - - /* Get the memory resource for the register mapping */ - rid = 0; - sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->sc_mem_res == NULL) - panic("%s: Cannot map registers", device_get_name(dev)); - - /* Allocate an IRQ resource for the MMC controller */ - rid = 0; - sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE | RF_SHAREABLE); - if (sc->sc_irq_res == NULL) - goto errout; - - /* Allocate DMA tags and maps */ - err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, - NULL, MAXPHYS, 1, MAXPHYS, BUS_DMA_ALLOCNOW, NULL, - NULL, &sc->sc_dmatag); - if (err != 0) - goto errout; - - err = bus_dmamap_create(sc->sc_dmatag, 0, &sc->sc_dmamap); - if (err != 0) - goto errout; - - /* Initialise the DMA channels to be used by the controller */ - err = ti_mmchs_init_dma_channels(sc); - if (err != 0) - goto errout; - - /* Set the register offset */ - if (ti_chip() == CHIP_OMAP_4) - sc->sc_reg_off = OMAP4_MMCHS_REG_OFFSET; - else if (ti_chip() == CHIP_AM335X) - sc->sc_reg_off = AM335X_MMCHS_REG_OFFSET; - else - panic("Unknown OMAP device\n"); - - /* Get the physical address of the MMC data register, needed for DMA */ - sc->sc_data_reg_paddr = BUS_SPACE_PHYSADDR(sc->sc_mem_res, - sc->sc_reg_off + MMCHS_DATA); - - /* Set the initial power state to off */ - sc->sc_cur_power_mode = power_off; - - return (0); - -errout: - ti_mmchs_deactivate(dev); - return (ENOMEM); -} - -/** - * ti_mmchs_probe - probe function for the driver - * @dev: mmc device handle - * - * - * - * RETURNS: - * always returns 0 - */ -static int -ti_mmchs_probe(device_t dev) -{ - - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (!ofw_bus_is_compatible(dev, "ti,mmchs")) - return (ENXIO); - - device_set_desc(dev, "TI MMC/SD/SDIO High Speed Interface"); - return (0); -} - -/** - * ti_mmchs_attach - attach function for the driver - * @dev: mmc device handle - * - * Driver initialisation, sets-up the bus mappings, DMA mapping/channels and - * the actual controller by calling ti_mmchs_init(). - * - * RETURNS: - * Returns 0 on success or a negative error code. - */ -static int -ti_mmchs_attach(device_t dev) -{ - struct ti_mmchs_softc *sc = device_get_softc(dev); - int unit = device_get_unit(dev); - phandle_t node; - pcell_t did; - int err; - - /* Save the device and bus tag */ - sc->sc_dev = dev; - - /* Get the mmchs device id from FDT */ - node = ofw_bus_get_node(dev); - if ((OF_getprop(node, "mmchs-device-id", &did, sizeof(did))) <= 0) { - device_printf(dev, "missing mmchs-device-id attribute in FDT\n"); - return (ENXIO); - } - sc->device_id = fdt32_to_cpu(did); - - /* Initiate the mtex lock */ - TI_MMCHS_LOCK_INIT(sc); - - /* Indicate the DMA channels haven't yet been allocated */ - sc->sc_dmach_rd = (unsigned int)-1; - sc->sc_dmach_wr = (unsigned int)-1; - - /* Get the hint'ed write detect pin */ - /* TODO: take this from FDT */ - if (resource_int_value("ti_mmchs", unit, "wp_gpio", &sc->sc_wp_gpio_pin) != 0){ - sc->sc_wp_gpio_pin = -1; - } else { - /* Get the GPIO device, we need this for the write protect pin */ - sc->sc_gpio_dev = devclass_get_device(devclass_find("gpio"), 0); - if (sc->sc_gpio_dev == NULL) - device_printf(dev, "Error: failed to get the GPIO device\n"); - else - GPIO_PIN_SETFLAGS(sc->sc_gpio_dev, sc->sc_wp_gpio_pin, - GPIO_PIN_INPUT); - } - - /* Get the TWL voltage regulator device, we need this to for setting the - * voltage of the bus on certain OMAP platforms. - */ - sc->sc_vreg_name = NULL; - - /* TODO: add voltage regulator knob to FDT */ -#ifdef notyet - sc->sc_vreg_dev = devclass_get_device(devclass_find("twl_vreg"), 0); - if (sc->sc_vreg_dev == NULL) { - device_printf(dev, "Error: failed to get the votlage regulator" - " device\n"); - sc->sc_vreg_name = NULL; - } -#endif - - /* Activate the device */ - err = ti_mmchs_activate(dev); - if (err) - goto out; - - /* Initialise the controller */ - ti_mmchs_hw_init(dev); - - /* Activate the interrupt and attach a handler */ - err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE, - NULL, ti_mmchs_intr, sc, &sc->sc_irq_h); - if (err != 0) - goto out; - - /* Add host details */ - sc->host.f_min = sc->sc_ref_freq / 1023; - sc->host.f_max = sc->sc_ref_freq; - sc->host.host_ocr = MMC_OCR_290_300 | MMC_OCR_300_310; - sc->host.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; - - device_add_child(dev, "mmc", 0); - - err = bus_generic_attach(dev); - -out: - if (err) { - TI_MMCHS_LOCK_DESTROY(sc); - ti_mmchs_deactivate(dev); - -#ifdef SOC_TI_AM335X - printf("%s: DMA unimplemented\n", __func__); -#else - if (sc->sc_dmach_rd != (unsigned int)-1) - ti_sdma_deactivate_channel(sc->sc_dmach_rd); - if (sc->sc_dmach_wr != (unsigned int)-1) - ti_sdma_deactivate_channel(sc->sc_dmach_wr); -#endif - } - - return (err); -} - -/** - * ti_mmchs_detach - dettach function for the driver - * @dev: mmc device handle - * - * Shutdowns the controll and release resources allocated by the driver. - * - * RETURNS: - * Always returns 0. - */ -static int -ti_mmchs_detach(device_t dev) -{ -#ifndef SOC_TI_AM335X - struct ti_mmchs_softc *sc = device_get_softc(dev); -#endif - - ti_mmchs_hw_fini(dev); - ti_mmchs_deactivate(dev); - -#ifdef SOC_TI_AM335X - printf("%s: DMA unimplemented\n", __func__); -#else - ti_sdma_deactivate_channel(sc->sc_dmach_wr); - ti_sdma_deactivate_channel(sc->sc_dmach_rd); -#endif - - return (0); -} - -static device_method_t ti_mmchs_methods[] = { - /* device_if */ - DEVMETHOD(device_probe, ti_mmchs_probe), - DEVMETHOD(device_attach, ti_mmchs_attach), - DEVMETHOD(device_detach, ti_mmchs_detach), - - /* Bus interface */ - DEVMETHOD(bus_read_ivar, ti_mmchs_read_ivar), - DEVMETHOD(bus_write_ivar, ti_mmchs_write_ivar), - - /* mmcbr_if - MMC state machine callbacks */ - DEVMETHOD(mmcbr_update_ios, ti_mmchs_update_ios), - DEVMETHOD(mmcbr_request, ti_mmchs_request), - DEVMETHOD(mmcbr_get_ro, ti_mmchs_get_ro), - DEVMETHOD(mmcbr_acquire_host, ti_mmchs_acquire_host), - DEVMETHOD(mmcbr_release_host, ti_mmchs_release_host), - - {0, 0}, -}; - -static driver_t ti_mmchs_driver = { - "ti_mmchs", - ti_mmchs_methods, - sizeof(struct ti_mmchs_softc), -}; -static devclass_t ti_mmchs_devclass; - -DRIVER_MODULE(ti_mmchs, simplebus, ti_mmchs_driver, ti_mmchs_devclass, 0, 0); -MODULE_DEPEND(ti_mmchs, ti_prcm, 1, 1, 1); -#ifdef SOC_TI_AM335X -MODULE_DEPEND(ti_mmchs, ti_edma, 1, 1, 1); -#else -MODULE_DEPEND(ti_mmchs, ti_sdma, 1, 1, 1); -#endif -MODULE_DEPEND(ti_mmchs, ti_gpio, 1, 1, 1); - -/* FIXME: MODULE_DEPEND(ti_mmchs, twl_vreg, 1, 1, 1); */ diff --git a/sys/arm/ti/ti_mmchs.h b/sys/arm/ti/ti_mmchs.h deleted file mode 100644 index 175c0c6d10e..00000000000 --- a/sys/arm/ti/ti_mmchs.h +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * Copyright (c) 2011 - * Ben Gray . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ -#ifndef _TI_MMCHS_H_ -#define _TI_MMCHS_H_ - -/** - * Header file for the TI MMC/SD/SDIO driver. - * - * Simply contains register addresses and bit flags. - */ - -/* Register offsets within each of the MMC/SD/SDIO controllers */ -#define MMCHS_SYSCONFIG 0x010 -#define MMCHS_SYSSTATUS 0x014 -#define MMCHS_CSRE 0x024 -#define MMCHS_SYSTEST 0x028 -#define MMCHS_CON 0x02C -#define MMCHS_PWCNT 0x030 -#define MMCHS_BLK 0x104 -#define MMCHS_ARG 0x108 -#define MMCHS_CMD 0x10C -#define MMCHS_RSP10 0x110 -#define MMCHS_RSP32 0x114 -#define MMCHS_RSP54 0x118 -#define MMCHS_RSP76 0x11C -#define MMCHS_DATA 0x120 -#define MMCHS_PSTATE 0x124 -#define MMCHS_HCTL 0x128 -#define MMCHS_SYSCTL 0x12C -#define MMCHS_STAT 0x130 -#define MMCHS_IE 0x134 -#define MMCHS_ISE 0x138 -#define MMCHS_AC12 0x13C -#define MMCHS_CAPA 0x140 -#define MMCHS_CUR_CAPA 0x148 -#define MMCHS_REV 0x1FC - -/* OMAP4 and OMAP4 have different register addresses */ -#define OMAP3_MMCHS_REG_OFFSET 0x000 -#define OMAP4_MMCHS_REG_OFFSET 0x100 -#define AM335X_MMCHS_REG_OFFSET 0x100 - -/* Register bit settings */ -#define MMCHS_SYSCONFIG_CLK_FUN (2 << 8) -#define MMCHS_SYSCONFIG_CLK_IFC (1 << 8) -#define MMCHS_SYSCONFIG_SIDL (2 << 3) -#define MMCHS_SYSCONFIG_ENW (1 << 2) -#define MMCHS_SYSCONFIG_SRST (1 << 1) -#define MMCHS_SYSCONFIG_AIDL (1 << 0) -#define MMCHS_STAT_BADA (1UL << 29) -#define MMCHS_STAT_CERR (1UL << 28) -#define MMCHS_STAT_ACE (1UL << 24) -#define MMCHS_STAT_DEB (1UL << 22) -#define MMCHS_STAT_DCRC (1UL << 21) -#define MMCHS_STAT_DTO (1UL << 20) -#define MMCHS_STAT_CIE (1UL << 19) -#define MMCHS_STAT_CEB (1UL << 18) -#define MMCHS_STAT_CCRC (1UL << 17) -#define MMCHS_STAT_CTO (1UL << 16) -#define MMCHS_STAT_ERRI (1UL << 15) -#define MMCHS_STAT_OBI (1UL << 9) -#define MMCHS_STAT_CIRQ (1UL << 8) -#define MMCHS_STAT_BRR (1UL << 5) -#define MMCHS_STAT_BWR (1UL << 4) -#define MMCHS_STAT_BGE (1UL << 2) -#define MMCHS_STAT_TC (1UL << 1) -#define MMCHS_STAT_CC (1UL << 0) - -#define MMCHS_STAT_CLEAR_MASK 0x3BFF8337UL - -#define MMCHS_SYSCTL_SRD (1UL << 26) -#define MMCHS_SYSCTL_SRC (1UL << 25) -#define MMCHS_SYSCTL_SRA (1UL << 24) -#define MMCHS_SYSCTL_DTO(x) (((x) & 0xf) << 16) -#define MMCHS_SYSCTL_DTO_MASK MMCHS_SYSCTL_DTO(0xf) -#define MMCHS_SYSCTL_CLKD(x) (((x) & 0x3ff) << 6) -#define MMCHS_SYSCTL_CLKD_MASK MMCHS_SYSCTL_CLKD(0x3ff) -#define MMCHS_SYSCTL_CEN (1UL << 2) -#define MMCHS_SYSCTL_ICS (1UL << 1) -#define MMCHS_SYSCTL_ICE (1UL << 0) - -#define MMCHS_HCTL_OBWE (1UL << 27) -#define MMCHS_HCTL_REM (1UL << 26) -#define MMCHS_HCTL_INS (1UL << 25) -#define MMCHS_HCTL_IWE (1UL << 24) -#define MMCHS_HCTL_IBG (1UL << 19) -#define MMCHS_HCTL_RWC (1UL << 18) -#define MMCHS_HCTL_CR (1UL << 17) -#define MMCHS_HCTL_SBGR (1UL << 16) -#define MMCHS_HCTL_SDVS_MASK (7UL << 9) -#define MMCHS_HCTL_SDVS_V18 (5UL << 9) -#define MMCHS_HCTL_SDVS_V30 (6UL << 9) -#define MMCHS_HCTL_SDVS_V33 (7UL << 9) -#define MMCHS_HCTL_SDBP (1UL << 8) -#define MMCHS_HCTL_DTW (1UL << 1) - -#define MMCHS_CAPA_VS18 (1UL << 26) -#define MMCHS_CAPA_VS30 (1UL << 25) -#define MMCHS_CAPA_VS33 (1UL << 24) - -#define MMCHS_CMD_CMD_TYPE_IO_ABORT (3UL << 21) -#define MMCHS_CMD_CMD_TYPE_FUNC_SEL (2UL << 21) -#define MMCHS_CMD_CMD_TYPE_SUSPEND (1UL << 21) -#define MMCHS_CMD_CMD_TYPE_OTHERS (0UL << 21) -#define MMCHS_CMD_CMD_TYPE_MASK (3UL << 22) - -#define MMCHS_CMD_DP (1UL << 21) -#define MMCHS_CMD_CICE (1UL << 20) -#define MMCHS_CMD_CCCE (1UL << 19) - -#define MMCHS_CMD_RSP_TYPE_MASK (3UL << 16) -#define MMCHS_CMD_RSP_TYPE_NO (0UL << 16) -#define MMCHS_CMD_RSP_TYPE_136 (1UL << 16) -#define MMCHS_CMD_RSP_TYPE_48 (2UL << 16) -#define MMCHS_CMD_RSP_TYPE_48_BSY (3UL << 16) - -#define MMCHS_CMD_MSBS (1UL << 5) -#define MMCHS_CMD_DDIR (1UL << 4) -#define MMCHS_CMD_ACEN (1UL << 2) -#define MMCHS_CMD_BCE (1UL << 1) -#define MMCHS_CMD_DE (1UL << 0) - -#define MMCHS_CON_CLKEXTFREE (1UL << 16) -#define MMCHS_CON_PADEN (1UL << 15) -#define MMCHS_CON_OBIE (1UL << 14) -#define MMCHS_CON_OBIP (1UL << 13) -#define MMCHS_CON_CEATA (1UL << 12) -#define MMCHS_CON_CTPL (1UL << 11) - -#define MMCHS_CON_DVAL_8_4MS (3UL << 9) -#define MMCHS_CON_DVAL_1MS (2UL << 9) -#define MMCHS_CON_DVAL_231US (1UL << 9) -#define MMCHS_CON_DVAL_33US (0UL << 9) -#define MMCHS_CON_DVAL_MASK (3UL << 9) - -#define MMCHS_CON_WPP (1UL << 8) -#define MMCHS_CON_CDP (1UL << 7) -#define MMCHS_CON_MIT (1UL << 6) -#define MMCHS_CON_DW8 (1UL << 5) -#define MMCHS_CON_MODE (1UL << 4) -#define MMCHS_CON_STR (1UL << 3) -#define MMCHS_CON_HR (1UL << 2) -#define MMCHS_CON_INIT (1UL << 1) -#define MMCHS_CON_OD (1UL << 0) - -#define MMCHS_CAPA_VS18 (1UL << 26) -#define MMCHS_CAPA_VS30 (1UL << 25) -#define MMCHS_CAPA_VS33 (1UL << 24) - -#endif /* _TI_MMCHS_H_ */ From 5df0ffc76253f695d8fee104f99bc2e2287c32a1 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 13 Oct 2014 16:23:51 +0000 Subject: [PATCH 098/112] class, subclass and progif were never used, so don't bother setting them. --- sys/dev/sdhci/sdhci_pci.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sys/dev/sdhci/sdhci_pci.c b/sys/dev/sdhci/sdhci_pci.c index af60503ad07..626f1973b75 100644 --- a/sys/dev/sdhci/sdhci_pci.c +++ b/sys/dev/sdhci/sdhci_pci.c @@ -260,16 +260,12 @@ sdhci_pci_attach(device_t dev) struct sdhci_pci_softc *sc = device_get_softc(dev); uint32_t model; uint16_t subvendor; - uint8_t class, subclass, progif; int bar, err, rid, slots, i; sc->dev = dev; model = (uint32_t)pci_get_device(dev) << 16; model |= (uint32_t)pci_get_vendor(dev) & 0x0000ffff; subvendor = pci_get_subvendor(dev); - class = pci_get_class(dev); - subclass = pci_get_subclass(dev); - progif = pci_get_progif(dev); /* Apply chip specific quirks. */ for (i = 0; sdhci_devices[i].model != 0; i++) { if (sdhci_devices[i].model == model && From 756906b40ef9b5e5b9917218319c32467322b35c Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 13 Oct 2014 16:23:58 +0000 Subject: [PATCH 099/112] Use the C99 flexible array construct to denote a variable amount of data rather than the old-school [1] construct. We have required c99 compilers for some time. --- sys/dev/isp/ispmbox.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/isp/ispmbox.h b/sys/dev/isp/ispmbox.h index 85b31e51594..d2a29b27fb3 100644 --- a/sys/dev/isp/ispmbox.h +++ b/sys/dev/isp/ispmbox.h @@ -1442,7 +1442,7 @@ typedef struct { uint16_t snscb_addr[4]; /* response buffer address */ uint16_t snscb_sblen; /* subcommand buffer length (words) */ uint16_t snscb_reserved1; - uint16_t snscb_data[1]; /* variable data */ + uint16_t snscb_data[]; /* variable data */ } sns_screq_t; /* Subcommand Request Structure */ typedef struct { @@ -1503,7 +1503,7 @@ typedef struct { uint8_t snscb_port_type; uint8_t snscb_port_id[3]; uint8_t snscb_portname[8]; - uint16_t snscb_data[1]; /* variable data */ + uint16_t snscb_data[]; /* variable data */ } sns_scrsp_t; /* Subcommand Response Structure */ typedef struct { From 623b63e7617bc8ef70c805f99222557c7bf87ade Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 13 Oct 2014 16:33:08 +0000 Subject: [PATCH 100/112] Use a switch on ti_chip() to find which SoC we are on. This allow us t only enable support for the SoCs we are built for. --- sys/arm/ti/ti_sdhci.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/arm/ti/ti_sdhci.c b/sys/arm/ti/ti_sdhci.c index 63aeb9bdf6a..024c830ad9d 100644 --- a/sys/arm/ti/ti_sdhci.c +++ b/sys/arm/ti/ti_sdhci.c @@ -494,13 +494,21 @@ ti_sdhci_attach(device_t dev) * Set the offset from the device's memory start to the MMCHS registers. * Also for OMAP4 disable high speed mode due to erratum ID i626. */ - if (ti_chip() == CHIP_OMAP_4) { + switch (ti_chip()) { +#ifdef SOC_OMAP4 + case CHIP_OMAP_4: sc->mmchs_reg_off = OMAP4_MMCHS_REG_OFFSET; sc->disable_highspeed = true; - } else if (ti_chip() == CHIP_AM335X) + break; +#endif +#ifdef SOC_TI_AM335X + case CHIP_AM335X: sc->mmchs_reg_off = AM335X_MMCHS_REG_OFFSET; - else + break; +#endif + default: panic("Unknown OMAP device\n"); + } /* * The standard SDHCI registers are at a fixed offset (the same on all From fdb5bf37fa1da8deb5a6c7860ed993050d22074d Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 13 Oct 2014 16:37:06 +0000 Subject: [PATCH 101/112] Decode the arguments passed to _umtx_op(). In particular, decode the opcode. MFC after: 1 week Sponsored by: Norse --- usr.bin/kdump/kdump.c | 21 +++++++++++++++ usr.bin/kdump/mksubr | 58 ++++++++++++++++++++++++++++++++++++++++ usr.bin/truss/syscall.h | 5 ++-- usr.bin/truss/syscalls.c | 21 +++++++++++++++ 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index ac0e88ba1f6..e0a607993be 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -57,6 +57,7 @@ extern int errno; #include #include #include +#include #include #include #include @@ -1268,6 +1269,26 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags) ip++; narg--; break; + case SYS__umtx_op: + print_number(ip, narg, c); + putchar(','); + umtxopname(*ip); + switch (*ip) { + case UMTX_OP_CV_WAIT: + ip++; + narg--; + putchar(','); + umtxcvwaitflags(*ip); + break; + case UMTX_OP_RW_RDLOCK: + ip++; + narg--; + putchar(','); + umtxrwlockflags(*ip); + break; + } + ip++; + narg--; } } while (narg > 0) { diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index d8d803fa925..aa001f8a1b7 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -185,6 +185,7 @@ cat <<_EOF_ #include #include #include +#include #include #include #include @@ -489,6 +490,7 @@ auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" +auto_switch_type "umtxopname" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h" auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h" auto_or_type "wait6optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h" @@ -677,6 +679,62 @@ cat <<_EOF_ } } +/* + * AUTO - Special + * + * Just print 0 as 0. + */ +void +umtxcvwaitflags(intmax_t arg) +{ + int or = 0; + if (arg == 0) { + printf("0"); + return; + } + printf("%#jx<", (uintmax_t)arg); +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+[[:space:]]*" \ + $include_dir/sys/umtx.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' +cat <<_EOF_ + printf(">"); + if (or == 0) + printf("%jd", arg); +} + + +/* + * AUTO - Special + * + * Just print 0 as 0. + */ +void +umtxrwlockflags(intmax_t arg) +{ + int or = 0; + if (arg == 0) { + printf("0"); + return; + } + printf("%#jx<", (uintmax_t)arg); +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+[[:space:]]*" \ + $include_dir/sys/umtx.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' +cat <<_EOF_ + printf(">"); + if (or == 0) + printf("%jd", arg); +} _EOF_ egrep '#define[[:space:]]+CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)' \ $include_dir/sys/capsicum.h | \ diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h index f13fa8b5310..a57361188c5 100644 --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -5,6 +5,7 @@ * Hex -- values that should be printed in hex (addresses) * Octal -- Same as above, but octal * Int -- normal integer values (file descriptors, for example) + * LongHex -- long value that should be printed in hex * Name -- pointer to a NULL-terminated string. * BinString -- pointer to an array of chars, printed via strvisx(). * Ptr -- pointer to some unspecified structure. Just print as hex for now. @@ -34,13 +35,13 @@ * $FreeBSD$ */ -enum Argtype { None = 1, Hex, Octal, Int, Name, Ptr, Stat, Ioctl, Quad, +enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, - LinuxSockArgs }; + LinuxSockArgs, Umtxop }; #define ARG_MASK 0xff #define OUT 0x100 diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index ebdc72e5a4c..700af609de1 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -279,6 +279,9 @@ static struct syscall syscalls[] = { { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } }, { .name = "procctl", .ret_type = 1, .nargs = 4, .args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } }, + { .name = "_umtx_op", .ret_type = 1, .nargs = 5, + .args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 }, + { Ptr, 4 } } }, { .name = 0 }, }; @@ -412,6 +415,18 @@ static struct xlat procctl_arg[] = { X(PROC_SPROTECT) XEND }; +static struct xlat umtx_ops[] = { + X(UMTX_OP_RESERVED0) X(UMTX_OP_RESERVED1) X(UMTX_OP_WAIT) + X(UMTX_OP_WAKE) X(UMTX_OP_MUTEX_TRYLOCK) X(UMTX_OP_MUTEX_LOCK) + X(UMTX_OP_MUTEX_UNLOCK) X(UMTX_OP_SET_CEILING) X(UMTX_OP_CV_WAIT) + X(UMTX_OP_CV_SIGNAL) X(UMTX_OP_CV_BROADCAST) X(UMTX_OP_WAIT_UINT) + X(UMTX_OP_RW_RDLOCK) X(UMTX_OP_RW_WRLOCK) X(UMTX_OP_RW_UNLOCK) + X(UMTX_OP_WAIT_UINT_PRIVATE) X(UMTX_OP_WAKE_PRIVATE) + X(UMTX_OP_MUTEX_WAIT) X(UMTX_OP_MUTEX_WAKE) X(UMTX_OP_SEM_WAIT) + X(UMTX_OP_SEM_WAKE) X(UMTX_OP_NWAKE_PRIVATE) X(UMTX_OP_MUTEX_WAKE2) + XEND +}; + #undef X #undef XEND @@ -608,6 +623,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval, case Int: asprintf(&tmp, "%d", (int)args[sc->offset]); break; + case LongHex: + asprintf(&tmp, "0x%lx", args[sc->offset]); + break; case Name: { /* NULL-terminated string. */ char *tmp2; @@ -1275,6 +1293,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval, case Procctl: tmp = strdup(xlookup(procctl_arg, args[sc->offset])); break; + case Umtxop: + tmp = strdup(xlookup(umtx_ops, args[sc->offset])); + break; default: errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK); } From 6e97fd7dbfa5525ca23f9e36e21d752b29cd71ec Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 13 Oct 2014 16:40:40 +0000 Subject: [PATCH 103/112] Move the sdhci option to files.ti, it's common to both SoCs. --- sys/arm/ti/am335x/files.am335x | 1 - sys/arm/ti/files.ti | 1 + sys/arm/ti/omap4/files.omap4 | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/arm/ti/am335x/files.am335x b/sys/arm/ti/am335x/files.am335x index fe2ebb84b9d..800a563842c 100644 --- a/sys/arm/ti/am335x/files.am335x +++ b/sys/arm/ti/am335x/files.am335x @@ -12,5 +12,4 @@ arm/ti/am335x/am335x_scm_padconf.c standard arm/ti/am335x/am335x_usbss.c optional musb fdt arm/ti/ti_edma3.c standard -arm/ti/ti_sdhci.c optional sdhci arm/ti/cpsw/if_cpsw.c optional cpsw diff --git a/sys/arm/ti/files.ti b/sys/arm/ti/files.ti index 0adea066cd8..d6d2b428293 100644 --- a/sys/arm/ti/files.ti +++ b/sys/arm/ti/files.ti @@ -22,6 +22,7 @@ arm/ti/ti_pruss.c standard arm/ti/ti_adc.c optional ti_adc arm/ti/ti_gpio.c optional gpio arm/ti/ti_i2c.c optional ti_i2c +arm/ti/ti_sdhci.c optional sdhci dev/uart/uart_dev_ti8250.c optional uart dev/uart/uart_dev_ns8250.c optional uart diff --git a/sys/arm/ti/omap4/files.omap4 b/sys/arm/ti/omap4/files.omap4 index 9611c6eded9..ee166ee2b04 100644 --- a/sys/arm/ti/omap4/files.omap4 +++ b/sys/arm/ti/omap4/files.omap4 @@ -6,7 +6,6 @@ arm/ti/ti_smc.S standard arm/ti/usb/omap_ehci.c optional usb ehci arm/ti/ti_sdma.c optional ti_sdma -arm/ti/ti_sdhci.c optional sdhci arm/ti/omap4/omap4_l2cache.c optional pl310 arm/ti/omap4/omap4_prcm_clks.c standard From 7d25e50fdfd135ea6930932ecf53749dacef80b3 Mon Sep 17 00:00:00 2001 From: Sean Bruno Date: Mon, 13 Oct 2014 16:48:01 +0000 Subject: [PATCH 104/112] Repair build of tools/ath/athalq and define missing value len. Reviewed by: adrian --- sys/contrib/dev/ath/ath_hal/ar9300/ar9300desc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300desc.h b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300desc.h index 9054db0b1f4..5b314ebf56d 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300desc.h +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300desc.h @@ -347,6 +347,7 @@ struct ar9300_txc { /* ds_status2 */ #define AR_data_len 0x00000fff +#define AR_data_len_S 0 #define AR_rx_more 0x00001000 #define AR_num_delim 0x003fc000 #define AR_num_delim_S 14 From fc6e35c65cd9d12b35c43020ada6bb6d3538e186 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 13 Oct 2014 19:05:18 +0000 Subject: [PATCH 105/112] Fix compiler locking diagnostic warnings. PR: 194289 --- lib/libcuse/cuse_lib.c | 90 +++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/lib/libcuse/cuse_lib.c b/lib/libcuse/cuse_lib.c index 707e69d3d29..321522da09c 100644 --- a/lib/libcuse/cuse_lib.c +++ b/lib/libcuse/cuse_lib.c @@ -87,17 +87,11 @@ static TAILQ_HEAD(, cuse_dev_entered) h_cuse_entered __guarded_by(m_cuse); static struct cuse_vm_allocation a_cuse[CUSE_ALLOC_UNIT_MAX] __guarded_by(m_cuse); -static void -cuse_lock(void) __locks_exclusive(m_cuse) -{ - pthread_mutex_lock(&m_cuse); -} +#define CUSE_LOCK() \ + pthread_mutex_lock(&m_cuse) -static void -cuse_unlock(void) __unlocks(m_cuse) -{ - pthread_mutex_unlock(&m_cuse); -} +#define CUSE_UNLOCK() \ + pthread_mutex_unlock(&m_cuse) int cuse_init(void) @@ -150,7 +144,7 @@ cuse_vmoffset(void *_ptr) unsigned long remainder; int n; - cuse_lock(); + CUSE_LOCK(); for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { if (a_cuse[n].ptr == NULL) continue; @@ -160,7 +154,7 @@ cuse_vmoffset(void *_ptr) if ((ptr >= ptr_min) && (ptr <= ptr_max)) { - cuse_unlock(); + CUSE_UNLOCK(); remainder = (ptr - ptr_min); @@ -169,7 +163,7 @@ cuse_vmoffset(void *_ptr) return ((n * PAGE_SIZE * CUSE_ALLOC_PAGES_MAX) + remainder); } } - cuse_unlock(); + CUSE_UNLOCK(); return (0x80000000UL); /* failure */ } @@ -192,7 +186,7 @@ cuse_vmalloc(int size) info.page_count = (size + PAGE_SIZE - 1) / PAGE_SIZE; - cuse_lock(); + CUSE_LOCK(); for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { if (a_cuse[n].ptr != NULL) @@ -201,7 +195,7 @@ cuse_vmalloc(int size) a_cuse[n].ptr = ((uint8_t *)1); /* reserve */ a_cuse[n].size = 0; - cuse_unlock(); + CUSE_UNLOCK(); info.alloc_nr = n; @@ -209,7 +203,7 @@ cuse_vmalloc(int size) if (error) { - cuse_lock(); + CUSE_LOCK(); a_cuse[n].ptr = NULL; @@ -230,20 +224,20 @@ cuse_vmalloc(int size) if (error) { /* ignore */ } - cuse_lock(); + CUSE_LOCK(); a_cuse[n].ptr = NULL; break; } - cuse_lock(); + CUSE_LOCK(); a_cuse[n].ptr = ptr; a_cuse[n].size = size; - cuse_unlock(); + CUSE_UNLOCK(); return (ptr); /* success */ } - cuse_unlock(); + CUSE_UNLOCK(); return (NULL); /* failure */ } @@ -255,12 +249,12 @@ cuse_is_vmalloc_addr(void *ptr) if (f_cuse < 0 || ptr == NULL) return (0); /* false */ - cuse_lock(); + CUSE_LOCK(); for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { if (a_cuse[n].ptr == ptr) break; } - cuse_unlock(); + CUSE_UNLOCK(); return (n != CUSE_ALLOC_UNIT_MAX); } @@ -268,6 +262,7 @@ cuse_is_vmalloc_addr(void *ptr) void cuse_vmfree(void *ptr) { + struct cuse_vm_allocation temp; struct cuse_alloc_info info; int error; int n; @@ -275,32 +270,35 @@ cuse_vmfree(void *ptr) if (f_cuse < 0) return; - memset(&info, 0, sizeof(info)); - - cuse_lock(); + CUSE_LOCK(); for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { if (a_cuse[n].ptr != ptr) continue; - cuse_unlock(); + temp = a_cuse[n]; + + CUSE_UNLOCK(); + + munmap(temp.ptr, temp.size); + + memset(&info, 0, sizeof(info)); info.alloc_nr = n; - munmap(ptr, a_cuse[n].size); - error = ioctl(f_cuse, CUSE_IOCTL_FREE_MEMORY, &info); - if (error) { - /* ignore */ + if (error != 0) { + /* ignore any errors */ + DPRINTF("Freeing memory failed: %d\n", errno); } - cuse_lock(); + CUSE_LOCK(); a_cuse[n].ptr = NULL; a_cuse[n].size = 0; break; } - cuse_unlock(); + CUSE_UNLOCK(); } int @@ -407,9 +405,9 @@ cuse_dev_create(const struct cuse_methods *mtod, void *priv0, void *priv1, free(cdev); return (NULL); } - cuse_lock(); + CUSE_LOCK(); TAILQ_INSERT_TAIL(&h_cuse, cdev, entry); - cuse_unlock(); + CUSE_UNLOCK(); return (cdev); } @@ -423,9 +421,9 @@ cuse_dev_destroy(struct cuse_dev *cdev) if (f_cuse < 0) return; - cuse_lock(); + CUSE_LOCK(); TAILQ_REMOVE(&h_cuse, cdev, entry); - cuse_unlock(); + CUSE_UNLOCK(); error = ioctl(f_cuse, CUSE_IOCTL_DESTROY_DEV, &cdev); if (error) @@ -477,7 +475,7 @@ cuse_wait_and_process(void) cdev = info.dev; - cuse_lock(); + CUSE_LOCK(); enter.thread = curr; enter.per_file_handle = (void *)info.per_file_handle; enter.cmd = info.command; @@ -485,7 +483,7 @@ cuse_wait_and_process(void) enter.got_signal = 0; enter.cdev = cdev; TAILQ_INSERT_TAIL(&h_cuse_entered, &enter, entry); - cuse_unlock(); + CUSE_UNLOCK(); DPRINTF("cuse: Command = %d = %s, flags = %d, arg = 0x%08x, ptr = 0x%08x\n", (int)info.command, cuse_cmd_str(info.command), (int)info.fflags, @@ -507,7 +505,7 @@ cuse_wait_and_process(void) error = 0; - cuse_lock(); + CUSE_LOCK(); TAILQ_FOREACH(pe, &h_cuse_entered, entry) { if (pe->cdev != cdev) continue; @@ -520,7 +518,7 @@ cuse_wait_and_process(void) pthread_kill(pe->thread, SIGHUP); error = CUSE_ERR_BUSY; } - cuse_unlock(); + CUSE_UNLOCK(); if (error == 0) break; @@ -571,7 +569,7 @@ cuse_wait_and_process(void) break; case CUSE_CMD_SIGNAL: - cuse_lock(); + CUSE_LOCK(); TAILQ_FOREACH(pe, &h_cuse_entered, entry) { if (pe->cdev != cdev) continue; @@ -583,7 +581,7 @@ cuse_wait_and_process(void) pe->got_signal = 1; pthread_kill(pe->thread, SIGHUP); } - cuse_unlock(); + CUSE_UNLOCK(); break; default: @@ -594,9 +592,9 @@ cuse_wait_and_process(void) DPRINTF("cuse: Command error = %d for %s\n", error, cuse_cmd_str(info.command)); - cuse_lock(); + CUSE_LOCK(); TAILQ_REMOVE(&h_cuse_entered, &enter, entry); - cuse_unlock(); + CUSE_UNLOCK(); /* we ignore any sync command failures */ ioctl(f_cuse, CUSE_IOCTL_SYNC_COMMAND, &error); @@ -610,12 +608,12 @@ cuse_dev_get_entered(void) struct cuse_dev_entered *pe; pthread_t curr = pthread_self(); - cuse_lock(); + CUSE_LOCK(); TAILQ_FOREACH(pe, &h_cuse_entered, entry) { if (pe->thread == curr) break; } - cuse_unlock(); + CUSE_UNLOCK(); return (pe); } From ba6e85e0cf0e9e8dafe0ab06d5756663c12cfe23 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 13 Oct 2014 20:39:51 +0000 Subject: [PATCH 106/112] Use write_psize instead of write_asize when doing vdev_space_update. Without this change the accounting of L2ARC usage would be wrong and give 16EB free space because the number became negative and overflows. Obtained from: FreeNAS (issue #6239) MFC after: 2 weeks --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index 33f308b859a..153ff1309bf 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -5232,7 +5232,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz, ARCSTAT_INCR(arcstat_l2_write_bytes, write_asize); ARCSTAT_INCR(arcstat_l2_size, write_sz); ARCSTAT_INCR(arcstat_l2_asize, write_asize); - vdev_space_update(dev->l2ad_vdev, write_asize, 0, 0); + vdev_space_update(dev->l2ad_vdev, write_psize, 0, 0); /* * Bump device hand to the device start if it is approaching the end. From 33b8f2518c1625795b38930dd20b2952cfed2714 Mon Sep 17 00:00:00 2001 From: Sean Bruno Date: Mon, 13 Oct 2014 21:04:14 +0000 Subject: [PATCH 107/112] Update tcp(4) with plpmtud blackhole sysctls Submitted by: Mikhail MFC after: 2 weeks Relnotes: yes --- share/man/man4/tcp.4 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index a95078fe73f..2b6668f21c3 100644 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -518,6 +518,21 @@ avoid packet drops. Number of retries (SYN or SYN/ACK retransmits) before disabling ECN on a specific connection. This is needed to help with connection establishment when a broken firewall is in the network path. +.It Va pmtud_blackhole_detection +Turn on automatic path MTU blackhole detection. In case of retransmits we will +lower the MSS to check if it's MTU problem. If current MSS is greater than +configured value to try, it will be set to it, otherwise, MSS will be set to +default values (net.inet.tcp.mssdflt and net.inet.tcp.v6mssdflt). +.It Va pmtud_blackhole_mss +MSS to try for IPv4 if PMTU blackhole detection is turned on. +.It Va v6pmtud_blackhole_mss +MSS to try for IPv6 if PMTU blackhole detection is turned on. +.It Va pmtud_blackhole_activated +Number of times the code was activated to attempt a MSS downshift. +.It Va pmtud_blackhole_min_activated +Number of times the blackhole MSS was used in an attempt to downshift. +.It Va pmtud_blackhole_failed +Number of times that we failed to connect after we downshifted the MSS. .El .Sh ERRORS A socket operation may fail with one of the following errors returned: From 0f3e3bc526628b6b15c427ff5930e40275a7fd4b Mon Sep 17 00:00:00 2001 From: Sean Bruno Date: Mon, 13 Oct 2014 21:05:29 +0000 Subject: [PATCH 108/112] Catch ipv6 case when attempting to do PLPMTUD blackhole detection. Submitted by: Mikhail MFC after: 2 weeks Relnotes: yes --- sys/netinet/tcp_output.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 7db0e506899..3da1ab362e2 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1273,6 +1273,11 @@ send: */ ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6)); + if (V_path_mtu_discovery && tp->t_maxopd > V_tcp_minmss) + tp->t_flags2 |= TF2_PLPMTU_PMTUD; + else + tp->t_flags2 &= ~TF2_PLPMTU_PMTUD; + if (tp->t_state == TCPS_SYN_SENT) TCP_PROBE5(connect__request, NULL, tp, ip6, tp, th); From 882ac53ed7ba31847423ef9ae7edee134b05cf47 Mon Sep 17 00:00:00 2001 From: Sean Bruno Date: Mon, 13 Oct 2014 21:06:21 +0000 Subject: [PATCH 109/112] Handle small file case with regards to plpmtud blackhole detection. Submitted by: Mikhail MFC after: 2 weeks Relnotes: yes --- sys/netinet/tcp_timer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 62a9b6d1787..3702a2e7b69 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -693,7 +693,15 @@ tcp_timer_rexmt(void * xtp) TCPT_RANGESET(tp->t_rxtcur, rexmt, tp->t_rttmin, TCPTV_REXMTMAX); - if (V_tcp_pmtud_blackhole_detect && (tp->t_state == TCPS_ESTABLISHED)) { + /* + * We enter the path for PLMTUD if connection is established or, if + * connection is FIN_WAIT_1 status, reason for the last is that if + * amount of data we send is very small, we could send it in couple of + * packets and process straight to FIN. In that case we won't catch + * ESTABLISHED state. + */ + if (V_tcp_pmtud_blackhole_detect && (((tp->t_state == TCPS_ESTABLISHED)) + || (tp->t_state == TCPS_FIN_WAIT_1))) { int optlen; #ifdef INET6 int isipv6; From d6f180ad78e97a0720ebf6b5da63f6bb720d4c03 Mon Sep 17 00:00:00 2001 From: Sean Bruno Date: Mon, 13 Oct 2014 21:08:27 +0000 Subject: [PATCH 110/112] Bump .Dd Submitted by: gjb MFC after: 2 weeks Relnotes: yes --- share/man/man4/tcp.4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index 2b6668f21c3..cbca912fe5a 100644 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -34,7 +34,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd November 8, 2013 +.Dd October 13, 2014 .Dt TCP 4 .Os .Sh NAME From f9721976514fd3ee8d8ae74e1b32f2e63a4719f7 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 13 Oct 2014 22:15:26 +0000 Subject: [PATCH 111/112] Promote libevent to lib/ level and fold ftp-proxy into its parent Makefile. This allows us to use libevent for other application in the future. For now libevent is still INTERNALLIB and no shared library is installed. MFC after: 1 month --- lib/Makefile | 5 +++++ {usr.sbin/ftp-proxy => lib}/libevent/Makefile | 10 +++++++--- share/mk/src.libnames.mk | 4 ++++ usr.sbin/ftp-proxy/Makefile | 16 ++++++++++++++-- usr.sbin/ftp-proxy/Makefile.inc | 5 ----- usr.sbin/ftp-proxy/ftp-proxy/Makefile | 17 ----------------- 6 files changed, 30 insertions(+), 27 deletions(-) rename {usr.sbin/ftp-proxy => lib}/libevent/Makefile (76%) delete mode 100644 usr.sbin/ftp-proxy/Makefile.inc delete mode 100644 usr.sbin/ftp-proxy/ftp-proxy/Makefile diff --git a/lib/Makefile b/lib/Makefile index a5ab970f014..c558f118849 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -44,6 +44,7 @@ SUBDIR= ${SUBDIR_ORDERED} \ libdevstat \ libdwarf \ libedit \ + ${_libevent} \ libexecinfo \ libexpat \ libfetch \ @@ -226,6 +227,10 @@ _libnetgraph= libnetgraph _libypclnt= libypclnt .endif +.if ${MK_PF} != "no" +_libevent= libevent +.endif + .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _libsmb= libsmb _libvgl= libvgl diff --git a/usr.sbin/ftp-proxy/libevent/Makefile b/lib/libevent/Makefile similarity index 76% rename from usr.sbin/ftp-proxy/libevent/Makefile rename to lib/libevent/Makefile index a8ff09b9ba5..d8b1e2032ce 100644 --- a/usr.sbin/ftp-proxy/libevent/Makefile +++ b/lib/libevent/Makefile @@ -1,10 +1,14 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../contrib/pf/libevent +.PATH: ${.CURDIR}/../../contrib/pf/libevent +.include + +LIB= event +SHLIB_MAJOR= 1 +PRIVATELIB= +INTERNALLIB= -LIB= event -INTERNALLIB=yes SRCS= buffer.c evbuffer.c event.c kqueue.c log.c poll.c select.c signal.c HDRS= event.h diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index bc41ea2a64a..336ede11e3a 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -21,6 +21,10 @@ LIBBSDSTATDIR= ${ROOTOBJDIR}/lib/libbsdstat LDBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.so LIBBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.a +LIBEVENTDIR= ${ROOTOBJDIR}/lib/libevent +LDEVENT?= ${LIBEVENTDIR}/libevent.so +LIBEVENT?= ${LIBEVENTDIR}/libevent.a + LIBHEIMIPCCDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcc LDHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.so LIBHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.a diff --git a/usr.sbin/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/Makefile index 67660c8cad3..7a3ef477226 100644 --- a/usr.sbin/ftp-proxy/Makefile +++ b/usr.sbin/ftp-proxy/Makefile @@ -1,5 +1,17 @@ # $FreeBSD$ -SUBDIR= libevent ftp-proxy +.PATH: ${.CURDIR}/../../contrib/pf/ftp-proxy -.include +PROG= ftp-proxy +MAN= ftp-proxy.8 + +SRCS= ftp-proxy.c filter.c + +CFLAGS+=-I${.CURDIR}/../../contrib/pf/libevent + +LDADD+= ${LIBEVENT} +DPADD+= ${LIBEVENT} + +WARNS?= 3 + +.include diff --git a/usr.sbin/ftp-proxy/Makefile.inc b/usr.sbin/ftp-proxy/Makefile.inc deleted file mode 100644 index 9043d098fca..00000000000 --- a/usr.sbin/ftp-proxy/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -LIBEVENT= ${.OBJDIR}/../libevent/libevent.a - -.include "../Makefile.inc" diff --git a/usr.sbin/ftp-proxy/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/ftp-proxy/Makefile deleted file mode 100644 index de498881501..00000000000 --- a/usr.sbin/ftp-proxy/ftp-proxy/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../../contrib/pf/ftp-proxy - -PROG= ftp-proxy -MAN= ftp-proxy.8 - -SRCS= ftp-proxy.c filter.c - -CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent - -LDADD+= ${LIBEVENT} -DPADD+= ${LIBEVENT} - -WARNS?= 3 - -.include From 78433c77c68dea98d73ff4527ce189fe901e9f45 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Mon, 13 Oct 2014 22:30:08 +0000 Subject: [PATCH 112/112] Import patch from libc++ r197313 which allows using libc++ headers with gcc Differential Revision: https://reviews.freebsd.org/D942 Reviewed by: imp --- contrib/libc++/include/__config | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/libc++/include/__config b/contrib/libc++/include/__config index a8c3498b0a3..ccf7f756b1c 100644 --- a/contrib/libc++/include/__config +++ b/contrib/libc++/include/__config @@ -374,6 +374,7 @@ namespace std { #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS +#define _LIBCPP_HAS_NO_STRONG_ENUMS #else // __GXX_EXPERIMENTAL_CXX0X__