summaryrefslogtreecommitdiffstats
path: root/sys/dev/aic
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2002-01-17 20:34:58 +0000
committerjoerg <joerg@FreeBSD.org>2002-01-17 20:34:58 +0000
commit4791f4faa9aa78b5437ac9314e73a0ef04e24081 (patch)
tree826fbb0071b24e8bc2afc180d9e5d82bf7e7ba79 /sys/dev/aic
parentf49b6f89b44b57ecdf49d55adb2d41ab34fdb18b (diff)
downloadFreeBSD-src-4791f4faa9aa78b5437ac9314e73a0ef04e24081.zip
FreeBSD-src-4791f4faa9aa78b5437ac9314e73a0ef04e24081.tar.gz
Back out the hack from rev 1.13 that was done to initiate a bus rescan
at insert time. When asking gibbs for approval for an MFC, this was his reply: 1) It leaks memory if it can't allocate a path. 2) It defers allocation of aic->path until the call to scan the bus. This means the path may be NULL when an interrupt occurs prior to the call to scan the bus (stray bus reset for instance), which will lead to a panic. 3) The driver in current doesn't recover from the failure to allocate aic->path. The driver doesn't check during normal operation if the path is NULL, so again a panic will result. 4) aic_cam_rescan calls malloc with M_WAITOK. aic_cam_rescan is called from attach where it isn't necessarily safe to sleep. 5) And most importantly, it co-opts the xpt_periph from the driver level. This was never part of the design (xpt_periph used to be static). Making a call of this type may completely confuse the XPT if other XPT operations are ongoing. In the long term, Justin and Warner agreed to implement solution where CAM itself will initiate the bus rescan if a new bus is added. For the time being (and in particular in light of the upcoming 4.5 release), we now have camcontrol available on the boot floppy, and can have pccardd initiate the rescan through it.
Diffstat (limited to 'sys/dev/aic')
-rw-r--r--sys/dev/aic/aic.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/sys/dev/aic/aic.c b/sys/dev/aic/aic.c
index 6282cda..94529a1 100644
--- a/sys/dev/aic/aic.c
+++ b/sys/dev/aic/aic.c
@@ -30,8 +30,6 @@
#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>
@@ -41,7 +39,6 @@
#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>
@@ -68,9 +65,6 @@ 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;
@@ -1529,6 +1523,14 @@ 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,
@@ -1542,9 +1544,6 @@ aic_attach(struct aic_softc *aic)
if (aic->flags & AIC_FAST_ENABLE)
printf(", fast SCSI");
printf("\n");
-
- aic_cam_rescan(aic); /* have CAM rescan the bus */
-
return (0);
}
@@ -1557,29 +1556,3 @@ 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. */
-}
OpenPOWER on IntegriCloud