Date: Sat, 30 Jul 2011 13:28:12 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r224513 - in projects/hid: contrib/top release/amd64 release/i386 release/powerpc sbin/mount share/mk sys/cam sys/cam/ata sys/dev/ahci sys/dev/ath sys/dev/ath/ath_hal/ar5416 sys/dev/mpt... Message-ID: <201107301328.p6UDSCea001716@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sat Jul 30 13:28:11 2011 New Revision: 224513 URL: http://svn.freebsd.org/changeset/base/224513 Log: MFC@r224512 Modified: projects/hid/release/amd64/make-memstick.sh projects/hid/release/i386/make-memstick.sh projects/hid/release/powerpc/make-memstick.sh projects/hid/sbin/mount/mount.c projects/hid/sys/cam/ata/ata_da.c projects/hid/sys/cam/cam_periph.c projects/hid/sys/dev/ahci/ahci.c projects/hid/sys/dev/ahci/ahci.h projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416.h projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c projects/hid/sys/dev/ath/if_ath_sysctl.c projects/hid/sys/dev/mpt/mpt.c projects/hid/sys/dev/mpt/mpt.h projects/hid/sys/dev/mpt/mpt_cam.c projects/hid/sys/dev/mpt/mpt_debug.c projects/hid/sys/dev/mpt/mpt_pci.c projects/hid/sys/dev/mpt/mpt_raid.c projects/hid/sys/dev/mpt/mpt_raid.h projects/hid/sys/dev/mpt/mpt_user.c projects/hid/sys/dev/re/if_re.c projects/hid/sys/dev/usb/input/ums.c projects/hid/sys/pci/if_rlreg.h projects/hid/sys/powerpc/powermac/fcu.c projects/hid/sys/ufs/ffs/ffs_alloc.c projects/hid/sys/ufs/ffs/ffs_softdep.c projects/hid/sys/ufs/ffs/ffs_vfsops.c projects/hid/sys/ufs/ffs/ffs_vnops.c projects/hid/sys/ufs/ufs/inode.h projects/hid/usr.sbin/mfiutil/mfi_show.c Directory Properties: projects/hid/ (props changed) projects/hid/cddl/contrib/opensolaris/ (props changed) projects/hid/contrib/bind9/ (props changed) projects/hid/contrib/binutils/ (props changed) projects/hid/contrib/bzip2/ (props changed) projects/hid/contrib/compiler-rt/ (props changed) projects/hid/contrib/dialog/ (props changed) projects/hid/contrib/ee/ (props changed) projects/hid/contrib/expat/ (props changed) projects/hid/contrib/file/ (props changed) projects/hid/contrib/gcc/ (props changed) projects/hid/contrib/gdb/ (props changed) projects/hid/contrib/gdtoa/ (props changed) projects/hid/contrib/gnu-sort/ (props changed) projects/hid/contrib/groff/ (props changed) projects/hid/contrib/less/ (props changed) projects/hid/contrib/libpcap/ (props changed) projects/hid/contrib/libstdc++/ (props changed) projects/hid/contrib/llvm/ (props changed) projects/hid/contrib/llvm/tools/clang/ (props changed) projects/hid/contrib/ncurses/ (props changed) projects/hid/contrib/netcat/ (props changed) projects/hid/contrib/ntp/ (props changed) projects/hid/contrib/one-true-awk/ (props changed) projects/hid/contrib/openbsm/ (props changed) projects/hid/contrib/openpam/ (props changed) projects/hid/contrib/pf/ (props changed) projects/hid/contrib/sendmail/ (props changed) projects/hid/contrib/tcpdump/ (props changed) projects/hid/contrib/tcsh/ (props changed) projects/hid/contrib/tnftp/ (props changed) projects/hid/contrib/top/ (props changed) projects/hid/contrib/top/install-sh (props changed) projects/hid/contrib/tzcode/stdtime/ (props changed) projects/hid/contrib/tzcode/zic/ (props changed) projects/hid/contrib/tzdata/ (props changed) projects/hid/contrib/wpa/ (props changed) projects/hid/contrib/xz/ (props changed) projects/hid/crypto/openssh/ (props changed) projects/hid/crypto/openssl/ (props changed) projects/hid/gnu/lib/ (props changed) projects/hid/gnu/usr.bin/binutils/ (props changed) projects/hid/gnu/usr.bin/cc/cc_tools/ (props changed) projects/hid/gnu/usr.bin/gdb/ (props changed) projects/hid/lib/libc/ (props changed) projects/hid/lib/libc/stdtime/ (props changed) projects/hid/lib/libutil/ (props changed) projects/hid/lib/libz/ (props changed) projects/hid/sbin/ (props changed) projects/hid/sbin/ipfw/ (props changed) projects/hid/share/mk/bsd.arch.inc.mk (props changed) projects/hid/share/zoneinfo/ (props changed) projects/hid/sys/ (props changed) projects/hid/sys/amd64/include/xen/ (props changed) projects/hid/sys/boot/ (props changed) projects/hid/sys/boot/i386/efi/ (props changed) projects/hid/sys/boot/ia64/efi/ (props changed) projects/hid/sys/boot/ia64/ski/ (props changed) projects/hid/sys/boot/powerpc/boot1.chrp/ (props changed) projects/hid/sys/boot/powerpc/ofw/ (props changed) projects/hid/sys/cddl/contrib/opensolaris/ (props changed) projects/hid/sys/conf/ (props changed) projects/hid/sys/contrib/dev/acpica/ (props changed) projects/hid/sys/contrib/octeon-sdk/ (props changed) projects/hid/sys/contrib/pf/ (props changed) projects/hid/sys/contrib/x86emu/ (props changed) projects/hid/usr.bin/calendar/ (props changed) projects/hid/usr.bin/csup/ (props changed) projects/hid/usr.bin/procstat/ (props changed) projects/hid/usr.sbin/ndiscvt/ (props changed) projects/hid/usr.sbin/rtadvctl/ (props changed) projects/hid/usr.sbin/rtadvd/ (props changed) projects/hid/usr.sbin/zic/ (props changed) Modified: projects/hid/release/amd64/make-memstick.sh ============================================================================== --- projects/hid/release/amd64/make-memstick.sh Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/release/amd64/make-memstick.sh Sat Jul 30 13:28:11 2011 (r224513) @@ -32,7 +32,7 @@ if [ -e ${2} ]; then exit 1 fi -echo '/dev/gpt/FreeBSD_Install / ufs rw,noatime 1 1' > ${1}/etc/fstab +echo '/dev/gpt/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab rm -f ${tempfile} makefs -B little ${tempfile} ${1} if [ $? -ne 0 ]; then Modified: projects/hid/release/i386/make-memstick.sh ============================================================================== --- projects/hid/release/i386/make-memstick.sh Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/release/i386/make-memstick.sh Sat Jul 30 13:28:11 2011 (r224513) @@ -32,7 +32,7 @@ if [ -e ${2} ]; then exit 1 fi -echo '/dev/gpt/FreeBSD_Install / ufs rw,noatime 1 1' > ${1}/etc/fstab +echo '/dev/gpt/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab rm -f ${tempfile} makefs -B little ${tempfile} ${1} if [ $? -ne 0 ]; then Modified: projects/hid/release/powerpc/make-memstick.sh ============================================================================== --- projects/hid/release/powerpc/make-memstick.sh Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/release/powerpc/make-memstick.sh Sat Jul 30 13:28:11 2011 (r224513) @@ -32,7 +32,7 @@ if [ -e ${2} ]; then exit 1 fi -echo '/dev/da0s3 / ufs rw,noatime 1 1' > ${1}/etc/fstab +echo '/dev/da0s3 / ufs ro,noatime 1 1' > ${1}/etc/fstab rm -f ${tempfile} makefs -B big ${tempfile} ${1} if [ $? -ne 0 ]; then Modified: projects/hid/sbin/mount/mount.c ============================================================================== --- projects/hid/sbin/mount/mount.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sbin/mount/mount.c Sat Jul 30 13:28:11 2011 (r224513) @@ -317,7 +317,7 @@ main(int argc, char *argv[]) rval = 0; switch (argc) { case 0: - if ((mntsize = getmntinfo(&mntbuf, MNT_WAIT)) == 0) + if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) err(1, "getmntinfo"); if (all) { while ((fs = getfsent()) != NULL) { @@ -666,7 +666,7 @@ getmntpt(const char *name) struct statfs *mntbuf; int i, mntsize; - mntsize = getmntinfo(&mntbuf, MNT_WAIT); + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = mntsize - 1; i >= 0; i--) { if (strcmp(mntbuf[i].f_mntfromname, name) == 0 || strcmp(mntbuf[i].f_mntonname, name) == 0) Modified: projects/hid/sys/cam/ata/ata_da.c ============================================================================== --- projects/hid/sys/cam/ata/ata_da.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/cam/ata/ata_da.c Sat Jul 30 13:28:11 2011 (r224513) @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #define ATA_MAX_28BIT_LBA 268435455UL typedef enum { + ADA_STATE_RAHEAD, ADA_STATE_WCACHE, ADA_STATE_NORMAL } ada_state; @@ -94,7 +95,8 @@ typedef enum { } ada_quirks; typedef enum { - ADA_CCB_WCACHE = 0x01, + ADA_CCB_RAHEAD = 0x01, + ADA_CCB_WCACHE = 0x02, ADA_CCB_BUFFER_IO = 0x03, ADA_CCB_WAITING = 0x04, ADA_CCB_DUMP = 0x05, @@ -132,6 +134,7 @@ struct ada_softc { int outstanding_cmds; int trim_max_ranges; int trim_running; + int read_ahead; int write_cache; #ifdef ADA_TEST_FAILURE int force_read_error; @@ -294,10 +297,19 @@ static void adaresume(void *arg); #define ADA_DEFAULT_SPINDOWN_SUSPEND 1 #endif +#ifndef ADA_DEFAULT_READ_AHEAD +#define ADA_DEFAULT_READ_AHEAD 1 +#endif + #ifndef ADA_DEFAULT_WRITE_CACHE #define ADA_DEFAULT_WRITE_CACHE 1 #endif +#define ADA_RA (softc->read_ahead >= 0 ? \ + softc->read_ahead : ada_read_ahead) +#define ADA_WC (softc->write_cache >= 0 ? \ + softc->write_cache : ada_write_cache) + /* * Most platforms map firmware geometry to actual, but some don't. If * not overridden, default to nothing. @@ -312,6 +324,7 @@ static int ada_default_timeout = ADA_DEF static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED; static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN; static int ada_spindown_suspend = ADA_DEFAULT_SPINDOWN_SUSPEND; +static int ada_read_ahead = ADA_DEFAULT_READ_AHEAD; static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, @@ -334,6 +347,9 @@ TUNABLE_INT("kern.cam.ada.spindown_shutd SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RW, &ada_spindown_suspend, 0, "Spin down upon suspend"); TUNABLE_INT("kern.cam.ada.spindown_suspend", &ada_spindown_suspend); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RW, + &ada_read_ahead, 0, "Enable disk read-ahead"); +TUNABLE_INT("kern.cam.ada.read_ahead", &ada_read_ahead); SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW, &ada_write_cache, 0, "Enable disk write cache"); TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache); @@ -737,16 +753,19 @@ adaasync(void *callback_arg, u_int32_t c softc = (struct ada_softc *)periph->softc; cam_periph_async(periph, code, path, arg); - if (ada_write_cache < 0 && softc->write_cache < 0) - break; if (softc->state != ADA_STATE_NORMAL) break; xpt_setup_ccb(&cgd.ccb_h, periph->path, CAM_PRIORITY_NORMAL); cgd.ccb_h.func_code = XPT_GDEV_TYPE; xpt_action((union ccb *)&cgd); - if ((cgd.ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) == 0) - break; - softc->state = ADA_STATE_WCACHE; + if (ADA_RA >= 0 && + cgd.ident_data.support.command1 & ATA_SUPPORT_LOOKAHEAD) + softc->state = ADA_STATE_RAHEAD; + else if (ADA_WC >= 0 && + cgd.ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) + softc->state = ADA_STATE_WCACHE; + else + break; cam_periph_acquire(periph); cam_freeze_devq_arg(periph->path, RELSIM_RELEASE_RUNLEVEL, CAM_RL_DEV + 1); @@ -789,6 +808,9 @@ adasysctlinit(void *context, int pending } SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), + OID_AUTO, "read_ahead", CTLFLAG_RW | CTLFLAG_MPSAFE, + &softc->read_ahead, 0, "Enable disk read ahead."); + SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "write_cache", CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->write_cache, 0, "Enable disk write cache."); #ifdef ADA_TEST_FAILURE @@ -922,6 +944,10 @@ adaregister(struct cam_periph *periph, v quirks = softc->quirks; TUNABLE_INT_FETCH(announce_buf, &quirks); softc->quirks = quirks; + softc->read_ahead = -1; + snprintf(announce_buf, sizeof(announce_buf), + "kern.cam.ada.%d.read_ahead", periph->unit_number); + TUNABLE_INT_FETCH(announce_buf, &softc->read_ahead); softc->write_cache = -1; snprintf(announce_buf, sizeof(announce_buf), "kern.cam.ada.%d.write_cache", periph->unit_number); @@ -1044,7 +1070,14 @@ adaregister(struct cam_periph *periph, v (ADA_DEFAULT_TIMEOUT * hz) / ADA_ORDEREDTAG_INTERVAL, adasendorderedtag, softc); - if ((ada_write_cache >= 0 || softc->write_cache >= 0) && + if (ADA_RA >= 0 && + cgd->ident_data.support.command1 & ATA_SUPPORT_LOOKAHEAD) { + softc->state = ADA_STATE_RAHEAD; + cam_periph_acquire(periph); + cam_freeze_devq_arg(periph->path, + RELSIM_RELEASE_RUNLEVEL, CAM_RL_DEV + 1); + xpt_schedule(periph, CAM_PRIORITY_DEV); + } else if (ADA_WC >= 0 && cgd->ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) { softc->state = ADA_STATE_WCACHE; cam_periph_acquire(periph); @@ -1317,8 +1350,19 @@ out: adaschedule(periph); break; } + case ADA_STATE_RAHEAD: case ADA_STATE_WCACHE: { + if (softc->flags & ADA_FLAG_PACK_INVALID) { + softc->state = ADA_STATE_NORMAL; + xpt_release_ccb(start_ccb); + cam_release_devq(periph->path, + RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_DEV + 1, FALSE); + adaschedule(periph); + cam_periph_release_locked(periph); + return; + } + cam_fill_ataio(ataio, 1, adadone, @@ -1328,10 +1372,15 @@ out: 0, ada_default_timeout*1000); - ata_28bit_cmd(ataio, ATA_SETFEATURES, (softc->write_cache > 0 || - (softc->write_cache < 0 && ada_write_cache)) ? - ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE, 0, 0); - start_ccb->ccb_h.ccb_state = ADA_CCB_WCACHE; + if (softc->state == ADA_STATE_RAHEAD) { + ata_28bit_cmd(ataio, ATA_SETFEATURES, ADA_RA ? + ATA_SF_ENAB_RCACHE : ATA_SF_DIS_RCACHE, 0, 0); + start_ccb->ccb_h.ccb_state = ADA_CCB_RAHEAD; + } else { + ata_28bit_cmd(ataio, ATA_SETFEATURES, ADA_WC ? + ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE, 0, 0); + start_ccb->ccb_h.ccb_state = ADA_CCB_WCACHE; + } xpt_action(start_ccb); break; } @@ -1343,6 +1392,7 @@ adadone(struct cam_periph *periph, union { struct ada_softc *softc; struct ccb_ataio *ataio; + struct ccb_getdev *cgd; softc = (struct ada_softc *)periph->softc; ataio = &done_ccb->ataio; @@ -1423,6 +1473,47 @@ adadone(struct cam_periph *periph, union biodone(bp); break; } + case ADA_CCB_RAHEAD: + { + if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + if (adaerror(done_ccb, 0, 0) == ERESTART) { + return; + } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { + cam_release_devq(done_ccb->ccb_h.path, + /*relsim_flags*/0, + /*reduction*/0, + /*timeout*/0, + /*getcount_only*/0); + } + } + + /* + * Since our peripheral may be invalidated by an error + * above or an external event, we must release our CCB + * before releasing the reference on the peripheral. + * The peripheral will only go away once the last reference + * is removed, and we need it around for the CCB release + * operation. + */ + cgd = (struct ccb_getdev *)done_ccb; + xpt_setup_ccb(&cgd->ccb_h, periph->path, CAM_PRIORITY_NORMAL); + cgd->ccb_h.func_code = XPT_GDEV_TYPE; + xpt_action((union ccb *)cgd); + if (ADA_WC >= 0 && + cgd->ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) { + softc->state = ADA_STATE_WCACHE; + xpt_release_ccb(done_ccb); + xpt_schedule(periph, CAM_PRIORITY_DEV); + return; + } + softc->state = ADA_STATE_NORMAL; + xpt_release_ccb(done_ccb); + cam_release_devq(periph->path, + RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_DEV + 1, FALSE); + adaschedule(periph); + cam_periph_release_locked(periph); + return; + } case ADA_CCB_WCACHE: { if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { Modified: projects/hid/sys/cam/cam_periph.c ============================================================================== --- projects/hid/sys/cam/cam_periph.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/cam/cam_periph.c Sat Jul 30 13:28:11 2011 (r224513) @@ -1550,7 +1550,8 @@ camperiphscsisenseerror(union ccb *ccb, * make sure we actually have retries available. */ if ((err_action & SSQ_DECREMENT_COUNT) != 0) { - if (ccb->ccb_h.retry_count > 0) + if (ccb->ccb_h.retry_count > 0 && + (periph->flags & CAM_PERIPH_INVALID) == 0) ccb->ccb_h.retry_count--; else { *action_string = "Retries exhausted"; @@ -1718,6 +1719,7 @@ int cam_periph_error(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags, union ccb *save_ccb) { + struct cam_periph *periph; const char *action_string; cam_status status; int frozen; @@ -1725,7 +1727,8 @@ cam_periph_error(union ccb *ccb, cam_fla int openings; u_int32_t relsim_flags; u_int32_t timeout = 0; - + + periph = xpt_path_periph(ccb->ccb_h.path); action_string = NULL; status = ccb->ccb_h.status; frozen = (status & CAM_DEV_QFRZN) != 0; @@ -1787,9 +1790,9 @@ cam_periph_error(union ccb *ccb, cam_fla xpt_print(ccb->ccb_h.path, "Data overrun\n"); printed++; } - error = EIO; /* we have to kill the command */ /* decrement the number of retries */ - if (ccb->ccb_h.retry_count > 0) { + if (ccb->ccb_h.retry_count > 0 && + (periph->flags & CAM_PERIPH_INVALID) == 0) { ccb->ccb_h.retry_count--; error = ERESTART; } else { @@ -1808,7 +1811,8 @@ cam_periph_error(union ccb *ccb, cam_fla struct cam_path *newpath; if ((camflags & CAM_RETRY_SELTO) != 0) { - if (ccb->ccb_h.retry_count > 0) { + if (ccb->ccb_h.retry_count > 0 && + (periph->flags & CAM_PERIPH_INVALID) == 0) { ccb->ccb_h.retry_count--; error = ERESTART; @@ -1826,10 +1830,11 @@ cam_periph_error(union ccb *ccb, cam_fla timeout = periph_selto_delay; break; } + action_string = "Retries exhausted"; } error = ENXIO; /* Should we do more if we can't create the path?? */ - if (xpt_create_path(&newpath, xpt_path_periph(ccb->ccb_h.path), + if (xpt_create_path(&newpath, periph, xpt_path_path_id(ccb->ccb_h.path), xpt_path_target_id(ccb->ccb_h.path), CAM_LUN_WILDCARD) != CAM_REQ_CMP) @@ -1874,11 +1879,16 @@ cam_periph_error(union ccb *ccb, cam_fla /* FALLTHROUGH */ case CAM_REQUEUE_REQ: /* Unconditional requeue */ - error = ERESTART; if (bootverbose && printed == 0) { xpt_print(ccb->ccb_h.path, "Request requeued\n"); printed++; } + if ((periph->flags & CAM_PERIPH_INVALID) == 0) + error = ERESTART; + else { + action_string = "Retries exhausted"; + error = EIO; + } break; case CAM_RESRC_UNAVAIL: /* Wait a bit for the resource shortage to abate. */ @@ -1893,7 +1903,8 @@ cam_periph_error(union ccb *ccb, cam_fla /* FALLTHROUGH */ default: /* decrement the number of retries */ - if (ccb->ccb_h.retry_count > 0) { + if (ccb->ccb_h.retry_count > 0 && + (periph->flags & CAM_PERIPH_INVALID) == 0) { ccb->ccb_h.retry_count--; error = ERESTART; if (bootverbose && printed == 0) { Modified: projects/hid/sys/dev/ahci/ahci.c ============================================================================== --- projects/hid/sys/dev/ahci/ahci.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ahci/ahci.c Sat Jul 30 13:28:11 2011 (r224513) @@ -1879,12 +1879,13 @@ ahci_execute_transaction(struct ahci_slo device_printf(dev, "Poll timeout on slot %d port %d\n", slot->slot, port); device_printf(dev, "is %08x cs %08x ss %08x " - "rs %08x tfd %02x serr %08x\n", + "rs %08x tfd %02x serr %08x cmd %08x\n", ATA_INL(ch->r_mem, AHCI_P_IS), ATA_INL(ch->r_mem, AHCI_P_CI), ATA_INL(ch->r_mem, AHCI_P_SACT), ch->rslots, ATA_INL(ch->r_mem, AHCI_P_TFD), - ATA_INL(ch->r_mem, AHCI_P_SERR)); + ATA_INL(ch->r_mem, AHCI_P_SERR), + ATA_INL(ch->r_mem, AHCI_P_CMD)); et = AHCI_ERR_TIMEOUT; } @@ -1960,8 +1961,12 @@ ahci_timeout(struct ahci_slot *slot) ccs = (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CCS_MASK) >> AHCI_P_CMD_CCS_SHIFT; if ((sstatus & (1 << slot->slot)) != 0 || ccs == slot->slot || - ch->fbs_enabled) + ch->fbs_enabled || ch->wrongccs) slot->state = AHCI_SLOT_EXECUTING; + else if ((ch->rslots & (1 << ccs)) == 0) { + ch->wrongccs = 1; + slot->state = AHCI_SLOT_EXECUTING; + } callout_reset(&slot->timeout, (int)slot->ccb->ccb_h.timeout * hz / 2000, @@ -1971,10 +1976,12 @@ ahci_timeout(struct ahci_slot *slot) device_printf(dev, "Timeout on slot %d port %d\n", slot->slot, slot->ccb->ccb_h.target_id & 0x0f); - device_printf(dev, "is %08x cs %08x ss %08x rs %08x tfd %02x serr %08x\n", + device_printf(dev, "is %08x cs %08x ss %08x rs %08x tfd %02x " + "serr %08x cmd %08x\n", ATA_INL(ch->r_mem, AHCI_P_IS), ATA_INL(ch->r_mem, AHCI_P_CI), ATA_INL(ch->r_mem, AHCI_P_SACT), ch->rslots, - ATA_INL(ch->r_mem, AHCI_P_TFD), ATA_INL(ch->r_mem, AHCI_P_SERR)); + ATA_INL(ch->r_mem, AHCI_P_TFD), ATA_INL(ch->r_mem, AHCI_P_SERR), + ATA_INL(ch->r_mem, AHCI_P_CMD)); /* Handle frozen command. */ if (ch->frozen) { @@ -1987,7 +1994,7 @@ ahci_timeout(struct ahci_slot *slot) } xpt_done(fccb); } - if (!ch->fbs_enabled) { + if (!ch->fbs_enabled && !ch->wrongccs) { /* Without FBS we know real timeout source. */ ch->fatalerr = 1; /* Handle command with timeout. */ @@ -2585,6 +2592,7 @@ ahci_reset(device_t dev) xpt_release_simq(ch->sim, TRUE); ch->eslots = 0; ch->toslots = 0; + ch->wrongccs = 0; ch->fatalerr = 0; /* Tell the XPT about the event */ xpt_async(AC_BUS_RESET, ch->path, NULL); Modified: projects/hid/sys/dev/ahci/ahci.h ============================================================================== --- projects/hid/sys/dev/ahci/ahci.h Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ahci/ahci.h Sat Jul 30 13:28:11 2011 (r224513) @@ -426,6 +426,7 @@ struct ahci_channel { int resetting; /* Hard-reset in progress. */ int resetpolldiv; /* Hard-reset poll divider. */ int listening; /* SUD bit is cleared. */ + int wrongccs; /* CCS field in CMD was wrong */ union ccb *frozen; /* Frozen command */ struct callout pm_timer; /* Power management events */ struct callout reset_timer; /* Hard-reset timeout */ Modified: projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416.h Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416.h Sat Jul 30 13:28:11 2011 (r224513) @@ -218,6 +218,8 @@ extern HAL_BOOL ar5416ResetKeyCacheEntry extern HAL_BOOL ar5416SetKeyCacheEntry(struct ath_hal *ah, uint16_t entry, const HAL_KEYVAL *k, const uint8_t *mac, int xorKey); +extern uint32_t ar5416GetRxFilter(struct ath_hal *ah); +extern void ar5416SetRxFilter(struct ath_hal *ah, uint32_t bits); extern void ar5416StartPcuReceive(struct ath_hal *ah); extern void ar5416StopPcuReceive(struct ath_hal *ah); extern HAL_BOOL ar5416SetupRxDesc(struct ath_hal *, Modified: projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c ============================================================================== --- projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Sat Jul 30 13:28:11 2011 (r224513) @@ -117,6 +117,8 @@ ar5416InitState(struct ath_hal_5416 *ahp ah->ah_resetTxQueue = ar5416ResetTxQueue; /* Receive Functions */ + ah->ah_getRxFilter = ar5416GetRxFilter; + ah->ah_setRxFilter = ar5416SetRxFilter; ah->ah_startPcuReceive = ar5416StartPcuReceive; ah->ah_stopPcuReceive = ar5416StopPcuReceive; ah->ah_setupRxDesc = ar5416SetupRxDesc; Modified: projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c ============================================================================== --- projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Sat Jul 30 13:28:11 2011 (r224513) @@ -73,8 +73,15 @@ ar5416IsCalSupp(struct ath_hal *ah, cons case ADC_GAIN_CAL: case ADC_DC_CAL: /* Run ADC Gain Cal for either 5ghz any or 2ghz HT40 */ - if (IEEE80211_IS_CHAN_5GHZ(chan)) - return AH_TRUE; + /* + * Merlin (AR9280) doesn't ever complete ADC calibrations + * in 5ghz non-HT40 mode (ie, HT20, 11a). For now, disable + * it for Merlin only until further information is + * available. + */ + if (! AR_SREV_MERLIN(ah)) + if (IEEE80211_IS_CHAN_5GHZ(chan)) + return AH_TRUE; if (IEEE80211_IS_CHAN_HT40(chan)) return AH_TRUE; return AH_FALSE; @@ -186,36 +193,22 @@ ar5416RunInitCals(struct ath_hal *ah, in } #endif + +/* + * AGC calibration for the AR5416, AR9130, AR9160, AR9280. + */ HAL_BOOL ar5416InitCalHardware(struct ath_hal *ah, const struct ieee80211_channel *chan) { - if (AR_SREV_MERLIN_10_OR_LATER(ah)) { - /* Enable Rx Filter Cal */ - OS_REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); - OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, - AR_PHY_AGC_CONTROL_FLTR_CAL); - - /* Clear the carrier leak cal bit */ - OS_REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); - - /* kick off the cal */ - OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL); - /* Poll for offset calibration complete */ - if (!ath_hal_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) { - HALDEBUG(ah, HAL_DEBUG_ANY, - "%s: offset calibration failed to complete in 1ms; " - "noisy environment?\n", __func__); - return AH_FALSE; - } + if (AR_SREV_MERLIN_10_OR_LATER(ah)) { + /* Disable ADC */ + OS_REG_CLR_BIT(ah, AR_PHY_ADC_CTL, + AR_PHY_ADC_CTL_OFF_PWDADC); - /* Set the cl cal bit and rerun the cal a 2nd time */ /* Enable Rx Filter Cal */ - OS_REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); - - OS_REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); } /* Calibrate the AGC */ @@ -229,6 +222,16 @@ ar5416InitCalHardware(struct ath_hal *ah return AH_FALSE; } + if (AR_SREV_MERLIN_10_OR_LATER(ah)) { + /* Enable ADC */ + OS_REG_SET_BIT(ah, AR_PHY_ADC_CTL, + AR_PHY_ADC_CTL_OFF_PWDADC); + + /* Disable Rx Filter Cal */ + OS_REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, + AR_PHY_AGC_CONTROL_FLTR_CAL); + } + return AH_TRUE; } @@ -247,7 +250,8 @@ ar5416InitCal(struct ath_hal *ah, const /* Do initial chipset-specific calibration */ if (! AH5416(ah)->ah_cal_initcal(ah, chan)) { - HALDEBUG(ah, HAL_DEBUG_ANY, "%s: initial chipset calibration did " + HALDEBUG(ah, HAL_DEBUG_ANY, + "%s: initial chipset calibration did " "not complete in time; noisy environment?\n", __func__); return AH_FALSE; } Modified: projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c ============================================================================== --- projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Sat Jul 30 13:28:11 2011 (r224513) @@ -27,6 +27,46 @@ #include "ar5416/ar5416desc.h" /* + * Get the receive filter. + */ +uint32_t +ar5416GetRxFilter(struct ath_hal *ah) +{ + uint32_t bits = OS_REG_READ(ah, AR_RX_FILTER); + uint32_t phybits = OS_REG_READ(ah, AR_PHY_ERR); + + if (phybits & AR_PHY_ERR_RADAR) + bits |= HAL_RX_FILTER_PHYRADAR; + if (phybits & (AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING)) + bits |= HAL_RX_FILTER_PHYERR; + return bits; +} + +/* + * Set the receive filter. + */ +void +ar5416SetRxFilter(struct ath_hal *ah, u_int32_t bits) +{ + uint32_t phybits; + + OS_REG_WRITE(ah, AR_RX_FILTER, (bits & 0xffff)); + phybits = 0; + if (bits & HAL_RX_FILTER_PHYRADAR) + phybits |= AR_PHY_ERR_RADAR; + if (bits & HAL_RX_FILTER_PHYERR) + phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING; + OS_REG_WRITE(ah, AR_PHY_ERR, phybits); + if (phybits) { + OS_REG_WRITE(ah, AR_RXCFG, + OS_REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA); + } else { + OS_REG_WRITE(ah, AR_RXCFG, + OS_REG_READ(ah, AR_RXCFG) &~ AR_RXCFG_ZLFDMA); + } +} + +/* * Start receive at the PCU engine */ void Modified: projects/hid/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- projects/hid/sys/dev/ath/if_ath_sysctl.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/ath/if_ath_sysctl.c Sat Jul 30 13:28:11 2011 (r224513) @@ -354,7 +354,21 @@ ath_sysctl_intmit(SYSCTL_HANDLER_ARGS) error = sysctl_handle_int(oidp, &intmit, 0, req); if (error || !req->newptr) return error; - return !ath_hal_setintmit(sc->sc_ah, intmit) ? EINVAL : 0; + + /* reusing error; 1 here means "good"; 0 means "fail" */ + error = ath_hal_setintmit(sc->sc_ah, intmit); + if (! error) + return EINVAL; + + /* + * Reset the hardware here - disabling ANI in the HAL + * doesn't reset ANI related registers, so it'll leave + * things in an inconsistent state. + */ + if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) + ath_reset(sc->sc_ifp); + + return 0; } #ifdef IEEE80211_SUPPORT_TDMA Modified: projects/hid/sys/dev/mpt/mpt.c ============================================================================== --- projects/hid/sys/dev/mpt/mpt.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/mpt/mpt.c Sat Jul 30 13:28:11 2011 (r224513) @@ -301,66 +301,75 @@ mpt_modevent(module_t mod, int type, voi return (error); } -int +static int mpt_stdload(struct mpt_personality *pers) { + /* Load is always successful. */ return (0); } -int +static int mpt_stdprobe(struct mpt_softc *mpt) { + /* Probe is always successful. */ return (0); } -int +static int mpt_stdattach(struct mpt_softc *mpt) { + /* Attach is always successful. */ return (0); } -int +static int mpt_stdenable(struct mpt_softc *mpt) { + /* Enable is always successful. */ return (0); } -void +static void mpt_stdready(struct mpt_softc *mpt) { -} +} -int +static int mpt_stdevent(struct mpt_softc *mpt, request_t *req, MSG_EVENT_NOTIFY_REPLY *msg) { + mpt_lprt(mpt, MPT_PRT_DEBUG, "mpt_stdevent: 0x%x\n", msg->Event & 0xFF); /* Event was not for us. */ return (0); } -void +static void mpt_stdreset(struct mpt_softc *mpt, int type) { + } -void +static void mpt_stdshutdown(struct mpt_softc *mpt) { + } -void +static void mpt_stddetach(struct mpt_softc *mpt) { + } -int +static int mpt_stdunload(struct mpt_personality *pers) { + /* Unload is always successful. */ return (0); } @@ -383,7 +392,6 @@ mpt_postattach(void *unused) } SYSINIT(mptdev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, mpt_postattach, NULL); - /******************************* Bus DMA Support ******************************/ void mpt_map_rquest(void *arg, bus_dma_segment_t *segs, int nseg, int error) @@ -478,6 +486,7 @@ static int mpt_default_reply_handler(struct mpt_softc *mpt, request_t *req, uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame) { + mpt_prt(mpt, "Default Handler Called: req=%p:%u reply_descriptor=%x frame=%p\n", req, req->serno, reply_desc, reply_frame); @@ -494,8 +503,8 @@ static int mpt_config_reply_handler(struct mpt_softc *mpt, request_t *req, uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame) { - if (req != NULL) { + if (req != NULL) { if (reply_frame != NULL) { MSG_CONFIG *cfgp; MSG_CONFIG_REPLY *reply; @@ -528,6 +537,7 @@ static int mpt_handshake_reply_handler(struct mpt_softc *mpt, request_t *req, uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame) { + /* Nothing to be done. */ return (TRUE); } @@ -650,6 +660,7 @@ static int mpt_core_event(struct mpt_softc *mpt, request_t *req, MSG_EVENT_NOTIFY_REPLY *msg) { + mpt_lprt(mpt, MPT_PRT_DEBUG, "mpt_core_event: 0x%x\n", msg->Event & 0xFF); switch(msg->Event & 0xFF) { @@ -870,6 +881,7 @@ mpt_complete_request_chain(struct mpt_so void mpt_dump_reply_frame(struct mpt_softc *mpt, MSG_DEFAULT_REPLY *reply_frame) { + mpt_prt(mpt, "Address Reply:\n"); mpt_print_reply(reply_frame); } @@ -881,12 +893,14 @@ static __inline uint32_t mpt_rd_intr(st static __inline uint32_t mpt_rd_db(struct mpt_softc *mpt) { + return mpt_read(mpt, MPT_OFFSET_DOORBELL); } static __inline uint32_t mpt_rd_intr(struct mpt_softc *mpt) { + return mpt_read(mpt, MPT_OFFSET_INTR_STATUS); } @@ -895,6 +909,7 @@ static int mpt_wait_db_ack(struct mpt_softc *mpt) { int i; + for (i=0; i < MPT_MAX_WAIT; i++) { if (!MPT_DB_IS_BUSY(mpt_rd_intr(mpt))) { maxwait_ack = i > maxwait_ack ? i : maxwait_ack; @@ -910,6 +925,7 @@ static int mpt_wait_db_int(struct mpt_softc *mpt) { int i; + for (i = 0; i < MPT_MAX_WAIT; i++) { if (MPT_DB_INTR(mpt_rd_intr(mpt))) { maxwait_int = i > maxwait_int ? i : maxwait_int; @@ -925,6 +941,7 @@ void mpt_check_doorbell(struct mpt_softc *mpt) { uint32_t db = mpt_rd_db(mpt); + if (MPT_STATE(db) != MPT_DB_STATE_RUNNING) { mpt_prt(mpt, "Device not running\n"); mpt_print_db(db); @@ -956,6 +973,7 @@ static int mpt_download_fw(struct mpt_so static int mpt_soft_reset(struct mpt_softc *mpt) { + mpt_lprt(mpt, MPT_PRT_DEBUG, "soft reset\n"); /* Have to use hard reset if we are not in Running state */ @@ -1019,6 +1037,7 @@ mpt_enable_diag_mode(struct mpt_softc *m static void mpt_disable_diag_mode(struct mpt_softc *mpt) { + mpt_write(mpt, MPT_OFFSET_SEQUENCE, 0xFFFFFFFF); } @@ -1094,6 +1113,7 @@ mpt_hard_reset(struct mpt_softc *mpt) static void mpt_core_ioc_reset(struct mpt_softc *mpt, int type) { + /* * Complete all pending requests with a status * appropriate for an IOC reset. @@ -1102,7 +1122,6 @@ mpt_core_ioc_reset(struct mpt_softc *mpt MPI_IOCSTATUS_INVALID_STATE); } - /* * Reset the IOC when needed. Try software command first then if needed * poke at the magic diagnostic reset. Note that a hard reset resets @@ -1263,6 +1282,7 @@ retry: void mpt_send_cmd(struct mpt_softc *mpt, request_t *req) { + if (mpt->verbose > MPT_PRT_DEBUG2) { mpt_dump_request(mpt, req); } @@ -2110,6 +2130,7 @@ mpt_send_event_request(struct mpt_softc void mpt_enable_ints(struct mpt_softc *mpt) { + /* Unmask every thing except door bell int */ mpt_write(mpt, MPT_OFFSET_INTR_MASK, MPT_INTR_DB_MASK); } @@ -2120,6 +2141,7 @@ mpt_enable_ints(struct mpt_softc *mpt) void mpt_disable_ints(struct mpt_softc *mpt) { + /* Mask all interrupts */ mpt_write(mpt, MPT_OFFSET_INTR_MASK, MPT_INTR_REPLY_MASK | MPT_INTR_DB_MASK); @@ -2219,7 +2241,7 @@ mpt_detach(struct mpt_softc *mpt) return (0); } -int +static int mpt_core_load(struct mpt_personality *pers) { int i; @@ -2245,7 +2267,7 @@ mpt_core_load(struct mpt_personality *pe * Initialize per-instance driver data and perform * initial controller configuration. */ -int +static int mpt_core_attach(struct mpt_softc *mpt) { int val, error; @@ -2276,9 +2298,10 @@ mpt_core_attach(struct mpt_softc *mpt) return (error); } -int +static int mpt_core_enable(struct mpt_softc *mpt) { + /* * We enter with the IOC enabled, but async events * not enabled, ports not enabled and interrupts @@ -2326,13 +2349,14 @@ mpt_core_enable(struct mpt_softc *mpt) return (0); } -void +static void mpt_core_shutdown(struct mpt_softc *mpt) { + mpt_disable_ints(mpt); } -void +static void mpt_core_detach(struct mpt_softc *mpt) { int val; @@ -2351,9 +2375,10 @@ mpt_core_detach(struct mpt_softc *mpt) mpt_dma_buf_free(mpt); } -int +static int mpt_core_unload(struct mpt_personality *pers) { + /* Unload is always successful. */ return (0); } @@ -2575,6 +2600,7 @@ static void mpt_dma_buf_free(struct mpt_softc *mpt) { int i; + if (mpt->request_dmat == 0) { mpt_lprt(mpt, MPT_PRT_DEBUG, "already released dma memory\n"); return; Modified: projects/hid/sys/dev/mpt/mpt.h ============================================================================== --- projects/hid/sys/dev/mpt/mpt.h Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/mpt/mpt.h Sat Jul 30 13:28:11 2011 (r224513) @@ -1075,16 +1075,6 @@ mpt_complete_request_chain(struct mpt_so int mpt_reset(struct mpt_softc *, int /*reinit*/); /****************************** Debugging ************************************/ -typedef struct mpt_decode_entry { - char *name; - u_int value; - u_int mask; -} mpt_decode_entry_t; - -int mpt_decode_value(mpt_decode_entry_t *table, u_int num_entries, - const char *name, u_int value, u_int *cur_column, - u_int wrap_point); - void mpt_dump_data(struct mpt_softc *, const char *, void *, int); void mpt_dump_request(struct mpt_softc *, request_t *); @@ -1110,17 +1100,21 @@ do { \ mpt_prt(mpt, __VA_ARGS__); \ } while (0) +#if 0 #define mpt_lprtc(mpt, level, ...) \ do { \ if (level <= (mpt)->verbose) \ mpt_prtc(mpt, __VA_ARGS__); \ } while (0) +#endif #else void mpt_lprt(struct mpt_softc *, int, const char *, ...) __printflike(3, 4); +#if 0 void mpt_lprtc(struct mpt_softc *, int, const char *, ...) __printflike(3, 4); #endif +#endif void mpt_prt(struct mpt_softc *, const char *, ...) __printflike(2, 3); void mpt_prtc(struct mpt_softc *, const char *, ...) @@ -1277,7 +1271,6 @@ void mpt_check_doorbell(struct mpt_soft void mpt_dump_reply_frame(struct mpt_softc *mpt, MSG_DEFAULT_REPLY *reply_frame); -void mpt_set_config_regs(struct mpt_softc *); int mpt_issue_cfg_req(struct mpt_softc */*mpt*/, request_t */*req*/, cfgparms_t *params, bus_addr_t /*addr*/, bus_size_t/*len*/, @@ -1331,6 +1324,5 @@ char *mpt_ioc_diag(uint32_t diag); void mpt_req_state(mpt_req_state_t state); void mpt_print_config_request(void *vmsg); void mpt_print_request(void *vmsg); -void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *msg); void mpt_dump_sgl(SGE_IO_UNION *se, int offset); #endif /* _MPT_H_ */ Modified: projects/hid/sys/dev/mpt/mpt_cam.c ============================================================================== --- projects/hid/sys/dev/mpt/mpt_cam.c Sat Jul 30 13:25:11 2011 (r224512) +++ projects/hid/sys/dev/mpt/mpt_cam.c Sat Jul 30 13:28:11 2011 (r224513) @@ -193,7 +193,7 @@ MODULE_DEPEND(mpt_cam, cam, 1, 1, 1); int mpt_enable_sata_wc = -1; TUNABLE_INT("hw.mpt.enable_sata_wc", &mpt_enable_sata_wc); -int +static int mpt_cam_probe(struct mpt_softc *mpt) { int role; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107301328.p6UDSCea001716>