Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Sep 2010 23:11:56 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r212279 - in user/nwhitehorn/ps3: amd64/include boot/i386/boot2 boot/i386/efi boot/i386/libi386 boot/i386/loader boot/i386/zfsloader boot/ofw/libofw boot/pc98/boot2 cam/ata cam/scsi cdd...
Message-ID:  <201009062311.o86NBu2l070299@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Mon Sep  6 23:11:56 2010
New Revision: 212279
URL: http://svn.freebsd.org/changeset/base/212279

Log:
  IFC @ r212278

Modified:
  user/nwhitehorn/ps3/amd64/include/cpufunc.h
  user/nwhitehorn/ps3/boot/i386/boot2/Makefile
  user/nwhitehorn/ps3/boot/i386/efi/Makefile
  user/nwhitehorn/ps3/boot/i386/libi386/pxe.c
  user/nwhitehorn/ps3/boot/i386/loader/Makefile
  user/nwhitehorn/ps3/boot/i386/zfsloader/Makefile
  user/nwhitehorn/ps3/boot/ofw/libofw/ofw_copy.c
  user/nwhitehorn/ps3/boot/pc98/boot2/Makefile
  user/nwhitehorn/ps3/boot/pc98/boot2/boot2.c
  user/nwhitehorn/ps3/cam/ata/ata_da.c
  user/nwhitehorn/ps3/cam/scsi/scsi_da.c
  user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
  user/nwhitehorn/ps3/cddl/dev/dtrace/dtrace_load.c
  user/nwhitehorn/ps3/dev/acpi_support/acpi_hp.c
  user/nwhitehorn/ps3/dev/acpica/acpi.c
  user/nwhitehorn/ps3/dev/acpica/acpi_hpet.c
  user/nwhitehorn/ps3/dev/ata/ata-all.h
  user/nwhitehorn/ps3/dev/ata/ata-lowlevel.c
  user/nwhitehorn/ps3/dev/ata/chipsets/ata-ahci.c
  user/nwhitehorn/ps3/dev/ata/chipsets/ata-siliconimage.c
  user/nwhitehorn/ps3/dev/bge/if_bge.c
  user/nwhitehorn/ps3/dev/bge/if_bgereg.h
  user/nwhitehorn/ps3/dev/fb/vesa.c
  user/nwhitehorn/ps3/dev/hwpmc/hwpmc_core.c
  user/nwhitehorn/ps3/dev/if_ndis/if_ndis_usb.c
  user/nwhitehorn/ps3/dev/iscsi/initiator/iscsi.c
  user/nwhitehorn/ps3/dev/iscsi/initiator/iscsivar.h
  user/nwhitehorn/ps3/dev/powermac_nvram/powermac_nvram.c
  user/nwhitehorn/ps3/dev/powermac_nvram/powermac_nvramvar.h
  user/nwhitehorn/ps3/dev/sis/if_sis.c
  user/nwhitehorn/ps3/dev/sis/if_sisreg.h
  user/nwhitehorn/ps3/dev/twa/tw_osl_freebsd.c
  user/nwhitehorn/ps3/dev/usb/controller/ehci.c
  user/nwhitehorn/ps3/dev/usb/controller/ohci.c
  user/nwhitehorn/ps3/dev/usb/controller/uhci.c
  user/nwhitehorn/ps3/dev/usb/input/atp.c
  user/nwhitehorn/ps3/dev/usb/input/uep.c
  user/nwhitehorn/ps3/dev/usb/input/uhid.c
  user/nwhitehorn/ps3/dev/usb/input/ukbd.c
  user/nwhitehorn/ps3/dev/usb/input/ums.c
  user/nwhitehorn/ps3/dev/usb/misc/udbp.c
  user/nwhitehorn/ps3/dev/usb/misc/ufm.c
  user/nwhitehorn/ps3/dev/usb/net/if_aue.c
  user/nwhitehorn/ps3/dev/usb/net/if_axe.c
  user/nwhitehorn/ps3/dev/usb/net/if_axereg.h
  user/nwhitehorn/ps3/dev/usb/net/if_cdce.c
  user/nwhitehorn/ps3/dev/usb/net/if_cue.c
  user/nwhitehorn/ps3/dev/usb/net/if_kue.c
  user/nwhitehorn/ps3/dev/usb/net/if_rue.c
  user/nwhitehorn/ps3/dev/usb/net/if_udav.c
  user/nwhitehorn/ps3/dev/usb/net/uhso.c
  user/nwhitehorn/ps3/dev/usb/serial/u3g.c
  user/nwhitehorn/ps3/dev/usb/serial/uark.c
  user/nwhitehorn/ps3/dev/usb/serial/ubsa.c
  user/nwhitehorn/ps3/dev/usb/serial/ubser.c
  user/nwhitehorn/ps3/dev/usb/serial/uchcom.c
  user/nwhitehorn/ps3/dev/usb/serial/ucycom.c
  user/nwhitehorn/ps3/dev/usb/serial/ufoma.c
  user/nwhitehorn/ps3/dev/usb/serial/uftdi.c
  user/nwhitehorn/ps3/dev/usb/serial/ugensa.c
  user/nwhitehorn/ps3/dev/usb/serial/uipaq.c
  user/nwhitehorn/ps3/dev/usb/serial/ulpt.c
  user/nwhitehorn/ps3/dev/usb/serial/umct.c
  user/nwhitehorn/ps3/dev/usb/serial/umoscom.c
  user/nwhitehorn/ps3/dev/usb/serial/uvisor.c
  user/nwhitehorn/ps3/dev/usb/storage/umass.c
  user/nwhitehorn/ps3/dev/usb/storage/urio.c
  user/nwhitehorn/ps3/dev/usb/usb_compat_linux.c
  user/nwhitehorn/ps3/dev/usb/usb_controller.h
  user/nwhitehorn/ps3/dev/usb/usb_device.c
  user/nwhitehorn/ps3/dev/usb/usb_generic.c
  user/nwhitehorn/ps3/dev/usb/usb_hub.c
  user/nwhitehorn/ps3/dev/usb/usb_transfer.c
  user/nwhitehorn/ps3/dev/usb/usb_transfer.h
  user/nwhitehorn/ps3/dev/usb/usbdi.h
  user/nwhitehorn/ps3/dev/usb/usbdi_util.h
  user/nwhitehorn/ps3/dev/usb/wlan/if_rum.c
  user/nwhitehorn/ps3/dev/usb/wlan/if_run.c
  user/nwhitehorn/ps3/dev/usb/wlan/if_uath.c
  user/nwhitehorn/ps3/dev/usb/wlan/if_upgt.c
  user/nwhitehorn/ps3/dev/usb/wlan/if_ural.c
  user/nwhitehorn/ps3/dev/usb/wlan/if_urtw.c
  user/nwhitehorn/ps3/dev/usb/wlan/if_zyd.c
  user/nwhitehorn/ps3/fs/ext2fs/ext2_alloc.c
  user/nwhitehorn/ps3/fs/nfsclient/nfs_clbio.c
  user/nwhitehorn/ps3/fs/nfsclient/nfs_clvnops.c
  user/nwhitehorn/ps3/fs/unionfs/union_vfsops.c
  user/nwhitehorn/ps3/geom/geom_io.c
  user/nwhitehorn/ps3/geom/sched/subr_disk.c
  user/nwhitehorn/ps3/i386/include/cpufunc.h
  user/nwhitehorn/ps3/kern/kern_et.c
  user/nwhitehorn/ps3/kern/kern_malloc.c
  user/nwhitehorn/ps3/kern/kern_rmlock.c
  user/nwhitehorn/ps3/kern/kern_sig.c
  user/nwhitehorn/ps3/kern/sched_ule.c
  user/nwhitehorn/ps3/kern/subr_bus.c
  user/nwhitehorn/ps3/kern/subr_disk.c
  user/nwhitehorn/ps3/kern/subr_sbuf.c
  user/nwhitehorn/ps3/kern/uipc_syscalls.c
  user/nwhitehorn/ps3/kern/vfs_subr.c
  user/nwhitehorn/ps3/mips/rmi/intr_machdep.c
  user/nwhitehorn/ps3/mips/rmi/iodi.c
  user/nwhitehorn/ps3/mips/rmi/pic.h
  user/nwhitehorn/ps3/mips/rmi/xlr_machdep.c
  user/nwhitehorn/ps3/mips/rmi/xlr_pci.c
  user/nwhitehorn/ps3/net/if_epair.c
  user/nwhitehorn/ps3/net/if_lagg.c
  user/nwhitehorn/ps3/netinet/in.c
  user/nwhitehorn/ps3/netinet/ip_carp.c
  user/nwhitehorn/ps3/netinet/ip_input.c
  user/nwhitehorn/ps3/netinet/ip_var.h
  user/nwhitehorn/ps3/netinet/ipfw/ip_fw_nat.c
  user/nwhitehorn/ps3/netinet/sctp_input.c
  user/nwhitehorn/ps3/netinet/sctp_output.c
  user/nwhitehorn/ps3/netinet/sctp_pcb.c
  user/nwhitehorn/ps3/netinet/sctp_timer.c
  user/nwhitehorn/ps3/netinet/sctp_uio.h
  user/nwhitehorn/ps3/netinet/sctputil.c
  user/nwhitehorn/ps3/netinet6/ip6_input.c
  user/nwhitehorn/ps3/netinet6/ip6_var.h
  user/nwhitehorn/ps3/nfsclient/nfs_diskless.c
  user/nwhitehorn/ps3/powerpc/aim/mmu_oea.c
  user/nwhitehorn/ps3/powerpc/aim/nexus.c
  user/nwhitehorn/ps3/powerpc/conf/GENERIC64
  user/nwhitehorn/ps3/powerpc/include/param.h
  user/nwhitehorn/ps3/powerpc/powerpc/mp_machdep.c
  user/nwhitehorn/ps3/sparc64/conf/GENERIC
  user/nwhitehorn/ps3/sys/_rmlock.h
  user/nwhitehorn/ps3/sys/bio.h
  user/nwhitehorn/ps3/sys/bus.h
  user/nwhitehorn/ps3/sys/copyright.h
  user/nwhitehorn/ps3/sys/rmlock.h
  user/nwhitehorn/ps3/vm/memguard.c
  user/nwhitehorn/ps3/vm/memguard.h
  user/nwhitehorn/ps3/vm/vm_page.c
Directory Properties:
  user/nwhitehorn/ps3/   (props changed)
  user/nwhitehorn/ps3/amd64/include/xen/   (props changed)
  user/nwhitehorn/ps3/boot/powerpc/ps3/   (props changed)
  user/nwhitehorn/ps3/cddl/contrib/opensolaris/   (props changed)
  user/nwhitehorn/ps3/contrib/dev/acpica/   (props changed)
  user/nwhitehorn/ps3/contrib/pf/   (props changed)
  user/nwhitehorn/ps3/contrib/x86emu/   (props changed)
  user/nwhitehorn/ps3/dev/xen/xenpci/   (props changed)
  user/nwhitehorn/ps3/powerpc/ps3/   (props changed)

Modified: user/nwhitehorn/ps3/amd64/include/cpufunc.h
==============================================================================
--- user/nwhitehorn/ps3/amd64/include/cpufunc.h	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/amd64/include/cpufunc.h	Mon Sep  6 23:11:56 2010	(r212279)
@@ -421,40 +421,40 @@ invlpg(u_long addr)
 	__asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory");
 }
 
-static __inline u_int
+static __inline u_short
 rfs(void)
 {
-	u_int sel;
-	__asm __volatile("mov %%fs,%0" : "=rm" (sel));
+	u_short sel;
+	__asm __volatile("movw %%fs,%0" : "=rm" (sel));
 	return (sel);
 }
 
-static __inline u_int
+static __inline u_short
 rgs(void)
 {
-	u_int sel;
-	__asm __volatile("mov %%gs,%0" : "=rm" (sel));
+	u_short sel;
+	__asm __volatile("movw %%gs,%0" : "=rm" (sel));
 	return (sel);
 }
 
-static __inline u_int
+static __inline u_short
 rss(void)
 {
-	u_int sel;
-	__asm __volatile("mov %%ss,%0" : "=rm" (sel));
+	u_short sel;
+	__asm __volatile("movw %%ss,%0" : "=rm" (sel));
 	return (sel);
 }
 
 static __inline void
-load_ds(u_int sel)
+load_ds(u_short sel)
 {
-	__asm __volatile("mov %0,%%ds" : : "rm" (sel));
+	__asm __volatile("movw %0,%%ds" : : "rm" (sel));
 }
 
 static __inline void
-load_es(u_int sel)
+load_es(u_short sel)
 {
-	__asm __volatile("mov %0,%%es" : : "rm" (sel));
+	__asm __volatile("movw %0,%%es" : : "rm" (sel));
 }
 
 static __inline void
@@ -476,10 +476,10 @@ cpu_mwait(int extensions, int hints)
 #define	MSR_FSBASE	0xc0000100
 #endif
 static __inline void
-load_fs(u_int sel)
+load_fs(u_short sel)
 {
 	/* Preserve the fsbase value across the selector load */
-	__asm __volatile("rdmsr; mov %0,%%fs; wrmsr"
+	__asm __volatile("rdmsr; movw %0,%%fs; wrmsr"
 	    : : "rm" (sel), "c" (MSR_FSBASE) : "eax", "edx");
 }
 
@@ -487,28 +487,28 @@ load_fs(u_int sel)
 #define	MSR_GSBASE	0xc0000101
 #endif
 static __inline void
-load_gs(u_int sel)
+load_gs(u_short sel)
 {
 	/*
 	 * Preserve the gsbase value across the selector load.
 	 * Note that we have to disable interrupts because the gsbase
 	 * being trashed happens to be the kernel gsbase at the time.
 	 */
-	__asm __volatile("pushfq; cli; rdmsr; mov %0,%%gs; wrmsr; popfq"
+	__asm __volatile("pushfq; cli; rdmsr; movw %0,%%gs; wrmsr; popfq"
 	    : : "rm" (sel), "c" (MSR_GSBASE) : "eax", "edx");
 }
 #else
 /* Usable by userland */
 static __inline void
-load_fs(u_int sel)
+load_fs(u_short sel)
 {
-	__asm __volatile("mov %0,%%fs" : : "rm" (sel));
+	__asm __volatile("movw %0,%%fs" : : "rm" (sel));
 }
 
 static __inline void
-load_gs(u_int sel)
+load_gs(u_short sel)
 {
-	__asm __volatile("mov %0,%%gs" : : "rm" (sel));
+	__asm __volatile("movw %0,%%gs" : : "rm" (sel));
 }
 #endif
 
@@ -692,8 +692,8 @@ void	load_dr4(u_int64_t dr4);
 void	load_dr5(u_int64_t dr5);
 void	load_dr6(u_int64_t dr6);
 void	load_dr7(u_int64_t dr7);
-void	load_fs(u_int sel);
-void	load_gs(u_int sel);
+void	load_fs(u_short sel);
+void	load_gs(u_short sel);
 void	ltr(u_short sel);
 void	outb(u_int port, u_char data);
 void	outl(u_int port, u_int data);

Modified: user/nwhitehorn/ps3/boot/i386/boot2/Makefile
==============================================================================
--- user/nwhitehorn/ps3/boot/i386/boot2/Makefile	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/i386/boot2/Makefile	Mon Sep  6 23:11:56 2010	(r212279)
@@ -3,7 +3,9 @@
 .include <bsd.own.mk>
 
 # XXX: clang can compile the boot code just fine, but boot2 gets too big
-CC:=${CC:C/^cc|^clang/gcc/}
+.if ${CC:T:Mclang} == "clang"
+CC=gcc
+.endif
 
 FILES=		boot boot1 boot2
 

Modified: user/nwhitehorn/ps3/boot/i386/efi/Makefile
==============================================================================
--- user/nwhitehorn/ps3/boot/i386/efi/Makefile	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/i386/efi/Makefile	Mon Sep  6 23:11:56 2010	(r212279)
@@ -42,7 +42,7 @@ ${PROG}:	${LDSCRIPT}
 
 CLEANFILES=	vers.c loader.efi
 
-NEWVERSWHAT=	"EFI loader" ${MACHINE_ARCH}
+NEWVERSWHAT=	"EFI loader" x86
 
 vers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
 	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}

Modified: user/nwhitehorn/ps3/boot/i386/libi386/pxe.c
==============================================================================
--- user/nwhitehorn/ps3/boot/i386/libi386/pxe.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/i386/libi386/pxe.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -409,6 +409,7 @@ pxe_perror(int err)
  * Reach inside the libstand NFS code and dig out an NFS handle
  * for the root filesystem.
  */
+#ifdef OLD_NFSV2
 struct nfs_iodesc {
 	struct	iodesc	*iodesc;
 	off_t	off;
@@ -456,6 +457,64 @@ pxe_setnfshandle(char *rootpath)
 	sprintf(cp, "X");
 	setenv("boot.nfsroot.nfshandle", buf, 1);
 }
+#else	/* !OLD_NFSV2 */
+
+#define	NFS_V3MAXFHSIZE		64
+
+struct nfs_iodesc {
+	struct iodesc *iodesc;
+	off_t off;
+	uint32_t fhsize;
+	u_char fh[NFS_V3MAXFHSIZE];
+	/* structure truncated */
+};
+extern struct nfs_iodesc nfs_root_node;
+extern int rpc_port;
+
+static void
+pxe_rpcmountcall()
+{
+	struct iodesc *d;
+	int error;
+
+	if (!(d = socktodesc(pxe_sock)))
+		return;
+        d->myport = htons(--rpc_port);
+        d->destip = rootip;
+	if ((error = nfs_getrootfh(d, rootpath, &nfs_root_node.fhsize,
+	    nfs_root_node.fh)) != 0) {
+		printf("NFS MOUNT RPC error: %d\n", error);
+		nfs_root_node.fhsize = 0;
+	}
+	nfs_root_node.iodesc = d;
+}
+
+static void
+pxe_setnfshandle(char *rootpath)
+{
+	int i;
+	u_char *fh;
+	char buf[2 * NFS_V3MAXFHSIZE + 3], *cp;
+
+	/*
+	 * If NFS files were never opened, we need to do mount call
+	 * ourselves. Use nfs_root_node.iodesc as flag indicating
+	 * previous NFS usage.
+	 */
+	if (nfs_root_node.iodesc == NULL)
+		pxe_rpcmountcall();
+
+	fh = &nfs_root_node.fh[0];
+	buf[0] = 'X';
+	cp = &buf[1];
+	for (i = 0; i < nfs_root_node.fhsize; i++, cp += 2)
+		sprintf(cp, "%02x", fh[i]);
+	sprintf(cp, "X");
+	setenv("boot.nfsroot.nfshandle", buf, 1);
+	sprintf(buf, "%d", nfs_root_node.fhsize);
+	setenv("boot.nfsroot.nfshandlelen", buf, 1);
+}
+#endif	/* OLD_NFSV2 */
 
 void
 pxenv_call(int func)

Modified: user/nwhitehorn/ps3/boot/i386/loader/Makefile
==============================================================================
--- user/nwhitehorn/ps3/boot/i386/loader/Makefile	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/i386/loader/Makefile	Mon Sep  6 23:11:56 2010	(r212279)
@@ -6,7 +6,7 @@ MK_SSP=		no
 LOADER?=	loader
 PROG=		${LOADER}.sym
 INTERNALPROG=
-NEWVERSWHAT?=	"bootstrap loader" i386
+NEWVERSWHAT?=	"bootstrap loader" x86
 
 # architecture-specific loader code
 SRCS=		main.c conf.c vers.c

Modified: user/nwhitehorn/ps3/boot/i386/zfsloader/Makefile
==============================================================================
--- user/nwhitehorn/ps3/boot/i386/zfsloader/Makefile	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/i386/zfsloader/Makefile	Mon Sep  6 23:11:56 2010	(r212279)
@@ -3,7 +3,7 @@
 .PATH:	${.CURDIR}/../loader
 
 LOADER=		zfsloader
-NEWVERSWHAT=	"ZFS enabled bootstrap loader" i386
+NEWVERSWHAT=	"ZFS enabled bootstrap loader" x86
 LOADER_ZFS_SUPPORT=yes
 LOADER_ONLY=	yes
 NO_MAN=		yes

Modified: user/nwhitehorn/ps3/boot/ofw/libofw/ofw_copy.c
==============================================================================
--- user/nwhitehorn/ps3/boot/ofw/libofw/ofw_copy.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/ofw/libofw/ofw_copy.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -68,7 +68,7 @@ ofw_mapmem(vm_offset_t dest, const size_
 	/*
 	 * Trim area covered by existing mapping, if any
 	 */
-	if (dest < (last_dest + last_len)) {
+	if (dest < (last_dest + last_len) && dest >= last_dest) {
 		nlen -= (last_dest + last_len) - dest;
 		dest = last_dest + last_len;
 	}

Modified: user/nwhitehorn/ps3/boot/pc98/boot2/Makefile
==============================================================================
--- user/nwhitehorn/ps3/boot/pc98/boot2/Makefile	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/pc98/boot2/Makefile	Mon Sep  6 23:11:56 2010	(r212279)
@@ -1,5 +1,12 @@
 # $FreeBSD$
 
+.include <bsd.own.mk>
+
+# XXX: clang can compile the boot code just fine, but boot2 gets too big
+.if ${CC:T:Mclang} == "clang"
+CC=gcc
+.endif
+
 FILES=		boot boot1 boot2
 
 NM?=		nm

Modified: user/nwhitehorn/ps3/boot/pc98/boot2/boot2.c
==============================================================================
--- user/nwhitehorn/ps3/boot/pc98/boot2/boot2.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/boot/pc98/boot2/boot2.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -187,9 +187,8 @@ xfsread(ino_t inode, void *buf, size_t n
 static inline uint32_t
 memsize(void)
 {
-    u_char *p = (u_char *)PTOV(0);
-
-    return *(p + 0x401) * 128 * 1024 + *(u_int16_t *)(p + 0x594) * 1024 * 1024;
+    return (*(u_char *)PTOV(0x401) * 128 * 1024 +
+	*(uint16_t *)PTOV(0x594) * 1024 * 1024);
 }
 
 static inline void

Modified: user/nwhitehorn/ps3/cam/ata/ata_da.c
==============================================================================
--- user/nwhitehorn/ps3/cam/ata/ata_da.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/cam/ata/ata_da.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -874,7 +874,8 @@ adastart(struct cam_periph *periph, unio
 		}
 		bioq_remove(&softc->bio_queue, bp);
 
-		if ((softc->flags & ADA_FLAG_NEED_OTAG) != 0) {
+		if ((bp->bio_flags & BIO_ORDERED) != 0
+		 || (softc->flags & ADA_FLAG_NEED_OTAG) != 0) {
 			softc->flags &= ~ADA_FLAG_NEED_OTAG;
 			softc->ordered_tag_count++;
 			tag_code = 0;

Modified: user/nwhitehorn/ps3/cam/scsi/scsi_da.c
==============================================================================
--- user/nwhitehorn/ps3/cam/scsi/scsi_da.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/cam/scsi/scsi_da.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -1354,7 +1354,8 @@ dastart(struct cam_periph *periph, union
 
 			bioq_remove(&softc->bio_queue, bp);
 
-			if ((softc->flags & DA_FLAG_NEED_OTAG) != 0) {
+			if ((bp->bio_flags & BIO_ORDERED) != 0
+			 || (softc->flags & DA_FLAG_NEED_OTAG) != 0) {
 				softc->flags &= ~DA_FLAG_NEED_OTAG;
 				softc->ordered_tag_count++;
 				tag_code = MSG_ORDERED_Q_TAG;
@@ -1368,7 +1369,8 @@ dastart(struct cam_periph *periph, union
 						/*retries*/da_retry_count,
 						/*cbfcnp*/dadone,
 						/*tag_action*/tag_code,
-						/*read_op*/bp->bio_cmd == BIO_READ,
+						/*read_op*/bp->bio_cmd
+							== BIO_READ,
 						/*byte2*/0,
 						softc->minimum_cmd_size,
 						/*lba*/bp->bio_pblkno,
@@ -1377,17 +1379,24 @@ dastart(struct cam_periph *periph, union
 						/*data_ptr*/ bp->bio_data,
 						/*dxfer_len*/ bp->bio_bcount,
 						/*sense_len*/SSD_FULL_SIZE,
-						/*timeout*/da_default_timeout*1000);
+						da_default_timeout * 1000);
 				break;
 			case BIO_FLUSH:
+				/*
+				 * BIO_FLUSH doesn't currently communicate
+				 * range data, so we synchronize the cache
+				 * over the whole disk.  We also force
+				 * ordered tag semantics the flush applies
+				 * to all previously queued I/O.
+				 */
 				scsi_synchronize_cache(&start_ccb->csio,
 						       /*retries*/1,
 						       /*cbfcnp*/dadone,
-						       MSG_SIMPLE_Q_TAG,
-						       /*begin_lba*/0,/* Cover the whole disk */
+						       MSG_ORDERED_Q_TAG,
+						       /*begin_lba*/0,
 						       /*lb_count*/0,
 						       SSD_FULL_SIZE,
-						       /*timeout*/da_default_timeout*1000);
+						       da_default_timeout*1000);
 				break;
 			}
 			start_ccb->ccb_h.ccb_state = DA_CCB_BUFFER_IO;

Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==============================================================================
--- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -598,6 +598,7 @@ sendreq:
 		break;
 	case ZIO_TYPE_IOCTL:
 		bp->bio_cmd = BIO_FLUSH;
+		bp->bio_flags |= BIO_ORDERED;
 		bp->bio_data = NULL;
 		bp->bio_offset = cp->provider->mediasize;
 		bp->bio_length = 0;

Modified: user/nwhitehorn/ps3/cddl/dev/dtrace/dtrace_load.c
==============================================================================
--- user/nwhitehorn/ps3/cddl/dev/dtrace/dtrace_load.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/cddl/dev/dtrace/dtrace_load.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -163,7 +163,7 @@ dtrace_load(void *dummy)
 #else
 	dtrace_dev = make_dev(&dtrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
 	    "dtrace/dtrace");
-	helper_dev = make_dev(&helper_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+	helper_dev = make_dev(&helper_cdevsw, 0, UID_ROOT, GID_WHEEL, 0660,
 	    "dtrace/helper");
 #endif
 

Modified: user/nwhitehorn/ps3/dev/acpi_support/acpi_hp.c
==============================================================================
--- user/nwhitehorn/ps3/dev/acpi_support/acpi_hp.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/acpi_support/acpi_hp.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/uio.h>
 #include <sys/proc.h>
 #include <sys/kernel.h>
+#include <sys/limits.h>
 #include <sys/bus.h>
 #include <sys/sbuf.h>
 #include <sys/module.h>
@@ -116,7 +117,6 @@ struct acpi_hp_inst_seq_pair {
 
 struct acpi_hp_softc {
 	device_t	dev;
-	ACPI_HANDLE	handle;
 	device_t	wmi_dev;
 	int		has_notify;		/* notification GUID found */
 	int		has_cmi;		/* CMI GUID found */
@@ -289,6 +289,7 @@ static struct {
 
 ACPI_SERIAL_DECL(hp, "HP ACPI-WMI Mapping");
 
+static void	acpi_hp_identify(driver_t *driver, device_t parent);
 static int	acpi_hp_probe(device_t dev);
 static int	acpi_hp_attach(device_t dev);
 static int	acpi_hp_detach(device_t dev);
@@ -320,6 +321,7 @@ static struct cdevsw hpcmi_cdevsw = {
 };
 
 static device_method_t acpi_hp_methods[] = {
+	DEVMETHOD(device_identify, acpi_hp_identify),
 	DEVMETHOD(device_probe, acpi_hp_probe),
 	DEVMETHOD(device_attach, acpi_hp_attach),
 	DEVMETHOD(device_detach, acpi_hp_detach),
@@ -405,7 +407,7 @@ acpi_hp_evaluate_auto_on_off(struct acpi
 			    	    "WLAN on air changed to %i "
 			    	    "(new_wlan_status is %i)\n",
 			    	    sc->was_wlan_on_air, new_wlan_status);
-			acpi_UserNotify("HP", sc->handle,
+			acpi_UserNotify("HP", ACPI_ROOT_OBJECT,
 			    0xc0+sc->was_wlan_on_air);
 		}
 	}
@@ -420,7 +422,7 @@ acpi_hp_evaluate_auto_on_off(struct acpi
 				    " to %i (new_bluetooth_status is %i)\n",
 				    sc->was_bluetooth_on_air,
 				    new_bluetooth_status);
-			acpi_UserNotify("HP", sc->handle,
+			acpi_UserNotify("HP", ACPI_ROOT_OBJECT,
 			    0xd0+sc->was_bluetooth_on_air);
 		}
 	}
@@ -433,16 +435,43 @@ acpi_hp_evaluate_auto_on_off(struct acpi
 				    "WWAN on air changed to %i"
 			    	    " (new_wwan_status is %i)\n",
 				    sc->was_wwan_on_air, new_wwan_status);
-			acpi_UserNotify("HP", sc->handle,
+			acpi_UserNotify("HP", ACPI_ROOT_OBJECT,
 			    0xe0+sc->was_wwan_on_air);
 		}
 	}
 }
 
+static void
+acpi_hp_identify(driver_t *driver, device_t parent)
+{
+
+	/* Don't do anything if driver is disabled. */
+	if (acpi_disabled("hp"))
+		return;
+
+	/* Add only a single device instance. */
+	if (device_find_child(parent, "acpi_hp", -1) != NULL)
+		return;
+
+	/* Make sure acpi_wmi driver is present. */
+	if (devclass_find("acpi_wmi") == NULL)
+		return;
+
+	/*
+	 * Add our device with late order, so that it is hopefully
+	 * probed after acpi_wmi.
+	 * XXX User proper constant instead of UINT_MAX for order.
+	 */
+	if (BUS_ADD_CHILD(parent, UINT_MAX, "acpi_hp", -1) == NULL)
+		device_printf(parent, "add acpi_hp child failed\n");
+}
+
 static int
 acpi_hp_probe(device_t dev)
 {
-	if (acpi_disabled("hp") || device_get_unit(dev) != 0)
+
+	/* Skip auto-enumerated devices from ACPI namespace. */
+	if (acpi_get_handle(dev) != NULL)
 		return (ENXIO);
 	device_set_desc(dev, "HP ACPI-WMI Mapping");
 
@@ -460,7 +489,6 @@ acpi_hp_attach(device_t dev)
 
 	sc = device_get_softc(dev);
 	sc->dev = dev;
-	sc->handle = acpi_get_handle(dev);
 	sc->has_notify = 0;
 	sc->has_cmi = 0;
 	sc->bluetooth_enable_if_radio_on = 0;
@@ -477,7 +505,7 @@ acpi_hp_attach(device_t dev)
 	sc->verbose = 0;
 	memset(sc->cmi_order, 0, sizeof(sc->cmi_order));
 
-	if (!(wmi_devclass = devclass_find ("acpi_wmi"))) {
+	if (!(wmi_devclass = devclass_find("acpi_wmi"))) {
 		device_printf(dev, "Couldn't find acpi_wmi devclass\n");
 		return (EINVAL);
 	}

Modified: user/nwhitehorn/ps3/dev/acpica/acpi.c
==============================================================================
--- user/nwhitehorn/ps3/dev/acpica/acpi.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/acpica/acpi.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -1690,10 +1690,10 @@ acpi_probe_order(ACPI_HANDLE handle, int
     ACPI_OBJECT_TYPE type;
 
     /*
-     * 1. I/O port and memory system resource holders
-     * 2. Embedded controllers (to handle early accesses)
-     * 3. PCI Link Devices
-     * 100000. CPUs
+     * 1. CPUs
+     * 2. I/O port and memory system resource holders
+     * 3. Embedded controllers (to handle early accesses)
+     * 4. PCI Link Devices
      */
     AcpiGetType(handle, &type);
     if (type == ACPI_TYPE_PROCESSOR)
@@ -1753,8 +1753,7 @@ acpi_probe_child(ACPI_HANDLE handle, UIN
 	     * placeholder so that the probe/attach passes will run
 	     * breadth-first.  Orders less than ACPI_DEV_BASE_ORDER
 	     * are reserved for special objects (i.e., system
-	     * resources).  CPU devices have a very high order to
-	     * ensure they are probed after other devices.
+	     * resources).
 	     */
 	    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "scanning '%s'\n", handle_str));
 	    order = level * 10 + 100;

Modified: user/nwhitehorn/ps3/dev/acpica/acpi_hpet.c
==============================================================================
--- user/nwhitehorn/ps3/dev/acpica/acpi_hpet.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/acpica/acpi_hpet.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -74,6 +74,7 @@ struct hpet_softc {
 	int			irq;
 	int			useirq;
 	int			legacy_route;
+	uint32_t		allowed_irqs;
 	struct resource		*mem_res;
 	struct resource		*intr_res;
 	void			*intr_handle;
@@ -146,7 +147,7 @@ hpet_start(struct eventtimer *et,
 	struct hpet_timer *mt = (struct hpet_timer *)et->et_priv;
 	struct hpet_timer *t;
 	struct hpet_softc *sc = mt->sc;
-	uint32_t fdiv;
+	uint32_t fdiv, cmp;
 
 	t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
 	if (period != NULL) {
@@ -164,23 +165,31 @@ hpet_start(struct eventtimer *et,
 			fdiv += sc->freq * first->sec;
 	} else
 		fdiv = t->div;
+	if (t->irq < 0)
+		bus_write_4(sc->mem_res, HPET_ISR, 1 << t->num);
+	t->caps |= HPET_TCNF_INT_ENB;
 	t->last = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
+restart:
+	cmp = t->last + fdiv;
 	if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) {
 		t->caps |= HPET_TCNF_TYPE;
 		bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num),
 		    t->caps | HPET_TCNF_VAL_SET);
-		bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num),
-		    t->last + fdiv);
-		bus_read_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num));
-		bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num),
-		    t->div);
+		bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num), cmp);
+		bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num), t->div);
 	} else {
-		bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num),
-		    t->last + fdiv);
+		t->caps &= ~HPET_TCNF_TYPE;
+		bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num), t->caps);
+		bus_write_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num), cmp);
+	}
+	if (fdiv < 5000) {
+		bus_read_4(sc->mem_res, HPET_TIMER_COMPARATOR(t->num));
+		t->last = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
+		if ((int32_t)(t->last - cmp) < 0) {
+			fdiv *= 2;
+			goto restart;
+		}
 	}
-	t->caps |= HPET_TCNF_INT_ENB;
-	bus_write_4(sc->mem_res, HPET_ISR, 1 << t->num);
-	bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(t->num), t->caps);
 	return (0);
 }
 
@@ -321,7 +330,7 @@ hpet_attach(device_t dev)
 	int i, j, num_msi, num_timers, num_percpu_et, num_percpu_t, cur_cpu;
 	int pcpu_master;
 	static int maxhpetet = 0;
-	uint32_t val, val2, cvectors;
+	uint32_t val, val2, cvectors, dvectors;
 	uint16_t vendor, rev;
 
 	ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__);
@@ -438,10 +447,9 @@ hpet_attach(device_t dev)
 		sc->t[1].vectors = 0;
 	}
 
-	num_msi = 0;
-	sc->useirq = 0;
-	/* Find common legacy IRQ vectors for all timers. */
-	cvectors = 0xffff0000;
+	/* Check what IRQs we want use. */
+	/* By default allow any PCI IRQs. */
+	sc->allowed_irqs = 0xffff0000;
 	/*
 	 * HPETs in AMD chipsets before SB800 have problems with IRQs >= 16
 	 * Lower are also not always working for different reasons.
@@ -450,7 +458,25 @@ hpet_attach(device_t dev)
 	 * interrupt loss. Avoid legacy IRQs for AMD.
 	 */
 	if (vendor == HPET_VENDID_AMD)
-		cvectors = 0x00000000;
+		sc->allowed_irqs = 0x00000000;
+	/*
+	 * Neither QEMU nor VirtualBox report supported IRQs correctly.
+	 * The only way to use HPET there is to specify IRQs manually
+	 * and/or use legacy_route. Legacy_route mode work on both.
+	 */
+	if (vm_guest)
+		sc->allowed_irqs = 0x00000000;
+	/* Let user override. */
+	resource_int_value(device_get_name(dev), device_get_unit(dev),
+	     "allowed_irqs", &sc->allowed_irqs);
+
+	num_msi = 0;
+	sc->useirq = 0;
+	/* Find IRQ vectors for all timers. */
+	cvectors = sc->allowed_irqs & 0xffff0000;
+	dvectors = sc->allowed_irqs & 0x0000ffff;
+	if (sc->legacy_route)
+		dvectors &= 0x0000fefe;
 	for (i = 0; i < num_timers; i++) {
 		t = &sc->t[i];
 		if (sc->legacy_route && i < 2)
@@ -465,6 +491,10 @@ hpet_attach(device_t dev)
 			}
 		}
 #endif
+		else if (dvectors & t->vectors) {
+			t->irq = ffs(dvectors & t->vectors) - 1;
+			dvectors &= ~(1 << t->irq);
+		}
 		if (t->irq >= 0) {
 			if (!(t->intr_res =
 			    bus_alloc_resource(dev, SYS_RES_IRQ, &t->intr_rid,
@@ -495,7 +525,7 @@ hpet_attach(device_t dev)
 	if (sc->legacy_route)
 		hpet_enable(sc);
 	/* Group timers for per-CPU operation. */
-	num_percpu_et = min(num_msi / mp_ncpus, 2);
+	num_percpu_et = min(num_msi / mp_ncpus, 1);
 	num_percpu_t = num_percpu_et * mp_ncpus;
 	pcpu_master = 0;
 	cur_cpu = CPU_FIRST();
@@ -510,7 +540,8 @@ hpet_attach(device_t dev)
 			bus_bind_intr(dev, t->intr_res, cur_cpu);
 			cur_cpu = CPU_NEXT(cur_cpu);
 			num_percpu_t--;
-		}
+		} else if (t->irq >= 0)
+			bus_bind_intr(dev, t->intr_res, CPU_FIRST());
 	}
 	bus_write_4(sc->mem_res, HPET_ISR, 0xffffffff);
 	sc->irq = -1;
@@ -545,7 +576,7 @@ hpet_attach(device_t dev)
 			/* Legacy route doesn't need more configuration. */
 		} else
 #ifdef DEV_APIC
-		if (t->irq >= 0) {
+		if ((t->caps & HPET_TCAP_FSB_INT_DEL) && t->irq >= 0) {
 			uint64_t addr;
 			uint32_t data;	
 			
@@ -561,7 +592,9 @@ hpet_attach(device_t dev)
 				t->irq = -2;
 		} else
 #endif
-		if (sc->irq >= 0 && (t->vectors & (1 << sc->irq)))
+		if (t->irq >= 0)
+			t->caps |= (t->irq << 9);
+		else if (sc->irq >= 0 && (t->vectors & (1 << sc->irq)))
 			t->caps |= (sc->irq << 9) | HPET_TCNF_INT_TYPE;
 		bus_write_4(sc->mem_res, HPET_TIMER_CAP_CNF(i), t->caps);
 		/* Skip event timers without set up IRQ. */
@@ -585,7 +618,7 @@ hpet_attach(device_t dev)
 			t->et.et_quality -= 10;
 		t->et.et_frequency = sc->freq;
 		t->et.et_min_period.sec = 0;
-		t->et.et_min_period.frac = 0x00004000LLU << 32;
+		t->et.et_min_period.frac = 0x00008000LLU << 32;
 		t->et.et_max_period.sec = 0xfffffffeLLU / sc->freq;
 		t->et.et_max_period.frac =
 		    ((0xfffffffeLLU << 32) / sc->freq) << 32;

Modified: user/nwhitehorn/ps3/dev/ata/ata-all.h
==============================================================================
--- user/nwhitehorn/ps3/dev/ata/ata-all.h	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/ata/ata-all.h	Mon Sep  6 23:11:56 2010	(r212279)
@@ -565,6 +565,7 @@ struct ata_channel {
 #define         ATA_NO_ATAPI_DMA	0x40
 #define         ATA_SATA		0x80
 #define         ATA_DMA_BEFORE_CMD	0x100
+#define         ATA_KNOWN_PRESENCE	0x200
 
     int				pm_level;	/* power management level */
     int                         devices;        /* what is present */

Modified: user/nwhitehorn/ps3/dev/ata/ata-lowlevel.c
==============================================================================
--- user/nwhitehorn/ps3/dev/ata/ata-lowlevel.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/ata/ata-lowlevel.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -474,7 +474,8 @@ ata_generic_reset(device_t dev)
     ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_MASTER));
     DELAY(10);
     ostat0 = ATA_IDX_INB(ch, ATA_STATUS);
-    if ((ostat0 & 0xf8) != 0xf8 && ostat0 != 0xa5) {
+    if (((ostat0 & 0xf8) != 0xf8 || (ch->flags & ATA_KNOWN_PRESENCE)) &&
+	    ostat0 != 0xa5) {
 	stat0 = ATA_S_BUSY;
 	mask |= 0x01;
     }
@@ -484,7 +485,8 @@ ata_generic_reset(device_t dev)
 	ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_SLAVE));
 	DELAY(10);      
 	ostat1 = ATA_IDX_INB(ch, ATA_STATUS);
-	if ((ostat1 & 0xf8) != 0xf8 && ostat1 != 0xa5) {
+	if (((ostat1 & 0xf8) != 0xf8 || (ch->flags & ATA_KNOWN_PRESENCE)) &&
+		ostat1 != 0xa5) {
 	    stat1 = ATA_S_BUSY;
 	    mask |= 0x02;
 	}
@@ -570,22 +572,16 @@ ata_generic_reset(device_t dev)
 	    }
 	}
 
-	if (mask == 0x00)       /* nothing to wait for */
-	    break;
-	if (mask == 0x01)       /* wait for master only */
-	    if (!(stat0 & ATA_S_BUSY) || (stat0 == 0xff && timeout > 10))
-		break;
-	if (mask == 0x02)       /* wait for slave only */
-	    if (!(stat1 & ATA_S_BUSY) || (stat1 == 0xff && timeout > 10))
-		break;
-	if (mask == 0x03) {     /* wait for both master & slave */
-	    if (!(stat0 & ATA_S_BUSY) && !(stat1 & ATA_S_BUSY))
-		break;
-	    if ((stat0 == 0xff) && (timeout > 20))
-		mask &= ~0x01;
-	    if ((stat1 == 0xff) && (timeout > 20))
-		mask &= ~0x02;
+	if ((ch->flags & ATA_KNOWN_PRESENCE) == 0 &&
+	    timeout > ((mask == 0x03) ? 20 : 10)) {
+		if ((mask & 0x01) && stat0 == 0xff)
+			mask &= ~0x01;
+		if ((mask & 0x02) && stat1 == 0xff)
+			mask &= ~0x02;
 	}
+	if (((mask & 0x01) == 0 || !(stat0 & ATA_S_BUSY)) &&
+	    ((mask & 0x02) == 0 || !(stat1 & ATA_S_BUSY)))
+		break;
 	ata_udelay(100000);
     }
 

Modified: user/nwhitehorn/ps3/dev/ata/chipsets/ata-ahci.c
==============================================================================
--- user/nwhitehorn/ps3/dev/ata/chipsets/ata-ahci.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/ata/chipsets/ata-ahci.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -815,7 +815,7 @@ ata_ahci_hardreset(device_t dev, int por
     if (!ata_sata_phy_reset(dev, port, 0))
 	return (ENOENT);
     /* Wait for clearing busy status. */
-    if (ata_ahci_wait_ready(dev, 10000)) {
+    if (ata_ahci_wait_ready(dev, 15000)) {
 	device_printf(dev, "hardware reset timeout\n");
 	return (EBUSY);
     }

Modified: user/nwhitehorn/ps3/dev/ata/chipsets/ata-siliconimage.c
==============================================================================
--- user/nwhitehorn/ps3/dev/ata/chipsets/ata-siliconimage.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/ata/chipsets/ata-siliconimage.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -316,6 +316,7 @@ ata_sii_ch_attach(device_t dev)
 	ch->r_io[ATA_SCONTROL].offset = 0x100 + (unit01 << 7) + (unit10 << 8);
 	ch->flags |= ATA_NO_SLAVE;
 	ch->flags |= ATA_SATA;
+	ch->flags |= ATA_KNOWN_PRESENCE;
 
 	/* enable PHY state change interrupt */
 	ATA_OUTL(ctlr->r_res2, 0x148 + (unit01 << 7) + (unit10 << 8),(1 << 16));
@@ -364,7 +365,15 @@ ata_sii_status(device_t dev)
 static void
 ata_sii_reset(device_t dev)
 {
+    struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
+    int offset = ((ch->unit & 1) << 7) + ((ch->unit & 2) << 8);
+    uint32_t val;
+
+    /* Apply R_ERR on DMA activate FIS errata workaround. */
+    val = ATA_INL(ctlr->r_res2, 0x14c + offset);
+    if ((val & 0x3) == 0x1)
+	ATA_OUTL(ctlr->r_res2, 0x14c + offset, val & ~0x3);
 
     if (ata_sata_phy_reset(dev, -1, 1))
 	ata_generic_reset(dev);

Modified: user/nwhitehorn/ps3/dev/bge/if_bge.c
==============================================================================
--- user/nwhitehorn/ps3/dev/bge/if_bge.c	Mon Sep  6 23:07:58 2010	(r212278)
+++ user/nwhitehorn/ps3/dev/bge/if_bge.c	Mon Sep  6 23:11:56 2010	(r212279)
@@ -355,8 +355,10 @@ static int bge_suspend(device_t);
 static int bge_resume(device_t);
 static void bge_release_resources(struct bge_softc *);
 static void bge_dma_map_addr(void *, bus_dma_segment_t *, int, int);
-static int bge_dma_alloc(device_t);
+static int bge_dma_alloc(struct bge_softc *);
 static void bge_dma_free(struct bge_softc *);
+static int bge_dma_ring_alloc(struct bge_softc *, bus_size_t, bus_size_t,
+    bus_dma_tag_t *, uint8_t **, bus_dmamap_t *, bus_addr_t *, const char *);
 
 static int bge_get_eaddr_fw(struct bge_softc *sc, uint8_t ether_addr[]);
 static int bge_get_eaddr_mem(struct bge_softc *, uint8_t[]);
@@ -614,13 +616,9 @@ bge_dma_map_addr(void *arg, bus_dma_segm
 	if (error)
 		return;
 
-	ctx = arg;
-
-	if (nseg > ctx->bge_maxsegs) {
-		ctx->bge_maxsegs = 0;
-		return;
-	}
+	KASSERT(nseg == 1, ("%s: %d segments returned!", __func__, nseg));
 
+	ctx = arg;
 	ctx->bge_busaddr = segs->ds_addr;
 }
 
@@ -2122,27 +2120,84 @@ bge_dma_free(struct bge_softc *sc)
 	if (sc->bge_cdata.bge_stats_tag)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_stats_tag);
 
+	if (sc->bge_cdata.bge_buffer_tag)
+		bus_dma_tag_destroy(sc->bge_cdata.bge_buffer_tag);
+
 	/* Destroy the parent tag. */
 	if (sc->bge_cdata.bge_parent_tag)
 		bus_dma_tag_destroy(sc->bge_cdata.bge_parent_tag);
 }
 
 static int
-bge_dma_alloc(device_t dev)
+bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t alignment,
+    bus_size_t maxsize, bus_dma_tag_t *tag, uint8_t **ring, bus_dmamap_t *map,
+    bus_addr_t *paddr, const char *msg)
 {
 	struct bge_dmamap_arg ctx;
-	struct bge_softc *sc;
 	bus_addr_t lowaddr;
-	bus_size_t sbsz, txsegsz, txmaxsegsz;
-	int i, error;
+	bus_size_t ring_end;
+	int error;
 
-	sc = device_get_softc(dev);
+	lowaddr = BUS_SPACE_MAXADDR;
+again:
+	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
+	    alignment, 0, lowaddr, BUS_SPACE_MAXADDR, NULL,
+	    NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag);
+	if (error != 0) {
+		device_printf(sc->bge_dev,
+		    "could not create %s dma tag\n", msg);
+		return (ENOMEM);
+	}
+	/* Allocate DMA'able memory for ring. */
+	error = bus_dmamem_alloc(*tag, (void **)ring,
+	    BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, map);
+	if (error != 0) {
+		device_printf(sc->bge_dev,
+		    "could not allocate DMA'able memory for %s\n", msg);
+		return (ENOMEM);
+	}
+	/* Load the address of the ring. */
+	ctx.bge_busaddr = 0;
+	error = bus_dmamap_load(*tag, *map, *ring, maxsize, bge_dma_map_addr,
+	    &ctx, BUS_DMA_NOWAIT);
+	if (error != 0) {
+		device_printf(sc->bge_dev,
+		    "could not load DMA'able memory for %s\n", msg);
+		return (ENOMEM);
+	}
+	*paddr = ctx.bge_busaddr;
+	ring_end = *paddr + maxsize;
+	if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0 &&
+	    BGE_ADDR_HI(*paddr) != BGE_ADDR_HI(ring_end)) {
+		/*
+		 * 4GB boundary crossed.  Limit maximum allowable DMA
+		 * address space to 32bit and try again.
+		 */
+		bus_dmamap_unload(*tag, *map);
+		bus_dmamem_free(*tag, *ring, *map);
+		bus_dma_tag_destroy(*tag);
+		if (bootverbose)
+			device_printf(sc->bge_dev, "4GB boundary crossed, "
+			    "limit DMA address space to 32bit for %s\n", msg);
+		*ring = NULL;
+		*tag = NULL;
+		*map = NULL;
+		lowaddr = BUS_SPACE_MAXADDR_32BIT;
+		goto again;
+	}
+	return (0);
+}
+
+static int
+bge_dma_alloc(struct bge_softc *sc)
+{
+	bus_addr_t lowaddr;
+	bus_size_t boundary, sbsz, txsegsz, txmaxsegsz;
+	int i, error;
 
 	lowaddr = BUS_SPACE_MAXADDR;
 	if ((sc->bge_flags & BGE_FLAG_40BIT_BUG) != 0)
 		lowaddr = BGE_DMA_MAXADDR;
-	if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0)
-		lowaddr = BUS_SPACE_MAXADDR_32BIT;
 	/*
 	 * Allocate the parent bus DMA tag appropriate for PCI.
 	 */
@@ -2150,16 +2205,84 @@ bge_dma_alloc(device_t dev)
 	    1, 0, lowaddr, BUS_SPACE_MAXADDR, NULL,
 	    NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
 	    0, NULL, NULL, &sc->bge_cdata.bge_parent_tag);
-
 	if (error != 0) {
 		device_printf(sc->bge_dev,
 		    "could not allocate parent dma tag\n");
 		return (ENOMEM);
 	}
 
+	/* Create tag for standard RX ring. */
+	error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_STD_RX_RING_SZ,
+	    &sc->bge_cdata.bge_rx_std_ring_tag,
+	    (uint8_t **)&sc->bge_ldata.bge_rx_std_ring,
+	    &sc->bge_cdata.bge_rx_std_ring_map,
+	    &sc->bge_ldata.bge_rx_std_ring_paddr, "RX ring");
+	if (error)
+		return (error);
+
+	/* Create tag for RX return ring. */
+	error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_RX_RTN_RING_SZ(sc),
+	    &sc->bge_cdata.bge_rx_return_ring_tag,
+	    (uint8_t **)&sc->bge_ldata.bge_rx_return_ring,
+	    &sc->bge_cdata.bge_rx_return_ring_map,
+	    &sc->bge_ldata.bge_rx_return_ring_paddr, "RX return ring");
+	if (error)
+		return (error);
+
+	/* Create tag for TX ring. */
+	error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_TX_RING_SZ,
+	    &sc->bge_cdata.bge_tx_ring_tag,
+	    (uint8_t **)&sc->bge_ldata.bge_tx_ring,
+	    &sc->bge_cdata.bge_tx_ring_map,
+	    &sc->bge_ldata.bge_tx_ring_paddr, "TX ring");
+	if (error)
+		return (error);
+
 	/*
-	 * Create tag for Tx mbufs.
+	 * Create tag for status block.
+	 * Because we only use single Tx/Rx/Rx return ring, use
+	 * minimum status block size except BCM5700 AX/BX which
+	 * seems to want to see full status block size regardless
+	 * of configured number of ring.
 	 */
+	if (sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
+	    sc->bge_chipid != BGE_CHIPID_BCM5700_C0)
+		sbsz = BGE_STATUS_BLK_SZ;
+	else
+		sbsz = 32;
+	error = bge_dma_ring_alloc(sc, PAGE_SIZE, sbsz,
+	    &sc->bge_cdata.bge_status_tag,
+	    (uint8_t **)&sc->bge_ldata.bge_status_block,
+	    &sc->bge_cdata.bge_status_map,
+	    &sc->bge_ldata.bge_status_block_paddr, "status block");
+	if (error)
+		return (error);
+
+	/* Create tag for jumbo RX ring. */
+	if (BGE_IS_JUMBO_CAPABLE(sc)) {
+		error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_JUMBO_RX_RING_SZ,
+		    &sc->bge_cdata.bge_rx_jumbo_ring_tag,
+		    (uint8_t **)&sc->bge_ldata.bge_rx_jumbo_ring,
+		    &sc->bge_cdata.bge_rx_jumbo_ring_map,
+		    &sc->bge_ldata.bge_rx_jumbo_ring_paddr, "jumbo RX ring");
+		if (error)
+			return (error);
+	}
+
+	/* Create parent tag for buffers. */
+	boundary = 0;
+	if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0)
+		boundary = BGE_DMA_BNDRY;
+	error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
+	    1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
+	    NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
+	    0, NULL, NULL, &sc->bge_cdata.bge_buffer_tag);
+	if (error != 0) {
+		device_printf(sc->bge_dev,
+		    "could not allocate buffer dma tag\n");
+		return (ENOMEM);
+	}
+	/* Create tag for Tx mbufs. */
 	if (sc->bge_flags & BGE_FLAG_TSO) {
 		txsegsz = BGE_TSOSEG_SZ;
 		txmaxsegsz = 65535 + sizeof(struct ether_vlan_header);
@@ -2167,7 +2290,7 @@ bge_dma_alloc(device_t dev)
 		txsegsz = MCLBYTES;
 		txmaxsegsz = MCLBYTES * BGE_NSEG_NEW;
 	}
-	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, 1,
+	error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1,
 	    0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL,
 	    txmaxsegsz, BGE_NSEG_NEW, txsegsz, 0, NULL, NULL,
 	    &sc->bge_cdata.bge_tx_mtag);
@@ -2177,10 +2300,8 @@ bge_dma_alloc(device_t dev)
 		return (ENOMEM);
 	}
 
-	/*
-	 * Create tag for Rx mbufs.
-	 */
-	error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, 1, 0,
+	/* Create tag for Rx mbufs. */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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