Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mps/mps_sas.c
Show First 20 Lines • Show All 716 Lines • ▼ Show 20 Lines | mps_attach_sas(struct mps_softc *sc) | ||||
struct mpssas_softc *sassc; | struct mpssas_softc *sassc; | ||||
cam_status status; | cam_status status; | ||||
int unit, error = 0, reqs; | int unit, error = 0, reqs; | ||||
MPS_FUNCTRACE(sc); | MPS_FUNCTRACE(sc); | ||||
mps_dprint(sc, MPS_INIT, "%s entered\n", __func__); | mps_dprint(sc, MPS_INIT, "%s entered\n", __func__); | ||||
sassc = malloc(sizeof(struct mpssas_softc), M_MPT2, M_WAITOK|M_ZERO); | sassc = malloc(sizeof(struct mpssas_softc), M_MPT2, M_WAITOK|M_ZERO); | ||||
if(!sassc) { | |||||
mps_dprint(sc, MPS_INIT|MPS_ERROR, | |||||
"Cannot allocate SAS controller memory\n"); | |||||
return (ENOMEM); | |||||
} | |||||
/* | /* | ||||
* XXX MaxTargets could change during a reinit. Since we don't | * XXX MaxTargets could change during a reinit. Since we don't | ||||
* resize the targets[] array during such an event, cache the value | * resize the targets[] array during such an event, cache the value | ||||
* of MaxTargets here so that we don't get into trouble later. This | * of MaxTargets here so that we don't get into trouble later. This | ||||
* should move into the reinit logic. | * should move into the reinit logic. | ||||
*/ | */ | ||||
sassc->maxtargets = sc->facts->MaxTargets + sc->facts->MaxVolumes; | sassc->maxtargets = sc->facts->MaxTargets + sc->facts->MaxVolumes; | ||||
sassc->targets = malloc(sizeof(struct mpssas_target) * | sassc->targets = malloc(sizeof(struct mpssas_target) * | ||||
sassc->maxtargets, M_MPT2, M_WAITOK|M_ZERO); | sassc->maxtargets, M_MPT2, M_WAITOK|M_ZERO); | ||||
if(!sassc->targets) { | |||||
mps_dprint(sc, MPS_INIT|MPS_ERROR, | |||||
"Cannot allocate SAS target memory\n"); | |||||
free(sassc, M_MPT2); | |||||
return (ENOMEM); | |||||
} | |||||
sc->sassc = sassc; | sc->sassc = sassc; | ||||
sassc->sc = sc; | sassc->sc = sc; | ||||
reqs = sc->num_reqs - sc->num_prireqs - 1; | reqs = sc->num_reqs - sc->num_prireqs - 1; | ||||
if ((sassc->devq = cam_simq_alloc(reqs)) == NULL) { | if ((sassc->devq = cam_simq_alloc(reqs)) == NULL) { | ||||
mps_dprint(sc, MPS_ERROR, "Cannot allocate SIMQ\n"); | mps_dprint(sc, MPS_ERROR, "Cannot allocate SIMQ\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
▲ Show 20 Lines • Show All 2,662 Lines • ▼ Show 20 Lines | for (i=0; i< maxtargets; i++) { | ||||
SLIST_FOREACH_SAFE(lun, &targ->luns, lun_link, lun_tmp) { | SLIST_FOREACH_SAFE(lun, &targ->luns, lun_link, lun_tmp) { | ||||
free(lun, M_MPT2); | free(lun, M_MPT2); | ||||
} | } | ||||
} | } | ||||
free(sassc->targets, M_MPT2); | free(sassc->targets, M_MPT2); | ||||
sassc->targets = malloc(sizeof(struct mpssas_target) * maxtargets, | sassc->targets = malloc(sizeof(struct mpssas_target) * maxtargets, | ||||
M_MPT2, M_WAITOK|M_ZERO); | M_MPT2, M_WAITOK|M_ZERO); | ||||
if (!sassc->targets) { | |||||
panic("%s failed to alloc targets with error %d\n", | |||||
__func__, ENOMEM); | |||||
} | |||||
} | } |