Free the shared devq last since CAM expects it to be there if
xpt_alloc_device() gets called, which can happen during detach in certain situations. Fixes module unload. MFC after: 3 days
This commit is contained in:
parent
a3fe8ea3ed
commit
f7f3c3e1a6
@ -139,10 +139,12 @@ amr_cam_attach(struct amr_softc *sc)
|
||||
/*
|
||||
* Allocate a devq for all our channels combined. This should
|
||||
* allow for the maximum number of SCSI commands we will accept
|
||||
* at one time.
|
||||
* at one time. Save the pointer in the softc so we can find it later
|
||||
* during detach.
|
||||
*/
|
||||
if ((devq = cam_simq_alloc(AMR_MAX_SCSI_CMDS)) == NULL)
|
||||
return(ENOMEM);
|
||||
sc->amr_cam_devq = devq;
|
||||
|
||||
/*
|
||||
* Iterate over our channels, registering them with CAM
|
||||
@ -182,19 +184,22 @@ amr_cam_attach(struct amr_softc *sc)
|
||||
void
|
||||
amr_cam_detach(struct amr_softc *sc)
|
||||
{
|
||||
int chn, first;
|
||||
int chn;
|
||||
|
||||
for (chn = 0, first = 1; chn < sc->amr_maxchan; chn++) {
|
||||
for (chn = 0; chn < sc->amr_maxchan; chn++) {
|
||||
|
||||
/*
|
||||
* If a sim was allocated for this channel, free it
|
||||
*/
|
||||
if (sc->amr_cam_sim[chn] != NULL) {
|
||||
xpt_bus_deregister(cam_sim_path(sc->amr_cam_sim[chn]));
|
||||
cam_sim_free(sc->amr_cam_sim[chn], first ? TRUE : FALSE);
|
||||
first = 0;
|
||||
cam_sim_free(sc->amr_cam_sim[chn], FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now free the devq */
|
||||
if (sc->amr_cam_devq != NULL)
|
||||
cam_simq_free(sc->amr_cam_devq);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
|
@ -202,6 +202,7 @@ struct amr_softc
|
||||
/* CAM attachments for passthrough */
|
||||
struct cam_sim *amr_cam_sim[AMR_MAX_CHANNELS];
|
||||
TAILQ_HEAD(, ccb_hdr) amr_cam_ccbq;
|
||||
struct cam_devq *amr_cam_devq;
|
||||
|
||||
/* control device */
|
||||
struct cdev *amr_dev_t;
|
||||
|
Loading…
Reference in New Issue
Block a user