diff options
author | peter <peter@FreeBSD.org> | 2001-02-23 02:32:31 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-02-23 02:32:31 +0000 |
commit | 81e9930fea074aff072b441a796aa6e1ae0c1af7 (patch) | |
tree | 29df3c59d4b47e9bbdc24becb33f09b75531a511 /sys | |
parent | 88a22127a8400148ac64930f4843800ec5ea843c (diff) | |
download | FreeBSD-src-81e9930fea074aff072b441a796aa6e1ae0c1af7.zip FreeBSD-src-81e9930fea074aff072b441a796aa6e1ae0c1af7.tar.gz |
Sigh, nobody ever got back to me about this. So, here it is..
Implement auto scsi scan at insert time for the aic driver.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/aic/aic.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/sys/dev/aic/aic.c b/sys/dev/aic/aic.c index 2123766..634373e 100644 --- a/sys/dev/aic/aic.c +++ b/sys/dev/aic/aic.c @@ -30,6 +30,8 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/bus.h> +#include <sys/malloc.h> +#include <sys/devicestat.h> /* for struct devstat */ #include <machine/bus_pio.h> #include <machine/bus.h> @@ -39,6 +41,7 @@ #include <cam/cam_sim.h> #include <cam/cam_xpt_sim.h> #include <cam/cam_debug.h> +#include <cam/cam_periph.h> #include <cam/scsi/scsi_message.h> @@ -65,6 +68,9 @@ static void aic_timeout __P((void *arg)); static void aic_scsi_reset __P((struct aic_softc *aic)); static void aic_chip_reset __P((struct aic_softc *aic)); static void aic_reset __P((struct aic_softc *aic, int initiate_reset)); +static void aic_cam_rescan_callback __P((struct cam_periph *periph, + union ccb *ccb)); +static void aic_cam_rescan __P((struct aic_softc *aic)); devclass_t aic_devclass; @@ -1497,14 +1503,6 @@ aic_attach(struct aic_softc *aic) return (ENXIO); } - if (xpt_create_path(&aic->path, /*periph*/NULL, - cam_sim_path(aic->sim), CAM_TARGET_WILDCARD, - CAM_LUN_WILDCARD) != CAM_REQ_CMP) { - xpt_bus_deregister(cam_sim_path(aic->sim)); - cam_sim_free(aic->sim, /*free_devq*/TRUE); - return (ENXIO); - } - aic_init(aic); printf("aic%d: %s", aic->unit, @@ -1516,6 +1514,9 @@ aic_attach(struct aic_softc *aic) if (aic->flags & AIC_PARITY_ENABLE) printf(", parity check"); printf("\n"); + + aic_cam_rescan(aic); /* have CAM rescan the bus */ + return (0); } @@ -1528,3 +1529,29 @@ aic_detach(struct aic_softc *aic) cam_sim_free(aic->sim, /*free_devq*/TRUE); return (0); } + +static void +aic_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) +{ + free(ccb, M_TEMP); +} + +static void +aic_cam_rescan(struct aic_softc *aic) +{ + union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); + + if (xpt_create_path(&aic->path, xpt_periph, cam_sim_path(aic->sim), 0, 0) + != CAM_REQ_CMP) { + /* A failure is benign as the user can do a manual rescan */ + return; + } + + xpt_setup_ccb(&ccb->ccb_h, aic->path, 5/*priority (low)*/); + ccb->ccb_h.func_code = XPT_SCAN_BUS; + ccb->ccb_h.cbfcnp = aic_cam_rescan_callback; + ccb->crcn.flags = CAM_FLAG_NONE; + xpt_action(ccb); + + /* The scan is in progress now. */ +} |