Date: Thu, 5 Feb 2009 09:26:59 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 157203 for review Message-ID: <200902050926.n159QxeX012662@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=157203 Change 157203 by hselasky@hselasky_laptop001 on 2009/02/05 09:26:14 USB2 mass storage: Remove CAM layer quirks. According to Edward Tomasz, trasz, the issues being worked around have been resolved. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/storage/umass2.c#27 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/storage/umass2.c#27 (text+ko) ==== @@ -168,7 +168,6 @@ #endif #define UMASS_GONE ((struct umass_softc *)1) -#define UMASS_MAXUNIT 64 /* XXX temporary */ #define UMASS_BULK_SIZE (1 << 17) #define UMASS_CBI_DIAGNOSTIC_CMDLEN 12 /* bytes */ @@ -1044,7 +1043,6 @@ static uint8_t umass_no_transform(struct umass_softc *, uint8_t *, uint8_t); static uint8_t umass_std_transform(struct umass_softc *, union ccb *, uint8_t *, uint8_t); -static int umass_driver_loaded(struct module *, int what, void *); #if USB_DEBUG static void umass_bbb_dump_cbw(struct umass_softc *, umass_bbb_cbw_t *); @@ -1267,9 +1265,6 @@ #define UFI_COMMAND_LENGTH 12 /* UFI commands are always 12 bytes */ #define ATAPI_COMMAND_LENGTH 12 /* ATAPI commands are always 12 bytes */ -static struct cam_sim *umass_sim[UMASS_MAXUNIT]; -static struct mtx umass_mtx; - static devclass_t umass_devclass; static device_method_t umass_methods[] = { @@ -1286,7 +1281,7 @@ .size = sizeof(struct umass_softc), }; -DRIVER_MODULE(umass, ushub, umass_driver, umass_devclass, umass_driver_loaded, 0); +DRIVER_MODULE(umass, ushub, umass_driver, umass_devclass, NULL, 0); MODULE_DEPEND(umass, usb2_storage, 1, 1, 1); MODULE_DEPEND(umass, usb2_core, 1, 1, 1); MODULE_DEPEND(umass, cam, 1, 1, 1); @@ -1444,11 +1439,6 @@ struct usb2_interface_descriptor *id; int32_t err; - if (device_get_unit(dev) >= UMASS_MAXUNIT) { - device_printf(dev, "Maxunit(%u) limit reached!\n", - UMASS_MAXUNIT); - return (ENOMEM); - } /* * NOTE: the softc struct is bzero-ed in device_set_driver. * We can safely call umass_detach without specifically @@ -1466,6 +1456,9 @@ device_set_usb2_desc(dev); + mtx_init(&sc->sc_mtx, device_get_nameunit(dev), + NULL, MTX_DEF | MTX_RECURSE); + /* get interface index */ id = usb2_get_interface_descriptor(uaa->iface); @@ -1534,7 +1527,7 @@ err = usb2_transfer_setup(uaa->device, &uaa->info.bIfaceIndex, sc->sc_xfer, umass_bbb_config, - UMASS_T_BBB_MAX, sc, &umass_mtx); + UMASS_T_BBB_MAX, sc, &sc->sc_mtx); /* skip reset first time */ sc->sc_last_xfer_index = UMASS_T_BBB_COMMAND; @@ -1545,7 +1538,7 @@ &uaa->info.bIfaceIndex, sc->sc_xfer, umass_cbi_config, (sc->sc_proto & UMASS_PROTO_CBI_I) ? UMASS_T_CBI_MAX : (UMASS_T_CBI_MAX - 2), sc, - &umass_mtx); + &sc->sc_mtx); /* skip reset first time */ sc->sc_last_xfer_index = UMASS_T_CBI_COMMAND; @@ -1618,12 +1611,12 @@ usb2_transfer_unsetup(sc->sc_xfer, UMASS_T_MAX); #if (__FreeBSD_version >= 700037) - mtx_lock(&umass_mtx); + mtx_lock(&sc->sc_mtx); #endif umass_cam_detach_sim(sc); #if (__FreeBSD_version >= 700037) - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); #endif return (0); /* success */ @@ -1687,7 +1680,7 @@ { union ccb *ccb; - mtx_assert(&umass_mtx, MA_OWNED); + mtx_assert(&sc->sc_mtx, MA_OWNED); ccb = sc->sc_transfer.ccb; sc->sc_transfer.ccb = NULL; @@ -2599,10 +2592,6 @@ { struct cam_devq *devq; /* Per device Queue */ - if (umass_sim[sc->sc_unit] != NULL) { - sc->sc_sim = umass_sim[sc->sc_unit]; - goto register_only; - } /* * A HBA is attached to the CAM layer. * @@ -2620,7 +2609,7 @@ sc /* priv */ , sc->sc_unit /* unit number */ , #if (__FreeBSD_version >= 700037) - &umass_mtx /* mutex */ , + &sc->sc_mtx /* mutex */ , #endif 1 /* maximum device openings */ , 0 /* maximum tagged device openings */ , @@ -2630,33 +2619,27 @@ cam_simq_free(devq); return (ENOMEM); } - umass_sim[sc->sc_unit] = sc->sc_sim; - -register_only: - - /* update the softc pointer */ - sc->sc_sim->softc = sc; #if (__FreeBSD_version >= 700037) - mtx_lock(&umass_mtx); + mtx_lock(&sc->sc_mtx); #endif #if (__FreeBSD_version >= 700048) if (xpt_bus_register(sc->sc_sim, sc->sc_dev, sc->sc_unit) != CAM_SUCCESS) { - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); return (ENOMEM); } #else if (xpt_bus_register(sc->sc_sim, sc->sc_unit) != CAM_SUCCESS) { #if (__FreeBSD_version >= 700037) - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); #endif return (ENOMEM); } #endif #if (__FreeBSD_version >= 700037) - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); #endif return (0); } @@ -2698,14 +2681,14 @@ return; } #if (__FreeBSD_version >= 700037) - mtx_lock(&umass_mtx); + mtx_lock(&sc->sc_mtx); #endif if (xpt_create_path(&path, xpt_periph, cam_sim_path(sc->sc_sim), CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { #if (__FreeBSD_version >= 700037) - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); #endif free(ccb, M_USBDEV); return; @@ -2717,7 +2700,7 @@ xpt_action(ccb); #if (__FreeBSD_version >= 700037) - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); #endif /* The scan is in progress now. */ @@ -2755,14 +2738,11 @@ static void umass_cam_detach_sim(struct umass_softc *sc) { - if (sc->sc_sim) { + if (sc->sc_sim != NULL) { if (xpt_bus_deregister(cam_sim_path(sc->sc_sim))) { -#if 0 /* NOTYET */ - cam_sim_free(sc->sc_sim, /* free_devq */ TRUE); -#else /* accessing the softc is not possible after this */ sc->sc_sim->softc = UMASS_GONE; -#endif + cam_sim_free(sc->sc_sim, /* free_devq */ TRUE); } else { panic("%s: CAM layer is busy!\n", sc->sc_name); @@ -2787,7 +2767,7 @@ } if (sc) { #if (__FreeBSD_version < 700037) - mtx_lock(&umass_mtx); + mtx_lock(&sc->sc_mtx); #endif } /* @@ -3071,7 +3051,7 @@ done: #if (__FreeBSD_version < 700037) if (sc) { - mtx_unlock(&umass_mtx); + mtx_unlock(&sc->sc_mtx); } #endif return; @@ -3638,28 +3618,3 @@ } #endif - -static int -umass_driver_loaded(struct module *mod, int what, void *arg) -{ - uint16_t x; - - switch (what) { - case MOD_LOAD: - mtx_init(&umass_mtx, "UMASS lock", NULL, (MTX_DEF | MTX_RECURSE)); - break; - - case MOD_UNLOAD: - for (x = 0; x != UMASS_MAXUNIT; x++) { - /* cleanup */ - if (umass_sim[x]) - cam_sim_free(umass_sim[x], /* free_devq */ TRUE); - } - mtx_destroy(&umass_mtx); - break; - default: - return (EOPNOTSUPP); - } - - return (0); -}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902050926.n159QxeX012662>