Commit f513e021 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: Don't track endpoint halts in usbcore

This patch is a repeat of as331 as described in

http://marc.theaimsgroup.com/?l=linux-usb-devel&m=108811725219677&w=2

It has been updated slightly to match the current source.  It should be
non-controversial; it has nothing to do with hubs or locking.  Please
apply.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 07d45d36
......@@ -143,9 +143,6 @@ static void usb_ctrl_complete(struct urb *urb, struct pt_regs *regs)
if (ctrl_msg->dr.bRequest == USB_REQ_CLEAR_FEATURE) {
/* Special case handling for pipe reset */
le16_to_cpus(&ctrl_msg->dr.wIndex);
usb_endpoint_running(adapter->usb_dev,
ctrl_msg->dr.wIndex & ~USB_DIR_IN,
(ctrl_msg->dr.wIndex & USB_DIR_IN) == 0);
/* toggle is reset on clear */
usb_settoggle(adapter->usb_dev,
......
......@@ -283,9 +283,8 @@ static char *usb_dump_interface(
/* TBD:
* 0. TBDs
* 1. marking active config and ifaces (code lists all, but should mark
* 1. marking active interface altsettings (code lists all, but should mark
* which ones are active, if any)
* 2. add <halted> status to each endpoint line
*/
static char *usb_dump_config_descriptor(char *start, char *end, const struct usb_config_descriptor *desc, int active)
......
......@@ -1311,13 +1311,10 @@ static void hcd_endpoint_disable (struct usb_device *udev, int endpoint)
rescan:
/* (re)block new requests, as best we can */
if (endpoint & USB_DIR_IN) {
usb_endpoint_halt (udev, epnum, 0);
if (endpoint & USB_DIR_IN)
udev->epmaxpacketin [epnum] = 0;
} else {
usb_endpoint_halt (udev, epnum, 1);
else
udev->epmaxpacketout [epnum] = 0;
}
/* then kill any current requests */
spin_lock (&hcd_data_lock);
......
......@@ -376,8 +376,6 @@ extern void usb_bus_put (struct usb_bus *bus);
extern int usb_find_interface_driver (struct usb_device *dev,
struct usb_interface *interface);
#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
/*
......
......@@ -2044,8 +2044,6 @@ hub_port_init (struct usb_device *hdev, struct usb_device *udev, int port)
!= udev->descriptor.bMaxPacketSize0)) {
usb_disable_endpoint(udev, 0 + USB_DIR_IN);
usb_disable_endpoint(udev, 0 + USB_DIR_OUT);
usb_endpoint_running(udev, 0, 1);
usb_endpoint_running(udev, 0, 0);
udev->epmaxpacketin [0] = udev->descriptor.bMaxPacketSize0;
udev->epmaxpacketout[0] = udev->descriptor.bMaxPacketSize0;
}
......
......@@ -859,9 +859,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
* the copy in usb-storage, for as long as we need two copies.
*/
/* toggle was reset by the clear, then ep was reactivated */
/* toggle was reset by the clear */
usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);
usb_endpoint_running(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
return 0;
}
......@@ -875,9 +874,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
* Deallocates hcd/hardware state for this endpoint ... and nukes all
* pending urbs.
*
* If the HCD hasn't registered a disable() function, this marks the
* endpoint as halted and sets its maxpacket size to 0 to prevent
* further submissions.
* If the HCD hasn't registered a disable() function, this sets the
* endpoint's maxpacket size to 0 to prevent further submissions.
*/
void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr)
{
......@@ -886,13 +884,10 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr)
else {
unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK;
if (usb_endpoint_out(epaddr)) {
usb_endpoint_halt(dev, epnum, 1);
if (usb_endpoint_out(epaddr))
dev->epmaxpacketout[epnum] = 0;
} else {
usb_endpoint_halt(dev, epnum, 0);
else
dev->epmaxpacketin[epnum] = 0;
}
}
}
......@@ -935,7 +930,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
usb_disable_endpoint(dev, i + USB_DIR_IN);
}
dev->toggle[0] = dev->toggle[1] = 0;
dev->halted[0] = dev->halted[1] = 0;
/* getting rid of interfaces will disconnect
* any drivers bound to them (a key side effect)
......@@ -971,9 +965,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
* @dev: the device whose interface is being enabled
* @epd: pointer to the endpoint descriptor
*
* Marks the endpoint as running, resets its toggle, and stores
* its maxpacket value. For control endpoints, both the input
* and output sides are handled.
* Resets the endpoint toggle and stores its maxpacket value.
* For control endpoints, both the input and output sides are handled.
*/
void usb_enable_endpoint(struct usb_device *dev,
struct usb_endpoint_descriptor *epd)
......@@ -985,12 +978,10 @@ void usb_enable_endpoint(struct usb_device *dev,
USB_ENDPOINT_XFER_CONTROL);
if (usb_endpoint_out(epaddr) || is_control) {
usb_endpoint_running(dev, epnum, 1);
usb_settoggle(dev, epnum, 1, 0);
dev->epmaxpacketout[epnum] = maxsize;
}
if (!usb_endpoint_out(epaddr) || is_control) {
usb_endpoint_running(dev, epnum, 0);
usb_settoggle(dev, epnum, 0, 0);
dev->epmaxpacketin[epnum] = maxsize;
}
......@@ -1171,7 +1162,6 @@ int usb_reset_configuration(struct usb_device *dev)
}
dev->toggle[0] = dev->toggle[1] = 0;
dev->halted[0] = dev->halted[1] = 0;
/* re-init hc/hcd interface/endpoint state */
for (i = 0; i < config->desc.bNumInterfaces; i++) {
......
......@@ -256,13 +256,6 @@ int usb_submit_urb(struct urb *urb, int mem_flags)
if (!usb_pipecontrol (pipe) && dev->state < USB_STATE_CONFIGURED)
return -ENODEV;
/* (actually HCDs may need to duplicate this, endpoint might yet
* stall due to queued bulk/intr transactions that complete after
* we check)
*/
if (usb_endpoint_halted (dev, usb_pipeendpoint (pipe), is_out))
return -EPIPE;
/* FIXME there should be a sharable lock protecting us against
* config/altsetting changes and disconnects, kicking in here.
* (here == before maxpacket, and eventually endpoint type,
......
......@@ -153,17 +153,9 @@ static void qtd_copy_status (
usb_pipein (urb->pipe) ? "in" : "out",
token, urb->status);
/* stall indicates some recovery action is needed */
if (urb->status == -EPIPE) {
int pipe = urb->pipe;
if (!usb_pipecontrol (pipe))
usb_endpoint_halt (urb->dev,
usb_pipeendpoint (pipe),
usb_pipeout (pipe));
/* if async CSPLIT failed, try cleaning out the TT buffer */
} else if (urb->dev->tt && !usb_pipeint (urb->pipe)
if (urb->status != -EPIPE
&& urb->dev->tt && !usb_pipeint (urb->pipe)
&& ((token & QTD_STS_MMF) != 0
|| QTD_CERR(token) == 0)
&& (!ehci_is_ARC(ehci)
......
......@@ -146,11 +146,6 @@ static int hci_submit_urb (struct urb * urb, int mem_flags)
if (!urb->dev || !urb->dev->bus || urb->hcpriv)
return -EINVAL;
if (usb_endpoint_halted
(urb->dev, usb_pipeendpoint (pipe), usb_pipeout (pipe))) {
printk ("hci_submit_urb: endpoint_halted\n");
return -EPIPE;
}
hci = (hci_t *) urb->dev->bus->hcpriv;
/* a request to the virtual root hub */
......
......@@ -751,12 +751,6 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
cc = TD_CC_GET (tdINFO);
/* control endpoints only have soft stalls */
if (type != PIPE_CONTROL && cc == TD_CC_STALL)
usb_endpoint_halt (urb->dev,
usb_pipeendpoint (urb->pipe),
usb_pipeout (urb->pipe));
/* update packet status if needed (short is normally ok) */
if (cc == TD_DATAUNDERRUN
&& !(urb->transfer_flags & URB_SHORT_NOT_OK))
......
......@@ -1120,10 +1120,6 @@ static int uhci_result_common(struct uhci_hcd *uhci, struct urb *urb)
td_error:
ret = uhci_map_status(status, uhci_packetout(td_token(td)));
if (ret == -EPIPE)
/* endpoint has stalled - mark it halted */
usb_endpoint_halt(urb->dev, uhci_endpoint(td_token(td)),
uhci_packetout(td_token(td)));
err:
/*
......
......@@ -214,8 +214,8 @@ static struct usb_driver mts_usb_driver = {
#ifdef MTS_DO_DEBUG
static inline void mts_debug_dump(struct mts_desc* desc) {
MTS_DEBUG("desc at 0x%x: halted = %02x%02x, toggle = %02x%02x\n",
(int)desc,(int)desc->usb_dev->halted[1],(int)desc->usb_dev->halted[0],
MTS_DEBUG("desc at 0x%x: toggle = %02x%02x\n",
(int)desc,
(int)desc->usb_dev->toggle[1],(int)desc->usb_dev->toggle[0]
);
MTS_DEBUG("ep_out=%x ep_response=%x ep_image=%x\n",
......
......@@ -265,9 +265,7 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
USB_ENDPOINT_HALT, endp,
NULL, 0, 3*HZ);
/* reset the toggles and endpoint flags */
usb_endpoint_running(us->pusb_dev, usb_pipeendpoint(pipe),
usb_pipeout(pipe));
/* reset the endpoint toggle */
usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
usb_pipeout(pipe), 0);
......
......@@ -294,8 +294,6 @@ struct usb_device {
struct semaphore serialize;
unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */
unsigned int halted[2]; /* endpoint halts; one bit per endpoint # & direction; */
/* [0] = IN, [1] = OUT */
int epmaxpacketin[16]; /* INput endpoint specific maximums */
int epmaxpacketout[16]; /* OUTput endpoint specific maximums */
......@@ -1084,10 +1082,6 @@ void usb_sg_wait (struct usb_sg_request *io);
#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep)))
#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep)))
/* Endpoint halt control/status ... likewise USE WITH CAUTION */
#define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
#define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment