PERFORCE change 154154 for review
Marko Zec
zec at FreeBSD.org
Fri Dec 5 16:10:28 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=154154
Change 154154 by zec at zec_tca51 on 2008/12/06 00:10:26
IFC @ 154151
Affected files ...
.. //depot/projects/vimage/src/sys/amd64/amd64/db_trace.c#4 integrate
.. //depot/projects/vimage/src/sys/arm/mv/mv_pci.c#2 integrate
.. //depot/projects/vimage/src/sys/arm/mv/orion/std.db88f5xxx#2 integrate
.. //depot/projects/vimage/src/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h#5 integrate
.. //depot/projects/vimage/src/sys/dev/cxgb/common/cxgb_ael1002.c#9 integrate
.. //depot/projects/vimage/src/sys/dev/cxgb/cxgb_main.c#21 integrate
.. //depot/projects/vimage/src/sys/dev/pccbb/pccbb.c#8 integrate
.. //depot/projects/vimage/src/sys/dev/pccbb/pccbb_pci.c#7 integrate
.. //depot/projects/vimage/src/sys/dev/pccbb/pccbbvar.h#5 integrate
.. //depot/projects/vimage/src/sys/i386/include/atomic.h#5 integrate
.. //depot/projects/vimage/src/sys/kern/kern_exec.c#19 integrate
.. //depot/projects/vimage/src/sys/kern/kern_exit.c#27 integrate
.. //depot/projects/vimage/src/sys/kern/kern_fork.c#23 integrate
.. //depot/projects/vimage/src/sys/kern/kern_linker.c#21 integrate
.. //depot/projects/vimage/src/sys/kern/kern_module.c#6 integrate
.. //depot/projects/vimage/src/sys/kern/kern_proc.c#18 integrate
.. //depot/projects/vimage/src/sys/libkern/iconv.c#2 integrate
.. //depot/projects/vimage/src/sys/netinet/ip_carp.c#18 integrate
.. //depot/projects/vimage/src/sys/sys/module.h#4 integrate
.. //depot/projects/vimage/src/sys/sys/proc.h#27 integrate
Differences ...
==== //depot/projects/vimage/src/sys/amd64/amd64/db_trace.c#4 (text+ko) ====
@@ -25,7 +25,9 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/db_trace.c,v 1.82 2007/12/02 20:40:30 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/db_trace.c,v 1.83 2008/12/05 11:34:36 kib Exp $");
+
+#include "opt_compat.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -318,6 +320,10 @@
frame_type = INTERRUPT;
else if (strcmp(name, "Xfast_syscall") == 0)
frame_type = SYSCALL;
+#ifdef COMPAT_IA32
+ else if (strcmp(name, "Xint0x80_syscall") == 0)
+ frame_type = SYSCALL;
+#endif
/* XXX: These are interrupts with trap frames. */
else if (strcmp(name, "Xtimerint") == 0 ||
strcmp(name, "Xcpustop") == 0 ||
==== //depot/projects/vimage/src/sys/arm/mv/mv_pci.c#2 (text+ko) ====
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/mv/mv_pci.c,v 1.2 2008/11/19 17:07:01 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/mv/mv_pci.c,v 1.3 2008/12/05 15:27:28 raj Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -598,6 +598,10 @@
mem_limit = mem_base + sc->sc_info->op_mem_size - 1;
/* Configure I/O decode registers */
+ pcib_mbus_write_config(sc->sc_dev, bus, slot, func, PCIR_IOBASEL_1,
+ io_base >> 8, 1);
+ pcib_mbus_write_config(sc->sc_dev, bus, slot, func, PCIR_IOBASEH_1,
+ io_base >> 16, 2);
pcib_mbus_write_config(sc->sc_dev, bus, slot, func, PCIR_IOLIMITL_1,
io_limit >> 8, 1);
pcib_mbus_write_config(sc->sc_dev, bus, slot, func, PCIR_IOLIMITH_1,
==== //depot/projects/vimage/src/sys/arm/mv/orion/std.db88f5xxx#2 (text+ko) ====
@@ -1,13 +1,13 @@
-# $FreeBSD: src/sys/arm/mv/orion/std.db88f5xxx,v 1.1 2008/10/13 20:07:13 raj Exp $
+# $FreeBSD: src/sys/arm/mv/orion/std.db88f5xxx,v 1.2 2008/12/05 15:31:51 raj Exp $
include "../mv/std.mv"
files "../mv/orion/files.db88f5xxx"
-makeoptions KERNPHYSADDR=0x00400000
-makeoptions KERNVIRTADDR=0xc0400000
+makeoptions KERNPHYSADDR=0x00900000
+makeoptions KERNVIRTADDR=0xc0900000
-options KERNPHYSADDR=0x00400000
-options KERNVIRTADDR=0xc0400000
+options KERNPHYSADDR=0x00900000
+options KERNVIRTADDR=0xc0900000
options PHYSADDR=0x00000000
options PHYSMEM_SIZE=0x08000000
options STARTUP_PAGETABLE_ADDR=0x00100000
==== //depot/projects/vimage/src/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h#5 (text+ko) ====
@@ -387,6 +387,49 @@
#define _DONT_USE_1275_GENERIC_NAMES
#define _HAVE_CPUID_INSN
+#elif defined(__mips__)
+
+/*
+ * Define the appropriate "processor characteristics"
+ */
+#define _STACK_GROWS_DOWNWARD
+#define _LONG_LONG_LTOH
+#define _BIT_FIELDS_LTOH
+#define _IEEE_754
+#define _CHAR_IS_SIGNED
+#define _BOOL_ALIGNMENT 1
+#define _CHAR_ALIGNMENT 1
+#define _SHORT_ALIGNMENT 2
+#define _INT_ALIGNMENT 4
+#define _FLOAT_ALIGNMENT 4
+#define _FLOAT_COMPLEX_ALIGNMENT 4
+#define _LONG_ALIGNMENT 4
+#define _LONG_LONG_ALIGNMENT 4
+#define _DOUBLE_ALIGNMENT 4
+#define _DOUBLE_COMPLEX_ALIGNMENT 4
+#define _LONG_DOUBLE_ALIGNMENT 4
+#define _LONG_DOUBLE_COMPLEX_ALIGNMENT 4
+#define _POINTER_ALIGNMENT 4
+#define _MAX_ALIGNMENT 4
+#define _ALIGNMENT_REQUIRED 0
+
+#define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT
+
+/*
+ * Define the appropriate "implementation choices".
+ */
+#define _ILP32
+#if !defined(_I32LPx) && defined(_KERNEL)
+#define _I32LPx
+#endif
+#define _SUNOS_VTOC_16
+#define _DMA_USES_PHYSADDR
+#define _FIRMWARE_NEEDS_FDISK
+#define _PSM_MODULES
+#define _RTC_CONFIG
+#define _DONT_USE_1275_GENERIC_NAMES
+#define _HAVE_CPUID_INSN
+
#elif defined(__powerpc__)
/*
==== //depot/projects/vimage/src/sys/dev/cxgb/common/cxgb_ael1002.c#9 (text+ko) ====
@@ -28,7 +28,7 @@
***************************************************************************/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/common/cxgb_ael1002.c,v 1.9 2008/11/21 19:22:25 gnn Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/common/cxgb_ael1002.c,v 1.10 2008/12/04 20:32:53 gnn Exp $");
#include <cxgb_include.h>
@@ -205,6 +205,16 @@
t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out);
msleep(125);
t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait);
+
+ /* Phy loopback work around for ael1006 */
+ /* Soft reset phy by toggling loopback */
+ msleep(125);
+ /* Put phy into local loopback */
+ t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 0, 1);
+ msleep(125);
+ /* Take phy out of local loopback */
+ t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 0);
+
return 0;
}
==== //depot/projects/vimage/src/sys/dev/cxgb/cxgb_main.c#21 (text+ko) ====
@@ -28,7 +28,7 @@
***************************************************************************/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.75 2008/12/01 05:43:30 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.76 2008/12/05 21:40:11 gnn Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -402,6 +402,8 @@
int msi_needed, reg;
#endif
int must_load = 0;
+ char buf[80];
+
sc = device_get_softc(dev);
sc->dev = dev;
sc->msi_count = 0;
@@ -614,6 +616,11 @@
G_FW_VERSION_MAJOR(vers), G_FW_VERSION_MINOR(vers),
G_FW_VERSION_MICRO(vers));
+ snprintf(buf, sizeof(buf), "%s\t E/C: %s S/N: %s",
+ ai->desc,
+ sc->params.vpd.ec, sc->params.vpd.sn);
+ device_set_desc_copy(dev, buf);
+
device_printf(sc->dev, "Firmware Version %s\n", &sc->fw_version[0]);
callout_reset(&sc->cxgb_tick_ch, CXGB_TICKS(sc), cxgb_tick, sc);
t3_add_attach_sysctls(sc);
==== //depot/projects/vimage/src/sys/dev/pccbb/pccbb.c#8 (text+ko) ====
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb.c,v 1.172 2008/08/10 09:55:14 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb.c,v 1.176 2008/12/05 05:20:08 imp Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -344,7 +344,7 @@
sc->flags |= CBB_KTHREAD_DONE;
while (sc->flags & CBB_KTHREAD_RUNNING) {
DEVPRINTF((sc->dev, "Waiting for thread to die\n"));
- cv_broadcast(&sc->cv);
+ wakeup(&sc->intrhand);
msleep(sc->event_thread, &sc->mtx, PWAIT, "cbbun", 0);
}
mtx_unlock(&sc->mtx);
@@ -353,8 +353,6 @@
bus_release_resource(brdev, SYS_RES_MEMORY, CBBR_SOCKBASE,
sc->base_res);
mtx_destroy(&sc->mtx);
- cv_destroy(&sc->cv);
- cv_destroy(&sc->powercv);
return (0);
}
@@ -435,11 +433,8 @@
}
free(devlist, M_TEMP);
- if (wake > 0) {
- mtx_lock(&sc->mtx);
- cv_signal(&sc->cv);
- mtx_unlock(&sc->mtx);
- }
+ if (wake > 0)
+ wakeup(&sc->intrhand);
}
void
@@ -519,12 +514,12 @@
* a chance to run.
*/
mtx_lock(&sc->mtx);
- cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
- cv_wait(&sc->cv, &sc->mtx);
+ cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD | CBB_SOCKET_MASK_CSTS);
+ msleep(&sc->intrhand, &sc->mtx, PZERO, "-", 0);
err = 0;
while (err != EWOULDBLOCK &&
(sc->flags & CBB_KTHREAD_DONE) == 0)
- err = cv_timedwait(&sc->cv, &sc->mtx, hz / 4);
+ err = msleep(&sc->intrhand, &sc->mtx, PZERO, "-", hz / 5);
}
DEVPRINTF((sc->dev, "Thread terminating\n"));
sc->flags &= ~CBB_KTHREAD_RUNNING;
@@ -800,7 +795,7 @@
sane = 10;
while (!(cbb_get(sc, CBB_SOCKET_STATE) & CBB_STATE_POWER_CYCLE) &&
cnt == sc->powerintr && sane-- > 0)
- cv_timedwait(&sc->powercv, &sc->mtx, hz / 20);
+ msleep(&sc->powerintr, &sc->mtx, PZERO, "-", hz / 20);
mtx_unlock(&sc->mtx);
/*
* The TOPIC95B requires a little bit extra time to get
@@ -837,7 +832,18 @@
}
if (status & CBB_STATE_BAD_VCC_REQ) {
device_printf(sc->dev, "Bad Vcc requested\n");
- /* XXX Do we want to do something to mitigate things here? */
+ /*
+ * Turn off the power, and try again. Retrigger other
+ * active interrupts via force register. From NetBSD
+ * PR 36652, coded by me to description there.
+ */
+ sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK;
+ sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK;
+ cbb_set(sc, CBB_SOCKET_CONTROL, sock_ctrl);
+ status &= ~CBB_STATE_BAD_VCC_REQ;
+ status &= ~CBB_STATE_DATA_LOST;
+ status |= CBB_FORCE_CV_TEST;
+ cbb_set(sc, CBB_SOCKET_FORCE, status);
goto done;
}
if (sc->chipset == CB_TOPIC97) {
@@ -935,32 +941,32 @@
/*
* Asserting reset for 20ms is necessary for most bridges. For some
- * reason, the Ricoh RF5C47x bridges need it asserted for 400ms.
+ * reason, the Ricoh RF5C47x bridges need it asserted for 400ms. The
+ * root cause of this is unknown, and NetBSD does the same thing.
*/
delay = sc->chipset == CB_RF5C47X ? 400 : 20;
PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL, |CBBM_BRIDGECTRL_RESET, 2);
pause("cbbP3", hz * delay / 1000);
/*
- * If a card exists and we're turning it on, take it out of reset.
+ * If a card exists and we're turning it on, take it out of reset.
+ * After clearing reset, wait up to 1.1s for the first configuration
+ * register (vendor/product) configuration register of device 0.0 to
+ * become != 0xffffffff. The PCMCIA PC Card Host System Specification
+ * says that when powering up the card, the PCI Spec v2.1 must be
+ * followed. In PCI spec v2.2 Table 4-6, Trhfa (Reset High to first
+ * Config Access) is at most 2^25 clocks, or just over 1s. Section
+ * 2.2.1 states any card not ready to participate in bus transactions
+ * must tristate its outputs. Therefore, any access to its
+ * configuration registers must be ignored. In that state, the config
+ * reg will read 0xffffffff. Section 6.2.1 states a vendor id of
+ * 0xffff is invalid, so this can never match a real card. Print a
+ * warning if it never returns a real id. The PCMCIA PC Card
+ * Electrical Spec Section 5.2.7.1 implies only device 0 is present on
+ * a cardbus bus, so that's the only register we check here.
*/
if (on && CBB_CARD_PRESENT(cbb_get(sc, CBB_SOCKET_STATE))) {
/*
- * After clearing reset, wait up to 1.1s for the first
- * configuration register (vendor/product) configuration
- * register of device 0.0 to become != 0xffffffff. The PCMCIA
- * PC Card Host System Specification says that when powering
- * up the card, the PCI Spec v2.1 must be followed. In PCI
- * spec v2.2 Table 4-6, Trhfa (Reset High to first Config
- * Access) is at most 2^25 clocks, or just over 1s. Section
- * 2.2.1 states any card not ready to participate in bus
- * transactions must tristate its outputs. Therefore, any
- * access to its configuration registers must be ignored. In
- * that state, the config reg will read 0xffffffff. Section
- * 6.2.1 states a vendor id of 0xffff is invalid, so this can
- * never match a real card. Print a warning if it never
- * returns a real id. The PCMCIA PC Card Electrical Spec
- * Section 5.2.7.1 implies only device 0.
*/
PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL,
&~CBBM_BRIDGECTRL_RESET, 2);
@@ -1034,8 +1040,8 @@
return (EINVAL);
}
- basereg = win*8 + CBBR_MEMBASE0;
- limitreg = win*8 + CBBR_MEMLIMIT0;
+ basereg = win * 8 + CBBR_MEMBASE0;
+ limitreg = win * 8 + CBBR_MEMLIMIT0;
pci_write_config(brdev, basereg, start, 4);
pci_write_config(brdev, limitreg, end, 4);
@@ -1564,9 +1570,7 @@
cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
/* Signal the thread to wakeup. */
- mtx_lock(&sc->mtx);
- cv_signal(&sc->cv);
- mtx_unlock(&sc->mtx);
+ wakeup(&sc->intrhand);
error = bus_generic_resume(self);
==== //depot/projects/vimage/src/sys/dev/pccbb/pccbb_pci.c#7 (text+ko) ====
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb_pci.c,v 1.29 2008/10/02 22:50:11 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pccbb/pccbb_pci.c,v 1.30 2008/12/05 05:20:08 imp Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -117,7 +117,7 @@
pci_read_config(DEV, REG, SIZE) MASK1) MASK2, SIZE)
static void cbb_chipinit(struct cbb_softc *sc);
-static void cbb_pci_intr(void *arg);
+static int cbb_pci_filt(void *arg);
static struct yenta_chipinfo {
uint32_t yc_id;
@@ -313,8 +313,6 @@
parent = device_get_parent(brdev);
mtx_init(&sc->mtx, device_get_nameunit(brdev), "cbb", MTX_DEF);
- cv_init(&sc->cv, "cbb cv");
- cv_init(&sc->powercv, "cbb cv");
sc->chipset = cbb_chipset(pci_get_devid(brdev), NULL);
sc->dev = brdev;
sc->cbdev = NULL;
@@ -332,7 +330,6 @@
if (!sc->base_res) {
device_printf(brdev, "Could not map register memory\n");
mtx_destroy(&sc->mtx);
- cv_destroy(&sc->cv);
return (ENOMEM);
} else {
DEVPRINTF((brdev, "Found memory at %08lx\n",
@@ -416,7 +413,7 @@
}
if (bus_setup_intr(brdev, sc->irq_res, INTR_TYPE_AV | INTR_MPSAFE,
- NULL, cbb_pci_intr, sc, &sc->intrhand)) {
+ cbb_pci_filt, NULL, sc, &sc->intrhand)) {
device_printf(brdev, "couldn't establish interrupt\n");
goto err;
}
@@ -451,7 +448,6 @@
sc->base_res);
}
mtx_destroy(&sc->mtx);
- cv_destroy(&sc->cv);
return (ENOMEM);
}
@@ -686,11 +682,13 @@
return (0);
}
-static void
-cbb_pci_intr(void *arg)
+#define DELTA (CBB_SOCKET_MASK_CD)
+static int
+cbb_pci_filt(void *arg)
{
struct cbb_softc *sc = arg;
uint32_t sockevent;
+ int retval = FILTER_STRAY;
/*
* Read the socket event. Sometimes, the theory goes, the PCI
@@ -705,9 +703,6 @@
*/
sockevent = cbb_get(sc, CBB_SOCKET_EVENT);
if (sockevent != 0 && (sockevent & ~CBB_SOCKET_EVENT_VALID_MASK) == 0) {
- /* ack the interrupt */
- cbb_set(sc, CBB_SOCKET_EVENT, sockevent);
-
/*
* If anything has happened to the socket, we assume that
* the card is no longer OK, and we shouldn't call its
@@ -721,24 +716,24 @@
* of the pccard software used a similar trick and achieved
* excellent results.
*/
- if (sockevent & CBB_SOCKET_EVENT_CD) {
- mtx_lock(&sc->mtx);
- cbb_clrb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
+ if (sockevent & DELTA) {
+ cbb_clrb(sc, CBB_SOCKET_MASK, DELTA);
+ cbb_set(sc, CBB_SOCKET_EVENT, DELTA);
sc->cardok = 0;
cbb_disable_func_intr(sc);
- cv_signal(&sc->cv);
- mtx_unlock(&sc->mtx);
+ wakeup(&sc->intrhand);
}
/*
* If we get a power interrupt, wakeup anybody that might
* be waiting for one.
*/
if (sockevent & CBB_SOCKET_EVENT_POWER) {
- mtx_lock(&sc->mtx);
+ cbb_clrb(sc, CBB_SOCKET_MASK, CBB_SOCKET_EVENT_POWER);
+ cbb_set(sc, CBB_SOCKET_EVENT, CBB_SOCKET_EVENT_POWER);
sc->powerintr++;
- cv_signal(&sc->powercv);
- mtx_unlock(&sc->mtx);
+ wakeup((void *)&sc->powerintr);
}
+ retval = FILTER_HANDLED;
}
/*
* Some chips also require us to read the old ExCA registe for
@@ -753,6 +748,7 @@
* the event independent of the CBB_SOCKET_EVENT_CD above.
*/
exca_getb(&sc->exca[0], EXCA_CSC);
+ return retval;
}
/************************************************************************/
==== //depot/projects/vimage/src/sys/dev/pccbb/pccbbvar.h#5 (text+ko) ====
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/pccbb/pccbbvar.h,v 1.32 2007/09/30 11:05:15 marius Exp $
+ * $FreeBSD: src/sys/dev/pccbb/pccbbvar.h,v 1.33 2008/12/05 05:20:08 imp Exp $
*/
/*
@@ -67,8 +67,6 @@
unsigned int secbus;
unsigned int subbus;
struct mtx mtx;
- struct cv cv;
- struct cv powercv;
int cardok;
u_int32_t flags;
#define CBB_16BIT_CARD 0x20000000
@@ -89,7 +87,7 @@
device_t cbdev;
struct proc *event_thread;
void (*chipinit)(struct cbb_softc *);
- volatile int powerintr;
+ int powerintr;
};
/* result of detect_card */
==== //depot/projects/vimage/src/sys/i386/include/atomic.h#5 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/i386/include/atomic.h,v 1.49 2008/11/22 05:55:56 kmacy Exp $
+ * $FreeBSD: src/sys/i386/include/atomic.h,v 1.50 2008/12/05 21:17:54 kib Exp $
*/
#ifndef _MACHINE_ATOMIC_H_
#define _MACHINE_ATOMIC_H_
@@ -32,20 +32,9 @@
#error this file needs sys/cdefs.h as a prerequisite
#endif
-
-#if defined(I686_CPU)
-#define mb() __asm__ __volatile__ ("mfence;": : :"memory")
-#define wmb() __asm__ __volatile__ ("sfence;": : :"memory")
-#define rmb() __asm__ __volatile__ ("lfence;": : :"memory")
-#else
-/*
- * do we need a serializing instruction?
- */
-#define mb()
-#define wmb()
-#define rmb()
-#endif
-
+#define mb() __asm __volatile("lock;addl $0,(%esp)")
+#define wmb() __asm __volatile("lock;addl $0,(%esp)")
+#define rmb() __asm __volatile("lock;addl $0,(%esp)")
/*
* Various simple operations on memory, each of which is atomic in the
==== //depot/projects/vimage/src/sys/kern/kern_exec.c#19 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_exec.c,v 1.326 2008/11/05 19:40:36 rodrigc Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_exec.c,v 1.327 2008/12/05 20:50:24 kib Exp $");
#include "opt_hwpmc_hooks.h"
#include "opt_kdtrace.h"
@@ -609,7 +609,7 @@
p->p_flag |= P_EXEC;
if (p->p_pptr && (p->p_flag & P_PPWAIT)) {
p->p_flag &= ~P_PPWAIT;
- wakeup(p->p_pptr);
+ cv_broadcast(&p->p_pwait);
}
/*
==== //depot/projects/vimage/src/sys/kern/kern_exit.c#27 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.316 2008/11/29 14:32:14 bz Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.317 2008/12/05 20:50:24 kib Exp $");
#include "opt_compat.h"
#include "opt_kdtrace.h"
@@ -544,6 +544,7 @@
* proc lock.
*/
wakeup(p->p_pptr);
+ cv_broadcast(&p->p_pwait);
sched_exit(p->p_pptr, td);
PROC_SLOCK(p);
p->p_state = PRS_ZOMBIE;
@@ -776,6 +777,7 @@
PROC_UNLOCK(p);
tdsignal(t, NULL, SIGCHLD, p->p_ksi);
wakeup(t);
+ cv_broadcast(&p->p_pwait);
PROC_UNLOCK(t);
sx_xunlock(&proctree_lock);
return (0);
==== //depot/projects/vimage/src/sys/kern/kern_fork.c#23 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_fork.c,v 1.297 2008/11/29 14:32:14 bz Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_fork.c,v 1.298 2008/12/05 20:50:24 kib Exp $");
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
@@ -763,7 +763,7 @@
*/
PROC_LOCK(p2);
while (p2->p_flag & P_PPWAIT)
- msleep(p1, &p2->p_mtx, PWAIT, "ppwait", 0);
+ cv_wait(&p2->p_pwait, &p2->p_mtx);
PROC_UNLOCK(p2);
/*
==== //depot/projects/vimage/src/sys/kern/kern_linker.c#21 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_linker.c,v 1.161 2008/10/23 20:26:15 des Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_linker.c,v 1.162 2008/12/05 13:40:25 jhb Exp $");
#include "opt_ddb.h"
#include "opt_hwpmc_hooks.h"
@@ -588,7 +588,30 @@
" informing modules\n"));
/*
- * Inform any modules associated with this file.
+ * Quiesce all the modules to give them a chance to veto the unload.
+ */
+ MOD_SLOCK;
+ for (mod = TAILQ_FIRST(&file->modules); mod;
+ mod = module_getfnext(mod)) {
+
+ error = module_quiesce(mod);
+ if (error != 0 && flags != LINKER_UNLOAD_FORCE) {
+ KLD_DPF(FILE, ("linker_file_unload: module %s"
+ " vetoed unload\n", module_getname(mod)));
+ /*
+ * XXX: Do we need to tell all the quiesced modules
+ * that they can resume work now via a new module
+ * event?
+ */
+ MOD_SUNLOCK;
+ return (error);
+ }
+ }
+ MOD_SUNLOCK;
+
+ /*
+ * Inform any modules associated with this file that they are
+ * being be unloaded.
*/
MOD_XLOCK;
for (mod = TAILQ_FIRST(&file->modules); mod; mod = next) {
@@ -598,9 +621,9 @@
/*
* Give the module a chance to veto the unload.
*/
- if ((error = module_unload(mod, flags)) != 0) {
- KLD_DPF(FILE, ("linker_file_unload: module %p"
- " vetoes unload\n", mod));
+ if ((error = module_unload(mod)) != 0) {
+ KLD_DPF(FILE, ("linker_file_unload: module %s"
+ " failed unload\n", mod));
return (error);
}
MOD_XLOCK;
==== //depot/projects/vimage/src/sys/kern/kern_module.c#6 (text+ko) ====
@@ -27,7 +27,7 @@
#include "opt_compat.h"
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_module.c,v 1.55 2008/03/16 10:58:05 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_module.c,v 1.57 2008/12/05 16:47:30 jhb Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -130,6 +130,21 @@
printf("module_register_init: MOD_LOAD (%s, %p, %p) error"
" %d\n", data->name, (void *)data->evhand, data->priv,
error);
+ } else {
+ MOD_XLOCK;
+ if (mod->file) {
+ /*
+ * Once a module is succesfully loaded, move
+ * it to the head of the module list for this
+ * linker file. This resorts the list so that
+ * when the kernel linker iterates over the
+ * modules to unload them, it will unload them
+ * in the reverse order they were loaded.
+ */
+ TAILQ_REMOVE(&mod->file->modules, mod, flink);
+ TAILQ_INSERT_HEAD(&mod->file->modules, mod, flink);
+ }
+ MOD_XUNLOCK;
}
mtx_unlock(&Giant);
}
@@ -196,9 +211,7 @@
TAILQ_REMOVE(&modules, mod, link);
if (mod->file)
TAILQ_REMOVE(&mod->file->modules, mod, flink);
- MOD_XUNLOCK;
free(mod, M_MODULE);
- MOD_XLOCK;
}
}
@@ -232,16 +245,25 @@
}
int
-module_unload(module_t mod, int flags)
+module_quiesce(module_t mod)
{
int error;
mtx_lock(&Giant);
error = MOD_EVENT(mod, MOD_QUIESCE);
+ mtx_unlock(&Giant);
if (error == EOPNOTSUPP || error == EINVAL)
error = 0;
- if (error == 0 || flags == LINKER_UNLOAD_FORCE)
- error = MOD_EVENT(mod, MOD_UNLOAD);
+ return (error);
+}
+
+int
+module_unload(module_t mod)
+{
+ int error;
+
+ mtx_lock(&Giant);
+ error = MOD_EVENT(mod, MOD_UNLOAD);
mtx_unlock(&Giant);
return (error);
}
@@ -262,6 +284,14 @@
return (TAILQ_NEXT(mod, flink));
}
+const char *
+module_getname(module_t mod)
+{
+
+ MOD_LOCK_ASSERT;
+ return (mod->name);
+}
+
void
module_setspecific(module_t mod, modspecific_t *datap)
{
==== //depot/projects/vimage/src/sys/kern/kern_proc.c#18 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_proc.c,v 1.273 2008/12/02 06:50:26 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_proc.c,v 1.274 2008/12/05 20:50:24 kib Exp $");
#include "opt_compat.h"
#include "opt_ddb.h"
@@ -231,6 +231,7 @@
bzero(&p->p_mtx, sizeof(struct mtx));
mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN | MTX_RECURSE);
+ cv_init(&p->p_pwait, "ppwait");
TAILQ_INIT(&p->p_threads); /* all threads in proc */
EVENTHANDLER_INVOKE(process_init, p);
p->p_stats = pstats_alloc();
==== //depot/projects/vimage/src/sys/libkern/iconv.c#2 (text+ko) ====
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/libkern/iconv.c,v 1.12 2005/10/31 15:41:26 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/libkern/iconv.c,v 1.13 2008/12/05 21:19:24 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -39,6 +39,7 @@
#include <sys/iconv.h>
#include <sys/malloc.h>
#include <sys/mount.h>
+#include <sys/sx.h>
#include <sys/syslog.h>
#include "iconv_converter_if.h"
@@ -52,6 +53,8 @@
MODULE_VERSION(libiconv, 2);
+static struct sx iconv_lock;
+
#ifdef notnow
/*
* iconv converter instance
@@ -86,11 +89,16 @@
{
struct iconv_cspair *csp;
+ sx_xlock(&iconv_lock);
while ((csp = TAILQ_FIRST(&iconv_cslist)) != NULL) {
if (csp->cp_refcount)
return EBUSY;
+ }
+
+ while ((csp = TAILQ_FIRST(&iconv_cslist)) != NULL)
iconv_unregister_cspair(csp);
- }
+ sx_xunlock(&iconv_lock);
+ sx_destroy(&iconv_lock);
return 0;
}
@@ -102,6 +110,7 @@
switch (type) {
case MOD_LOAD:
error = 0;
+ sx_init(&iconv_lock, "iconv");
break;
case MOD_UNLOAD:
error = iconv_mod_unload();
@@ -311,7 +320,7 @@
int error;
error = 0;
-
+ sx_slock(&iconv_lock);
TAILQ_FOREACH(dcp, &iconv_converters, cc_link) {
name = ICONV_CONVERTER_NAME(dcp);
if (name == NULL)
@@ -320,6 +329,7 @@
if (error)
break;
}
+ sx_sunlock(&iconv_lock);
if (error)
return error;
spc = 0;
@@ -343,7 +353,7 @@
error = 0;
bzero(&csi, sizeof(csi));
csi.cs_version = ICONV_CSPAIR_INFO_VER;
-
+ sx_slock(&iconv_lock);
TAILQ_FOREACH(csp, &iconv_cslist, cp_link) {
csi.cs_id = csp->cp_id;
csi.cs_refcount = csp->cp_refcount;
@@ -354,6 +364,7 @@
if (error)
break;
}
+ sx_sunlock(&iconv_lock);
return error;
}
@@ -387,9 +398,12 @@
return EINVAL;
if (iconv_lookupconv(din.ia_converter, &dcp) != 0)
return EINVAL;
+ sx_xlock(&iconv_lock);
error = iconv_register_cspair(din.ia_to, din.ia_from, dcp, NULL, &csp);
- if (error)
+ if (error) {
+ sx_xunlock(&iconv_lock);
return error;
+ }
if (din.ia_datalen) {
csp->cp_data = malloc(din.ia_datalen, M_ICONVDATA, M_WAITOK);
error = copyin(din.ia_data, csp->cp_data, din.ia_datalen);
@@ -400,10 +414,12 @@
error = SYSCTL_OUT(req, &dout, sizeof(dout));
if (error)
goto bad;
+ sx_xunlock(&iconv_lock);
ICDEBUG("%s => %s, %d bytes\n",din.ia_from, din.ia_to, din.ia_datalen);
return 0;
bad:
iconv_unregister_cspair(csp);
+ sx_xunlock(&iconv_lock);
return error;
}
@@ -433,16 +449,22 @@
switch (type) {
case MOD_LOAD:
+ sx_xlock(&iconv_lock);
error = iconv_register_converter(dcp);
- if (error)
+ if (error) {
+ sx_xunlock(&iconv_lock);
break;
+ }
error = ICONV_CONVERTER_INIT(dcp);
if (error)
iconv_unregister_converter(dcp);
+ sx_xunlock(&iconv_lock);
break;
case MOD_UNLOAD:
+ sx_xlock(&iconv_lock);
ICONV_CONVERTER_DONE(dcp);
error = iconv_unregister_converter(dcp);
+ sx_xunlock(&iconv_lock);
break;
default:
error = EINVAL;
==== //depot/projects/vimage/src/sys/netinet/ip_carp.c#18 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/netinet/ip_carp.c,v 1.59 2008/12/02 21:37:28 bz Exp $");
+__FBSDID("$FreeBSD: src/sys/netinet/ip_carp.c,v 1.60 2008/12/05 14:37:14 glebius Exp $");
#include "opt_carp.h"
#include "opt_bpf.h"
@@ -2148,6 +2148,7 @@
static void
carp_set_state(struct carp_softc *sc, int state)
{
+ int link_state;
if (sc->sc_carpdev)
CARP_SCLOCK_ASSERT(sc);
@@ -2158,16 +2159,16 @@
sc->sc_state = state;
switch (state) {
case BACKUP:
- SC2IFP(sc)->if_link_state = LINK_STATE_DOWN;
+ link_state = LINK_STATE_DOWN;
break;
case MASTER:
- SC2IFP(sc)->if_link_state = LINK_STATE_UP;
+ link_state = LINK_STATE_UP;
break;
default:
- SC2IFP(sc)->if_link_state = LINK_STATE_UNKNOWN;
+ link_state = LINK_STATE_UNKNOWN;
break;
}
- rt_ifmsg(SC2IFP(sc));
+ if_link_state_change(SC2IFP(sc), link_state);
}
void
==== //depot/projects/vimage/src/sys/sys/module.h#4 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/sys/module.h,v 1.24 2008/03/16 10:58:01 rwatson Exp $
+ * $FreeBSD: src/sys/sys/module.h,v 1.25 2008/12/05 13:40:25 jhb Exp $
*/
#ifndef _SYS_MODULE_H_
@@ -154,11 +154,13 @@
int module_register(const struct moduledata *, struct linker_file *);
module_t module_lookupbyname(const char *);
module_t module_lookupbyid(int);
+int module_quiesce(module_t);
void module_reference(module_t);
void module_release(module_t);
-int module_unload(module_t, int flags);
+int module_unload(module_t);
int module_getid(module_t);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list