summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ata')
-rw-r--r--sys/dev/ata/ata-all.c27
-rw-r--r--sys/dev/ata/atapi-cam.c32
2 files changed, 25 insertions, 34 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
index f342c81..1ad3c51 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 84b44c5..3f8e650 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 */
}
OpenPOWER on IntegriCloud