diff options
| author | Alexander Motin <mav@FreeBSD.org> | 2010-01-28 08:41:30 +0000 |
|---|---|---|
| committer | Alexander Motin <mav@FreeBSD.org> | 2010-01-28 08:41:30 +0000 |
| commit | 83c5d981ac176d1cfae8d6dab3c0420ed9d43477 (patch) | |
| tree | d7388e60da90bf39b478369ea46d12722c323f78 /sys/dev | |
| parent | e59faa5014f233788065a5306b0bdd22343ec2cf (diff) | |
Notes
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ahci/ahci.c | 55 | ||||
| -rw-r--r-- | sys/dev/ahci/ahci.h | 15 | ||||
| -rw-r--r-- | sys/dev/asr/asr.c | 1 | ||||
| -rw-r--r-- | sys/dev/ata/ata-all.c | 27 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-cam.c | 32 | ||||
| -rw-r--r-- | sys/dev/ciss/ciss.c | 48 | ||||
| -rw-r--r-- | sys/dev/hptiop/hptiop.c | 29 | ||||
| -rw-r--r-- | sys/dev/hptrr/hptrr_osm_bsd.c | 32 | ||||
| -rw-r--r-- | sys/dev/hptrr/os_bsd.h | 1 | ||||
| -rw-r--r-- | sys/dev/mly/mly.c | 22 | ||||
| -rw-r--r-- | sys/dev/mpt/mpt_cam.h | 1 | ||||
| -rw-r--r-- | sys/dev/mpt/mpt_raid.c | 17 | ||||
| -rw-r--r-- | sys/dev/ppbus/vpo.c | 37 | ||||
| -rw-r--r-- | sys/dev/siis/siis.c | 35 | ||||
| -rw-r--r-- | sys/dev/trm/trm.c | 18 | ||||
| -rw-r--r-- | sys/dev/twa/tw_osl_cam.c | 59 | ||||
| -rw-r--r-- | sys/dev/usb/storage/umass.c | 77 |
17 files changed, 138 insertions, 368 deletions
diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 789a8aa717af..ecff8a02391b 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include <cam/cam_ccb.h> #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_debug.h> /* local prototypes */ @@ -86,7 +85,7 @@ static void ahci_start_fr(device_t dev); static void ahci_stop_fr(device_t dev); static int ahci_sata_connect(struct ahci_channel *ch); -static int ahci_sata_phy_reset(device_t dev, int quick); +static int ahci_sata_phy_reset(device_t dev); static void ahci_issue_read_log(device_t dev); static void ahci_process_read_log(device_t dev, union ccb *ccb); @@ -348,6 +347,8 @@ ahci_attach(device_t dev) ctlr->caps = ATA_INL(ctlr->r_mem, AHCI_CAP); if (version >= 0x00010020) ctlr->caps2 = ATA_INL(ctlr->r_mem, AHCI_CAP2); + if (ctlr->caps & AHCI_CAP_EMS) + ctlr->capsem = ATA_INL(ctlr->r_mem, AHCI_EM_CTL); ctlr->ichannels = ATA_INL(ctlr->r_mem, AHCI_PI); if (ctlr->quirks & AHCI_Q_1CH) { ctlr->caps &= ~AHCI_CAP_NPMASK; @@ -417,6 +418,17 @@ ahci_attach(device_t dev) (ctlr->caps2 & AHCI_CAP2_NVMP) ? " NVMP":"", (ctlr->caps2 & AHCI_CAP2_BOH) ? " BOH":""); } + if (bootverbose && (ctlr->caps & AHCI_CAP_EMS)) { + device_printf(dev, "EM Caps: %s%s%s%s%s%s%s%s\n", + (ctlr->capsem & AHCI_EM_PM) ? " PM":"", + (ctlr->capsem & AHCI_EM_ALHD) ? " ALHD":"", + (ctlr->capsem & AHCI_EM_XMT) ? " XMT":"", + (ctlr->capsem & AHCI_EM_SMB) ? " SMB":"", + (ctlr->capsem & AHCI_EM_SGPIO) ? " SGPIO":"", + (ctlr->capsem & AHCI_EM_SES2) ? " SES-2":"", + (ctlr->capsem & AHCI_EM_SAFTE) ? " SAF-TE":"", + (ctlr->capsem & AHCI_EM_LED) ? " LED":""); + } /* Attach all channels on this controller */ for (unit = 0; unit < ctlr->channels; unit++) { if ((ctlr->ichannels & (1 << unit)) == 0) @@ -1131,6 +1143,8 @@ ahci_phy_check_events(device_t dev, u_int32_t serr) if ((serr & ATA_SE_PHY_CHANGED) && (ch->pm_level == 0)) { u_int32_t status = ATA_INL(ch->r_mem, AHCI_P_SSTS); + union ccb *ccb; + if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) { @@ -1142,6 +1156,15 @@ ahci_phy_check_events(device_t dev, u_int32_t serr) device_printf(dev, "DISCONNECT requested\n"); ch->devices = 0; } + if ((ccb = xpt_alloc_ccb_nowait()) == NULL) + return; + if (xpt_create_path(&ccb->ccb_h.path, NULL, + cam_sim_path(ch->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); + return; + } + xpt_rescan(ccb); } } @@ -1511,6 +1534,13 @@ ahci_execute_transaction(struct ahci_slot *slot) if (timeout && (count >= timeout)) { device_printf(ch->dev, "Poll timeout on slot %d\n", slot->slot); + device_printf(dev, "is %08x cs %08x ss %08x " + "rs %08x tfd %02x serr %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)); et = AHCI_ERR_TIMEOUT; } if (et != AHCI_ERR_NONE) { @@ -1935,7 +1965,7 @@ ahci_wait_ready(device_t dev, int t) (ATA_S_BUSY | ATA_S_DRQ)) { DELAY(1000); if (timeout++ > t) { - device_printf(dev, "port is not ready (timeout %dms) " + device_printf(dev, "device is not ready (timeout %dms) " "tfd = %08x\n", t, val); return (EBUSY); } @@ -1952,6 +1982,7 @@ ahci_reset(device_t dev) struct ahci_controller *ctlr = device_get_softc(device_get_parent(dev)); int i; + xpt_freeze_simq(ch->sim, 1); if (bootverbose) device_printf(dev, "AHCI reset...\n"); /* Requeue freezed command. */ @@ -1986,7 +2017,7 @@ ahci_reset(device_t dev) /* Disable port interrupts */ ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); /* Reset and reconnect PHY, */ - if (!ahci_sata_phy_reset(dev, 0)) { + if (!ahci_sata_phy_reset(dev)) { if (bootverbose) device_printf(dev, "AHCI reset done: phy reset found no device\n"); @@ -1994,13 +2025,12 @@ ahci_reset(device_t dev) /* Enable wanted port interrupts */ ATA_OUTL(ch->r_mem, AHCI_P_IE, (AHCI_P_IX_CPD | AHCI_P_IX_PRC | AHCI_P_IX_PC)); + xpt_release_simq(ch->sim, TRUE); return; } /* Wait for clearing busy status. */ - if (ahci_wait_ready(dev, 10000)) { - device_printf(dev, "device ready timeout\n"); + if (ahci_wait_ready(dev, 15000)) ahci_clo(dev); - } ahci_start(dev); ch->devices = 1; /* Enable wanted port interrupts */ @@ -2012,6 +2042,7 @@ ahci_reset(device_t dev) AHCI_P_IX_DS | AHCI_P_IX_PS | (ctlr->ccc ? 0 : AHCI_P_IX_DHR))); if (bootverbose) device_printf(dev, "AHCI reset done: device found\n"); + xpt_release_simq(ch->sim, TRUE); } static int @@ -2104,20 +2135,12 @@ ahci_sata_connect(struct ahci_channel *ch) } static int -ahci_sata_phy_reset(device_t dev, int quick) +ahci_sata_phy_reset(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); int sata_rev; uint32_t val; - if (quick) { - val = ATA_INL(ch->r_mem, AHCI_P_SCTL); - if ((val & ATA_SC_DET_MASK) == ATA_SC_DET_IDLE) - return (ahci_sata_connect(ch)); - } - - if (bootverbose) - device_printf(dev, "hardware reset ...\n"); sata_rev = ch->user[ch->pm_present ? 15 : 0].revision; if (sata_rev == 1) val = ATA_SC_SPD_SPEED_GEN1; diff --git a/sys/dev/ahci/ahci.h b/sys/dev/ahci/ahci.h index e11f84f489d3..d136d82b3265 100644 --- a/sys/dev/ahci/ahci.h +++ b/sys/dev/ahci/ahci.h @@ -186,6 +186,20 @@ #define AHCI_CCCC_EN 0x00000001 #define AHCI_CCCP 0x18 +#define AHCI_EM_LOC 0x1C +#define AHCI_EM_CTL 0x20 +#define AHCI_EM_MR 0x00000001 +#define AHCI_EM_TM 0x00000100 +#define AHCI_EM_RST 0x00000200 +#define AHCI_EM_LED 0x00010000 +#define AHCI_EM_SAFTE 0x00020000 +#define AHCI_EM_SES2 0x00040000 +#define AHCI_EM_SGPIO 0x00080000 +#define AHCI_EM_SMB 0x01000000 +#define AHCI_EM_XMT 0x02000000 +#define AHCI_EM_ALHD 0x04000000 +#define AHCI_EM_PM 0x08000000 + #define AHCI_CAP2 0x24 #define AHCI_CAP2_BOH 0x00000001 #define AHCI_CAP2_NVMP 0x00000002 @@ -402,6 +416,7 @@ struct ahci_controller { } irqs[16]; uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ + uint32_t capsem; /* Controller capabilities */ int quirks; int numirqs; int channels; diff --git a/sys/dev/asr/asr.c b/sys/dev/asr/asr.c index 2bc5e2277246..ae363d0045d4 100644 --- a/sys/dev/asr/asr.c +++ b/sys/dev/asr/asr.c @@ -130,7 +130,6 @@ #include <cam/cam_ccb.h> #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> -#include <cam/cam_xpt_periph.h> #include <cam/scsi/scsi_all.h> #include <cam/scsi/scsi_message.h> diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index f342c819ef13..1ad3c5117c16 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #include <cam/cam_ccb.h> #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_debug.h> #endif @@ -289,12 +288,26 @@ ata_detach(device_t dev) static void ata_conn_event(void *context, int dummy) { - device_t dev = (device_t)context; - struct ata_channel *ch = device_get_softc(dev); + device_t dev = (device_t)context; + struct ata_channel *ch = device_get_softc(dev); +#ifdef ATA_CAM + union ccb *ccb; +#endif - mtx_lock(&ch->state_mtx); - ata_reinit(dev); - mtx_unlock(&ch->state_mtx); + mtx_lock(&ch->state_mtx); + ata_reinit(dev); + mtx_unlock(&ch->state_mtx); +#ifdef ATA_CAM + if ((ccb = xpt_alloc_ccb()) == NULL) + return; + if (xpt_create_path(&ccb->ccb_h.path, NULL, + cam_sim_path(ch->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); + return; + } + xpt_rescan(ccb); +#endif } int @@ -390,6 +403,7 @@ ata_reinit(device_t dev) /* kick off requests on the queue */ ata_start(dev); #else + xpt_freeze_simq(ch->sim, 1); if ((request = ch->running)) { ch->running = NULL; if (ch->state == ATA_ACTIVE) @@ -404,6 +418,7 @@ ata_reinit(device_t dev) ATA_RESET(dev); /* Tell the XPT about the event */ xpt_async(AC_BUS_RESET, ch->path, NULL); + xpt_release_simq(ch->sim, TRUE); #endif return(0); } diff --git a/sys/dev/ata/atapi-cam.c b/sys/dev/ata/atapi-cam.c index 84b44c563993..3f8e650708c3 100644 --- a/sys/dev/ata/atapi-cam.c +++ b/sys/dev/ata/atapi-cam.c @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include <cam/cam_periph.h> #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_debug.h> #include <cam/scsi/scsi_all.h> @@ -109,7 +108,6 @@ static int atapi_cam_event_handler(module_t mod, int what, void *arg); /* internal functions */ static void reinit_bus(struct atapi_xpt_softc *scp, enum reinit_reason reason); static void setup_async_cb(struct atapi_xpt_softc *, uint32_t); -static void cam_rescan_callback(struct cam_periph *, union ccb *); static void cam_rescan(struct cam_sim *); static void free_hcb_and_ccb_done(struct atapi_hcb *, u_int32_t); static struct atapi_hcb *allocate_hcb(struct atapi_xpt_softc *, int, int, union ccb *); @@ -315,6 +313,7 @@ reinit_bus(struct atapi_xpt_softc *scp, enum reinit_reason reason) { switch (reason) { case BOOT_ATTACH: + case ATTACH: break; case RESET: xpt_async(AC_BUS_RESET, scp->path, NULL); @@ -322,8 +321,6 @@ reinit_bus(struct atapi_xpt_softc *scp, enum reinit_reason reason) { if (!dev_changed) break; - /*FALLTHROUGH*/ - case ATTACH: cam_rescan(scp->sim); break; } @@ -822,41 +819,20 @@ atapi_async(void *callback_arg, u_int32_t code, } static void -cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ - if (ccb->ccb_h.status != CAM_REQ_CMP) { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, - ("Rescan failed, 0x%04x\n", ccb->ccb_h.status)); - } else { - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, - ("Rescan succeeded\n")); - } - xpt_free_path(ccb->ccb_h.path); - xpt_free_ccb(ccb); -} - -static void cam_rescan(struct cam_sim *sim) { - struct cam_path *path; union ccb *ccb; ccb = xpt_alloc_ccb_nowait(); if (ccb == NULL) return; - - if (xpt_create_path(&path, xpt_periph, cam_sim_path(sim), + if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sim), CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { xpt_free_ccb(ccb); return; } - - CAM_DEBUG(path, CAM_DEBUG_TRACE, ("Rescanning ATAPI bus.\n")); - xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("Rescanning ATAPI bus.\n")); + xpt_rescan(ccb); /* scan is in progress now */ } diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index c5ad417e70c8..4e336a94be28 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -173,8 +173,6 @@ static void ciss_unmap_request(struct ciss_request *cr); static int ciss_cam_init(struct ciss_softc *sc); static void ciss_cam_rescan_target(struct ciss_softc *sc, int bus, int target); -static void ciss_cam_rescan_all(struct ciss_softc *sc); -static void ciss_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb); static void ciss_cam_action(struct cam_sim *sim, union ccb *ccb); static int ciss_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio); static int ciss_cam_emulate(struct ciss_softc *sc, struct ccb_scsiio *csio); @@ -2863,13 +2861,6 @@ ciss_cam_init(struct ciss_softc *sc) mtx_unlock(&sc->ciss_mtx); } - /* - * Initiate a rescan of the bus. - */ - mtx_lock(&sc->ciss_mtx); - ciss_cam_rescan_all(sc); - mtx_unlock(&sc->ciss_mtx); - return(0); } @@ -2879,53 +2870,26 @@ ciss_cam_init(struct ciss_softc *sc) static void ciss_cam_rescan_target(struct ciss_softc *sc, int bus, int target) { - struct cam_path *path; union ccb *ccb; debug_called(1); - if ((ccb = malloc(sizeof(union ccb), CISS_MALLOC_CLASS, M_NOWAIT | M_ZERO)) == NULL) { + if ((ccb = xpt_alloc_ccb_nowait()) == NULL) { ciss_printf(sc, "rescan failed (can't allocate CCB)\n"); return; } - if (xpt_create_path(&path, xpt_periph, cam_sim_path(sc->ciss_cam_sim[bus]), - target, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, + cam_sim_path(sc->ciss_cam_sim[bus]), + target, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { ciss_printf(sc, "rescan failed (can't create path)\n"); - free(ccb, CISS_MALLOC_CLASS); + xpt_free_ccb(ccb); return; } - - xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = ciss_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); - + xpt_rescan(ccb); /* scan is now in progress */ } -static void -ciss_cam_rescan_all(struct ciss_softc *sc) -{ - int i; - - /* Rescan the logical buses */ - for (i = 0; i < sc->ciss_max_logical_bus; i++) - ciss_cam_rescan_target(sc, i, CAM_TARGET_WILDCARD); - /* Rescan the physical buses */ - for (i = CISS_PHYSICAL_BASE; i < sc->ciss_max_physical_bus + - CISS_PHYSICAL_BASE; i++) - ciss_cam_rescan_target(sc, i, CAM_TARGET_WILDCARD); -} - -static void -ciss_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ - xpt_free_path(ccb->ccb_h.path); - free(ccb, CISS_MALLOC_CLASS); -} - /************************************************************************ * Handle requests coming from CAM */ diff --git a/sys/dev/hptiop/hptiop.c b/sys/dev/hptiop/hptiop.c index 7218bc504425..1ea257becc33 100644 --- a/sys/dev/hptiop/hptiop.c +++ b/sys/dev/hptiop/hptiop.c @@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$"); #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> #include <cam/cam_debug.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_periph.h> #include <cam/scsi/scsi_all.h> #include <cam/scsi/scsi_message.h> @@ -105,7 +104,6 @@ static int hptiop_do_ioctl_itl(struct hpt_iop_hba *hba, struct hpt_iop_ioctl_param *pParams); static int hptiop_do_ioctl_mv(struct hpt_iop_hba *hba, struct hpt_iop_ioctl_param *pParams); -static void hptiop_bus_scan_cb(struct cam_periph *periph, union ccb *ccb); static int hptiop_rescan_bus(struct hpt_iop_hba *hba); static int hptiop_alloc_pci_res_itl(struct hpt_iop_hba *hba); static int hptiop_alloc_pci_res_mv(struct hpt_iop_hba *hba); @@ -1035,28 +1033,19 @@ invalid: static int hptiop_rescan_bus(struct hpt_iop_hba * hba) { - struct cam_path *path; union ccb *ccb; - if (xpt_create_path(&path, xpt_periph, cam_sim_path(hba->sim), - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) - return(EIO); - if ((ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK)) == NULL) + + if ((ccb = xpt_alloc_ccb()) == NULL) return(ENOMEM); - bzero(ccb, sizeof(union ccb)); - xpt_setup_ccb(&ccb->ccb_h, path, 5); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = hptiop_bus_scan_cb; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); + if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(hba->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); + return(EIO); + } + xpt_rescan(ccb); return(0); } -static void hptiop_bus_scan_cb(struct cam_periph *periph, union ccb *ccb) -{ - xpt_free_path(ccb->ccb_h.path); - free(ccb, M_TEMP); -} - static bus_dmamap_callback_t hptiop_map_srb; static bus_dmamap_callback_t hptiop_post_scsi_command; static bus_dmamap_callback_t hptiop_mv_map_ctlcfg; @@ -1539,8 +1528,6 @@ static int hptiop_attach(device_t dev) hba->ioctl_dev->si_drv1 = hba; #endif - hptiop_rescan_bus(hba); - return 0; diff --git a/sys/dev/hptrr/hptrr_osm_bsd.c b/sys/dev/hptrr/hptrr_osm_bsd.c index 78c8b60fe2e1..6bc30c22b36f 100644 --- a/sys/dev/hptrr/hptrr_osm_bsd.c +++ b/sys/dev/hptrr/hptrr_osm_bsd.c @@ -989,7 +989,6 @@ static void hpt_stop_tasks(PVBUS_EXT vbus_ext) static d_open_t hpt_open; static d_close_t hpt_close; static d_ioctl_t hpt_ioctl; -static void hpt_bus_scan_cb(struct cam_periph *periph, union ccb *ccb); static int hpt_rescan_bus(void); static struct cdevsw hpt_cdevsw = { @@ -1381,7 +1380,6 @@ invalid: static int hpt_rescan_bus(void) { - struct cam_path *path; union ccb *ccb; PVBUS vbus; PVBUS_EXT vbus_ext; @@ -1391,17 +1389,15 @@ static int hpt_rescan_bus(void) #endif ldm_for_each_vbus(vbus, vbus_ext) { - if (xpt_create_path(&path, xpt_periph, cam_sim_path(vbus_ext->sim), - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) - return(EIO); - if ((ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK)) == NULL) + if ((ccb = xpt_alloc_ccb()) == NULL) return(ENOMEM); - bzero(ccb, sizeof(union ccb)); - xpt_setup_ccb(&ccb->ccb_h, path, 5); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = hpt_bus_scan_cb; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); + if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, + cam_sim_path(vbus_ext->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); + return(EIO); + } + xpt_rescan(ccb); } #if (__FreeBSD_version >= 500000) @@ -1410,15 +1406,3 @@ static int hpt_rescan_bus(void) return(0); } - -static void hpt_bus_scan_cb(struct cam_periph *periph, union ccb *ccb) -{ - if (ccb->ccb_h.status != CAM_REQ_CMP) - KdPrint(("cam_scan_callback: failure status = %x",ccb->ccb_h.status)); - else - KdPrint(("Scan bus successfully!")); - - xpt_free_path(ccb->ccb_h.path); - free(ccb, M_TEMP); - return; -} diff --git a/sys/dev/hptrr/os_bsd.h b/sys/dev/hptrr/os_bsd.h index fb487e820b67..ec221f39b90a 100644 --- a/sys/dev/hptrr/os_bsd.h +++ b/sys/dev/hptrr/os_bsd.h @@ -91,7 +91,6 @@ #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> #include <cam/cam_debug.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_periph.h> #include <cam/scsi/scsi_all.h> #include <cam/scsi/scsi_message.h> diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c index 189f53991c96..90f2819ccbfd 100644 --- a/sys/dev/mly/mly.c +++ b/sys/dev/mly/mly.c @@ -101,7 +101,6 @@ static void mly_unmap_command(struct mly_command *mc); static int mly_cam_attach(struct mly_softc *sc); static void mly_cam_detach(struct mly_softc *sc); static void mly_cam_rescan_btl(struct mly_softc *sc, int bus, int target); -static void mly_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb); static void mly_cam_action(struct cam_sim *sim, union ccb *ccb); static int mly_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio); static void mly_cam_poll(struct cam_sim *sim); @@ -2017,29 +2016,18 @@ mly_cam_rescan_btl(struct mly_softc *sc, int bus, int target) debug_called(1); - if ((ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO)) == NULL) { + if ((ccb = xpt_alloc_ccb()) == NULL) { mly_printf(sc, "rescan failed (can't allocate CCB)\n"); return; } - - if (xpt_create_path(&sc->mly_cam_path, xpt_periph, - cam_sim_path(sc->mly_cam_sim[bus]), target, 0) != CAM_REQ_CMP) { + if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, + cam_sim_path(sc->mly_cam_sim[bus]), target, 0) != CAM_REQ_CMP) { mly_printf(sc, "rescan failed (can't create path)\n"); - free(ccb, M_TEMP); + xpt_free_ccb(ccb); return; } - xpt_setup_ccb(&ccb->ccb_h, sc->mly_cam_path, 5/*priority (low)*/); - ccb->ccb_h.func_code = XPT_SCAN_LUN; - ccb->ccb_h.cbfcnp = mly_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; debug(1, "rescan target %d:%d", bus, target); - xpt_action(ccb); -} - -static void -mly_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ - free(ccb, M_TEMP); + xpt_rescan(ccb); } /******************************************************************************** diff --git a/sys/dev/mpt/mpt_cam.h b/sys/dev/mpt/mpt_cam.h index f2faa4abdff8..8a18934d6483 100644 --- a/sys/dev/mpt/mpt_cam.h +++ b/sys/dev/mpt/mpt_cam.h @@ -102,7 +102,6 @@ #include <cam/cam_sim.h> #include <cam/cam_xpt.h> #include <cam/cam_periph.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_xpt_sim.h> #include <cam/cam_debug.h> #include <cam/scsi/scsi_all.h> diff --git a/sys/dev/mpt/mpt_raid.c b/sys/dev/mpt/mpt_raid.c index 5185ec0d7960..d313253fa9e9 100644 --- a/sys/dev/mpt/mpt_raid.c +++ b/sys/dev/mpt/mpt_raid.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include <cam/cam.h> #include <cam/cam_ccb.h> #include <cam/cam_sim.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_xpt_sim.h> #if __FreeBSD_version < 500000 @@ -656,14 +655,6 @@ mpt_terminate_raid_thread(struct mpt_softc *mpt) } static void -mpt_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ - - xpt_free_path(ccb->ccb_h.path); - xpt_free_ccb(ccb); -} - -static void mpt_raid_thread(void *arg) { struct mpt_softc *mpt; @@ -715,13 +706,7 @@ mpt_raid_thread(void *arg) xpt_free_ccb(ccb); mpt_prt(mpt, "Unable to rescan RAID Bus!\n"); } else { - xpt_setup_ccb(&ccb->ccb_h, path, 5); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = mpt_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - MPTLOCK_2_CAMLOCK(mpt); - xpt_action(ccb); - CAMLOCK_2_MPTLOCK(mpt); + xpt_rescan(ccb); } } } diff --git a/sys/dev/ppbus/vpo.c b/sys/dev/ppbus/vpo.c index 673a7858d4da..02bc9b397b2e 100644 --- a/sys/dev/ppbus/vpo.c +++ b/sys/dev/ppbus/vpo.c @@ -83,9 +83,6 @@ struct vpo_data { /* cam related functions */ static void vpo_action(struct cam_sim *sim, union ccb *ccb); static void vpo_poll(struct cam_sim *sim); -static void vpo_cam_rescan_callback(struct cam_periph *periph, - union ccb *ccb); -static void vpo_cam_rescan(struct vpo_data *vpo); static void vpo_identify(driver_t *driver, device_t parent) @@ -176,44 +173,10 @@ vpo_attach(device_t dev) return (ENXIO); } ppb_unlock(ppbus); - vpo_cam_rescan(vpo); /* have CAM rescan the bus */ return (0); } -static void -vpo_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ - - free(ccb, M_TEMP); -} - -static void -vpo_cam_rescan(struct vpo_data *vpo) -{ - device_t ppbus = device_get_parent(vpo->vpo_dev); - struct cam_path *path; - union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); - - ppb_lock(ppbus); - if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0) - != CAM_REQ_CMP) { - /* A failure is benign as the user can do a manual rescan */ - ppb_unlock(ppbus); - free(ccb, M_TEMP); - return; - } - - xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = vpo_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); - ppb_unlock(ppbus); - - /* The scan is in progress now. */ -} - /* * vpo_intr() */ diff --git a/sys/dev/siis/siis.c b/sys/dev/siis/siis.c index 6f693e4e8a2e..630ee7b44c97 100644 --- a/sys/dev/siis/siis.c +++ b/sys/dev/siis/siis.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include <cam/cam_ccb.h> #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> -#include <cam/cam_xpt_periph.h> #include <cam/cam_debug.h> /* local prototypes */ @@ -740,6 +739,8 @@ siis_phy_check_events(device_t dev) /* If we have a connection event, deal with it */ if (ch->pm_level == 0) { u_int32_t status = ATA_INL(ch->r_mem, SIIS_P_SSTS); + union ccb *ccb; + if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) { @@ -751,6 +752,15 @@ siis_phy_check_events(device_t dev) device_printf(dev, "DISCONNECT requested\n"); ch->devices = 0; } + if ((ccb = xpt_alloc_ccb_nowait()) == NULL) + return; + if (xpt_create_path(&ccb->ccb_h.path, NULL, + cam_sim_path(ch->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); + return; + } + xpt_rescan(ccb); } } @@ -1025,6 +1035,13 @@ siis_execute_transaction(struct siis_slot *slot) if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) ctp->control |= htole16(SIIS_PRB_PACKET_WRITE); } + /* Special handling for Soft Reset command. */ + if ((ccb->ccb_h.func_code == XPT_ATA_IO) && + (ccb->ataio.cmd.flags & CAM_ATAIO_CONTROL) && + (ccb->ataio.cmd.control & ATA_A_RESET)) { + /* Kick controller into sane state */ + siis_portinit(dev); + } /* Setup the FIS for this request */ if (!siis_setup_fis(dev, ctp, ccb, slot->slot)) { device_printf(ch->dev, "Setting up SATA FIS failed\n"); @@ -1081,10 +1098,11 @@ siis_timeout(struct siis_slot *slot) if (slot->state < SIIS_SLOT_RUNNING) return; device_printf(dev, "Timeout on slot %d\n", slot->slot); -device_printf(dev, "%s is %08x ss %08x rs %08x es %08x sts %08x serr %08x\n", - __func__, ATA_INL(ch->r_mem, SIIS_P_IS), ATA_INL(ch->r_mem, SIIS_P_SS), ch->rslots, - ATA_INL(ch->r_mem, SIIS_P_CMDERR), ATA_INL(ch->r_mem, SIIS_P_STS), - ATA_INL(ch->r_mem, SIIS_P_SERR)); + device_printf(dev, "%s is %08x ss %08x rs %08x es %08x sts %08x serr %08x\n", + __func__, ATA_INL(ch->r_mem, SIIS_P_IS), + ATA_INL(ch->r_mem, SIIS_P_SS), ch->rslots, + ATA_INL(ch->r_mem, SIIS_P_CMDERR), ATA_INL(ch->r_mem, SIIS_P_STS), + ATA_INL(ch->r_mem, SIIS_P_SERR)); if (ch->toslots == 0) xpt_freeze_simq(ch->sim, 1); @@ -1368,8 +1386,6 @@ siis_devreset(device_t dev) return (EBUSY); } } - if (bootverbose) - device_printf(dev, "device reset time=%dms\n", timeout); return (0); } @@ -1389,8 +1405,6 @@ siis_wait_ready(device_t dev, int t) return (EBUSY); } } - if (bootverbose) - device_printf(dev, "ready wait time=%dms\n", timeout); return (0); } @@ -1401,6 +1415,7 @@ siis_reset(device_t dev) int i, retry = 0, sata_rev; uint32_t val; + xpt_freeze_simq(ch->sim, 1); if (bootverbose) device_printf(dev, "SIIS reset...\n"); if (!ch->readlog && !ch->recovery) @@ -1466,6 +1481,7 @@ retry: "SIIS reset done: phy reset found no device\n"); /* Tell the XPT about the event */ xpt_async(AC_BUS_RESET, ch->path, NULL); + xpt_release_simq(ch->sim, TRUE); return; } /* Wait for clearing busy status. */ @@ -1496,6 +1512,7 @@ retry: device_printf(dev, "SIIS reset done: devices=%08x\n", ch->devices); /* Tell the XPT about the event */ xpt_async(AC_BUS_RESET, ch->path, NULL); + xpt_release_simq(ch->sim, TRUE); } static int diff --git a/sys/dev/trm/trm.c b/sys/dev/trm/trm.c index 26ab35239e7f..e7d5aad6d77d 100644 --- a/sys/dev/trm/trm.c +++ b/sys/dev/trm/trm.c @@ -747,15 +747,6 @@ trm_action(struct cam_sim *psim, union ccb *pccb) xpt_done(pccb); break; /* - * (Re)Scan the SCSI Bus - * Rescan the given bus, or bus/target/lun - */ - case XPT_SCAN_BUS: - TRM_DPRINTF(" XPT_SCAN_BUS \n"); - pccb->ccb_h.status = CAM_REQ_INVALID; - xpt_done(pccb); - break; - /* * Get EDT entries matching the given pattern */ case XPT_DEV_MATCH: @@ -819,15 +810,6 @@ trm_action(struct cam_sim *psim, union ccb *pccb) xpt_done(pccb); break; /* - * Scan Logical Unit - */ - case XPT_SCAN_LUN: - TRM_DPRINTF(" XPT_SCAN_LUN \n"); - pccb->ccb_h.status = CAM_REQ_INVALID; - xpt_done(pccb); - break; - - /* * Get/Set transfer rate/width/disconnection/tag queueing * settings * (GET) default/user transfer settings for the target diff --git a/sys/dev/twa/tw_osl_cam.c b/sys/dev/twa/tw_osl_cam.c index b7a085f19789..1d22920f291b 100644 --- a/sys/dev/twa/tw_osl_cam.c +++ b/sys/dev/twa/tw_osl_cam.c @@ -56,7 +56,6 @@ static TW_VOID twa_action(struct cam_sim *sim, union ccb *ccb); static TW_VOID twa_poll(struct cam_sim *sim); static TW_VOID twa_timeout(TW_VOID *arg); -static TW_VOID twa_bus_scan_cb(struct cam_periph *periph, union ccb *ccb); static TW_INT32 tw_osli_execute_scsi(struct tw_osli_req_context *req, union ccb *ccb); @@ -76,7 +75,6 @@ TW_INT32 tw_osli_cam_attach(struct twa_softc *sc) { struct cam_devq *devq; - TW_INT32 error; tw_osli_dbg_dprintf(3, sc, "entered"); @@ -149,23 +147,8 @@ tw_osli_cam_attach(struct twa_softc *sc) mtx_unlock(sc->sim_lock); return(ENXIO); } - - tw_osli_dbg_dprintf(3, sc, "Calling xpt_setup_ccb"); mtx_unlock(sc->sim_lock); - tw_osli_dbg_dprintf(3, sc, "Calling tw_osli_request_bus_scan"); - /* - * Request a bus scan, so that CAM gets to know of - * the logical units that we control. - */ - if ((error = tw_osli_request_bus_scan(sc))) - tw_osli_printf(sc, "error = %d", - TW_CL_SEVERITY_ERROR_STRING, - TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, - 0x2104, - "Bus scan request to CAM failed", - error); - tw_osli_dbg_dprintf(3, sc, "exiting"); return(0); } @@ -561,7 +544,6 @@ twa_timeout(TW_VOID *arg) TW_INT32 tw_osli_request_bus_scan(struct twa_softc *sc) { - struct cam_path *path; union ccb *ccb; tw_osli_dbg_dprintf(3, sc, "entering"); @@ -569,13 +551,12 @@ tw_osli_request_bus_scan(struct twa_softc *sc) /* If we get here before sc->sim is initialized, return an error. */ if (!(sc->sim)) return(ENXIO); - if ((ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK)) == NULL) + if ((ccb = xpt_alloc_ccb()) == NULL) return(ENOMEM); - bzero(ccb, sizeof(union ccb)); mtx_lock(sc->sim_lock); - if (xpt_create_path(&path, xpt_periph, cam_sim_path(sc->sim), - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { - free(ccb, M_TEMP); + if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(sc->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { + xpt_free_ccb(ccb); mtx_unlock(sc->sim_lock); return(EIO); } @@ -586,11 +567,7 @@ tw_osli_request_bus_scan(struct twa_softc *sc) sc->state &= ~TW_OSLI_CTLR_STATE_SIMQ_FROZEN; } - xpt_setup_ccb(&ccb->ccb_h, path, 5); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = twa_bus_scan_cb; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); + xpt_rescan(ccb); mtx_unlock(sc->sim_lock); return(0); } @@ -598,32 +575,6 @@ tw_osli_request_bus_scan(struct twa_softc *sc) /* - * Function name: twa_bus_scan_cb - * Description: Callback from CAM on a bus scan request. - * - * Input: periph -- we don't use this - * ccb -- bus scan request ccb that we sent to CAM - * Output: None - * Return value: None - */ -static TW_VOID -twa_bus_scan_cb(struct cam_periph *periph, union ccb *ccb) -{ - tw_osli_dbg_printf(3, "entering"); - - if (ccb->ccb_h.status != CAM_REQ_CMP) - printf("cam_scan_callback: failure status = %x\n", - ccb->ccb_h.status); - else - tw_osli_dbg_printf(3, "success"); - - xpt_free_path(ccb->ccb_h.path); - free(ccb, M_TEMP); -} - - - -/* * Function name: tw_osli_allow_new_requests * Description: Sets the appropriate status bits in a ccb such that, * when the ccb is completed by a call to xpt_done, diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index 4e57d82a1fdc..e41e55b7f909 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -469,8 +469,6 @@ static void umass_cbi_start_status(struct umass_softc *); static void umass_t_cbi_data_clear_stall_callback(struct usb_xfer *, uint8_t, uint8_t, usb_error_t); static int umass_cam_attach_sim(struct umass_softc *); -static void umass_cam_rescan_callback(struct cam_periph *, union ccb *); -static void umass_cam_rescan(struct umass_softc *); static void umass_cam_attach(struct umass_softc *); static void umass_cam_detach_sim(struct umass_softc *); static void umass_cam_action(struct cam_sim *, union ccb *); @@ -2145,68 +2143,6 @@ umass_cam_attach_sim(struct umass_softc *sc) } static void -umass_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ -#if USB_DEBUG - struct umass_softc *sc = NULL; - - if (ccb->ccb_h.status != CAM_REQ_CMP) { - DPRINTF(sc, UDMASS_SCSI, "%s:%d Rescan failed, 0x%04x\n", - periph->periph_name, periph->unit_number, - ccb->ccb_h.status); - } else { - DPRINTF(sc, UDMASS_SCSI, "%s%d: Rescan succeeded\n", - periph->periph_name, periph->unit_number); - } -#endif - - xpt_free_path(ccb->ccb_h.path); - free(ccb, M_USBDEV); -} - -static void -umass_cam_rescan(struct umass_softc *sc) -{ - struct cam_path *path; - union ccb *ccb; - - DPRINTF(sc, UDMASS_SCSI, "scbus%d: scanning for %d:%d:%d\n", - cam_sim_path(sc->sc_sim), - cam_sim_path(sc->sc_sim), - sc->sc_unit, CAM_LUN_WILDCARD); - - ccb = malloc(sizeof(*ccb), M_USBDEV, M_WAITOK | M_ZERO); - - if (ccb == NULL) { - return; - } -#if (__FreeBSD_version >= 700037) - mtx_lock(&sc->sc_mtx); -#endif - - if (xpt_create_path(&path, xpt_periph, cam_sim_path(sc->sc_sim), - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) - != CAM_REQ_CMP) { -#if (__FreeBSD_version >= 700037) - mtx_unlock(&sc->sc_mtx); -#endif - free(ccb, M_USBDEV); - return; - } - xpt_setup_ccb(&ccb->ccb_h, path, 5 /* priority (low) */ ); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = &umass_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); - -#if (__FreeBSD_version >= 700037) - mtx_unlock(&sc->sc_mtx); -#endif - - /* The scan is in progress now. */ -} - -static void umass_cam_attach(struct umass_softc *sc) { #ifndef USB_DEBUG @@ -2216,19 +2152,6 @@ umass_cam_attach(struct umass_softc *sc) sc->sc_name, cam_sim_path(sc->sc_sim), sc->sc_unit, CAM_LUN_WILDCARD, cam_sim_path(sc->sc_sim)); - - if (!cold) { - /* - * Notify CAM of the new device after a short delay. Any - * failure is benign, as the user can still do it by hand - * (camcontrol rescan <busno>). Only do this if we are not - * booting, because CAM does a scan after booting has - * completed, when interrupts have been enabled. - */ - - /* scan the new sim */ - umass_cam_rescan(sc); - } } /* umass_cam_detach |
