summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsimokawa <simokawa@FreeBSD.org>2003-01-31 14:11:22 +0000
committersimokawa <simokawa@FreeBSD.org>2003-01-31 14:11:22 +0000
commit30013fce110fa84157697face2a7b27ba4ac3fae (patch)
tree909bbd4187f8e696609f2c0f451bd3826ff4c46b /sys
parent02d8e2b208323d19b6fc75fb1a39d03f8cacbd29 (diff)
downloadFreeBSD-src-30013fce110fa84157697face2a7b27ba4ac3fae.zip
FreeBSD-src-30013fce110fa84157697face2a7b27ba4ac3fae.tar.gz
SBP related changes.
- Issue LOGOUT command on detach and shutdown. - Rename some functions.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/firewire/fwohci.c2
-rw-r--r--sys/dev/firewire/fwohci_pci.c7
-rw-r--r--sys/dev/firewire/sbp.c69
3 files changed, 64 insertions, 14 deletions
diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c
index a05becf..2c0a267 100644
--- a/sys/dev/firewire/fwohci.c
+++ b/sys/dev/firewire/fwohci.c
@@ -1676,7 +1676,7 @@ fwohci_irx_enable(struct firewire_comm *fc, int dmach)
}
int
-fwohci_shutdown(struct fwohci_softc *sc, device_t dev)
+fwohci_stop(struct fwohci_softc *sc, device_t dev)
{
u_int i;
diff --git a/sys/dev/firewire/fwohci_pci.c b/sys/dev/firewire/fwohci_pci.c
index f96a9cf..7ace8b7 100644
--- a/sys/dev/firewire/fwohci_pci.c
+++ b/sys/dev/firewire/fwohci_pci.c
@@ -262,7 +262,7 @@ fwohci_pci_detach(device_t self)
s = splfw();
- fwohci_shutdown(sc, self);
+ fwohci_stop(sc, self);
bus_generic_detach(self);
/* disable interrupts that might have been switched on */
@@ -314,7 +314,7 @@ fwohci_pci_suspend(device_t dev)
err = bus_generic_suspend(dev);
if (err)
return err;
- /* fwohci_shutdown(dev); */
+ /* fwohci_stop(dev); */
return 0;
}
@@ -335,7 +335,8 @@ fwohci_pci_shutdown(device_t dev)
{
fwohci_softc_t *sc = device_get_softc(dev);
- fwohci_shutdown(sc, dev);
+ bus_generic_shutdown(dev);
+ fwohci_stop(sc, dev);
return 0;
}
diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c
index 09fc481..d5d8a50 100644
--- a/sys/dev/firewire/sbp.c
+++ b/sys/dev/firewire/sbp.c
@@ -259,7 +259,7 @@ static struct fw_xfer * sbp_write_cmd __P((struct sbp_dev *, int, int));
static struct sbp_ocb * sbp_get_ocb __P((struct sbp_softc *));
static struct sbp_ocb * sbp_enqueue_ocb __P((struct sbp_dev *, struct sbp_ocb *));
static struct sbp_ocb * sbp_dequeue_ocb __P((struct sbp_dev *, u_int32_t));
-static void sbp_detach_target __P((struct sbp_target *));
+static void sbp_cam_detach_target __P((struct sbp_target *));
static void sbp_timeout __P((void *arg));
static void sbp_mgm_orb __P((struct sbp_dev *, int));
@@ -625,7 +625,12 @@ END_DEBUG
}
if(fwdev == NULL){
/* device has removed in lower driver */
- sbp_detach_target(target);
+ sbp_cam_detach_target(target);
+ if (target->luns != NULL)
+ free(target->luns, M_SBP);
+ target->num_lun = 0;;
+ target->luns = NULL;
+ target->fwdev = NULL;
}
}
/* traverse device list */
@@ -1614,6 +1619,41 @@ END_DEBUG
}
static int
+sbp_logout_all(struct sbp_softc *sbp)
+{
+ struct sbp_target *target;
+ struct sbp_dev *sdev;
+ int i, j;
+
+SBP_DEBUG(0)
+ printf("sbp_logout_all\n");
+END_DEBUG
+ for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) {
+ target = &sbp->targets[i];
+ if (target->luns == NULL)
+ continue;
+ for (j = 0; j < target->num_lun; j++) {
+ sdev = &target->luns[j];
+ if (sdev->status == SBP_DEV_ATTACHED) {
+ sbp_show_sdev_info(sdev, 2);
+ printf("logout\n");
+ sbp_mgm_orb(sdev, ORB_FUN_LGO);
+ }
+ }
+ }
+ return 0;
+}
+
+static int
+sbp_shutdown(device_t dev)
+{
+ struct sbp_softc *sbp = ((struct sbp_softc *)device_get_softc(dev));
+
+ sbp_logout_all(sbp);
+ return (0);
+}
+
+static int
sbp_detach(device_t dev)
{
struct sbp_softc *sbp = ((struct sbp_softc *)device_get_softc(dev));
@@ -1623,22 +1663,33 @@ sbp_detach(device_t dev)
SBP_DEBUG(0)
printf("sbp_detach\n");
END_DEBUG
-
+#if 0
/* bus reset for logout */
sbp->fd.post_explore = NULL;
fc->ibr(fc);
+#endif
- contigfree(sbp->ocb, sizeof (struct sbp_ocb) * SBP_NUM_OCB, M_SBP);
- fw_bindremove(fc, &sbp->fwb);
for (i = 0; i < SBP_NUM_TARGETS; i ++)
- sbp_detach_target(&sbp->targets[i]);
+ sbp_cam_detach_target(&sbp->targets[i]);
xpt_bus_deregister(cam_sim_path(sbp->sim));
+
+ sbp_logout_all(sbp);
+ /* XXX wait for logout completion */
+ tsleep(&i, FWPRI, "sbpdtc", hz/2);
+
+ fw_bindremove(fc, &sbp->fwb);
+ contigfree(sbp->ocb, sizeof (struct sbp_ocb) * SBP_NUM_OCB, M_SBP);
bus_dma_tag_destroy(sbp->dmat);
+
+ for (i = 0; i < SBP_NUM_TARGETS; i ++)
+ if (sbp->targets[i].luns != NULL)
+ free(sbp->targets[i].luns, M_SBP);
+
return (0);
}
static void
-sbp_detach_target(struct sbp_target *target)
+sbp_cam_detach_target(struct sbp_target *target)
{
int i;
struct sbp_dev *sdev;
@@ -1658,10 +1709,7 @@ END_DEBUG
sdev->path = NULL;
sbp_abort_all_ocbs(sdev, CAM_DEV_NOT_THERE);
}
- free(target->luns, M_SBP);
- target->luns = NULL;
}
- target->fwdev = NULL;
}
static void
@@ -2226,6 +2274,7 @@ static device_method_t sbp_methods[] = {
DEVMETHOD(device_probe, sbp_probe),
DEVMETHOD(device_attach, sbp_attach),
DEVMETHOD(device_detach, sbp_detach),
+ DEVMETHOD(device_shutdown, sbp_shutdown),
{ 0, 0 }
};
OpenPOWER on IntegriCloud