MFp4 //depot/projects/usb; 157203

- Remove CAM layer quirks

Submitted by:	Hans Petter Selasky
This commit is contained in:
Andrew Thompson 2009-02-09 22:09:21 +00:00
parent fc7ca11552
commit d102bcfd1b

View File

@ -168,7 +168,6 @@ SYSCTL_INT(_hw_usb2_umass, OID_AUTO, debug, CTLFLAG_RW,
#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_atapi_transform(struct umass_softc *, uint8_t *,
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 @@ static const uint8_t fake_inq_data[SHORT_INQUIRY_LENGTH] = {
#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 @@ static driver_t umass_driver = {
.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 @@ umass_attach(device_t dev)
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 @@ umass_attach(device_t dev)
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 @@ umass_attach(device_t dev)
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 @@ umass_attach(device_t dev)
&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;
@ -1587,7 +1580,7 @@ umass_attach(device_t dev)
* some devices need a delay after that the configuration value is
* set to function properly:
*/
usb2_pause_mtx(&Giant, USB_MS_HZ);
usb2_pause_mtx(&Giant, hz);
/* register the SIM */
err = umass_cam_attach_sim(sc);
@ -1618,12 +1611,12 @@ umass_detach(device_t dev)
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 @@ umass_cancel_ccb(struct umass_softc *sc)
{
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 @@ umass_cam_attach_sim(struct umass_softc *sc)
{
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 @@ umass_cam_attach_sim(struct umass_softc *sc)
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 @@ umass_cam_attach_sim(struct umass_softc *sc)
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 @@ umass_cam_rescan(struct umass_softc *sc)
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 @@ umass_cam_rescan(struct umass_softc *sc)
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 @@ umass_cam_attach(struct umass_softc *sc)
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 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
}
if (sc) {
#if (__FreeBSD_version < 700037)
mtx_lock(&umass_mtx);
mtx_lock(&sc->sc_mtx);
#endif
}
/*
@ -3071,7 +3051,7 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
done:
#if (__FreeBSD_version < 700037)
if (sc) {
mtx_unlock(&umass_mtx);
mtx_unlock(&sc->sc_mtx);
}
#endif
return;
@ -3638,28 +3618,3 @@ umass_dump_buffer(struct umass_softc *sc, uint8_t *buffer, uint32_t buflen,
}
#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);
}