Date: Mon, 7 Jan 2013 14:11:10 +0000 (UTC) From: Rick Macklem <rmacklem@svn.freebsd.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r245130 - in projects/nfsv4-packrats/sys: amd64/conf arm/arm arm/broadcom/bcm2835 arm/conf arm/include arm/ti/cpsw arm/ti/omap4 arm/versatile boot/fdt/dts conf contrib/octeon-sdk dev/ag... Message-ID: <50ead77e.7f18.72ee35c1@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Mon Jan 7 14:11:10 2013 New Revision: 245130 URL: http://svnweb.freebsd.org/changeset/base/245130 Log: Merge in an up to date kernel. Added: projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar5416/ar5416_spectral.c - copied unchanged from r245129, head/sys/dev/ath/ath_hal/ar5416/ar5416_spectral.c projects/nfsv4-packrats/sys/dev/ath/if_ath_spectral.c - copied unchanged from r245129, head/sys/dev/ath/if_ath_spectral.c projects/nfsv4-packrats/sys/dev/ath/if_ath_spectral.h - copied unchanged from r245129, head/sys/dev/ath/if_ath_spectral.h Deleted: projects/nfsv4-packrats/sys/dev/xen/evtchn/ projects/nfsv4-packrats/sys/dev/xen/xenpci/machine_reboot.c Modified: projects/nfsv4-packrats/sys/amd64/conf/GENERIC projects/nfsv4-packrats/sys/arm/arm/busdma_machdep-v6.c projects/nfsv4-packrats/sys/arm/arm/machdep.c projects/nfsv4-packrats/sys/arm/arm/pl310.c projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_fb.c projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_machdep.c projects/nfsv4-packrats/sys/arm/conf/BEAGLEBONE projects/nfsv4-packrats/sys/arm/include/machdep.h projects/nfsv4-packrats/sys/arm/include/pl310.h projects/nfsv4-packrats/sys/arm/ti/cpsw/if_cpsw.c projects/nfsv4-packrats/sys/arm/ti/cpsw/if_cpswreg.h projects/nfsv4-packrats/sys/arm/ti/cpsw/if_cpswvar.h projects/nfsv4-packrats/sys/arm/ti/omap4/omap4_l2cache.c projects/nfsv4-packrats/sys/arm/ti/omap4/omap4_smc.h projects/nfsv4-packrats/sys/arm/versatile/versatile_clcd.c projects/nfsv4-packrats/sys/boot/fdt/dts/pandaboard.dts projects/nfsv4-packrats/sys/conf/files projects/nfsv4-packrats/sys/conf/options.mips projects/nfsv4-packrats/sys/contrib/octeon-sdk/cvmx-app-init.h projects/nfsv4-packrats/sys/contrib/octeon-sdk/cvmx-helper-board.c projects/nfsv4-packrats/sys/dev/agp/agp_ali.c projects/nfsv4-packrats/sys/dev/agp/agp_amd.c projects/nfsv4-packrats/sys/dev/agp/agp_amd64.c projects/nfsv4-packrats/sys/dev/agp/agp_ati.c projects/nfsv4-packrats/sys/dev/agp/agp_intel.c projects/nfsv4-packrats/sys/dev/agp/agp_sis.c projects/nfsv4-packrats/sys/dev/agp/agp_via.c projects/nfsv4-packrats/sys/dev/ahci/ahci.c projects/nfsv4-packrats/sys/dev/ata/ata-pci.h projects/nfsv4-packrats/sys/dev/ata/chipsets/ata-intel.c projects/nfsv4-packrats/sys/dev/ath/ath_dfs/null/dfs_null.c projects/nfsv4-packrats/sys/dev/ath/ath_hal/ah.c projects/nfsv4-packrats/sys/dev/ath/ath_hal/ah.h projects/nfsv4-packrats/sys/dev/ath/ath_hal/ah_internal.h projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar5416/ar5416.h projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar5416/ar5416phy.h projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar5416/ar5416reg.h projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c projects/nfsv4-packrats/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c projects/nfsv4-packrats/sys/dev/ath/if_ath.c projects/nfsv4-packrats/sys/dev/ath/if_ath_rx.c projects/nfsv4-packrats/sys/dev/ath/if_athdfs.h projects/nfsv4-packrats/sys/dev/ath/if_athioctl.h projects/nfsv4-packrats/sys/dev/ath/if_athvar.h projects/nfsv4-packrats/sys/dev/fdt/fdtbus.c projects/nfsv4-packrats/sys/dev/ichsmb/ichsmb_pci.c projects/nfsv4-packrats/sys/dev/ichwd/ichwd.c projects/nfsv4-packrats/sys/dev/ichwd/ichwd.h projects/nfsv4-packrats/sys/dev/pci/pci.c projects/nfsv4-packrats/sys/dev/sound/pci/hda/hdac.c projects/nfsv4-packrats/sys/dev/sound/pci/hda/hdac.h projects/nfsv4-packrats/sys/dev/usb/serial/u3g.c projects/nfsv4-packrats/sys/dev/usb/usbdevs projects/nfsv4-packrats/sys/dev/usb/wlan/if_run.c projects/nfsv4-packrats/sys/dev/xen/control/control.c projects/nfsv4-packrats/sys/dev/xen/netfront/netfront.c projects/nfsv4-packrats/sys/fs/ext2fs/ext2_dinode.h projects/nfsv4-packrats/sys/fs/nandfs/nandfs_segment.c projects/nfsv4-packrats/sys/fs/nullfs/null.h projects/nfsv4-packrats/sys/fs/nullfs/null_subr.c projects/nfsv4-packrats/sys/fs/nullfs/null_vfsops.c projects/nfsv4-packrats/sys/fs/nullfs/null_vnops.c projects/nfsv4-packrats/sys/fs/tmpfs/tmpfs.h projects/nfsv4-packrats/sys/fs/tmpfs/tmpfs_subr.c projects/nfsv4-packrats/sys/fs/tmpfs/tmpfs_vfsops.c projects/nfsv4-packrats/sys/fs/tmpfs/tmpfs_vnops.c projects/nfsv4-packrats/sys/i386/conf/GENERIC projects/nfsv4-packrats/sys/i386/xen/xen_machdep.c projects/nfsv4-packrats/sys/ia64/conf/GENERIC projects/nfsv4-packrats/sys/kern/kern_exit.c projects/nfsv4-packrats/sys/kern/kern_lock.c projects/nfsv4-packrats/sys/kern/kern_synch.c projects/nfsv4-packrats/sys/kern/subr_param.c projects/nfsv4-packrats/sys/kern/vfs_mount.c projects/nfsv4-packrats/sys/kern/vfs_vnops.c projects/nfsv4-packrats/sys/mips/atheros/ar71xx_pci.c projects/nfsv4-packrats/sys/mips/beri/beri_machdep.c projects/nfsv4-packrats/sys/mips/conf/OCTEON1 projects/nfsv4-packrats/sys/modules/ath/Makefile projects/nfsv4-packrats/sys/net/zlib.c projects/nfsv4-packrats/sys/net/zlib.h projects/nfsv4-packrats/sys/net80211/ieee80211_hostap.c projects/nfsv4-packrats/sys/net80211/ieee80211_hwmp.c projects/nfsv4-packrats/sys/netinet/in.c projects/nfsv4-packrats/sys/netinet6/in6.c projects/nfsv4-packrats/sys/pc98/conf/GENERIC projects/nfsv4-packrats/sys/powerpc/conf/GENERIC projects/nfsv4-packrats/sys/powerpc/conf/GENERIC64 projects/nfsv4-packrats/sys/sparc64/conf/GENERIC projects/nfsv4-packrats/sys/sparc64/sparc64/interrupt.S projects/nfsv4-packrats/sys/sys/copyright.h projects/nfsv4-packrats/sys/sys/mount.h projects/nfsv4-packrats/sys/sys/vnode.h projects/nfsv4-packrats/sys/ufs/ffs/ffs_snapshot.c projects/nfsv4-packrats/sys/x86/include/specialreg.h Directory Properties: projects/nfsv4-packrats/sys/ (props changed) projects/nfsv4-packrats/sys/boot/ (props changed) projects/nfsv4-packrats/sys/conf/ (props changed) projects/nfsv4-packrats/sys/contrib/octeon-sdk/ (props changed) Modified: projects/nfsv4-packrats/sys/amd64/conf/GENERIC ============================================================================== --- projects/nfsv4-packrats/sys/amd64/conf/GENERIC Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/amd64/conf/GENERIC Mon Jan 7 14:11:10 2013 (r245130) @@ -35,6 +35,7 @@ options SOFTUPDATES # Enable FFS soft options UFS_ACL # Support for access control lists options UFS_DIRHASH # Improve performance on big directories options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options QUOTA # Enable disk quotas for UFS options MD_ROOT # MD is a potential root device options NFSCL # New Network Filesystem Client options NFSD # New Network Filesystem Server @@ -317,15 +318,6 @@ device usb # USB Bus (required) device ukbd # Keyboard device umass # Disks/Mass storage - Requires scbus and da -# FireWire support -device firewire # FireWire bus code -# sbp(4) works for some systems but causes boot failure on others -#device sbp # SCSI over FireWire (Requires scbus and da) -device fwe # Ethernet over FireWire (non-standard!) -device fwip # IP over FireWire (RFC 2734,3146) -device dcons # Dumb console driver -device dcons_crom # Configuration ROM for dcons - # Sound support device sound # Generic sound driver (required) device snd_cmi # CMedia CMI8338/CMI8738 Modified: projects/nfsv4-packrats/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- projects/nfsv4-packrats/sys/arm/arm/busdma_machdep-v6.c Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/arm/busdma_machdep-v6.c Mon Jan 7 14:11:10 2013 (r245130) @@ -1347,35 +1347,49 @@ _bus_dmamap_sync(bus_dma_tag_t dmat, bus while (sl != NULL) { /* write back the unaligned portions */ vm_paddr_t physaddr; + register_t s = 0; + buf = sl->vaddr; len = sl->datacount; physaddr = sl->busaddr; bbuf = buf & ~arm_dcache_align_mask; ebuf = buf + len; physaddr = physaddr & ~arm_dcache_align_mask; - unalign = buf & arm_dcache_align_mask; - if (unalign) { - memcpy(_tmp_cl, (void *)bbuf, unalign); - len += unalign; /* inv entire cache line */ - } - unalign = ebuf & arm_dcache_align_mask; - if (unalign) { - unalign = arm_dcache_align - unalign; - memcpy(_tmp_clend, (void *)ebuf, unalign); - len += unalign; /* inv entire cache line */ + + + if ((buf & arm_dcache_align_mask) || + (ebuf & arm_dcache_align_mask)) { + s = intr_disable(); + unalign = buf & arm_dcache_align_mask; + if (unalign) { + memcpy(_tmp_cl, (void *)bbuf, unalign); + len += unalign; /* inv entire cache line */ + } + + unalign = ebuf & arm_dcache_align_mask; + if (unalign) { + unalign = arm_dcache_align - unalign; + memcpy(_tmp_clend, (void *)ebuf, unalign); + len += unalign; /* inv entire cache line */ + } } - /* inv are cache length aligned */ + + /* inv are cache length aligned */ cpu_dcache_inv_range(bbuf, len); l2cache_inv_range(bbuf, physaddr, len); - unalign = (vm_offset_t)buf & arm_dcache_align_mask; - if (unalign) { - memcpy((void *)bbuf, _tmp_cl, unalign); - } - unalign = ebuf & arm_dcache_align_mask; - if (unalign) { - unalign = arm_dcache_align - unalign; - memcpy((void *)ebuf, _tmp_clend, unalign); + if ((buf & arm_dcache_align_mask) || + (ebuf & arm_dcache_align_mask)) { + unalign = (vm_offset_t)buf & arm_dcache_align_mask; + if (unalign) + memcpy((void *)bbuf, _tmp_cl, unalign); + + unalign = ebuf & arm_dcache_align_mask; + if (unalign) + memcpy((void *)ebuf, _tmp_clend, + arm_dcache_align - unalign); + + intr_restore(s); } sl = STAILQ_NEXT(sl, slinks); } Modified: projects/nfsv4-packrats/sys/arm/arm/machdep.c ============================================================================== --- projects/nfsv4-packrats/sys/arm/arm/machdep.c Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/arm/machdep.c Mon Jan 7 14:11:10 2013 (r245130) @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ptrace.h> #include <sys/signalvar.h> #include <sys/syscallsubr.h> +#include <sys/sysctl.h> #include <sys/sysent.h> #include <sys/sysproto.h> #include <sys/uio.h> @@ -162,8 +163,6 @@ const struct pmap_devmap *pmap_devmap_bo uint32_t board_id; struct arm_lbabi_tag *atag_list; -uint32_t revision; -uint64_t serial; char linux_command_line[LBABI_MAX_COMMAND_LINE + 1]; char atags[LBABI_MAX_COMMAND_LINE * 2]; uint32_t memstart[LBABI_MAX_BANKS]; @@ -171,6 +170,31 @@ uint32_t memsize[LBABI_MAX_BANKS]; uint32_t membanks; #endif +static uint32_t board_revision; +/* hex representation of uint64_t */ +static char board_serial[32]; + +SYSCTL_NODE(_hw, OID_AUTO, board, CTLFLAG_RD, 0, "Board attributes"); +SYSCTL_UINT(_hw_board, OID_AUTO, revision, CTLFLAG_RD, + &board_revision, 0, "Board revision"); +SYSCTL_STRING(_hw_board, OID_AUTO, serial, CTLFLAG_RD, + board_serial, 0, "Board serial"); + +void +board_set_serial(uint64_t serial) +{ + + snprintf(board_serial, sizeof(board_serial)-1, + "%016jx", serial); +} + +void +board_set_revision(uint32_t revision) +{ + + board_revision = revision; +} + void sendsig(catcher, ksi, mask) sig_t catcher; @@ -849,6 +873,8 @@ vm_offset_t linux_parse_boot_param(struct arm_boot_params *abp) { struct arm_lbabi_tag *walker; + uint32_t revision; + uint64_t serial; /* * Linux boot ABI: r0 = 0, r1 is the board type (!= 0) and r2 @@ -883,9 +909,11 @@ linux_parse_boot_param(struct arm_boot_p case ATAG_SERIAL: serial = walker->u.tag_sn.low | ((uint64_t)walker->u.tag_sn.high << 32); + board_set_serial(serial); break; case ATAG_REVISION: revision = walker->u.tag_rev.rev; + board_set_revision(revision); break; case ATAG_CMDLINE: /* XXX open question: Parse this for boothowto? */ Modified: projects/nfsv4-packrats/sys/arm/arm/pl310.c ============================================================================== --- projects/nfsv4-packrats/sys/arm/arm/pl310.c Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/arm/pl310.c Mon Jan 7 14:11:10 2013 (r245130) @@ -39,62 +39,39 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/mutex.h> #include <machine/intr.h> -#include <vm/vm.h> -#include <vm/pmap.h> -#include <machine/pl310.h> + #include <machine/bus.h> +#include <machine/pl310.h> #include <dev/fdt/fdt_common.h> #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> -/** - * PL310 - L2 Cache Controller register offsets. - * +/* + * Define this if you need to disable PL310 for debugging purpose + * Spec: + * http://infocenter.arm.com/help/topic/com.arm.doc.ddi0246e/DDI0246E_l2c310_r3p1_trm.pdf + */ + +/* + * Hardcode errata for now + * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0246b/pr01s02s02.html */ -#define PL310_CACHE_ID 0x000 -#define PL310_CACHE_TYPE 0x004 -#define PL310_CTRL 0x100 -#define PL310_AUX_CTRL 0x104 -#define PL310_EVENT_COUNTER_CTRL 0x200 -#define PL310_EVENT_COUNTER1_CONF 0x204 -#define PL310_EVENT_COUNTER0_CONF 0x208 -#define PL310_EVENT_COUNTER1_VAL 0x20C -#define PL310_EVENT_COUNTER0_VAL 0x210 -#define PL310_INTR_MASK 0x214 -#define PL310_MASKED_INTR_STAT 0x218 -#define PL310_RAW_INTR_STAT 0x21C -#define PL310_INTR_CLEAR 0x220 -#define PL310_CACHE_SYNC 0x730 -#define PL310_INV_LINE_PA 0x770 -#define PL310_INV_WAY 0x77C -#define PL310_CLEAN_LINE_PA 0x7B0 -#define PL310_CLEAN_LINE_IDX 0x7B8 -#define PL310_CLEAN_WAY 0x7BC -#define PL310_CLEAN_INV_LINE_PA 0x7F0 -#define PL310_CLEAN_INV_LINE_IDX 0x7F8 -#define PL310_CLEAN_INV_WAY 0x7FC -#define PL310_LOCKDOWN_D_WAY(x) (0x900 + ((x) * 8)) -#define PL310_LOCKDOWN_I_WAY(x) (0x904 + ((x) * 8)) -#define PL310_LOCKDOWN_LINE_ENABLE 0x950 -#define PL310_UNLOCK_ALL_LINES_WAY 0x954 -#define PL310_ADDR_FILTER_START 0xC00 -#define PL310_ADDR_FILTER_END 0xC04 -#define PL310_DEBUG_CTRL 0xF40 - - -#define PL310_AUX_CTRL_MASK 0xc0000fff -#define PL310_AUX_CTRL_ASSOCIATIVITY_SHIFT 16 -#define PL310_AUX_CTRL_WAY_SIZE_SHIFT 17 -#define PL310_AUX_CTRL_WAY_SIZE_MASK (0x7 << 17) -#define PL310_AUX_CTRL_SHARE_OVERRIDE_SHIFT 22 -#define PL310_AUX_CTRL_NS_LOCKDOWN_SHIFT 26 -#define PL310_AUX_CTRL_NS_INT_CTRL_SHIFT 27 -#define PL310_AUX_CTRL_DATA_PREFETCH_SHIFT 28 -#define PL310_AUX_CTRL_INSTR_PREFETCH_SHIFT 29 -#define PL310_AUX_CTRL_EARLY_BRESP_SHIFT 30 +#define PL310_ERRATA_588369 +#define PL310_ERRATA_753970 +#define PL310_ERRATA_727915 + +#define PL310_LOCK(sc) do { \ + mtx_lock_spin(&(sc)->sc_mtx); \ +} while(0); + +#define PL310_UNLOCK(sc) do { \ + mtx_unlock_spin(&(sc)->sc_mtx); \ +} while(0); +static int pl310_enabled = 1; +TUNABLE_INT("pl310.enabled", &pl310_enabled); void omap4_l2cache_wbinv_range(vm_paddr_t physaddr, vm_size_t size); void omap4_l2cache_inv_range(vm_paddr_t physaddr, vm_size_t size); @@ -112,34 +89,31 @@ static uint32_t g_l2cache_size; static struct pl310_softc *pl310_softc; -/** - * pl310_read4 - read a 32-bit value from the PL310 registers - * pl310_write4 - write a 32-bit value from the PL310 registers - * @off: byte offset within the register set to read from - * @val: the value to write into the register - * - * - * LOCKING: - * None - * - * RETURNS: - * nothing in case of write function, if read function returns the value read. - */ -static __inline uint32_t -pl310_read4(bus_size_t off) -{ - return bus_read_4(pl310_softc->sc_mem_res, off); -} -static __inline void -pl310_write4(bus_size_t off, uint32_t val) +static int +pl310_filter(void *arg) { - bus_write_4(pl310_softc->sc_mem_res, off, val); + struct pl310_softc *sc = arg; + uint32_t intr; + + intr = pl310_read4(sc, PL310_INTR_MASK); + + if (!sc->sc_enabled && (intr & INTR_MASK_ECNTR)) { + /* + * This is for debug purpose, so be blunt about it + * We disable PL310 only when something fishy is going + * on and we need to make sure L2 cache is 100% disabled + */ + panic("pl310: caches disabled but cache event detected\n"); + } + + return (FILTER_HANDLED); } static __inline void pl310_wait_background_op(uint32_t off, uint32_t mask) { - while (pl310_read4(off) & mask); + + while (pl310_read4(pl310_softc, off) & mask); } @@ -157,29 +131,51 @@ pl310_wait_background_op(uint32_t off, u static __inline void pl310_cache_sync(void) { - pl310_write4(PL310_CACHE_SYNC, 0); + if ((pl310_softc == NULL) || !pl310_softc->sc_enabled) + return; + +#ifdef PL310_ERRATA_753970 + if (pl310_softc->sc_rtl_revision == CACHE_ID_RELEASE_r3p0) + /* Write uncached PL310 register */ + pl310_write4(pl310_softc, 0x740, 0xffffffff); + else +#endif + pl310_write4(pl310_softc, PL310_CACHE_SYNC, 0xffffffff); } static void pl310_wbinv_all(void) { -#if 1 - pl310_write4(PL310_DEBUG_CTRL, 3); + + if ((pl310_softc == NULL) || !pl310_softc->sc_enabled) + return; + + PL310_LOCK(pl310_softc); +#ifdef PL310_ERRATA_727915 + if (pl310_softc->sc_rtl_revision == CACHE_ID_RELEASE_r2p0 || + pl310_softc->sc_rtl_revision == CACHE_ID_RELEASE_r3p0) + platform_pl310_write_debug(pl310_softc, 3); #endif - pl310_write4(PL310_CLEAN_INV_WAY, g_l2cache_way_mask); + pl310_write4(pl310_softc, PL310_CLEAN_INV_WAY, g_l2cache_way_mask); pl310_wait_background_op(PL310_CLEAN_INV_WAY, g_l2cache_way_mask); pl310_cache_sync(); -#if 1 - pl310_write4(PL310_DEBUG_CTRL, 0); +#ifdef PL310_ERRATA_727915 + if (pl310_softc->sc_rtl_revision == CACHE_ID_RELEASE_r2p0 || + pl310_softc->sc_rtl_revision == CACHE_ID_RELEASE_r3p0) + platform_pl310_write_debug(pl310_softc, 0); #endif - + PL310_UNLOCK(pl310_softc); } static void pl310_wbinv_range(vm_paddr_t start, vm_size_t size) { - + + if ((pl310_softc == NULL) || !pl310_softc->sc_enabled) + return; + + PL310_LOCK(pl310_softc); if (start & g_l2cache_align_mask) { size += start & g_l2cache_align_mask; start &= ~g_l2cache_align_mask; @@ -188,61 +184,73 @@ pl310_wbinv_range(vm_paddr_t start, vm_s size &= ~g_l2cache_align_mask; size += g_l2cache_line_size; } -#if 1 - pl310_write4(PL310_DEBUG_CTRL, 3); + +#ifdef PL310_ERRATA_727915 + platform_pl310_write_debug(pl310_softc, 3); #endif while (size > 0) { -#if 1 - /* - * Errata 588369 says that clean + inv may keep the - * cache line if it was clean, the recommanded workaround - * is to clean then invalidate the cache line, with - * write-back and cache linefill disabled - */ - - pl310_write4(PL310_CLEAN_LINE_PA, start); - pl310_write4(PL310_INV_LINE_PA, start); -#else - pl310_write4(PL310_CLEAN_INV_LINE_PA, start); +#ifdef PL310_ERRATA_588369 + if (pl310_softc->sc_rtl_revision <= CACHE_ID_RELEASE_r1p0) { + /* + * Errata 588369 says that clean + inv may keep the + * cache line if it was clean, the recommanded + * workaround is to clean then invalidate the cache + * line, with write-back and cache linefill disabled. + */ + pl310_write4(pl310_softc, PL310_CLEAN_LINE_PA, start); + pl310_write4(pl310_softc, PL310_INV_LINE_PA, start); + } else #endif + pl310_write4(pl310_softc, PL310_CLEAN_INV_LINE_PA, + start); start += g_l2cache_line_size; size -= g_l2cache_line_size; } -#if 1 - pl310_write4(PL310_DEBUG_CTRL, 0); +#ifdef PL310_ERRATA_727915 + platform_pl310_write_debug(pl310_softc, 0); #endif - pl310_wait_background_op(PL310_CLEAN_INV_LINE_PA, 1); + pl310_cache_sync(); - + PL310_UNLOCK(pl310_softc); } static void pl310_wb_range(vm_paddr_t start, vm_size_t size) { - + + if ((pl310_softc == NULL) || !pl310_softc->sc_enabled) + return; + + PL310_LOCK(pl310_softc); if (start & g_l2cache_align_mask) { size += start & g_l2cache_align_mask; start &= ~g_l2cache_align_mask; } + if (size & g_l2cache_align_mask) { size &= ~g_l2cache_align_mask; size += g_l2cache_line_size; } + while (size > 0) { - pl310_write4(PL310_CLEAN_LINE_PA, start); + pl310_write4(pl310_softc, PL310_CLEAN_LINE_PA, start); start += g_l2cache_line_size; size -= g_l2cache_line_size; } - pl310_cache_sync(); - pl310_wait_background_op(PL310_CLEAN_LINE_PA, 1); + pl310_cache_sync(); + PL310_UNLOCK(pl310_softc); } static void pl310_inv_range(vm_paddr_t start, vm_size_t size) { + if ((pl310_softc == NULL) || !pl310_softc->sc_enabled) + return; + + PL310_LOCK(pl310_softc); if (start & g_l2cache_align_mask) { size += start & g_l2cache_align_mask; start &= ~g_l2cache_align_mask; @@ -252,13 +260,13 @@ pl310_inv_range(vm_paddr_t start, vm_siz size += g_l2cache_line_size; } while (size > 0) { - pl310_write4(PL310_INV_LINE_PA, start); + pl310_write4(pl310_softc, PL310_INV_LINE_PA, start); start += g_l2cache_line_size; size -= g_l2cache_line_size; } - pl310_cache_sync(); - pl310_wait_background_op(PL310_INV_LINE_PA, 1); + pl310_cache_sync(); + PL310_UNLOCK(pl310_softc); } static int @@ -280,39 +288,100 @@ pl310_attach(device_t dev) uint32_t way_size; uint32_t ways_assoc; uint32_t ctrl_value; + uint32_t cache_id; + sc->sc_dev = dev; sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->sc_mem_res == NULL) panic("%s: Cannot map registers", device_get_name(dev)); + + /* Allocate an IRQ resource */ + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_ACTIVE | RF_SHAREABLE); + if (sc->sc_irq_res == NULL) { + panic("Cannot allocate IRQ\n"); + } + pl310_softc = sc; + mtx_init(&sc->sc_mtx, "pl310lock", NULL, MTX_SPIN); + sc->sc_enabled = pl310_enabled; - platform_init_pl310(sc); - aux_value = pl310_read4(PL310_AUX_CTRL); - way_size = (aux_value & PL310_AUX_CTRL_WAY_SIZE_MASK) >> - PL310_AUX_CTRL_WAY_SIZE_SHIFT; + /* activate the interrupt */ + bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + pl310_filter, NULL, sc, &sc->sc_irq_h); + + cache_id = pl310_read4(sc, PL310_CACHE_ID); + sc->sc_rtl_revision = (cache_id >> CACHE_ID_RELEASE_SHIFT) & + CACHE_ID_RELEASE_MASK; + device_printf(dev, "Part number: 0x%x, release: 0x%x\n", + (cache_id >> CACHE_ID_PARTNUM_SHIFT) & CACHE_ID_PARTNUM_MASK, + (cache_id >> CACHE_ID_RELEASE_SHIFT) & CACHE_ID_RELEASE_MASK); + aux_value = pl310_read4(sc, PL310_AUX_CTRL); + way_size = (aux_value & AUX_CTRL_WAY_SIZE_MASK) >> + AUX_CTRL_WAY_SIZE_SHIFT; way_size = 1 << (way_size + 13); - if (aux_value & (1 << PL310_AUX_CTRL_ASSOCIATIVITY_SHIFT)) + if (aux_value & (1 << AUX_CTRL_ASSOCIATIVITY_SHIFT)) ways_assoc = 16; else ways_assoc = 8; g_l2cache_way_mask = (1 << ways_assoc) - 1; g_l2cache_size = way_size * ways_assoc; /* Print the information */ - printf(" L2 Cache: %uKB/%dB %d ways\n", (g_l2cache_size / 1024), + device_printf(dev, "L2 Cache: %uKB/%dB %d ways\n", (g_l2cache_size / 1024), g_l2cache_line_size, ways_assoc); - ctrl_value = pl310_read4(PL310_CTRL); - if (!(ctrl_value & 0x1)) { + + ctrl_value = pl310_read4(sc, PL310_CTRL); + + if (sc->sc_enabled && !(ctrl_value & CTRL_ENABLED)) { /* Enable the L2 cache if disabled */ - pl310_write4(PL310_CTRL, ctrl_value & 0x1); + platform_pl310_write_ctrl(sc, CTRL_ENABLED); + } + + if (!sc->sc_enabled && (ctrl_value & CTRL_ENABLED)) { + /* + * Set counters so when cache event happens + * we'll get interrupt and be warned that something + * is off + */ + + /* Cache Line Eviction for Counter 0 */ + pl310_write4(sc, PL310_EVENT_COUNTER0_CONF, + EVENT_COUNTER_CONF_INCR | EVENT_COUNTER_CONF_CO); + /* Data Read Request for Counter 1 */ + pl310_write4(sc, PL310_EVENT_COUNTER1_CONF, + EVENT_COUNTER_CONF_INCR | EVENT_COUNTER_CONF_DRREQ); + + /* Temporary switch on for final flush*/ + sc->sc_enabled = 1; + pl310_wbinv_all(); + sc->sc_enabled = 0; + platform_pl310_write_ctrl(sc, CTRL_DISABLED); + + /* Enable and clear pending interrupts */ + pl310_write4(sc, PL310_INTR_CLEAR, INTR_MASK_ECNTR); + pl310_write4(sc, PL310_INTR_MASK, INTR_MASK_ALL); + + /* Enable counters and reset C0 and C1 */ + pl310_write4(sc, PL310_EVENT_COUNTER_CTRL, + EVENT_COUNTER_CTRL_ENABLED | + EVENT_COUNTER_CTRL_C0_RESET | + EVENT_COUNTER_CTRL_C1_RESET); + } + + if (sc->sc_enabled) + platform_pl310_init(sc); + pl310_wbinv_all(); - + /* Set the l2 functions in the set of cpufuncs */ cpufuncs.cf_l2cache_wbinv_all = pl310_wbinv_all; cpufuncs.cf_l2cache_wbinv_range = pl310_wbinv_range; cpufuncs.cf_l2cache_inv_range = pl310_inv_range; cpufuncs.cf_l2cache_wb_range = pl310_wb_range; + return (0); } @@ -330,4 +399,3 @@ static driver_t pl310_driver = { static devclass_t pl310_devclass; DRIVER_MODULE(pl310, simplebus, pl310_driver, pl310_devclass, 0, 0); - Modified: projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_fb.c ============================================================================== --- projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_fb.c Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_fb.c Mon Jan 7 14:11:10 2013 (r245130) @@ -891,7 +891,7 @@ bcmfb_putc(video_adapter_t *adp, vm_offs + (sc->depth/8) * (col + sc->xmargin); fg = a & 0xf ; - bg = (a >> 8) & 0xf; + bg = (a >> 4) & 0xf; for (i = 0; i < BCMFB_FONT_HEIGHT; i++) { for (j = 0, k = 7; j < 8; j++, k--) { Modified: projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_machdep.c ============================================================================== --- projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Mon Jan 7 14:11:10 2013 (r245130) @@ -78,6 +78,25 @@ initarm_gpio_init(void) void initarm_late_init(void) { + phandle_t system; + pcell_t cells[2]; + int len; + + /* + * It seems there is no way to let syscons framework know + * that framebuffer resolution has changed. So just try + * to fetch data from FDT and go with defaults if failed + */ + system = OF_finddevice("/system"); + if (system != 0) { + len = OF_getprop(system, "linux,serial", &cells, sizeof(cells)); + if (len > 0) + board_set_serial(fdt64_to_cpu(*((uint64_t *)cells))); + + len = OF_getprop(system, "linux,revision", &cells, sizeof(cells)); + if (len > 0) + board_set_revision(fdt32_to_cpu(*((uint32_t *)cells))); + } } #define FDT_DEVMAP_MAX (2) // FIXME Modified: projects/nfsv4-packrats/sys/arm/conf/BEAGLEBONE ============================================================================== --- projects/nfsv4-packrats/sys/arm/conf/BEAGLEBONE Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/conf/BEAGLEBONE Mon Jan 7 14:11:10 2013 (r245130) @@ -62,11 +62,11 @@ options WITNESS_SKIPSPIN #Don't run wit # NFS support #options NFSCL -#options NFSSERVER #Network Filesystem Server -#options NFSCLIENT #Network Filesystem Client +#options NFSD +#options NFSLOCKD # Uncomment this for NFS root -#options NFS_ROOT #NFS usable as /, requires NFSCLIENT +#options NFS_ROOT #NFS usable as /, requires NFSCL #options BOOTP_NFSROOT #options BOOTP_COMPAT #options BOOTP Modified: projects/nfsv4-packrats/sys/arm/include/machdep.h ============================================================================== --- projects/nfsv4-packrats/sys/arm/include/machdep.h Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/include/machdep.h Mon Jan 7 14:11:10 2013 (r245130) @@ -37,6 +37,10 @@ void initarm_gpio_init(void); void initarm_late_init(void); int platform_devmap_init(void); +/* Board-specific attributes */ +void board_set_serial(uint64_t); +void board_set_revision(uint32_t); + /* Needs to be initialised by platform_devmap_init */ extern const struct pmap_devmap *pmap_devmap_bootstrap_table; Modified: projects/nfsv4-packrats/sys/arm/include/pl310.h ============================================================================== --- projects/nfsv4-packrats/sys/arm/include/pl310.h Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/include/pl310.h Mon Jan 7 14:11:10 2013 (r245130) @@ -29,10 +29,140 @@ #ifndef PL310_H_ #define PL310_H_ + +/** + * PL310 - L2 Cache Controller register offsets. + * + */ +#define PL310_CACHE_ID 0x000 +#define CACHE_ID_RELEASE_SHIFT 0 +#define CACHE_ID_RELEASE_MASK 0x3f +#define CACHE_ID_RELEASE_r0p0 0x00 +#define CACHE_ID_RELEASE_r1p0 0x02 +#define CACHE_ID_RELEASE_r2p0 0x04 +#define CACHE_ID_RELEASE_r3p0 0x05 +#define CACHE_ID_RELEASE_r3p1 0x06 +#define CACHE_ID_RELEASE_r3p2 0x08 +#define CACHE_ID_RELEASE_r3p3 0x09 +#define CACHE_ID_PARTNUM_SHIFT 6 +#define CACHE_ID_PARTNUM_MASK 0xf +#define CACHE_ID_PARTNUM_VALUE 0x3 +#define PL310_CACHE_TYPE 0x004 +#define PL310_CTRL 0x100 +#define CTRL_ENABLED 0x01 +#define CTRL_DISABLED 0x00 +#define PL310_AUX_CTRL 0x104 +#define AUX_CTRL_MASK 0xc0000fff +#define AUX_CTRL_ASSOCIATIVITY_SHIFT 16 +#define AUX_CTRL_WAY_SIZE_SHIFT 17 +#define AUX_CTRL_WAY_SIZE_MASK (0x7 << 17) +#define AUX_CTRL_SHARE_OVERRIDE (1 << 22) +#define AUX_CTRL_NS_LOCKDOWN (1 << 26) +#define AUX_CTRL_NS_INT_CTRL (1 << 27) +#define AUX_CTRL_DATA_PREFETCH (1 << 28) +#define AUX_CTRL_INSTR_PREFETCH (1 << 29) +#define AUX_CTRL_EARLY_BRESP (1 << 30) +#define PL310_EVENT_COUNTER_CTRL 0x200 +#define EVENT_COUNTER_CTRL_ENABLED (1 << 0) +#define EVENT_COUNTER_CTRL_C0_RESET (1 << 1) +#define EVENT_COUNTER_CTRL_C1_RESET (1 << 2) +#define PL310_EVENT_COUNTER1_CONF 0x204 +#define PL310_EVENT_COUNTER0_CONF 0x208 +#define EVENT_COUNTER_CONF_NOINTR 0 +#define EVENT_COUNTER_CONF_INCR 1 +#define EVENT_COUNTER_CONF_OVFW 2 +#define EVENT_COUNTER_CONF_NOEV (0 << 2) +#define EVENT_COUNTER_CONF_CO (1 << 2) +#define EVENT_COUNTER_CONF_DRHIT (2 << 2) +#define EVENT_COUNTER_CONF_DRREQ (3 << 2) +#define EVENT_COUNTER_CONF_DWHIT (4 << 2) +#define EVENT_COUNTER_CONF_DWREQ (5 << 2) +#define EVENT_COUNTER_CONF_DWTREQ (6 << 2) +#define EVENT_COUNTER_CONF_DIRHIT (7 << 2) +#define EVENT_COUNTER_CONF_DIRREQ (8 << 2) +#define EVENT_COUNTER_CONF_WA (9 << 2) +#define PL310_EVENT_COUNTER1_VAL 0x20C +#define PL310_EVENT_COUNTER0_VAL 0x210 +#define PL310_INTR_MASK 0x214 +#define PL310_MASKED_INTR_STAT 0x218 +#define PL310_RAW_INTR_STAT 0x21C +#define PL310_INTR_CLEAR 0x220 +#define INTR_MASK_ALL ((1 << 9) - 1) +#define INTR_MASK_ECNTR (1 << 0) +#define INTR_MASK_PARRT (1 << 1) +#define INTR_MASK_PARRD (1 << 2) +#define INTR_MASK_ERRWT (1 << 3) +#define INTR_MASK_ERRWD (1 << 4) +#define INTR_MASK_ERRRT (1 << 5) +#define INTR_MASK_ERRRD (1 << 6) +#define INTR_MASK_SLVERR (1 << 7) +#define INTR_MASK_DECERR (1 << 8) +#define PL310_CACHE_SYNC 0x730 +#define PL310_INV_LINE_PA 0x770 +#define PL310_INV_WAY 0x77C +#define PL310_CLEAN_LINE_PA 0x7B0 +#define PL310_CLEAN_LINE_IDX 0x7B8 +#define PL310_CLEAN_WAY 0x7BC +#define PL310_CLEAN_INV_LINE_PA 0x7F0 +#define PL310_CLEAN_INV_LINE_IDX 0x7F8 +#define PL310_CLEAN_INV_WAY 0x7FC +#define PL310_LOCKDOWN_D_WAY(x) (0x900 + ((x) * 8)) +#define PL310_LOCKDOWN_I_WAY(x) (0x904 + ((x) * 8)) +#define PL310_LOCKDOWN_LINE_ENABLE 0x950 +#define PL310_UNLOCK_ALL_LINES_WAY 0x954 +#define PL310_ADDR_FILTER_STAR 0xC00 +#define PL310_ADDR_FILTER_END 0xC04 +#define PL310_DEBUG_CTRL 0xF40 +#define PL310_PREFETCH_CTRL 0xF60 +#define PREFETCH_CTRL_OFFSET_MASK (0x1f) +#define PREFETCH_CTRL_NOTSAMEID (1 << 21) +#define PREFETCH_CTRL_INCR_DL (1 << 23) +#define PREFETCH_CTRL_PREFETCH_DROP (1 << 24) +#define PREFETCH_CTRL_DL_ON_WRAP (1 << 27) +#define PREFETCH_CTRL_DATA_PREFETCH (1 << 28) +#define PREFETCH_CTRL_INSTR_PREFETCH (1 << 29) +#define PREFETCH_CTRL_DL (1 << 30) +#define PL310_POWER_CTRL 0xF60 + struct pl310_softc { + device_t sc_dev; struct resource *sc_mem_res; + struct resource *sc_irq_res; + void* sc_irq_h; + int sc_enabled; + struct mtx sc_mtx; + u_int sc_rtl_revision; }; -void platform_init_pl310(struct pl310_softc *sc); +/** + * pl310_read4 - read a 32-bit value from the PL310 registers + * pl310_write4 - write a 32-bit value from the PL310 registers + * @off: byte offset within the register set to read from + * @val: the value to write into the register + * + * + * LOCKING: + * None + * + * RETURNS: + * nothing in case of write function, if read function returns the value read. + */ +static __inline uint32_t +pl310_read4(struct pl310_softc *sc, bus_size_t off) +{ + + return bus_read_4(sc->sc_mem_res, off); +} + +static __inline void +pl310_write4(struct pl310_softc *sc, bus_size_t off, uint32_t val) +{ + + bus_write_4(sc->sc_mem_res, off, val); +} + +void platform_pl310_init(struct pl310_softc *); +void platform_pl310_write_ctrl(struct pl310_softc *, uint32_t); +void platform_pl310_write_debug(struct pl310_softc *, uint32_t); #endif /* PL310_H_ */ Modified: projects/nfsv4-packrats/sys/arm/ti/cpsw/if_cpsw.c ============================================================================== --- projects/nfsv4-packrats/sys/arm/ti/cpsw/if_cpsw.c Mon Jan 7 11:12:09 2013 (r245129) +++ projects/nfsv4-packrats/sys/arm/ti/cpsw/if_cpsw.c Mon Jan 7 14:11:10 2013 (r245130) @@ -95,10 +95,10 @@ static void cpsw_start(struct ifnet *ifp static void cpsw_start_locked(struct ifnet *ifp); static void cpsw_stop_locked(struct cpsw_softc *sc); static int cpsw_ioctl(struct ifnet *ifp, u_long command, caddr_t data); -static int cpsw_allocate_dma(struct cpsw_softc *sc); -static int cpsw_free_dma(struct cpsw_softc *sc); -static int cpsw_new_rxbuf(struct cpsw_softc *sc, uint32_t i, uint32_t next); -static void cpsw_watchdog(struct cpsw_softc *sc); +static int cpsw_init_slot_lists(struct cpsw_softc *sc); +static void cpsw_free_slot(struct cpsw_softc *sc, struct cpsw_slot *slot); +static void cpsw_fill_rx_queue_locked(struct cpsw_softc *sc); +static void cpsw_tx_watchdog(struct cpsw_softc *sc); static void cpsw_intr_rx_thresh(void *arg); static void cpsw_intr_rx(void *arg); @@ -156,10 +156,10 @@ static struct { driver_intr_t *handler; char * description; } cpsw_intrs[CPSW_INTR_COUNT + 1] = { - { cpsw_intr_rx_thresh,"CPSW RX threshold interrupt" }, + { cpsw_intr_rx_thresh, "CPSW RX threshold interrupt" }, { cpsw_intr_rx, "CPSW RX interrupt" }, { cpsw_intr_tx, "CPSW TX interrupt" }, - { cpsw_intr_misc,"CPSW misc interrupt" }, + { cpsw_intr_misc, "CPSW misc interrupt" }, }; /* Locking macros */ @@ -199,6 +199,34 @@ static struct { } while (0) +#include <machine/stdarg.h> +static void +cpsw_debugf_head(const char *funcname) +{ + int t = (int)(time_second % (24 * 60 * 60)); + + printf("%02d:%02d:%02d %s ", t / (60 * 60), (t / 60) % 60, t % 60, funcname); +} + +static void +cpsw_debugf(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + printf("\n"); + +} + +#define CPSW_DEBUGF(a) do { \ + if (sc->cpsw_if_flags & IFF_DEBUG) { \ + cpsw_debugf_head(__func__); \ + cpsw_debugf a; \ + } \ +} while (0) + static int cpsw_probe(device_t dev) { @@ -213,18 +241,20 @@ cpsw_probe(device_t dev) static int cpsw_attach(device_t dev) { - struct cpsw_softc *sc; + struct cpsw_softc *sc = device_get_softc(dev); struct mii_softc *miisc; struct ifnet *ifp; + void *phy_sc; int i, error, phy; uint32_t reg; - sc = device_get_softc(dev); + CPSW_DEBUGF(("")); + sc->dev = dev; sc->node = ofw_bus_get_node(dev); /* Get phy address from fdt */ - if (fdt_get_phyaddr(sc->node, sc->dev, &phy, (void **)&sc->phy_sc) != 0) { + if (fdt_get_phyaddr(sc->node, sc->dev, &phy, &phy_sc) != 0) { device_printf(dev, "failed to get PHY address from FDT\n"); return (ENXIO); } @@ -246,14 +276,32 @@ cpsw_attach(device_t dev) device_printf(dev, "Version %d.%d (%d)\n", (reg >> 8 & 0x7), reg & 0xFF, (reg >> 11) & 0x1F); - /* Allocate DMA, buffers, buffer descriptors */ - error = cpsw_allocate_dma(sc); + //cpsw_add_sysctls(sc); TODO + + /* Allocate a busdma tag and DMA safe memory for mbufs. */ + error = bus_dma_tag_create( + bus_get_dma_tag(sc->dev), /* parent */ + 1, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filtfunc, filtfuncarg */ + MCLBYTES, 1, /* maxsize, nsegments */ + MCLBYTES, 0, /* maxsegsz, flags */ + NULL, NULL, /* lockfunc, lockfuncarg */ + &sc->mbuf_dtag); /* dmatag */ if (error) { + device_printf(dev, "bus_dma_tag_create failed\n"); cpsw_detach(dev); - return (ENXIO); + return (ENOMEM); } - //cpsw_add_sysctls(sc); TODO + /* Initialize the tx_avail and rx_avail lists. */ + error = cpsw_init_slot_lists(sc); + if (error) { + device_printf(dev, "failed to allocate dmamaps\n"); + cpsw_detach(dev); + return (ENOMEM); + } /* Allocate network interface */ ifp = sc->ifp = if_alloc(IFT_ETHER); @@ -294,7 +342,7 @@ cpsw_attach(device_t dev) /* Initialze MDIO - ENABLE, PREAMBLE=0, FAULTENB, CLKDIV=0xFF */ /* TODO Calculate MDCLK=CLK/(CLKDIV+1) */ - cpsw_write_4(MDIOCONTROL, (1<<30) | (1<<18) | 0xFF); + cpsw_write_4(MDIOCONTROL, 1 << 30 | 1 << 18 | 0xFF); /* Attach PHY(s) */ error = mii_attach(dev, &sc->miibus, ifp, cpsw_ifmedia_upd, @@ -310,7 +358,7 @@ cpsw_attach(device_t dev) miisc = LIST_FIRST(&sc->mii->mii_phys); /* Select PHY and enable interrupts */ - cpsw_write_4(MDIOUSERPHYSEL0, (1 << 6) | (miisc->mii_phy & 0x1F)); + cpsw_write_4(MDIOUSERPHYSEL0, 1 << 6 | (miisc->mii_phy & 0x1F)); /* Attach interrupt handlers */ for (i = 1; i <= CPSW_INTR_COUNT; ++i) { @@ -332,17 +380,22 @@ cpsw_attach(device_t dev) static int cpsw_detach(device_t dev) { - struct cpsw_softc *sc; - int error,i; + struct cpsw_softc *sc = device_get_softc(dev); + int error, i; - sc = device_get_softc(dev); + CPSW_DEBUGF(("")); /* Stop controller and free TX queue */ - if (sc->ifp) - cpsw_shutdown(dev); + if (device_is_attached(dev)) { + ether_ifdetach(sc->ifp); + CPSW_GLOBAL_LOCK(sc); + cpsw_stop_locked(sc); + CPSW_GLOBAL_UNLOCK(sc); + callout_drain(&sc->wd_callout); + } - /* Wait for stopping ticks */ - callout_drain(&sc->wd_callout); + bus_generic_detach(dev); + device_delete_child(dev, sc->miibus); /* Stop and release all interrupts */ for (i = 0; i < CPSW_INTR_COUNT; ++i) { @@ -355,14 +408,17 @@ cpsw_detach(device_t dev) cpsw_intrs[i + 1].description); } - /* Detach network interface */ - if (sc->ifp) { - ether_ifdetach(sc->ifp); - if_free(sc->ifp); + /* Free dmamaps and mbufs */ + for (i = 0; i < CPSW_MAX_TX_BUFFERS; i++) { + cpsw_free_slot(sc, &sc->_tx_slots[i]); + } *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50ead77e.7f18.72ee35c1>