aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-01 14:50:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-01 14:50:16 -0400
commitc2aee376cf35d609feb8926afeb1d11e069a378c (patch)
tree2b3b794c8f78b2671c9b292eebef8f30bcb741e8
parentc350d6d1d78789d73e8bf2047ab6564a4af4a02b (diff)
parent226e2d2d31b1606c5fa8fb285b11e38badbad259 (diff)
Merge tag 'usb-4.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here is a number of USB gadget and other driver fixes for 4.18-rc3. There's a bunch of them here, most of them being gadget driver and xhci host controller fixes for reported issues (as normal), but there are also some new device ids, and some fixes for the typec code. There is an acpi core patch in here that was acked by the acpi maintainer as it is needed for the typec fixes in order to properly solve a problem in that driver. All of these have been in linux-next this week with no reported issues" * tag 'usb-4.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (33 commits) usb: chipidea: host: fix disconnection detect issue usb: typec: tcpm: fix logbuffer index is wrong if _tcpm_log is re-entered typec: tcpm: Fix a msecs vs jiffies bug NFC: pn533: Fix wrong GFP flag usage usb: cdc_acm: Add quirk for Uniden UBC125 scanner staging/typec: fix tcpci_rt1711h build errors usb: typec: ucsi: Fix for incorrect status data issue usb: typec: ucsi: acpi: Workaround for cache mode issue acpi: Add helper for deactivating memory region usb: xhci: increase CRS timeout value usb: xhci: tegra: fix runtime PM error handling usb: xhci: remove the code build warning xhci: Fix kernel oops in trace_xhci_free_virt_device xhci: Fix perceived dead host due to runtime suspend race with event handler dwc2: gadget: Fix ISOC IN DDMA PID bitfield value calculation usb: gadget: dwc2: fix memory leak in gadget_init() usb: gadget: composite: fix delayed_status race condition when set_interface usb: dwc2: fix isoc split in transfer with no data usb: dwc2: alloc dma aligned buffer for isoc split in usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub ...
-rw-r--r--Documentation/usb/gadget_configfs.txt2
-rw-r--r--drivers/acpi/osl.c72
-rw-r--r--drivers/nfc/pn533/usb.c4
-rw-r--r--drivers/staging/typec/Kconfig1
-rw-r--r--drivers/usb/chipidea/host.c5
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/dwc2/core.h3
-rw-r--r--drivers/usb/dwc2/gadget.c20
-rw-r--r--drivers/usb/dwc2/hcd.c93
-rw-r--r--drivers/usb/dwc2/hcd.h8
-rw-r--r--drivers/usb/dwc2/hcd_intr.c11
-rw-r--r--drivers/usb/dwc2/hcd_queue.c5
-rw-r--r--drivers/usb/dwc3/core.c23
-rw-r--r--drivers/usb/dwc3/dwc3-of-simple.c3
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/dwc3/dwc3-qcom.c13
-rw-r--r--drivers/usb/gadget/composite.c3
-rw-r--r--drivers/usb/gadget/function/f_fs.c26
-rw-r--r--drivers/usb/host/xhci-mem.c4
-rw-r--r--drivers/usb/host/xhci-tegra.c6
-rw-r--r--drivers/usb/host/xhci-trace.h36
-rw-r--r--drivers/usb/host/xhci.c47
-rw-r--r--drivers/usb/host/xhci.h4
-rw-r--r--drivers/usb/serial/cp210x.c14
-rw-r--r--drivers/usb/typec/tcpm.c10
-rw-r--r--drivers/usb/typec/ucsi/ucsi.c13
-rw-r--r--drivers/usb/typec/ucsi/ucsi_acpi.c5
-rw-r--r--include/linux/acpi.h3
28 files changed, 373 insertions, 66 deletions
diff --git a/Documentation/usb/gadget_configfs.txt b/Documentation/usb/gadget_configfs.txt
index 635e57493709..b8cb38a98c19 100644
--- a/Documentation/usb/gadget_configfs.txt
+++ b/Documentation/usb/gadget_configfs.txt
@@ -226,7 +226,7 @@ $ rm configs/<config name>.<number>/<function>
226where <config name>.<number> specify the configuration and <function> is 226where <config name>.<number> specify the configuration and <function> is
227a symlink to a function being removed from the configuration, e.g.: 227a symlink to a function being removed from the configuration, e.g.:
228 228
229$ rm configfs/c.1/ncm.usb0 229$ rm configs/c.1/ncm.usb0
230 230
231... 231...
232... 232...
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 7ca41bf023c9..8df9abfa947b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -45,6 +45,8 @@
45#include <linux/uaccess.h> 45#include <linux/uaccess.h>
46#include <linux/io-64-nonatomic-lo-hi.h> 46#include <linux/io-64-nonatomic-lo-hi.h>
47 47
48#include "acpica/accommon.h"
49#include "acpica/acnamesp.h"
48#include "internal.h" 50#include "internal.h"
49 51
50#define _COMPONENT ACPI_OS_SERVICES 52#define _COMPONENT ACPI_OS_SERVICES
@@ -1490,6 +1492,76 @@ int acpi_check_region(resource_size_t start, resource_size_t n,
1490} 1492}
1491EXPORT_SYMBOL(acpi_check_region); 1493EXPORT_SYMBOL(acpi_check_region);
1492 1494
1495static acpi_status acpi_deactivate_mem_region(acpi_handle handle, u32 level,
1496 void *_res, void **return_value)
1497{
1498 struct acpi_mem_space_context **mem_ctx;
1499 union acpi_operand_object *handler_obj;
1500 union acpi_operand_object *region_obj2;
1501 union acpi_operand_object *region_obj;
1502 struct resource *res = _res;
1503 acpi_status status;
1504
1505 region_obj = acpi_ns_get_attached_object(handle);
1506 if (!region_obj)
1507 return AE_OK;
1508
1509 handler_obj = region_obj->region.handler;
1510 if (!handler_obj)
1511 return AE_OK;
1512
1513 if (region_obj->region.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
1514 return AE_OK;
1515
1516 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE))
1517 return AE_OK;
1518
1519 region_obj2 = acpi_ns_get_secondary_object(region_obj);
1520 if (!region_obj2)
1521 return AE_OK;
1522
1523 mem_ctx = (void *)&region_obj2->extra.region_context;
1524
1525 if (!(mem_ctx[0]->address >= res->start &&
1526 mem_ctx[0]->address < res->end))
1527 return AE_OK;
1528
1529 status = handler_obj->address_space.setup(region_obj,
1530 ACPI_REGION_DEACTIVATE,
1531 NULL, (void **)mem_ctx);
1532 if (ACPI_SUCCESS(status))
1533 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
1534
1535 return status;
1536}
1537
1538/**
1539 * acpi_release_memory - Release any mappings done to a memory region
1540 * @handle: Handle to namespace node
1541 * @res: Memory resource
1542 * @level: A level that terminates the search
1543 *
1544 * Walks through @handle and unmaps all SystemMemory Operation Regions that
1545 * overlap with @res and that have already been activated (mapped).
1546 *
1547 * This is a helper that allows drivers to place special requirements on memory
1548 * region that may overlap with operation regions, primarily allowing them to
1549 * safely map the region as non-cached memory.
1550 *
1551 * The unmapped Operation Regions will be automatically remapped next time they
1552 * are called, so the drivers do not need to do anything else.
1553 */
1554acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
1555 u32 level)
1556{
1557 if (!(res->flags & IORESOURCE_MEM))
1558 return AE_TYPE;
1559
1560 return acpi_walk_namespace(ACPI_TYPE_REGION, handle, level,
1561 acpi_deactivate_mem_region, NULL, res, NULL);
1562}
1563EXPORT_SYMBOL_GPL(acpi_release_memory);
1564
1493/* 1565/*
1494 * Let drivers know whether the resource checks are effective 1566 * Let drivers know whether the resource checks are effective
1495 */ 1567 */
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index d5553c47014f..5d823e965883 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -74,7 +74,7 @@ static void pn533_recv_response(struct urb *urb)
74 struct sk_buff *skb = NULL; 74 struct sk_buff *skb = NULL;
75 75
76 if (!urb->status) { 76 if (!urb->status) {
77 skb = alloc_skb(urb->actual_length, GFP_KERNEL); 77 skb = alloc_skb(urb->actual_length, GFP_ATOMIC);
78 if (!skb) { 78 if (!skb) {
79 nfc_err(&phy->udev->dev, "failed to alloc memory\n"); 79 nfc_err(&phy->udev->dev, "failed to alloc memory\n");
80 } else { 80 } else {
@@ -186,7 +186,7 @@ static int pn533_usb_send_frame(struct pn533 *dev,
186 186
187 if (dev->protocol_type == PN533_PROTO_REQ_RESP) { 187 if (dev->protocol_type == PN533_PROTO_REQ_RESP) {
188 /* request for response for sent packet directly */ 188 /* request for response for sent packet directly */
189 rc = pn533_submit_urb_for_response(phy, GFP_ATOMIC); 189 rc = pn533_submit_urb_for_response(phy, GFP_KERNEL);
190 if (rc) 190 if (rc)
191 goto error; 191 goto error;
192 } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) { 192 } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) {
diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig
index 3aa981fbc8f5..e45ed08a5166 100644
--- a/drivers/staging/typec/Kconfig
+++ b/drivers/staging/typec/Kconfig
@@ -11,6 +11,7 @@ config TYPEC_TCPCI
11 11
12config TYPEC_RT1711H 12config TYPEC_RT1711H
13 tristate "Richtek RT1711H Type-C chip driver" 13 tristate "Richtek RT1711H Type-C chip driver"
14 depends on I2C
14 select TYPEC_TCPCI 15 select TYPEC_TCPCI
15 help 16 help
16 Richtek RT1711H Type-C chip driver that works with 17 Richtek RT1711H Type-C chip driver that works with
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index af45aa3222b5..4638d9b066be 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -124,8 +124,11 @@ static int host_start(struct ci_hdrc *ci)
124 124
125 hcd->power_budget = ci->platdata->power_budget; 125 hcd->power_budget = ci->platdata->power_budget;
126 hcd->tpl_support = ci->platdata->tpl_support; 126 hcd->tpl_support = ci->platdata->tpl_support;
127 if (ci->phy || ci->usb_phy) 127 if (ci->phy || ci->usb_phy) {
128 hcd->skip_phy_initialization = 1; 128 hcd->skip_phy_initialization = 1;
129 if (ci->usb_phy)
130 hcd->usb_phy = ci->usb_phy;
131 }
129 132
130 ehci = hcd_to_ehci(hcd); 133 ehci = hcd_to_ehci(hcd);
131 ehci->caps = ci->hw_bank.cap; 134 ehci->caps = ci->hw_bank.cap;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 7b366a6c0b49..998b32d0167e 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1758,6 +1758,9 @@ static const struct usb_device_id acm_ids[] = {
1758 { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */ 1758 { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */
1759 .driver_info = SINGLE_RX_URB, 1759 .driver_info = SINGLE_RX_URB,
1760 }, 1760 },
1761 { USB_DEVICE(0x1965, 0x0018), /* Uniden UBC125XLT */
1762 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1763 },
1761 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ 1764 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
1762 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1765 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1763 }, 1766 },
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 4a56ac772a3c..71b3b08ad516 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1004,6 +1004,7 @@ struct dwc2_hregs_backup {
1004 * @frame_list_sz: Frame list size 1004 * @frame_list_sz: Frame list size
1005 * @desc_gen_cache: Kmem cache for generic descriptors 1005 * @desc_gen_cache: Kmem cache for generic descriptors
1006 * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors 1006 * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors
1007 * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf
1007 * 1008 *
1008 * These are for peripheral mode: 1009 * These are for peripheral mode:
1009 * 1010 *
@@ -1177,6 +1178,8 @@ struct dwc2_hsotg {
1177 u32 frame_list_sz; 1178 u32 frame_list_sz;
1178 struct kmem_cache *desc_gen_cache; 1179 struct kmem_cache *desc_gen_cache;
1179 struct kmem_cache *desc_hsisoc_cache; 1180 struct kmem_cache *desc_hsisoc_cache;
1181 struct kmem_cache *unaligned_cache;
1182#define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024
1180 1183
1181#endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */ 1184#endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
1182 1185
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f0d9ccf1d665..a0f82cca2d9a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -812,6 +812,7 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
812 u32 index; 812 u32 index;
813 u32 maxsize = 0; 813 u32 maxsize = 0;
814 u32 mask = 0; 814 u32 mask = 0;
815 u8 pid = 0;
815 816
816 maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask); 817 maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask);
817 818
@@ -840,7 +841,11 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
840 ((len << DEV_DMA_NBYTES_SHIFT) & mask)); 841 ((len << DEV_DMA_NBYTES_SHIFT) & mask));
841 842
842 if (hs_ep->dir_in) { 843 if (hs_ep->dir_in) {
843 desc->status |= ((hs_ep->mc << DEV_DMA_ISOC_PID_SHIFT) & 844 if (len)
845 pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket);
846 else
847 pid = 1;
848 desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) &
844 DEV_DMA_ISOC_PID_MASK) | 849 DEV_DMA_ISOC_PID_MASK) |
845 ((len % hs_ep->ep.maxpacket) ? 850 ((len % hs_ep->ep.maxpacket) ?
846 DEV_DMA_SHORT : 0) | 851 DEV_DMA_SHORT : 0) |
@@ -884,6 +889,7 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep)
884 struct dwc2_dma_desc *desc; 889 struct dwc2_dma_desc *desc;
885 890
886 if (list_empty(&hs_ep->queue)) { 891 if (list_empty(&hs_ep->queue)) {
892 hs_ep->target_frame = TARGET_FRAME_INITIAL;
887 dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__); 893 dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__);
888 return; 894 return;
889 } 895 }
@@ -2755,8 +2761,6 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
2755 */ 2761 */
2756 tmp = dwc2_hsotg_read_frameno(hsotg); 2762 tmp = dwc2_hsotg_read_frameno(hsotg);
2757 2763
2758 dwc2_hsotg_complete_request(hsotg, ep, get_ep_head(ep), 0);
2759
2760 if (using_desc_dma(hsotg)) { 2764 if (using_desc_dma(hsotg)) {
2761 if (ep->target_frame == TARGET_FRAME_INITIAL) { 2765 if (ep->target_frame == TARGET_FRAME_INITIAL) {
2762 /* Start first ISO Out */ 2766 /* Start first ISO Out */
@@ -2817,9 +2821,6 @@ static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep)
2817 2821
2818 tmp = dwc2_hsotg_read_frameno(hsotg); 2822 tmp = dwc2_hsotg_read_frameno(hsotg);
2819 if (using_desc_dma(hsotg)) { 2823 if (using_desc_dma(hsotg)) {
2820 dwc2_hsotg_complete_request(hsotg, hs_ep,
2821 get_ep_head(hs_ep), 0);
2822
2823 hs_ep->target_frame = tmp; 2824 hs_ep->target_frame = tmp;
2824 dwc2_gadget_incr_frame_num(hs_ep); 2825 dwc2_gadget_incr_frame_num(hs_ep);
2825 dwc2_gadget_start_isoc_ddma(hs_ep); 2826 dwc2_gadget_start_isoc_ddma(hs_ep);
@@ -4739,9 +4740,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
4739 } 4740 }
4740 4741
4741 ret = usb_add_gadget_udc(dev, &hsotg->gadget); 4742 ret = usb_add_gadget_udc(dev, &hsotg->gadget);
4742 if (ret) 4743 if (ret) {
4744 dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
4745 hsotg->ctrl_req);
4743 return ret; 4746 return ret;
4744 4747 }
4745 dwc2_hsotg_dump(hsotg); 4748 dwc2_hsotg_dump(hsotg);
4746 4749
4747 return 0; 4750 return 0;
@@ -4755,6 +4758,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
4755int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg) 4758int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
4756{ 4759{
4757 usb_del_gadget_udc(&hsotg->gadget); 4760 usb_del_gadget_udc(&hsotg->gadget);
4761 dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
4758 4762
4759 return 0; 4763 return 0;
4760} 4764}
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index edaf0b6af4f0..b1104be3429c 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1567,11 +1567,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
1567 } 1567 }
1568 1568
1569 if (hsotg->params.host_dma) { 1569 if (hsotg->params.host_dma) {
1570 dwc2_writel((u32)chan->xfer_dma, 1570 dma_addr_t dma_addr;
1571 hsotg->regs + HCDMA(chan->hc_num)); 1571
1572 if (chan->align_buf) {
1573 if (dbg_hc(chan))
1574 dev_vdbg(hsotg->dev, "align_buf\n");
1575 dma_addr = chan->align_buf;
1576 } else {
1577 dma_addr = chan->xfer_dma;
1578 }
1579 dwc2_writel((u32)dma_addr, hsotg->regs + HCDMA(chan->hc_num));
1580
1572 if (dbg_hc(chan)) 1581 if (dbg_hc(chan))
1573 dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n", 1582 dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n",
1574 (unsigned long)chan->xfer_dma, chan->hc_num); 1583 (unsigned long)dma_addr, chan->hc_num);
1575 } 1584 }
1576 1585
1577 /* Start the split */ 1586 /* Start the split */
@@ -2625,6 +2634,35 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
2625 } 2634 }
2626} 2635}
2627 2636
2637static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
2638 struct dwc2_qh *qh,
2639 struct dwc2_host_chan *chan)
2640{
2641 if (!hsotg->unaligned_cache ||
2642 chan->max_packet > DWC2_KMEM_UNALIGNED_BUF_SIZE)
2643 return -ENOMEM;
2644
2645 if (!qh->dw_align_buf) {
2646 qh->dw_align_buf = kmem_cache_alloc(hsotg->unaligned_cache,
2647 GFP_ATOMIC | GFP_DMA);
2648 if (!qh->dw_align_buf)
2649 return -ENOMEM;
2650 }
2651
2652 qh->dw_align_buf_dma = dma_map_single(hsotg->dev, qh->dw_align_buf,
2653 DWC2_KMEM_UNALIGNED_BUF_SIZE,
2654 DMA_FROM_DEVICE);
2655
2656 if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) {
2657 dev_err(hsotg->dev, "can't map align_buf\n");
2658 chan->align_buf = 0;
2659 return -EINVAL;
2660 }
2661
2662 chan->align_buf = qh->dw_align_buf_dma;
2663 return 0;
2664}
2665
2628#define DWC2_USB_DMA_ALIGN 4 2666#define DWC2_USB_DMA_ALIGN 4
2629 2667
2630struct dma_aligned_buffer { 2668struct dma_aligned_buffer {
@@ -2802,6 +2840,32 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
2802 /* Set the transfer attributes */ 2840 /* Set the transfer attributes */
2803 dwc2_hc_init_xfer(hsotg, chan, qtd); 2841 dwc2_hc_init_xfer(hsotg, chan, qtd);
2804 2842
2843 /* For non-dword aligned buffers */
2844 if (hsotg->params.host_dma && qh->do_split &&
2845 chan->ep_is_in && (chan->xfer_dma & 0x3)) {
2846 dev_vdbg(hsotg->dev, "Non-aligned buffer\n");
2847 if (dwc2_alloc_split_dma_aligned_buf(hsotg, qh, chan)) {
2848 dev_err(hsotg->dev,
2849 "Failed to allocate memory to handle non-aligned buffer\n");
2850 /* Add channel back to free list */
2851 chan->align_buf = 0;
2852 chan->multi_count = 0;
2853 list_add_tail(&chan->hc_list_entry,
2854 &hsotg->free_hc_list);
2855 qtd->in_process = 0;
2856 qh->channel = NULL;
2857 return -ENOMEM;
2858 }
2859 } else {
2860 /*
2861 * We assume that DMA is always aligned in non-split
2862 * case or split out case. Warn if not.
2863 */
2864 WARN_ON_ONCE(hsotg->params.host_dma &&
2865 (chan->xfer_dma & 0x3));
2866 chan->align_buf = 0;
2867 }
2868
2805 if (chan->ep_type == USB_ENDPOINT_XFER_INT || 2869 if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
2806 chan->ep_type == USB_ENDPOINT_XFER_ISOC) 2870 chan->ep_type == USB_ENDPOINT_XFER_ISOC)
2807 /* 2871 /*
@@ -5246,6 +5310,19 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
5246 } 5310 }
5247 } 5311 }
5248 5312
5313 if (hsotg->params.host_dma) {
5314 /*
5315 * Create kmem caches to handle non-aligned buffer
5316 * in Buffer DMA mode.
5317 */
5318 hsotg->unaligned_cache = kmem_cache_create("dwc2-unaligned-dma",
5319 DWC2_KMEM_UNALIGNED_BUF_SIZE, 4,
5320 SLAB_CACHE_DMA, NULL);
5321 if (!hsotg->unaligned_cache)
5322 dev_err(hsotg->dev,
5323 "unable to create dwc2 unaligned cache\n");
5324 }
5325
5249 hsotg->otg_port = 1; 5326 hsotg->otg_port = 1;
5250 hsotg->frame_list = NULL; 5327 hsotg->frame_list = NULL;
5251 hsotg->frame_list_dma = 0; 5328 hsotg->frame_list_dma = 0;
@@ -5280,8 +5357,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
5280 return 0; 5357 return 0;
5281 5358
5282error4: 5359error4:
5283 kmem_cache_destroy(hsotg->desc_gen_cache); 5360 kmem_cache_destroy(hsotg->unaligned_cache);
5284 kmem_cache_destroy(hsotg->desc_hsisoc_cache); 5361 kmem_cache_destroy(hsotg->desc_hsisoc_cache);
5362 kmem_cache_destroy(hsotg->desc_gen_cache);
5285error3: 5363error3:
5286 dwc2_hcd_release(hsotg); 5364 dwc2_hcd_release(hsotg);
5287error2: 5365error2:
@@ -5322,8 +5400,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
5322 usb_remove_hcd(hcd); 5400 usb_remove_hcd(hcd);
5323 hsotg->priv = NULL; 5401 hsotg->priv = NULL;
5324 5402
5325 kmem_cache_destroy(hsotg->desc_gen_cache); 5403 kmem_cache_destroy(hsotg->unaligned_cache);
5326 kmem_cache_destroy(hsotg->desc_hsisoc_cache); 5404 kmem_cache_destroy(hsotg->desc_hsisoc_cache);
5405 kmem_cache_destroy(hsotg->desc_gen_cache);
5327 5406
5328 dwc2_hcd_release(hsotg); 5407 dwc2_hcd_release(hsotg);
5329 usb_put_hcd(hcd); 5408 usb_put_hcd(hcd);
@@ -5435,7 +5514,7 @@ int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg)
5435 dwc2_writel(hprt0, hsotg->regs + HPRT0); 5514 dwc2_writel(hprt0, hsotg->regs + HPRT0);
5436 5515
5437 /* Wait for the HPRT0.PrtSusp register field to be set */ 5516 /* Wait for the HPRT0.PrtSusp register field to be set */
5438 if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 300)) 5517 if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 3000))
5439 dev_warn(hsotg->dev, "Suspend wasn't generated\n"); 5518 dev_warn(hsotg->dev, "Suspend wasn't generated\n");
5440 5519
5441 /* 5520 /*
@@ -5616,6 +5695,8 @@ int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
5616 return ret; 5695 return ret;
5617 } 5696 }
5618 5697
5698 dwc2_hcd_rem_wakeup(hsotg);
5699
5619 hsotg->hibernated = 0; 5700 hsotg->hibernated = 0;
5620 hsotg->bus_suspended = 0; 5701 hsotg->bus_suspended = 0;
5621 hsotg->lx_state = DWC2_L0; 5702 hsotg->lx_state = DWC2_L0;
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index 7db1ee7e7a77..5502a501f516 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -76,6 +76,8 @@ struct dwc2_qh;
76 * (micro)frame 76 * (micro)frame
77 * @xfer_buf: Pointer to current transfer buffer position 77 * @xfer_buf: Pointer to current transfer buffer position
78 * @xfer_dma: DMA address of xfer_buf 78 * @xfer_dma: DMA address of xfer_buf
79 * @align_buf: In Buffer DMA mode this will be used if xfer_buf is not
80 * DWORD aligned
79 * @xfer_len: Total number of bytes to transfer 81 * @xfer_len: Total number of bytes to transfer
80 * @xfer_count: Number of bytes transferred so far 82 * @xfer_count: Number of bytes transferred so far
81 * @start_pkt_count: Packet count at start of transfer 83 * @start_pkt_count: Packet count at start of transfer
@@ -133,6 +135,7 @@ struct dwc2_host_chan {
133 135
134 u8 *xfer_buf; 136 u8 *xfer_buf;
135 dma_addr_t xfer_dma; 137 dma_addr_t xfer_dma;
138 dma_addr_t align_buf;
136 u32 xfer_len; 139 u32 xfer_len;
137 u32 xfer_count; 140 u32 xfer_count;
138 u16 start_pkt_count; 141 u16 start_pkt_count;
@@ -302,6 +305,9 @@ struct dwc2_hs_transfer_time {
302 * speed. Note that this is in "schedule slice" which 305 * speed. Note that this is in "schedule slice" which
303 * is tightly packed. 306 * is tightly packed.
304 * @ntd: Actual number of transfer descriptors in a list 307 * @ntd: Actual number of transfer descriptors in a list
308 * @dw_align_buf: Used instead of original buffer if its physical address
309 * is not dword-aligned
310 * @dw_align_buf_dma: DMA address for dw_align_buf
305 * @qtd_list: List of QTDs for this QH 311 * @qtd_list: List of QTDs for this QH
306 * @channel: Host channel currently processing transfers for this QH 312 * @channel: Host channel currently processing transfers for this QH
307 * @qh_list_entry: Entry for QH in either the periodic or non-periodic 313 * @qh_list_entry: Entry for QH in either the periodic or non-periodic
@@ -350,6 +356,8 @@ struct dwc2_qh {
350 struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES]; 356 struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES];
351 u32 ls_start_schedule_slice; 357 u32 ls_start_schedule_slice;
352 u16 ntd; 358 u16 ntd;
359 u8 *dw_align_buf;
360 dma_addr_t dw_align_buf_dma;
353 struct list_head qtd_list; 361 struct list_head qtd_list;
354 struct dwc2_host_chan *channel; 362 struct dwc2_host_chan *channel;
355 struct list_head qh_list_entry; 363 struct list_head qh_list_entry;
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index fbea5e3fb947..ed7f05cf4906 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -942,14 +942,21 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
942 frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index]; 942 frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
943 len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd, 943 len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
944 DWC2_HC_XFER_COMPLETE, NULL); 944 DWC2_HC_XFER_COMPLETE, NULL);
945 if (!len) { 945 if (!len && !qtd->isoc_split_offset) {
946 qtd->complete_split = 0; 946 qtd->complete_split = 0;
947 qtd->isoc_split_offset = 0;
948 return 0; 947 return 0;
949 } 948 }
950 949
951 frame_desc->actual_length += len; 950 frame_desc->actual_length += len;
952 951
952 if (chan->align_buf) {
953 dev_vdbg(hsotg->dev, "non-aligned buffer\n");
954 dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
955 DWC2_KMEM_UNALIGNED_BUF_SIZE, DMA_FROM_DEVICE);
956 memcpy(qtd->urb->buf + (chan->xfer_dma - qtd->urb->dma),
957 chan->qh->dw_align_buf, len);
958 }
959
953 qtd->isoc_split_offset += len; 960 qtd->isoc_split_offset += len;
954 961
955 hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum)); 962 hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum));
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index d7c3d6c776d8..301ced1618f8 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -383,7 +383,7 @@ static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg,
383 /* Get the map and adjust if this is a multi_tt hub */ 383 /* Get the map and adjust if this is a multi_tt hub */
384 map = qh->dwc_tt->periodic_bitmaps; 384 map = qh->dwc_tt->periodic_bitmaps;
385 if (qh->dwc_tt->usb_tt->multi) 385 if (qh->dwc_tt->usb_tt->multi)
386 map += DWC2_ELEMENTS_PER_LS_BITMAP * qh->ttport; 386 map += DWC2_ELEMENTS_PER_LS_BITMAP * (qh->ttport - 1);
387 387
388 return map; 388 return map;
389} 389}
@@ -1696,6 +1696,9 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
1696 1696
1697 if (qh->desc_list) 1697 if (qh->desc_list)
1698 dwc2_hcd_qh_free_ddma(hsotg, qh); 1698 dwc2_hcd_qh_free_ddma(hsotg, qh);
1699 else if (hsotg->unaligned_cache && qh->dw_align_buf)
1700 kmem_cache_free(hsotg->unaligned_cache, qh->dw_align_buf);
1701
1699 kfree(qh); 1702 kfree(qh);
1700} 1703}
1701 1704
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index ea91310113b9..103807587dc6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1272,7 +1272,6 @@ static int dwc3_probe(struct platform_device *pdev)
1272 if (!dwc->clks) 1272 if (!dwc->clks)
1273 return -ENOMEM; 1273 return -ENOMEM;
1274 1274
1275 dwc->num_clks = ARRAY_SIZE(dwc3_core_clks);
1276 dwc->dev = dev; 1275 dwc->dev = dev;
1277 1276
1278 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1277 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1307,15 +1306,19 @@ static int dwc3_probe(struct platform_device *pdev)
1307 if (IS_ERR(dwc->reset)) 1306 if (IS_ERR(dwc->reset))
1308 return PTR_ERR(dwc->reset); 1307 return PTR_ERR(dwc->reset);
1309 1308
1310 ret = clk_bulk_get(dev, dwc->num_clks, dwc->clks); 1309 if (dev->of_node) {
1311 if (ret == -EPROBE_DEFER) 1310 dwc->num_clks = ARRAY_SIZE(dwc3_core_clks);
1312 return ret; 1311
1313 /* 1312 ret = clk_bulk_get(dev, dwc->num_clks, dwc->clks);
1314 * Clocks are optional, but new DT platforms should support all clocks 1313 if (ret == -EPROBE_DEFER)
1315 * as required by the DT-binding. 1314 return ret;
1316 */ 1315 /*
1317 if (ret) 1316 * Clocks are optional, but new DT platforms should support all
1318 dwc->num_clks = 0; 1317 * clocks as required by the DT-binding.
1318 */
1319 if (ret)
1320 dwc->num_clks = 0;
1321 }
1319 1322
1320 ret = reset_control_deassert(dwc->reset); 1323 ret = reset_control_deassert(dwc->reset);
1321 if (ret) 1324 if (ret)
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 6b3ccd542bd7..dbeff5e6ad14 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -165,8 +165,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
165 165
166 reset_control_put(simple->resets); 166 reset_control_put(simple->resets);
167 167
168 pm_runtime_put_sync(dev);
169 pm_runtime_disable(dev); 168 pm_runtime_disable(dev);
169 pm_runtime_put_noidle(dev);
170 pm_runtime_set_suspended(dev);
170 171
171 return 0; 172 return 0;
172} 173}
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index c961a94d136b..f57e7c94b8e5 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -34,6 +34,7 @@
34#define PCI_DEVICE_ID_INTEL_GLK 0x31aa 34#define PCI_DEVICE_ID_INTEL_GLK 0x31aa
35#define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee 35#define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
36#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e 36#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
37#define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee
37 38
38#define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" 39#define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
39#define PCI_INTEL_BXT_FUNC_PMU_PWR 4 40#define PCI_INTEL_BXT_FUNC_PMU_PWR 4
@@ -289,6 +290,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
289 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), }, 290 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
290 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), }, 291 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
291 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), }, 292 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
293 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICLLP), },
292 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 294 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
293 { } /* Terminating Entry */ 295 { } /* Terminating Entry */
294}; 296};
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index b0e67ab2f98c..a6d0203e40b6 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -490,6 +490,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
490 qcom->dwc3 = of_find_device_by_node(dwc3_np); 490 qcom->dwc3 = of_find_device_by_node(dwc3_np);
491 if (!qcom->dwc3) { 491 if (!qcom->dwc3) {
492 dev_err(&pdev->dev, "failed to get dwc3 platform device\n"); 492 dev_err(&pdev->dev, "failed to get dwc3 platform device\n");
493 ret = -ENODEV;
493 goto depopulate; 494 goto depopulate;
494 } 495 }
495 496
@@ -547,8 +548,7 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
547 return 0; 548 return 0;
548} 549}
549 550
550#ifdef CONFIG_PM_SLEEP 551static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev)
551static int dwc3_qcom_pm_suspend(struct device *dev)
552{ 552{
553 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 553 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
554 int ret = 0; 554 int ret = 0;
@@ -560,7 +560,7 @@ static int dwc3_qcom_pm_suspend(struct device *dev)
560 return ret; 560 return ret;
561} 561}
562 562
563static int dwc3_qcom_pm_resume(struct device *dev) 563static int __maybe_unused dwc3_qcom_pm_resume(struct device *dev)
564{ 564{
565 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 565 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
566 int ret; 566 int ret;
@@ -571,23 +571,20 @@ static int dwc3_qcom_pm_resume(struct device *dev)
571 571
572 return ret; 572 return ret;
573} 573}
574#endif
575 574
576#ifdef CONFIG_PM 575static int __maybe_unused dwc3_qcom_runtime_suspend(struct device *dev)
577static int dwc3_qcom_runtime_suspend(struct device *dev)
578{ 576{
579 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 577 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
580 578
581 return dwc3_qcom_suspend(qcom); 579 return dwc3_qcom_suspend(qcom);
582} 580}
583 581
584static int dwc3_qcom_runtime_resume(struct device *dev) 582static int __maybe_unused dwc3_qcom_runtime_resume(struct device *dev)
585{ 583{
586 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 584 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
587 585
588 return dwc3_qcom_resume(qcom); 586 return dwc3_qcom_resume(qcom);
589} 587}
590#endif
591 588
592static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = { 589static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
593 SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume) 590 SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f242c2bcea81..d2fa071c21b1 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1719,6 +1719,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1719 */ 1719 */
1720 if (w_value && !f->get_alt) 1720 if (w_value && !f->get_alt)
1721 break; 1721 break;
1722
1723 spin_lock(&cdev->lock);
1722 value = f->set_alt(f, w_index, w_value); 1724 value = f->set_alt(f, w_index, w_value);
1723 if (value == USB_GADGET_DELAYED_STATUS) { 1725 if (value == USB_GADGET_DELAYED_STATUS) {
1724 DBG(cdev, 1726 DBG(cdev,
@@ -1728,6 +1730,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1728 DBG(cdev, "delayed_status count %d\n", 1730 DBG(cdev, "delayed_status count %d\n",
1729 cdev->delayed_status); 1731 cdev->delayed_status);
1730 } 1732 }
1733 spin_unlock(&cdev->lock);
1731 break; 1734 break;
1732 case USB_REQ_GET_INTERFACE: 1735 case USB_REQ_GET_INTERFACE:
1733 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) 1736 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index dce9d12c7981..33e2030503fa 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -215,6 +215,7 @@ struct ffs_io_data {
215 215
216 struct mm_struct *mm; 216 struct mm_struct *mm;
217 struct work_struct work; 217 struct work_struct work;
218 struct work_struct cancellation_work;
218 219
219 struct usb_ep *ep; 220 struct usb_ep *ep;
220 struct usb_request *req; 221 struct usb_request *req;
@@ -1072,22 +1073,31 @@ ffs_epfile_open(struct inode *inode, struct file *file)
1072 return 0; 1073 return 0;
1073} 1074}
1074 1075
1076static void ffs_aio_cancel_worker(struct work_struct *work)
1077{
1078 struct ffs_io_data *io_data = container_of(work, struct ffs_io_data,
1079 cancellation_work);
1080
1081 ENTER();
1082
1083 usb_ep_dequeue(io_data->ep, io_data->req);
1084}
1085
1075static int ffs_aio_cancel(struct kiocb *kiocb) 1086static int ffs_aio_cancel(struct kiocb *kiocb)
1076{ 1087{
1077 struct ffs_io_data *io_data = kiocb->private; 1088 struct ffs_io_data *io_data = kiocb->private;
1078 struct ffs_epfile *epfile = kiocb->ki_filp->private_data; 1089 struct ffs_data *ffs = io_data->ffs;
1079 int value; 1090 int value;
1080 1091
1081 ENTER(); 1092 ENTER();
1082 1093
1083 spin_lock_irq(&epfile->ffs->eps_lock); 1094 if (likely(io_data && io_data->ep && io_data->req)) {
1084 1095 INIT_WORK(&io_data->cancellation_work, ffs_aio_cancel_worker);
1085 if (likely(io_data && io_data->ep && io_data->req)) 1096 queue_work(ffs->io_completion_wq, &io_data->cancellation_work);
1086 value = usb_ep_dequeue(io_data->ep, io_data->req); 1097 value = -EINPROGRESS;
1087 else 1098 } else {
1088 value = -EINVAL; 1099 value = -EINVAL;
1089 1100 }
1090 spin_unlock_irq(&epfile->ffs->eps_lock);
1091 1101
1092 return value; 1102 return value;
1093} 1103}
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index acbd3d7b8828..8a62eee9eee1 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -886,12 +886,12 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
886 886
887 dev = xhci->devs[slot_id]; 887 dev = xhci->devs[slot_id];
888 888
889 trace_xhci_free_virt_device(dev);
890
891 xhci->dcbaa->dev_context_ptrs[slot_id] = 0; 889 xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
892 if (!dev) 890 if (!dev)
893 return; 891 return;
894 892
893 trace_xhci_free_virt_device(dev);
894
895 if (dev->tt_info) 895 if (dev->tt_info)
896 old_active_eps = dev->tt_info->active_eps; 896 old_active_eps = dev->tt_info->active_eps;
897 897
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index a8c1d073cba0..4b463e5202a4 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -481,7 +481,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
481 unsigned long mask; 481 unsigned long mask;
482 unsigned int port; 482 unsigned int port;
483 bool idle, enable; 483 bool idle, enable;
484 int err; 484 int err = 0;
485 485
486 memset(&rsp, 0, sizeof(rsp)); 486 memset(&rsp, 0, sizeof(rsp));
487 487
@@ -1223,10 +1223,10 @@ disable_rpm:
1223 pm_runtime_disable(&pdev->dev); 1223 pm_runtime_disable(&pdev->dev);
1224 usb_put_hcd(tegra->hcd); 1224 usb_put_hcd(tegra->hcd);
1225disable_xusbc: 1225disable_xusbc:
1226 if (!&pdev->dev.pm_domain) 1226 if (!pdev->dev.pm_domain)
1227 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBC); 1227 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBC);
1228disable_xusba: 1228disable_xusba:
1229 if (!&pdev->dev.pm_domain) 1229 if (!pdev->dev.pm_domain)
1230 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBA); 1230 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBA);
1231put_padctl: 1231put_padctl:
1232 tegra_xusb_padctl_put(tegra->padctl); 1232 tegra_xusb_padctl_put(tegra->padctl);
diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index 410544ffe78f..88b427434bd8 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -171,6 +171,37 @@ DEFINE_EVENT(xhci_log_trb, xhci_dbc_gadget_ep_queue,
171 TP_ARGS(ring, trb) 171 TP_ARGS(ring, trb)
172); 172);
173 173
174DECLARE_EVENT_CLASS(xhci_log_free_virt_dev,
175 TP_PROTO(struct xhci_virt_device *vdev),
176 TP_ARGS(vdev),
177 TP_STRUCT__entry(
178 __field(void *, vdev)
179 __field(unsigned long long, out_ctx)
180 __field(unsigned long long, in_ctx)
181 __field(u8, fake_port)
182 __field(u8, real_port)
183 __field(u16, current_mel)
184
185 ),
186 TP_fast_assign(
187 __entry->vdev = vdev;
188 __entry->in_ctx = (unsigned long long) vdev->in_ctx->dma;
189 __entry->out_ctx = (unsigned long long) vdev->out_ctx->dma;
190 __entry->fake_port = (u8) vdev->fake_port;
191 __entry->real_port = (u8) vdev->real_port;
192 __entry->current_mel = (u16) vdev->current_mel;
193 ),
194 TP_printk("vdev %p ctx %llx | %llx fake_port %d real_port %d current_mel %d",
195 __entry->vdev, __entry->in_ctx, __entry->out_ctx,
196 __entry->fake_port, __entry->real_port, __entry->current_mel
197 )
198);
199
200DEFINE_EVENT(xhci_log_free_virt_dev, xhci_free_virt_device,
201 TP_PROTO(struct xhci_virt_device *vdev),
202 TP_ARGS(vdev)
203);
204
174DECLARE_EVENT_CLASS(xhci_log_virt_dev, 205DECLARE_EVENT_CLASS(xhci_log_virt_dev,
175 TP_PROTO(struct xhci_virt_device *vdev), 206 TP_PROTO(struct xhci_virt_device *vdev),
176 TP_ARGS(vdev), 207 TP_ARGS(vdev),
@@ -208,11 +239,6 @@ DEFINE_EVENT(xhci_log_virt_dev, xhci_alloc_virt_device,
208 TP_ARGS(vdev) 239 TP_ARGS(vdev)
209); 240);
210 241
211DEFINE_EVENT(xhci_log_virt_dev, xhci_free_virt_device,
212 TP_PROTO(struct xhci_virt_device *vdev),
213 TP_ARGS(vdev)
214);
215
216DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device, 242DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device,
217 TP_PROTO(struct xhci_virt_device *vdev), 243 TP_PROTO(struct xhci_virt_device *vdev),
218 TP_ARGS(vdev) 244 TP_ARGS(vdev)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8c8da2d657fa..2f4850f25e82 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -908,6 +908,41 @@ static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
908 spin_unlock_irqrestore(&xhci->lock, flags); 908 spin_unlock_irqrestore(&xhci->lock, flags);
909} 909}
910 910
911static bool xhci_pending_portevent(struct xhci_hcd *xhci)
912{
913 struct xhci_port **ports;
914 int port_index;
915 u32 status;
916 u32 portsc;
917
918 status = readl(&xhci->op_regs->status);
919 if (status & STS_EINT)
920 return true;
921 /*
922 * Checking STS_EINT is not enough as there is a lag between a change
923 * bit being set and the Port Status Change Event that it generated
924 * being written to the Event Ring. See note in xhci 1.1 section 4.19.2.
925 */
926
927 port_index = xhci->usb2_rhub.num_ports;
928 ports = xhci->usb2_rhub.ports;
929 while (port_index--) {
930 portsc = readl(ports[port_index]->addr);
931 if (portsc & PORT_CHANGE_MASK ||
932 (portsc & PORT_PLS_MASK) == XDEV_RESUME)
933 return true;
934 }
935 port_index = xhci->usb3_rhub.num_ports;
936 ports = xhci->usb3_rhub.ports;
937 while (port_index--) {
938 portsc = readl(ports[port_index]->addr);
939 if (portsc & PORT_CHANGE_MASK ||
940 (portsc & PORT_PLS_MASK) == XDEV_RESUME)
941 return true;
942 }
943 return false;
944}
945
911/* 946/*
912 * Stop HC (not bus-specific) 947 * Stop HC (not bus-specific)
913 * 948 *
@@ -1009,7 +1044,7 @@ EXPORT_SYMBOL_GPL(xhci_suspend);
1009 */ 1044 */
1010int xhci_resume(struct xhci_hcd *xhci, bool hibernated) 1045int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1011{ 1046{
1012 u32 command, temp = 0, status; 1047 u32 command, temp = 0;
1013 struct usb_hcd *hcd = xhci_to_hcd(xhci); 1048 struct usb_hcd *hcd = xhci_to_hcd(xhci);
1014 struct usb_hcd *secondary_hcd; 1049 struct usb_hcd *secondary_hcd;
1015 int retval = 0; 1050 int retval = 0;
@@ -1043,8 +1078,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1043 command = readl(&xhci->op_regs->command); 1078 command = readl(&xhci->op_regs->command);
1044 command |= CMD_CRS; 1079 command |= CMD_CRS;
1045 writel(command, &xhci->op_regs->command); 1080 writel(command, &xhci->op_regs->command);
1081 /*
1082 * Some controllers take up to 55+ ms to complete the controller
1083 * restore so setting the timeout to 100ms. Xhci specification
1084 * doesn't mention any timeout value.
1085 */
1046 if (xhci_handshake(&xhci->op_regs->status, 1086 if (xhci_handshake(&xhci->op_regs->status,
1047 STS_RESTORE, 0, 10 * 1000)) { 1087 STS_RESTORE, 0, 100 * 1000)) {
1048 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 1088 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
1049 spin_unlock_irq(&xhci->lock); 1089 spin_unlock_irq(&xhci->lock);
1050 return -ETIMEDOUT; 1090 return -ETIMEDOUT;
@@ -1134,8 +1174,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1134 done: 1174 done:
1135 if (retval == 0) { 1175 if (retval == 0) {
1136 /* Resume root hubs only when have pending events. */ 1176 /* Resume root hubs only when have pending events. */
1137 status = readl(&xhci->op_regs->status); 1177 if (xhci_pending_portevent(xhci)) {
1138 if (status & STS_EINT) {
1139 usb_hcd_resume_root_hub(xhci->shared_hcd); 1178 usb_hcd_resume_root_hub(xhci->shared_hcd);
1140 usb_hcd_resume_root_hub(hcd); 1179 usb_hcd_resume_root_hub(hcd);
1141 } 1180 }
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 939e2f86b595..841e89ffe2e9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -382,6 +382,10 @@ struct xhci_op_regs {
382#define PORT_PLC (1 << 22) 382#define PORT_PLC (1 << 22)
383/* port configure error change - port failed to configure its link partner */ 383/* port configure error change - port failed to configure its link partner */
384#define PORT_CEC (1 << 23) 384#define PORT_CEC (1 << 23)
385#define PORT_CHANGE_MASK (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \
386 PORT_RC | PORT_PLC | PORT_CEC)
387
388
385/* Cold Attach Status - xHC can set this bit to report device attached during 389/* Cold Attach Status - xHC can set this bit to report device attached during
386 * Sx state. Warm port reset should be perfomed to clear this bit and move port 390 * Sx state. Warm port reset should be perfomed to clear this bit and move port
387 * to connected state. 391 * to connected state.
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eb6c26cbe579..ee0cc1d90b51 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -95,6 +95,9 @@ static const struct usb_device_id id_table[] = {
95 { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */ 95 { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */
96 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 96 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
97 { USB_DEVICE(0x10C4, 0x815F) }, /* Timewave HamLinkUSB */ 97 { USB_DEVICE(0x10C4, 0x815F) }, /* Timewave HamLinkUSB */
98 { USB_DEVICE(0x10C4, 0x817C) }, /* CESINEL MEDCAL N Power Quality Monitor */
99 { USB_DEVICE(0x10C4, 0x817D) }, /* CESINEL MEDCAL NT Power Quality Monitor */
100 { USB_DEVICE(0x10C4, 0x817E) }, /* CESINEL MEDCAL S Power Quality Monitor */
98 { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */ 101 { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */
99 { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */ 102 { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */
100 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */ 103 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */
@@ -112,6 +115,9 @@ static const struct usb_device_id id_table[] = {
112 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demonstration module */ 115 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demonstration module */
113 { USB_DEVICE(0x10C4, 0x8281) }, /* Nanotec Plug & Drive */ 116 { USB_DEVICE(0x10C4, 0x8281) }, /* Nanotec Plug & Drive */
114 { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesis ETRX2USB */ 117 { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesis ETRX2USB */
118 { USB_DEVICE(0x10C4, 0x82EF) }, /* CESINEL FALCO 6105 AC Power Supply */
119 { USB_DEVICE(0x10C4, 0x82F1) }, /* CESINEL MEDCAL EFD Earth Fault Detector */
120 { USB_DEVICE(0x10C4, 0x82F2) }, /* CESINEL MEDCAL ST Network Analyzer */
115 { USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */ 121 { USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */
116 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */ 122 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
117 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 123 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
@@ -124,7 +130,9 @@ static const struct usb_device_id id_table[] = {
124 { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */ 130 { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */
125 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ 131 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
126 { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */ 132 { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */
133 { USB_DEVICE(0x10C4, 0x851E) }, /* CESINEL MEDCAL PT Network Analyzer */
127 { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */ 134 { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */
135 { USB_DEVICE(0x10C4, 0x85B8) }, /* CESINEL ReCon T Energy Logger */
128 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ 136 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */
129 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ 137 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */
130 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */ 138 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
@@ -134,17 +142,23 @@ static const struct usb_device_id id_table[] = {
134 { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */ 142 { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */
135 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ 143 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
136 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ 144 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
145 { USB_DEVICE(0x10C4, 0x88FB) }, /* CESINEL MEDCAL STII Network Analyzer */
146 { USB_DEVICE(0x10C4, 0x8938) }, /* CESINEL MEDCAL S II Network Analyzer */
137 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ 147 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
138 { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */ 148 { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */
139 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */ 149 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
140 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ 150 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
151 { USB_DEVICE(0x10C4, 0x89A4) }, /* CESINEL FTBC Flexible Thyristor Bridge Controller */
141 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */ 152 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
142 { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */ 153 { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
143 { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */ 154 { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
144 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 155 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
145 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 156 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
157 { USB_DEVICE(0x10C4, 0xEA63) }, /* Silicon Labs Windows Update (CP2101-4/CP2102N) */
146 { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ 158 { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
147 { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */ 159 { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */
160 { USB_DEVICE(0x10C4, 0xEA7A) }, /* Silicon Labs Windows Update (CP2105) */
161 { USB_DEVICE(0x10C4, 0xEA7B) }, /* Silicon Labs Windows Update (CP2108) */
148 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 162 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
149 { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */ 163 { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */
150 { USB_DEVICE(0x10C4, 0xF003) }, /* Elan Digital Systems USBpulse100 */ 164 { USB_DEVICE(0x10C4, 0xF003) }, /* Elan Digital Systems USBpulse100 */
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 8a201dd53d36..d961f1ec0e08 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -418,17 +418,18 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
418 u64 ts_nsec = local_clock(); 418 u64 ts_nsec = local_clock();
419 unsigned long rem_nsec; 419 unsigned long rem_nsec;
420 420
421 mutex_lock(&port->logbuffer_lock);
421 if (!port->logbuffer[port->logbuffer_head]) { 422 if (!port->logbuffer[port->logbuffer_head]) {
422 port->logbuffer[port->logbuffer_head] = 423 port->logbuffer[port->logbuffer_head] =
423 kzalloc(LOG_BUFFER_ENTRY_SIZE, GFP_KERNEL); 424 kzalloc(LOG_BUFFER_ENTRY_SIZE, GFP_KERNEL);
424 if (!port->logbuffer[port->logbuffer_head]) 425 if (!port->logbuffer[port->logbuffer_head]) {
426 mutex_unlock(&port->logbuffer_lock);
425 return; 427 return;
428 }
426 } 429 }
427 430
428 vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args); 431 vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
429 432
430 mutex_lock(&port->logbuffer_lock);
431
432 if (tcpm_log_full(port)) { 433 if (tcpm_log_full(port)) {
433 port->logbuffer_head = max(port->logbuffer_head - 1, 0); 434 port->logbuffer_head = max(port->logbuffer_head - 1, 0);
434 strcpy(tmpbuffer, "overflow"); 435 strcpy(tmpbuffer, "overflow");
@@ -3043,7 +3044,8 @@ static void run_state_machine(struct tcpm_port *port)
3043 tcpm_port_is_sink(port) && 3044 tcpm_port_is_sink(port) &&
3044 time_is_after_jiffies(port->delayed_runtime)) { 3045 time_is_after_jiffies(port->delayed_runtime)) {
3045 tcpm_set_state(port, SNK_DISCOVERY, 3046 tcpm_set_state(port, SNK_DISCOVERY,
3046 port->delayed_runtime - jiffies); 3047 jiffies_to_msecs(port->delayed_runtime -
3048 jiffies));
3047 break; 3049 break;
3048 } 3050 }
3049 tcpm_set_state(port, unattached_state(port), 0); 3051 tcpm_set_state(port, unattached_state(port), 0);
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index bd5cca5632b3..8d0a6fe748bd 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -350,6 +350,19 @@ static void ucsi_connector_change(struct work_struct *work)
350 } 350 }
351 351
352 if (con->status.change & UCSI_CONSTAT_CONNECT_CHANGE) { 352 if (con->status.change & UCSI_CONSTAT_CONNECT_CHANGE) {
353 typec_set_pwr_role(con->port, con->status.pwr_dir);
354
355 switch (con->status.partner_type) {
356 case UCSI_CONSTAT_PARTNER_TYPE_UFP:
357 typec_set_data_role(con->port, TYPEC_HOST);
358 break;
359 case UCSI_CONSTAT_PARTNER_TYPE_DFP:
360 typec_set_data_role(con->port, TYPEC_DEVICE);
361 break;
362 default:
363 break;
364 }
365
353 if (con->status.connected) 366 if (con->status.connected)
354 ucsi_register_partner(con); 367 ucsi_register_partner(con);
355 else 368 else
diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index 44eb4e1ea817..a18112a83fae 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -79,6 +79,11 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
79 return -ENODEV; 79 return -ENODEV;
80 } 80 }
81 81
82 /* This will make sure we can use ioremap_nocache() */
83 status = acpi_release_memory(ACPI_HANDLE(&pdev->dev), res, 1);
84 if (ACPI_FAILURE(status))
85 return -ENOMEM;
86
82 /* 87 /*
83 * NOTE: The memory region for the data structures is used also in an 88 * NOTE: The memory region for the data structures is used also in an
84 * operation region, which means ACPI has already reserved it. Therefore 89 * operation region, which means ACPI has already reserved it. Therefore
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4b35a66383f9..e54f40974eb0 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -443,6 +443,9 @@ int acpi_check_resource_conflict(const struct resource *res);
443int acpi_check_region(resource_size_t start, resource_size_t n, 443int acpi_check_region(resource_size_t start, resource_size_t n,
444 const char *name); 444 const char *name);
445 445
446acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
447 u32 level);
448
446int acpi_resources_are_enforced(void); 449int acpi_resources_are_enforced(void);
447 450
448#ifdef CONFIG_HIBERNATION 451#ifdef CONFIG_HIBERNATION