mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
usb: host: fotg210: fix the endpoint's transactional opportunities calculation
Now that usb_endpoint_maxp() only returns the lowest 11 bits from wMaxPacketSize, we should make use of the usb_endpoint_* helpers instead and remove the unnecessary max_packet()/hb_mult() macro. Signed-off-by: Kelly Devilliv <kelly.devilliv@gmail.com> Link: https://lore.kernel.org/r/20210627125747.127646-3-kelly.devilliv@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c4c1faf825
commit
c2e8987642
1 changed files with 17 additions and 19 deletions
|
@ -2512,11 +2512,6 @@ static unsigned qh_completions(struct fotg210_hcd *fotg210,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
|
|
||||||
#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
|
|
||||||
/* ... and packet size, for any kind of endpoint descriptor */
|
|
||||||
#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
|
|
||||||
|
|
||||||
/* reverse of qh_urb_transaction: free a list of TDs.
|
/* reverse of qh_urb_transaction: free a list of TDs.
|
||||||
* used for cleanup after errors, before HC sees an URB's TDs.
|
* used for cleanup after errors, before HC sees an URB's TDs.
|
||||||
*/
|
*/
|
||||||
|
@ -2602,7 +2597,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
|
||||||
token |= (1 /* "in" */ << 8);
|
token |= (1 /* "in" */ << 8);
|
||||||
/* else it's already initted to "out" pid (0 << 8) */
|
/* else it's already initted to "out" pid (0 << 8) */
|
||||||
|
|
||||||
maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input));
|
maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* buffer gets wrapped in one or more qtds;
|
* buffer gets wrapped in one or more qtds;
|
||||||
|
@ -2716,9 +2711,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
|
||||||
gfp_t flags)
|
gfp_t flags)
|
||||||
{
|
{
|
||||||
struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
|
struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
|
||||||
|
struct usb_host_endpoint *ep;
|
||||||
u32 info1 = 0, info2 = 0;
|
u32 info1 = 0, info2 = 0;
|
||||||
int is_input, type;
|
int is_input, type;
|
||||||
int maxp = 0;
|
int maxp = 0;
|
||||||
|
int mult;
|
||||||
struct usb_tt *tt = urb->dev->tt;
|
struct usb_tt *tt = urb->dev->tt;
|
||||||
struct fotg210_qh_hw *hw;
|
struct fotg210_qh_hw *hw;
|
||||||
|
|
||||||
|
@ -2733,14 +2730,15 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
|
||||||
|
|
||||||
is_input = usb_pipein(urb->pipe);
|
is_input = usb_pipein(urb->pipe);
|
||||||
type = usb_pipetype(urb->pipe);
|
type = usb_pipetype(urb->pipe);
|
||||||
maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input);
|
ep = usb_pipe_endpoint(urb->dev, urb->pipe);
|
||||||
|
maxp = usb_endpoint_maxp(&ep->desc);
|
||||||
|
mult = usb_endpoint_maxp_mult(&ep->desc);
|
||||||
|
|
||||||
/* 1024 byte maxpacket is a hardware ceiling. High bandwidth
|
/* 1024 byte maxpacket is a hardware ceiling. High bandwidth
|
||||||
* acts like up to 3KB, but is built from smaller packets.
|
* acts like up to 3KB, but is built from smaller packets.
|
||||||
*/
|
*/
|
||||||
if (max_packet(maxp) > 1024) {
|
if (maxp > 1024) {
|
||||||
fotg210_dbg(fotg210, "bogus qh maxpacket %d\n",
|
fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp);
|
||||||
max_packet(maxp));
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2754,8 +2752,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
|
||||||
*/
|
*/
|
||||||
if (type == PIPE_INTERRUPT) {
|
if (type == PIPE_INTERRUPT) {
|
||||||
qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
|
qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
|
||||||
is_input, 0,
|
is_input, 0, mult * maxp));
|
||||||
hb_mult(maxp) * max_packet(maxp)));
|
|
||||||
qh->start = NO_FRAME;
|
qh->start = NO_FRAME;
|
||||||
|
|
||||||
if (urb->dev->speed == USB_SPEED_HIGH) {
|
if (urb->dev->speed == USB_SPEED_HIGH) {
|
||||||
|
@ -2792,7 +2789,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
|
||||||
think_time = tt ? tt->think_time : 0;
|
think_time = tt ? tt->think_time : 0;
|
||||||
qh->tt_usecs = NS_TO_US(think_time +
|
qh->tt_usecs = NS_TO_US(think_time +
|
||||||
usb_calc_bus_time(urb->dev->speed,
|
usb_calc_bus_time(urb->dev->speed,
|
||||||
is_input, 0, max_packet(maxp)));
|
is_input, 0, maxp));
|
||||||
qh->period = urb->interval;
|
qh->period = urb->interval;
|
||||||
if (qh->period > fotg210->periodic_size) {
|
if (qh->period > fotg210->periodic_size) {
|
||||||
qh->period = fotg210->periodic_size;
|
qh->period = fotg210->periodic_size;
|
||||||
|
@ -2855,11 +2852,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
|
||||||
* to help them do so. So now people expect to use
|
* to help them do so. So now people expect to use
|
||||||
* such nonconformant devices with Linux too; sigh.
|
* such nonconformant devices with Linux too; sigh.
|
||||||
*/
|
*/
|
||||||
info1 |= max_packet(maxp) << 16;
|
info1 |= maxp << 16;
|
||||||
info2 |= (FOTG210_TUNE_MULT_HS << 30);
|
info2 |= (FOTG210_TUNE_MULT_HS << 30);
|
||||||
} else { /* PIPE_INTERRUPT */
|
} else { /* PIPE_INTERRUPT */
|
||||||
info1 |= max_packet(maxp) << 16;
|
info1 |= maxp << 16;
|
||||||
info2 |= hb_mult(maxp) << 30;
|
info2 |= mult << 30;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -3929,6 +3926,7 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
|
||||||
int is_input;
|
int is_input;
|
||||||
long bandwidth;
|
long bandwidth;
|
||||||
unsigned multi;
|
unsigned multi;
|
||||||
|
struct usb_host_endpoint *ep;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this might be a "high bandwidth" highspeed endpoint,
|
* this might be a "high bandwidth" highspeed endpoint,
|
||||||
|
@ -3936,14 +3934,14 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
|
||||||
*/
|
*/
|
||||||
epnum = usb_pipeendpoint(pipe);
|
epnum = usb_pipeendpoint(pipe);
|
||||||
is_input = usb_pipein(pipe) ? USB_DIR_IN : 0;
|
is_input = usb_pipein(pipe) ? USB_DIR_IN : 0;
|
||||||
maxp = usb_maxpacket(dev, pipe, !is_input);
|
ep = usb_pipe_endpoint(dev, pipe);
|
||||||
|
maxp = usb_endpoint_maxp(&ep->desc);
|
||||||
if (is_input)
|
if (is_input)
|
||||||
buf1 = (1 << 11);
|
buf1 = (1 << 11);
|
||||||
else
|
else
|
||||||
buf1 = 0;
|
buf1 = 0;
|
||||||
|
|
||||||
maxp = max_packet(maxp);
|
multi = usb_endpoint_maxp_mult(&ep->desc);
|
||||||
multi = hb_mult(maxp);
|
|
||||||
buf1 |= maxp;
|
buf1 |= maxp;
|
||||||
maxp *= multi;
|
maxp *= multi;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue