Skip to content

Commit

Permalink
Merge tag 'fixes-for-v4.18-rc5' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/balbi/usb into usb-linus

Felipe writes:

usb: fixes for v4.18-rc5

With a total of 20 non-merge commits, we have accumulated quite a few
fixes. These include lot's of fixes the our audio gadget interface, a
build error fix for PPC64 builds for the frescale PHY driver,
sleep-while-atomic fixes on the r8a66597 UDC driver, 3-stage SETUP fix
for the aspeed-vhub UDC and some other misc fixes.
  • Loading branch information
Greg Kroah-Hartman committed Jul 17, 2018
2 parents 24dd9ba + eec24f2 commit 2c3806c
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 111 deletions.
3 changes: 2 additions & 1 deletion Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ A child node must exist to represent the core DWC3 IP block. The name of
the node is not important. The content of the node is defined in dwc3.txt.

Phy documentation is provided in the following places:
Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt
Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt - USB2.0 PHY
Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt - Type-C PHY

Example device nodes:

Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/dwc2/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -3430,7 +3430,7 @@ static void dwc2_gadget_handle_incomplete_isoc_in(struct dwc2_hsotg *hsotg)
for (idx = 1; idx < hsotg->num_of_eps; idx++) {
hs_ep = hsotg->eps_in[idx];
/* Proceed only unmasked ISOC EPs */
if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))
if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
continue;

epctrl = dwc2_readl(hsotg->regs + DIEPCTL(idx));
Expand Down Expand Up @@ -3476,7 +3476,7 @@ static void dwc2_gadget_handle_incomplete_isoc_out(struct dwc2_hsotg *hsotg)
for (idx = 1; idx < hsotg->num_of_eps; idx++) {
hs_ep = hsotg->eps_out[idx];
/* Proceed only unmasked ISOC EPs */
if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))
if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
continue;

epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));
Expand Down Expand Up @@ -3650,7 +3650,7 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw)
for (idx = 1; idx < hsotg->num_of_eps; idx++) {
hs_ep = hsotg->eps_out[idx];
/* Proceed only unmasked ISOC EPs */
if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))
if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
continue;

epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));
Expand Down
54 changes: 31 additions & 23 deletions drivers/usb/dwc2/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,57 +2665,65 @@ static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,

#define DWC2_USB_DMA_ALIGN 4

struct dma_aligned_buffer {
void *kmalloc_ptr;
void *old_xfer_buffer;
u8 data[0];
};

static void dwc2_free_dma_aligned_buffer(struct urb *urb)
{
struct dma_aligned_buffer *temp;
void *stored_xfer_buffer;
size_t length;

if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
return;

temp = container_of(urb->transfer_buffer,
struct dma_aligned_buffer, data);
/* Restore urb->transfer_buffer from the end of the allocated area */
memcpy(&stored_xfer_buffer, urb->transfer_buffer +
urb->transfer_buffer_length, sizeof(urb->transfer_buffer));

if (usb_urb_dir_in(urb))
memcpy(temp->old_xfer_buffer, temp->data,
urb->transfer_buffer_length);
urb->transfer_buffer = temp->old_xfer_buffer;
kfree(temp->kmalloc_ptr);
if (usb_urb_dir_in(urb)) {
if (usb_pipeisoc(urb->pipe))
length = urb->transfer_buffer_length;
else
length = urb->actual_length;

memcpy(stored_xfer_buffer, urb->transfer_buffer, length);
}
kfree(urb->transfer_buffer);
urb->transfer_buffer = stored_xfer_buffer;

urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
}

static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
{
struct dma_aligned_buffer *temp, *kmalloc_ptr;
void *kmalloc_ptr;
size_t kmalloc_size;

if (urb->num_sgs || urb->sg ||
urb->transfer_buffer_length == 0 ||
!((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
return 0;

/* Allocate a buffer with enough padding for alignment */
/*
* Allocate a buffer with enough padding for original transfer_buffer
* pointer. This allocation is guaranteed to be aligned properly for
* DMA
*/
kmalloc_size = urb->transfer_buffer_length +
sizeof(struct dma_aligned_buffer) + DWC2_USB_DMA_ALIGN - 1;
sizeof(urb->transfer_buffer);

kmalloc_ptr = kmalloc(kmalloc_size, mem_flags);
if (!kmalloc_ptr)
return -ENOMEM;

/* Position our struct dma_aligned_buffer such that data is aligned */
temp = PTR_ALIGN(kmalloc_ptr + 1, DWC2_USB_DMA_ALIGN) - 1;
temp->kmalloc_ptr = kmalloc_ptr;
temp->old_xfer_buffer = urb->transfer_buffer;
/*
* Position value of original urb->transfer_buffer pointer to the end
* of allocation for later referencing
*/
memcpy(kmalloc_ptr + urb->transfer_buffer_length,
&urb->transfer_buffer, sizeof(urb->transfer_buffer));

if (usb_urb_dir_out(urb))
memcpy(temp->data, urb->transfer_buffer,
memcpy(kmalloc_ptr, urb->transfer_buffer,
urb->transfer_buffer_length);
urb->transfer_buffer = temp->data;
urb->transfer_buffer = kmalloc_ptr;

urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;

Expand Down
9 changes: 7 additions & 2 deletions drivers/usb/dwc2/hcd_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,10 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
* avoid interrupt storms we'll wait before retrying if we've got
* several NAKs. If we didn't do this we'd retry directly from the
* interrupt handler and could end up quickly getting another
* interrupt (another NAK), which we'd retry.
* interrupt (another NAK), which we'd retry. Note that we do not
* delay retries for IN parts of control requests, as those are expected
* to complete fairly quickly, and if we delay them we risk confusing
* the device and cause it issue STALL.
*
* Note that in DMA mode software only gets involved to re-send NAKed
* transfers for split transactions, so we only need to apply this
Expand All @@ -1244,7 +1247,9 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
qtd->error_count = 0;
qtd->complete_split = 0;
qtd->num_naks++;
qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY;
qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY &&
!(chan->ep_type == USB_ENDPOINT_XFER_CONTROL &&
chan->ep_is_in);
dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_NAK);
goto handle_nak_done;
}
Expand Down
3 changes: 0 additions & 3 deletions drivers/usb/dwc3/ep0.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,15 +973,12 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
ret = dwc3_ep0_start_trans(dep);
} else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) &&
req->request.length && req->request.zero) {
u32 maxpacket;

ret = usb_gadget_map_request_by_dev(dwc->sysdev,
&req->request, dep->number);
if (ret)
return;

maxpacket = dep->endpoint.maxpacket;

/* prepare normal TRB */
dwc3_ep0_prepare_one_trb(dep, req->request.dma,
req->request.length,
Expand Down
1 change: 0 additions & 1 deletion drivers/usb/gadget/composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,6 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
if (cdev->use_os_string && cdev->os_desc_config &&
(ctrl->bRequestType & USB_TYPE_VENDOR) &&
ctrl->bRequest == cdev->b_vendor_code) {
struct usb_request *req;
struct usb_configuration *os_desc_cfg;
u8 *buf;
int interface;
Expand Down
24 changes: 12 additions & 12 deletions drivers/usb/gadget/function/f_uac2.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,14 @@ static struct usb_descriptor_header *hs_audio_desc[] = {
};

struct cntrl_cur_lay3 {
__u32 dCUR;
__le32 dCUR;
};

struct cntrl_range_lay3 {
__u16 wNumSubRanges;
__u32 dMIN;
__u32 dMAX;
__u32 dRES;
__le16 wNumSubRanges;
__le32 dMIN;
__le32 dMAX;
__le32 dRES;
} __packed;

static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
Expand Down Expand Up @@ -559,13 +559,13 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
if (!agdev->out_ep) {
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
return ret;
return -ENODEV;
}

agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
if (!agdev->in_ep) {
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
return ret;
return -ENODEV;
}

agdev->in_ep_maxpsize = max_t(u16,
Expand Down Expand Up @@ -703,9 +703,9 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
memset(&c, 0, sizeof(struct cntrl_cur_lay3));

if (entity_id == USB_IN_CLK_ID)
c.dCUR = p_srate;
c.dCUR = cpu_to_le32(p_srate);
else if (entity_id == USB_OUT_CLK_ID)
c.dCUR = c_srate;
c.dCUR = cpu_to_le32(c_srate);

value = min_t(unsigned, w_length, sizeof c);
memcpy(req->buf, &c, value);
Expand Down Expand Up @@ -742,15 +742,15 @@ in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)

if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) {
if (entity_id == USB_IN_CLK_ID)
r.dMIN = p_srate;
r.dMIN = cpu_to_le32(p_srate);
else if (entity_id == USB_OUT_CLK_ID)
r.dMIN = c_srate;
r.dMIN = cpu_to_le32(c_srate);
else
return -EOPNOTSUPP;

r.dMAX = r.dMIN;
r.dRES = 0;
r.wNumSubRanges = 1;
r.wNumSubRanges = cpu_to_le16(1);

value = min_t(unsigned, w_length, sizeof r);
memcpy(req->buf, &r, value);
Expand Down
Loading

0 comments on commit 2c3806c

Please sign in to comment.