Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jun 2009 20:50:10 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 165211 for review
Message-ID:  <200906252050.n5PKoAMF088967@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165211

Change 165211 by jhb@jhb_jhbbsd on 2009/06/25 20:49:23

	IFC @165208

Affected files ...

.. //depot/projects/smpng/sys/amd64/amd64/intr_machdep.c#34 integrate
.. //depot/projects/smpng/sys/amd64/amd64/io_apic.c#24 integrate
.. //depot/projects/smpng/sys/amd64/amd64/msi.c#12 integrate
.. //depot/projects/smpng/sys/amd64/include/intr_machdep.h#19 integrate
.. //depot/projects/smpng/sys/arm/conf/CAMBRIA.hints#6 integrate
.. //depot/projects/smpng/sys/cam/scsi/scsi_target.c#28 integrate
.. //depot/projects/smpng/sys/conf/files#246 integrate
.. //depot/projects/smpng/sys/dev/cas/if_cas.c#3 integrate
.. //depot/projects/smpng/sys/dev/drm/drm_irq.c#13 integrate
.. //depot/projects/smpng/sys/dev/drm/i915_dma.c#16 integrate
.. //depot/projects/smpng/sys/dev/drm/i915_drv.h#11 integrate
.. //depot/projects/smpng/sys/dev/drm/i915_irq.c#12 integrate
.. //depot/projects/smpng/sys/dev/drm/radeon_cp.c#24 integrate
.. //depot/projects/smpng/sys/dev/drm/radeon_irq.c#13 integrate
.. //depot/projects/smpng/sys/dev/e1000/if_igb.c#10 integrate
.. //depot/projects/smpng/sys/dev/iscsi/initiator/isc_soc.c#5 integrate
.. //depot/projects/smpng/sys/dev/ixgbe/ixgbe.c#7 integrate
.. //depot/projects/smpng/sys/dev/sound/midi/midi.c#19 integrate
.. //depot/projects/smpng/sys/dev/sound/midi/sequencer.c#24 integrate
.. //depot/projects/smpng/sys/dev/speaker/spkr.c#7 integrate
.. //depot/projects/smpng/sys/fs/coda/coda_psdev.c#4 integrate
.. //depot/projects/smpng/sys/fs/coda/coda_vnops.c#8 integrate
.. //depot/projects/smpng/sys/fs/pseudofs/pseudofs_vnops.c#60 integrate
.. //depot/projects/smpng/sys/gnu/fs/xfs/FreeBSD/xfs_ioctl.c#5 integrate
.. //depot/projects/smpng/sys/i386/i386/intr_machdep.c#35 integrate
.. //depot/projects/smpng/sys/i386/i386/io_apic.c#26 integrate
.. //depot/projects/smpng/sys/i386/i386/msi.c#12 integrate
.. //depot/projects/smpng/sys/i386/include/intr_machdep.h#21 integrate
.. //depot/projects/smpng/sys/kern/kern_intr.c#99 integrate
.. //depot/projects/smpng/sys/kern/kern_lockf.c#30 integrate
.. //depot/projects/smpng/sys/kern/sysv_shm.c#47 integrate
.. //depot/projects/smpng/sys/net/if_tap.c#52 integrate
.. //depot/projects/smpng/sys/net/if_tun.c#64 integrate
.. //depot/projects/smpng/sys/netinet/ip_carp.c#36 integrate
.. //depot/projects/smpng/sys/netinet6/in6.c#60 integrate
.. //depot/projects/smpng/sys/netinet6/in6_ifattach.c#39 integrate
.. //depot/projects/smpng/sys/netinet6/in6_src.c#43 integrate
.. //depot/projects/smpng/sys/netinet6/in6_var.h#24 integrate
.. //depot/projects/smpng/sys/netinet6/ip6_input.c#67 integrate
.. //depot/projects/smpng/sys/netinet6/nd6.c#57 integrate
.. //depot/projects/smpng/sys/netinet6/nd6_rtr.c#35 integrate
.. //depot/projects/smpng/sys/netipsec/key.c#40 integrate
.. //depot/projects/smpng/sys/sun4v/conf/GENERIC#17 integrate
.. //depot/projects/smpng/sys/sys/conf.h#60 integrate
.. //depot/projects/smpng/sys/sys/uio.h#25 integrate
.. //depot/projects/smpng/sys/sys/vnode.h#102 integrate
.. //depot/projects/smpng/sys/vm/vm_extern.h#35 integrate
.. //depot/projects/smpng/sys/vm/vm_fault.c#77 integrate
.. //depot/projects/smpng/sys/vm/vm_kern.c#45 integrate
.. //depot/projects/smpng/sys/vm/vm_map.c#100 integrate
.. //depot/projects/smpng/sys/vm/vm_map.h#44 integrate
.. //depot/projects/smpng/sys/vm/vm_mmap.c#79 integrate
.. //depot/projects/smpng/sys/vm/vm_object.c#110 integrate
.. //depot/projects/smpng/sys/vm/vm_object.h#39 integrate
.. //depot/projects/smpng/sys/vm/vm_pageout.c#73 integrate
.. //depot/projects/smpng/sys/vm/vm_pager.c#28 integrate
.. //depot/projects/smpng/sys/vm/vm_pager.h#16 integrate
.. //depot/projects/smpng/sys/vm/vnode_pager.c#75 integrate

Differences ...

==== //depot/projects/smpng/sys/amd64/amd64/intr_machdep.c#34 (text+ko) ====

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/amd64/intr_machdep.c,v 1.42 2008/12/02 14:19:53 ganbold Exp $
+ * $FreeBSD: src/sys/amd64/amd64/intr_machdep.c,v 1.43 2009/06/25 18:13:46 jhb Exp $
  */
 
 /*
@@ -51,7 +51,6 @@
 #include <sys/smp.h>
 #include <sys/syslog.h>
 #include <sys/systm.h>
-#include <sys/sx.h>
 #include <machine/clock.h>
 #include <machine/intr_machdep.h>
 #include <machine/smp.h>
@@ -73,14 +72,12 @@
 
 static int intrcnt_index;
 static struct intsrc *interrupt_sources[NUM_IO_INTS];
-static struct sx intr_table_lock;
+static struct mtx intr_table_lock;
 static struct mtx intrcnt_lock;
 static STAILQ_HEAD(, pic) pics;
 
 #ifdef SMP
 static int assign_cpu;
-
-static void	intr_assign_next_cpu(struct intsrc *isrc);
 #endif
 
 static int	intr_assign_cpu(void *arg, u_char cpu);
@@ -114,14 +111,14 @@
 {
 	int error;
 
-	sx_xlock(&intr_table_lock);
+	mtx_lock(&intr_table_lock);
 	if (intr_pic_registered(pic))
 		error = EBUSY;
 	else {
 		STAILQ_INSERT_TAIL(&pics, pic, pics);
 		error = 0;
 	}
-	sx_xunlock(&intr_table_lock);
+	mtx_unlock(&intr_table_lock);
 	return (error);
 }
 
@@ -145,16 +142,16 @@
 	    vector);
 	if (error)
 		return (error);
-	sx_xlock(&intr_table_lock);
+	mtx_lock(&intr_table_lock);
 	if (interrupt_sources[vector] != NULL) {
-		sx_xunlock(&intr_table_lock);
+		mtx_unlock(&intr_table_lock);
 		intr_event_destroy(isrc->is_event);
 		return (EEXIST);
 	}
 	intrcnt_register(isrc);
 	interrupt_sources[vector] = isrc;
 	isrc->is_handlers = 0;
-	sx_xunlock(&intr_table_lock);
+	mtx_unlock(&intr_table_lock);
 	return (0);
 }
 
@@ -178,18 +175,14 @@
 	error = intr_event_add_handler(isrc->is_event, name, filter, handler,
 	    arg, intr_priority(flags), flags, cookiep);
 	if (error == 0) {
-		sx_xlock(&intr_table_lock);
+		mtx_lock(&intr_table_lock);
 		intrcnt_updatename(isrc);
 		isrc->is_handlers++;
 		if (isrc->is_handlers == 1) {
-#ifdef SMP
-			if (assign_cpu)
-				intr_assign_next_cpu(isrc);
-#endif
 			isrc->is_pic->pic_enable_intr(isrc);
 			isrc->is_pic->pic_enable_source(isrc);
 		}
-		sx_xunlock(&intr_table_lock);
+		mtx_unlock(&intr_table_lock);
 	}
 	return (error);
 }
@@ -203,14 +196,14 @@
 	isrc = intr_handler_source(cookie);
 	error = intr_event_remove_handler(cookie);
 	if (error == 0) {
-		sx_xlock(&intr_table_lock);
+		mtx_lock(&intr_table_lock);
 		isrc->is_handlers--;
 		if (isrc->is_handlers == 0) {
 			isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI);
 			isrc->is_pic->pic_disable_intr(isrc);
 		}
 		intrcnt_updatename(isrc);
-		sx_xunlock(&intr_table_lock);
+		mtx_unlock(&intr_table_lock);
 	}
 	return (error);
 }
@@ -284,12 +277,12 @@
 #ifndef DEV_ATPIC
 	atpic_reset();
 #endif
-	sx_xlock(&intr_table_lock);
+	mtx_lock(&intr_table_lock);
 	STAILQ_FOREACH(pic, &pics, pics) {
 		if (pic->pic_resume != NULL)
 			pic->pic_resume(pic);
 	}
-	sx_xunlock(&intr_table_lock);
+	mtx_unlock(&intr_table_lock);
 }
 
 void
@@ -297,12 +290,12 @@
 {
 	struct pic *pic;
 
-	sx_xlock(&intr_table_lock);
+	mtx_lock(&intr_table_lock);
 	STAILQ_FOREACH(pic, &pics, pics) {
 		if (pic->pic_suspend != NULL)
 			pic->pic_suspend(pic);
 	}
-	sx_xunlock(&intr_table_lock);
+	mtx_unlock(&intr_table_lock);
 }
 
 static int
@@ -317,9 +310,9 @@
 	 */
 	if (assign_cpu && cpu != NOCPU) {
 		isrc = arg;
-		sx_xlock(&intr_table_lock);
+		mtx_lock(&intr_table_lock);
 		isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[cpu]);
-		sx_xunlock(&intr_table_lock);
+		mtx_unlock(&intr_table_lock);
 	}
 	return (0);
 #else
@@ -378,7 +371,7 @@
 	intrcnt_setname("???", 0);
 	intrcnt_index = 1;
 	STAILQ_INIT(&pics);
-	sx_init(&intr_table_lock, "intr sources");
+	mtx_init(&intr_table_lock, "intr sources", NULL, MTX_DEF | MTX_RECURSE);
 	mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN);
 }
 SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL);
@@ -435,19 +428,28 @@
 static cpumask_t intr_cpus = (1 << 0);
 static int current_cpu;
 
-static void
-intr_assign_next_cpu(struct intsrc *isrc)
+/*
+ * Return the CPU that the next interrupt source should use.  For now
+ * this just returns the next local APIC according to round-robin.
+ */
+u_int
+intr_next_cpu(void)
 {
+	u_int apic_id;
 
-	/*
-	 * Assign this source to a local APIC in a round-robin fashion.
-	 */
-	isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[current_cpu]);
+	/* Leave all interrupts on the BSP during boot. */
+	if (!assign_cpu)
+		return (cpu_apic_ids[0]);
+
+	mtx_lock(&intr_table_lock);
+	apic_id = cpu_apic_ids[current_cpu];
 	do {
 		current_cpu++;
 		if (current_cpu > mp_maxid)
 			current_cpu = 0;
 	} while (!(intr_cpus & (1 << current_cpu)));
+	mtx_unlock(&intr_table_lock);
+	return (apic_id);
 }
 
 /* Attempt to bind the specified IRQ to the specified CPU. */
@@ -487,6 +489,7 @@
 intr_shuffle_irqs(void *arg __unused)
 {
 	struct intsrc *isrc;
+	u_int apic_id;
 	int i;
 
 	/* Don't bother on UP. */
@@ -494,7 +497,7 @@
 		return;
 
 	/* Round-robin assign a CPU to each enabled source. */
-	sx_xlock(&intr_table_lock);
+	mtx_lock(&intr_table_lock);
 	assign_cpu = 1;
 	for (i = 0; i < NUM_IO_INTS; i++) {
 		isrc = interrupt_sources[i];
@@ -505,13 +508,13 @@
 			 * of picking one via round-robin.
 			 */
 			if (isrc->is_event->ie_cpu != NOCPU)
-				isrc->is_pic->pic_assign_cpu(isrc,
-				    cpu_apic_ids[isrc->is_event->ie_cpu]);
+				apic_id = isrc->is_event->ie_cpu;
 			else
-				intr_assign_next_cpu(isrc);
+				apic_id = intr_next_cpu();
+			isrc->is_pic->pic_assign_cpu(isrc, apic_id);
 		}
 	}
-	sx_xunlock(&intr_table_lock);
+	mtx_unlock(&intr_table_lock);
 }
 SYSINIT(intr_shuffle_irqs, SI_SUB_SMP, SI_ORDER_SECOND, intr_shuffle_irqs,
     NULL);

==== //depot/projects/smpng/sys/amd64/amd64/io_apic.c#24 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/io_apic.c,v 1.32 2009/01/29 09:22:56 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/io_apic.c,v 1.33 2009/06/25 18:13:46 jhb Exp $");
 
 #include "opt_isa.h"
 
@@ -372,7 +372,7 @@
 	struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc;
 
 	if (intpin->io_vector == 0)
-		ioapic_assign_cpu(isrc, pcpu_find(0)->pc_apic_id);
+		ioapic_assign_cpu(isrc, intr_next_cpu());
 	apic_enable_vector(intpin->io_cpu, intpin->io_vector);
 }
 

==== //depot/projects/smpng/sys/amd64/amd64/msi.c#12 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/msi.c,v 1.11 2009/06/15 13:47:49 mav Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/msi.c,v 1.12 2009/06/25 18:13:46 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -161,8 +161,6 @@
 {
 	struct msi_intsrc *msi = (struct msi_intsrc *)isrc;
 
-	if (msi->msi_vector == 0)
-		msi_assign_cpu(isrc, 0);
 	apic_enable_vector(msi->msi_cpu, msi->msi_vector);
 }
 
@@ -208,10 +206,11 @@
 	/* Store information to free existing irq. */
 	old_vector = msi->msi_vector;
 	old_id = msi->msi_cpu;
-	if (old_vector && old_id == apic_id)
+	if (old_id == apic_id)
 		return;
-	if (old_vector && !msi->msi_msix && msi->msi_first->msi_count > 1)
+	if (!msi->msi_msix && msi->msi_first->msi_count > 1)
 		return;
+
 	/* Allocate IDT vector on this cpu. */
 	vector = apic_alloc_vector(apic_id, msi->msi_irq);
 	if (vector == 0)
@@ -223,15 +222,14 @@
 		    msi->msi_msix ? "MSI-X" : "MSI", msi->msi_irq,
 		    msi->msi_cpu, msi->msi_vector);
 	pci_remap_msi_irq(msi->msi_dev, msi->msi_irq);
+
 	/*
 	 * Free the old vector after the new one is established.  This is done
 	 * to prevent races where we could miss an interrupt.
 	 */
-	if (old_vector)
-		apic_free_vector(old_id, old_vector, msi->msi_irq);
+	apic_free_vector(old_id, old_vector, msi->msi_irq);
 }
 
-
 void
 msi_init(void)
 {
@@ -287,7 +285,8 @@
 msi_alloc(device_t dev, int count, int maxcount, int *irqs)
 {
 	struct msi_intsrc *msi, *fsrc;
-	int cnt, i;
+	u_int cpu;
+	int cnt, i, vector;
 
 	if (!msi_enabled)
 		return (ENXIO);
@@ -333,12 +332,25 @@
 	/* Ok, we now have the IRQs allocated. */
 	KASSERT(cnt == count, ("count mismatch"));
 
+	/* Allocate 'count' IDT vectors. */
+	cpu = intr_next_cpu();
+	vector = apic_alloc_vectors(cpu, irqs, count, maxcount);
+	if (vector == 0) {
+		mtx_unlock(&msi_lock);
+		return (ENOSPC);
+	}
+
 	/* Assign IDT vectors and make these messages owned by 'dev'. */
 	fsrc = (struct msi_intsrc *)intr_lookup_source(irqs[0]);
 	for (i = 0; i < count; i++) {
 		msi = (struct msi_intsrc *)intr_lookup_source(irqs[i]);
+		msi->msi_cpu = cpu;
 		msi->msi_dev = dev;
-		msi->msi_vector = 0;
+		msi->msi_vector = vector + i;
+		if (bootverbose)
+			printf(
+		    "msi: routing MSI IRQ %d to local APIC %u vector %u\n",
+			    msi->msi_irq, msi->msi_cpu, msi->msi_vector);
 		msi->msi_first = fsrc;
 		KASSERT(msi->msi_intsrc.is_handlers == 0,
 		    ("dead MSI has handlers"));
@@ -391,18 +403,14 @@
 		KASSERT(msi->msi_dev == first->msi_dev, ("owner mismatch"));
 		msi->msi_first = NULL;
 		msi->msi_dev = NULL;
-		if (msi->msi_vector)
-			apic_free_vector(msi->msi_cpu, msi->msi_vector,
-			    msi->msi_irq);
+		apic_free_vector(msi->msi_cpu, msi->msi_vector, msi->msi_irq);
 		msi->msi_vector = 0;
 	}
 
 	/* Clear out the first message. */
 	first->msi_first = NULL;
 	first->msi_dev = NULL;
-	if (first->msi_vector)
-		apic_free_vector(first->msi_cpu, first->msi_vector,
-		    first->msi_irq);
+	apic_free_vector(first->msi_cpu, first->msi_vector, first->msi_irq);
 	first->msi_vector = 0;
 	first->msi_count = 0;
 
@@ -451,7 +459,8 @@
 msix_alloc(device_t dev, int *irq)
 {
 	struct msi_intsrc *msi;
-	int i;
+	u_int cpu;
+	int i, vector;
 
 	if (!msi_enabled)
 		return (ENXIO);
@@ -486,9 +495,17 @@
 		goto again;
 	}
 
+	/* Allocate an IDT vector. */
+	cpu = intr_next_cpu();
+	vector = apic_alloc_vector(cpu, i);
+	if (bootverbose)
+		printf("msi: routing MSI-X IRQ %d to local APIC %u vector %u\n",
+		    msi->msi_irq, cpu, vector);
+	
 	/* Setup source. */
+	msi->msi_cpu = cpu;
 	msi->msi_dev = dev;
-	msi->msi_vector = 0;
+	msi->msi_vector = vector;
 	msi->msi_msix = 1;
 
 	KASSERT(msi->msi_intsrc.is_handlers == 0, ("dead MSI-X has handlers"));
@@ -520,8 +537,7 @@
 
 	/* Clear out the message. */
 	msi->msi_dev = NULL;
-	if (msi->msi_vector)
-		apic_free_vector(msi->msi_cpu, msi->msi_vector, msi->msi_irq);
+	apic_free_vector(msi->msi_cpu, msi->msi_vector, msi->msi_irq);
 	msi->msi_vector = 0;
 	msi->msi_msix = 0;
 

==== //depot/projects/smpng/sys/amd64/include/intr_machdep.h#19 (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/amd64/include/intr_machdep.h,v 1.21 2009/02/03 09:01:45 jkoshy Exp $
+ * $FreeBSD: src/sys/amd64/include/intr_machdep.h,v 1.22 2009/06/25 18:13:46 jhb Exp $
  */
 
 #ifndef __MACHINE_INTR_MACHDEP_H__
@@ -152,6 +152,9 @@
 int	intr_config_intr(int vector, enum intr_trigger trig,
     enum intr_polarity pol);
 void	intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame);
+#ifdef SMP
+u_int	intr_next_cpu(void);
+#endif
 struct intsrc *intr_lookup_source(int vector);
 int	intr_register_pic(struct pic *pic);
 int	intr_register_source(struct intsrc *isrc);

==== //depot/projects/smpng/sys/arm/conf/CAMBRIA.hints#6 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/arm/conf/CAMBRIA.hints,v 1.9 2009/06/22 23:22:38 sam Exp $
+# $FreeBSD: src/sys/arm/conf/CAMBRIA.hints,v 1.10 2009/06/25 18:07:19 sam Exp $
 
 #
 # Device wiring for the Gateworks Cambria 2358.
@@ -14,16 +14,16 @@
 # NB: no UART1 on ixp435
 
 # optional GPS serial port
-hint.uart.1.at="ixp0"
-hint.uart.1.addr=0x53fc0000
-hint.uart.1.irq=20
-hint.uart.1.ier_rxbits=0x1
-hint.uart.1.rclk=1843200
+#hint.uart.1.at="ixp0"
+#hint.uart.1.addr=0x53fc0000
+#hint.uart.1.irq=20
+#hint.uart.1.ier_rxbits=0x1
+#hint.uart.1.rclk=1843200
 # optional RS485 serial port
-hint.uart.2.at="ixp0"
-hint.uart.2.addr=0x53f80000
-hint.uart.2.irq=21
-hint.uart.2.rclk=1843200
+#hint.uart.2.at="ixp0"
+#hint.uart.2.addr=0x53f80000
+#hint.uart.2.irq=21
+#hint.uart.2.rclk=1843200
 
 # NPE Hardware Queue Manager
 hint.ixpqmgr.0.at="ixp0"

==== //depot/projects/smpng/sys/cam/scsi/scsi_target.c#28 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_target.c,v 1.77 2009/06/10 20:59:32 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_target.c,v 1.78 2009/06/25 18:46:30 kib Exp $");
 
 
 #include <sys/param.h>
@@ -552,7 +552,7 @@
 	softc = (struct targ_softc *)dev->si_drv1;
 	write_len = error = 0;
 	CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
-		  ("write - uio_resid %d\n", uio->uio_resid));
+		  ("write - uio_resid %zd\n", uio->uio_resid));
 	while (uio->uio_resid >= sizeof(user_ccb) && error == 0) {
 		union ccb *ccb;
 

==== //depot/projects/smpng/sys/conf/files#246 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.1445 2009/06/24 15:38:17 raj Exp $
+# $FreeBSD: src/sys/conf/files,v 1.1446 2009/06/25 18:09:23 raj Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -489,10 +489,10 @@
 #
 dev/ata/ata_if.m		optional ata | atacore
 dev/ata/ata-all.c		optional ata | atacore
+dev/ata/ata-dma.c		optional ata | atacore
 dev/ata/ata-lowlevel.c		optional ata | atacore
 dev/ata/ata-queue.c		optional ata | atacore
-dev/ata/ata-dma.c		optional ata | atadma
-dev/ata/ata-sata.c		optional ata | atasata
+dev/ata/ata-sata.c		optional ata | atacore
 dev/ata/ata-card.c		optional ata pccard | atapccard
 dev/ata/ata-cbus.c		optional ata pc98 | atapc98
 dev/ata/ata-isa.c		optional ata isa | ataisa

==== //depot/projects/smpng/sys/dev/cas/if_cas.c#3 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cas/if_cas.c,v 1.2 2009/06/24 20:56:06 marius Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cas/if_cas.c,v 1.3 2009/06/25 16:38:16 marius Exp $");
 
 /*
  * driver for Sun Cassini/Cassini+ and National Semiconductor DP83065
@@ -1697,14 +1697,16 @@
 				refcount_acquire(&rxds->rxds_refcount);
 				bus_dmamap_sync(sc->sc_rdmatag,
 				    rxds->rxds_dmamap, BUS_DMASYNC_POSTREAD);
+#if __FreeBSD_version < 800016
 				MEXTADD(m, (caddr_t)rxds->rxds_buf +
 				    off * 256 + ETHER_ALIGN, len, cas_free,
-#if __FreeBSD_version < 800016
-				    rxds,
+				    rxds, M_RDONLY, EXT_NET_DRV);
 #else
+				MEXTADD(m, (caddr_t)rxds->rxds_buf +
+				    off * 256 + ETHER_ALIGN, len, cas_free,
 				    sc, (void *)(uintptr_t)idx,
+				    M_RDONLY, EXT_NET_DRV);
 #endif
-				    M_RDONLY, EXT_NET_DRV);
 				if ((m->m_flags & M_EXT) == 0) {
 					m_freem(m);
 					m = NULL;
@@ -1740,14 +1742,16 @@
 				m->m_len = min(CAS_PAGE_SIZE - off, len);
 				bus_dmamap_sync(sc->sc_rdmatag,
 				    rxds->rxds_dmamap, BUS_DMASYNC_POSTREAD);
+#if __FreeBSD_version < 800016
 				MEXTADD(m, (caddr_t)rxds->rxds_buf + off,
-				    m->m_len, cas_free,
-#if __FreeBSD_version < 800016
-				    rxds,
+				    m->m_len, cas_free, rxds, M_RDONLY,
+				    EXT_NET_DRV);
 #else
-				    sc, (void *)(uintptr_t)idx,
+				MEXTADD(m, (caddr_t)rxds->rxds_buf + off,
+				    m->m_len, cas_free, sc,
+				    (void *)(uintptr_t)idx, M_RDONLY,
+				    EXT_NET_DRV);
 #endif
-				    M_RDONLY, EXT_NET_DRV);
 				if ((m->m_flags & M_EXT) == 0) {
 					m_freem(m);
 					m = NULL;
@@ -1774,14 +1778,16 @@
 					bus_dmamap_sync(sc->sc_rdmatag,
 					    rxds2->rxds_dmamap,
 					    BUS_DMASYNC_POSTREAD);
+#if __FreeBSD_version < 800016
+					MEXTADD(m2, (caddr_t)rxds2->rxds_buf,
+					    m2->m_len, cas_free, rxds2,
+					    M_RDONLY, EXT_NET_DRV);
+#else
 					MEXTADD(m2, (caddr_t)rxds2->rxds_buf,
 					    m2->m_len, cas_free,
-#if __FreeBSD_version < 800016
-					    rxds2,
-#else
 					    sc, (void *)(uintptr_t)idx2,
+					    M_RDONLY, EXT_NET_DRV);
 #endif
-					    M_RDONLY, EXT_NET_DRV);
 					if ((m2->m_flags & M_EXT) == 0) {
 						m_freem(m2);
 						m2 = NULL;

==== //depot/projects/smpng/sys/dev/drm/drm_irq.c#13 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/drm/drm_irq.c,v 1.18 2009/06/25 14:15:45 rnoland Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/drm/drm_irq.c,v 1.21 2009/06/25 15:47:32 rnoland Exp $");
 
 /** @file drm_irq.c
  * Support code for handling setup/teardown of interrupt handlers and
@@ -89,7 +89,7 @@
 		return;
 
 	for (i = 0; i < dev->num_crtcs; i++) {
-		if (atomic_read(&dev->vblank[i].refcount) == 0 &&
+		if (dev->vblank[i].refcount == 0 &&
 		    dev->vblank[i].enabled && !dev->vblank[i].inmodeset) {
 			DRM_DEBUG("disabling vblank on crtc %d\n", i);
 			dev->vblank[i].last =
@@ -136,13 +136,14 @@
 	DRM_DEBUG("\n");
 
 	/* Zero per-crtc vblank stuff */
+	DRM_SPINLOCK(&dev->vbl_lock);
 	for (i = 0; i < num_crtcs; i++) {
 		DRM_INIT_WAITQUEUE(&dev->vblank[i].queue);
-		atomic_set(&dev->vblank[i].count, 0);
-		atomic_set(&dev->vblank[i].refcount, 0);
+		dev->vblank[i].refcount = 0;
+		atomic_set_rel_32(&dev->vblank[i].count, 0);
 	}
-
 	dev->vblank_disable_allowed = 0;
+	DRM_SPINUNLOCK(&dev->vbl_lock);
 
 	return 0;
 
@@ -275,7 +276,7 @@
 
 u32 drm_vblank_count(struct drm_device *dev, int crtc)
 {
-	return atomic_read(&dev->vblank[crtc].count);
+	return atomic_load_acq_32(&dev->vblank[crtc].count);
 }
 
 static void drm_update_vblank_count(struct drm_device *dev, int crtc)
@@ -301,45 +302,48 @@
 	DRM_DEBUG("enabling vblank interrupts on crtc %d, missed %d\n",
 	    crtc, diff);
 
-	atomic_add(diff, &dev->vblank[crtc].count);
+	atomic_add_rel_32(&dev->vblank[crtc].count, diff);
 }
 
 int drm_vblank_get(struct drm_device *dev, int crtc)
 {
 	int ret = 0;
 
-	DRM_SPINLOCK(&dev->vbl_lock);
+	/* Make sure that we are called with the lock held */
+	mtx_assert(&dev->vbl_lock, MA_OWNED);
+
 	/* Going from 0->1 means we have to enable interrupts again */
-	atomic_add_acq_int(&dev->vblank[crtc].refcount, 1);
-	if (dev->vblank[crtc].refcount == 1 &&
+	if (++dev->vblank[crtc].refcount == 1 &&
 	    !dev->vblank[crtc].enabled) {
 		ret = dev->driver->enable_vblank(dev, crtc);
 		DRM_DEBUG("enabling vblank on crtc %d, ret: %d\n", crtc, ret);
 		if (ret)
-			atomic_dec(&dev->vblank[crtc].refcount);
+			--dev->vblank[crtc].refcount;
 		else {
 			dev->vblank[crtc].enabled = 1;
 			drm_update_vblank_count(dev, crtc);
 		}
 	}
-	DRM_SPINUNLOCK(&dev->vbl_lock);
+
+	if (dev->vblank[crtc].enabled)
+		dev->vblank[crtc].last =
+		    dev->driver->get_vblank_counter(dev, crtc);
 
 	return ret;
 }
 
 void drm_vblank_put(struct drm_device *dev, int crtc)
 {
-	KASSERT(atomic_read(&dev->vblank[crtc].refcount) > 0,
+	/* Make sure that we are called with the lock held */
+	mtx_assert(&dev->vbl_lock, MA_OWNED);
+
+	KASSERT(dev->vblank[crtc].refcount > 0,
 	    ("invalid refcount"));
 
 	/* Last user schedules interrupt disable */
-	atomic_subtract_acq_int(&dev->vblank[crtc].refcount, 1);
-
-	DRM_SPINLOCK(&dev->vbl_lock);
-	if (dev->vblank[crtc].refcount == 0)
+	if (--dev->vblank[crtc].refcount == 0)
 	    callout_reset(&dev->vblank_disable_timer, 5 * DRM_HZ,
 		(timeout_t *)vblank_disable_fn, (void *)dev);
-	DRM_SPINUNLOCK(&dev->vbl_lock);
 }
 
 int drm_modeset_ctl(struct drm_device *dev, void *data,
@@ -348,13 +352,11 @@
 	struct drm_modeset_ctl *modeset = data;
 	int crtc, ret = 0;
 
-	DRM_DEBUG("num_crtcs=%d\n", dev->num_crtcs);
 	/* If drm_vblank_init() hasn't been called yet, just no-op */
 	if (!dev->num_crtcs)
 		goto out;
 
 	crtc = modeset->crtc;
-	DRM_DEBUG("crtc=%d\n", crtc);
 	if (crtc >= dev->num_crtcs) {
 		ret = EINVAL;
 		goto out;
@@ -369,25 +371,25 @@
 	 */
 	switch (modeset->cmd) {
 	case _DRM_PRE_MODESET:
-		DRM_DEBUG("pre-modeset\n");
+		DRM_DEBUG("pre-modeset, crtc %d\n", crtc);
+		DRM_SPINLOCK(&dev->vbl_lock);
 		if (!dev->vblank[crtc].inmodeset) {
 			dev->vblank[crtc].inmodeset = 0x1;
 			if (drm_vblank_get(dev, crtc) == 0)
 				dev->vblank[crtc].inmodeset |= 0x2;
 		}
+		DRM_SPINUNLOCK(&dev->vbl_lock);
 		break;
 	case _DRM_POST_MODESET:
-		DRM_DEBUG("post-modeset\n");
+		DRM_DEBUG("post-modeset, crtc %d\n", crtc);
+		DRM_SPINLOCK(&dev->vbl_lock);
 		if (dev->vblank[crtc].inmodeset) {
-			DRM_SPINLOCK(&dev->vbl_lock);
-			dev->vblank_disable_allowed = 1;
-			DRM_SPINUNLOCK(&dev->vbl_lock);
-
 			if (dev->vblank[crtc].inmodeset & 0x2)
 				drm_vblank_put(dev, crtc);
-
 			dev->vblank[crtc].inmodeset = 0;
 		}
+		dev->vblank_disable_allowed = 1;
+		DRM_SPINUNLOCK(&dev->vbl_lock);
 		break;
 	default:
 		ret = EINVAL;
@@ -421,7 +423,9 @@
 	if (crtc >= dev->num_crtcs)
 		return EINVAL;
 
+	DRM_SPINLOCK(&dev->vbl_lock);
 	ret = drm_vblank_get(dev, crtc);
+	DRM_SPINUNLOCK(&dev->vbl_lock);
 	if (ret) {
 		DRM_ERROR("failed to acquire vblank counter, %d\n", ret);
 		return ret;
@@ -478,13 +482,16 @@
 	}
 
 done:
+	DRM_SPINLOCK(&dev->vbl_lock);
 	drm_vblank_put(dev, crtc);
+	DRM_SPINUNLOCK(&dev->vbl_lock);
+
 	return ret;
 }
 
 void drm_handle_vblank(struct drm_device *dev, int crtc)
 {
-	atomic_inc(&dev->vblank[crtc].count);
+	atomic_add_rel_32(&dev->vblank[crtc].count, 1);
 	DRM_WAKEUP(&dev->vblank[crtc].queue);
 }
 

==== //depot/projects/smpng/sys/dev/drm/i915_dma.c#16 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/drm/i915_dma.c,v 1.19 2009/06/20 16:45:14 rnoland Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/drm/i915_dma.c,v 1.20 2009/06/25 19:23:25 rnoland Exp $");
 
 #include "dev/drm/drmP.h"
 #include "dev/drm/drm.h"
@@ -644,18 +644,17 @@
 			return -EFAULT;
 		}
 	}
-	DRM_LOCK();
 
 	ret = i915_dispatch_batchbuffer(dev, batch);
 
-	if (sarea_priv)
-		sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
-
-	DRM_UNLOCK();
 	if (batch->num_cliprects)
 		vsunlock(batch->cliprects, cliplen);
+
 	DRM_LOCK();
 
+	if (sarea_priv)
+		sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
+
 	return ret;
 }
 
@@ -697,10 +696,9 @@
 			return -EFAULT;
 		}
 	}
-	DRM_LOCK();
 
 	ret = i915_dispatch_cmdbuffer(dev, cmdbuf);
-	DRM_UNLOCK();
+
 	if (cmdbuf->num_cliprects) {
 		vsunlock(cmdbuf->buf, cmdbuf->sz);
 		vsunlock(cmdbuf->cliprects, cliplen);

==== //depot/projects/smpng/sys/dev/drm/i915_drv.h#11 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/drm/i915_drv.h,v 1.12 2009/06/20 16:45:14 rnoland Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/drm/i915_drv.h,v 1.13 2009/06/25 18:27:08 rnoland Exp $");
 
 #ifndef _I915_DRV_H_
 #define _I915_DRV_H_
@@ -129,7 +129,6 @@
 	int page_flipping;
 
 	wait_queue_head_t irq_queue;
-	atomic_t irq_received;
 	/** Protects user_irq_refcount and irq_mask_reg */
 	DRM_SPINTYPE user_irq_lock;
 	/** Refcount for i915_user_irq_get() versus i915_user_irq_put(). */

==== //depot/projects/smpng/sys/dev/drm/i915_irq.c#12 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/drm/i915_irq.c,v 1.14 2009/06/20 16:45:14 rnoland Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/drm/i915_irq.c,v 1.15 2009/06/25 18:27:08 rnoland Exp $");
 
 #include "dev/drm/drmP.h"
 #include "dev/drm/drm.h"
@@ -53,12 +53,6 @@
 #define I915_INTERRUPT_ENABLE_MASK	(I915_INTERRUPT_ENABLE_FIX | \
 				    	 I915_INTERRUPT_ENABLE_VAR)
 
-#define I915_PIPE_VBLANK_STATUS		(PIPE_START_VBLANK_INTERRUPT_STATUS |\
-					 PIPE_VBLANK_INTERRUPT_STATUS)
- 
-#define I915_PIPE_VBLANK_ENABLE		(PIPE_START_VBLANK_INTERRUPT_ENABLE |\
-					 PIPE_VBLANK_INTERRUPT_ENABLE)
-  
 #define DRM_I915_VBLANK_PIPE_ALL	(DRM_I915_VBLANK_PIPE_A | \
 					 DRM_I915_VBLANK_PIPE_B)
 
@@ -154,7 +148,7 @@
 	low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
 
 	if (!i915_pipe_enabled(dev, pipe)) {
-		DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
+		DRM_DEBUG("trying to get vblank count for disabled pipe %d\n", pipe);
 		return 0;
 	}
 
@@ -183,7 +177,7 @@
 	int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45;
 
 	if (!i915_pipe_enabled(dev, pipe)) {
-		DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
+		DRM_DEBUG("trying to get vblank count for disabled pipe %d\n", pipe);
 		return 0;
 	}
 
@@ -200,12 +194,10 @@
 	u32 vblank_enable;
 	int irq_received;
 
-	atomic_inc(&dev_priv->irq_received);
-
 	iir = I915_READ(IIR);
 
 	if (IS_I965G(dev)) {
-		vblank_status = I915_START_VBLANK_INTERRUPT_STATUS;
+		vblank_status = PIPE_START_VBLANK_INTERRUPT_STATUS;
 		vblank_enable = PIPE_START_VBLANK_INTERRUPT_ENABLE;
 	} else {
 		vblank_status = I915_VBLANK_INTERRUPT_STATUS;
@@ -305,9 +297,12 @@
 {
 	drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
 
+	if (dev->irq_enabled == 0)
+		return;
+
 	DRM_DEBUG("\n");
 	DRM_SPINLOCK(&dev_priv->user_irq_lock);
-	if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1))
+	if (++dev_priv->user_irq_refcount == 1)
 		i915_enable_irq(dev_priv, I915_USER_INTERRUPT);
 	DRM_SPINUNLOCK(&dev_priv->user_irq_lock);
 }
@@ -316,12 +311,13 @@
 {
 	drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
 
+	if (dev->irq_enabled == 0)
+		return;
+
 	DRM_SPINLOCK(&dev_priv->user_irq_lock);
-	if (dev->irq_enabled) {
-		KASSERT(dev_priv->user_irq_refcount > 0, ("invalid refcount"));
-		if (--dev_priv->user_irq_refcount == 0)
-			i915_disable_irq(dev_priv, I915_USER_INTERRUPT);
-	}
+	KASSERT(dev_priv->user_irq_refcount > 0, ("invalid refcount"));
+	if (--dev_priv->user_irq_refcount == 0)
+		i915_disable_irq(dev_priv, I915_USER_INTERRUPT);
 	DRM_SPINUNLOCK(&dev_priv->user_irq_lock);
 }
 
@@ -408,11 +404,8 @@
 int i915_enable_vblank(struct drm_device *dev, int pipe)
 {
 	drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
-	int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
-	u32 pipeconf;
 
-	pipeconf = I915_READ(pipeconf_reg);
-	if (!(pipeconf & PIPEACONF_ENABLE))
+	if (!i915_pipe_enabled(dev, pipe))
 		return -EINVAL;
 
 	DRM_SPINLOCK(&dev_priv->user_irq_lock);
@@ -500,8 +493,6 @@
 {

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906252050.n5PKoAMF088967>