Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/mpr/mpr_sas.c
Show First 20 Lines • Show All 730 Lines • ▼ Show 20 Lines | mpr_attach_sas(struct mpr_softc *sc) | ||||
struct mprsas_softc *sassc; | struct mprsas_softc *sassc; | ||||
cam_status status; | cam_status status; | ||||
int unit, error = 0, reqs; | int unit, error = 0, reqs; | ||||
MPR_FUNCTRACE(sc); | MPR_FUNCTRACE(sc); | ||||
mpr_dprint(sc, MPR_INIT, "%s entered\n", __func__); | mpr_dprint(sc, MPR_INIT, "%s entered\n", __func__); | ||||
sassc = malloc(sizeof(struct mprsas_softc), M_MPR, M_WAITOK|M_ZERO); | sassc = malloc(sizeof(struct mprsas_softc), M_MPR, M_WAITOK|M_ZERO); | ||||
if (!sassc) { | |||||
mpr_dprint(sc, MPR_INIT|MPR_ERROR, | |||||
"Cannot allocate SAS subsystem 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 mprsas_target) * | sassc->targets = malloc(sizeof(struct mprsas_target) * | ||||
sassc->maxtargets, M_MPR, M_WAITOK|M_ZERO); | sassc->maxtargets, M_MPR, M_WAITOK|M_ZERO); | ||||
if (!sassc->targets) { | |||||
mpr_dprint(sc, MPR_INIT|MPR_ERROR, | |||||
"Cannot allocate SAS target memory\n"); | |||||
free(sassc, M_MPR); | |||||
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) { | ||||
mpr_dprint(sc, MPR_INIT|MPR_ERROR, "Cannot allocate SIMQ\n"); | mpr_dprint(sc, MPR_INIT|MPR_ERROR, "Cannot allocate SIMQ\n"); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
▲ Show 20 Lines • Show All 2,783 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_MPR); | free(lun, M_MPR); | ||||
} | } | ||||
} | } | ||||
free(sassc->targets, M_MPR); | free(sassc->targets, M_MPR); | ||||
sassc->targets = malloc(sizeof(struct mprsas_target) * maxtargets, | sassc->targets = malloc(sizeof(struct mprsas_target) * maxtargets, | ||||
M_MPR, M_WAITOK|M_ZERO); | M_MPR, M_WAITOK|M_ZERO); | ||||
if (!sassc->targets) { | |||||
panic("%s failed to alloc targets with error %d\n", | |||||
__func__, ENOMEM); | |||||
} | |||||
} | } |