Merge tag 'fixes-for-v5.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 May 2020 13:37:20 +0000 (15:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 May 2020 13:37:20 +0000 (15:37 +0200)
Felipe writes:

USB: fixes for v5.7-rc6

The main part here are the important fixes for the raw-gadget before it
becomes an ABI. We're adding support for stall/halt/wedge which is
actually pretty important in many situations. There's also a NULL
pointer deref fix.

Apart from raw-gadget, I've included some recent sparse fixes to a few
drivers.

Signed-off-by: Felipe Balbi <balbi@kernel.org>
* tag 'fixes-for-v5.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
  usb: cdns3: gadget: make a bunch of functions static
  usb: mtu3: constify struct debugfs_reg32
  usb: gadget: udc: atmel: Make some symbols static
  usb: raw-gadget: fix null-ptr-deref when reenabling endpoints
  usb: raw-gadget: documentation updates
  usb: raw-gadget: support stalling/halting/wedging endpoints
  usb: raw-gadget: fix gadget endpoint selection
  usb: raw-gadget: improve uapi headers comments

drivers/usb/core/devio.c
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci-ring.c

index b9db981..d93d94d 100644 (file)
@@ -251,9 +251,19 @@ static int usbdev_mmap(struct file *file, struct vm_area_struct *vma)
        usbm->vma_use_count = 1;
        INIT_LIST_HEAD(&usbm->memlist);
 
-       if (dma_mmap_coherent(hcd->self.sysdev, vma, mem, dma_handle, size)) {
-               dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
-               return -EAGAIN;
+       if (hcd->localmem_pool || !hcd_uses_dma(hcd)) {
+               if (remap_pfn_range(vma, vma->vm_start,
+                                   virt_to_phys(usbm->mem) >> PAGE_SHIFT,
+                                   size, vma->vm_page_prot) < 0) {
+                       dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
+                       return -EAGAIN;
+               }
+       } else {
+               if (dma_mmap_coherent(hcd->self.sysdev, vma, mem, dma_handle,
+                                     size)) {
+                       dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
+                       return -EAGAIN;
+               }
        }
 
        vma->vm_flags |= VM_IO;
index 1d4f6f8..ea460b9 100644 (file)
@@ -362,6 +362,7 @@ static int xhci_plat_remove(struct platform_device *dev)
        struct clk *reg_clk = xhci->reg_clk;
        struct usb_hcd *shared_hcd = xhci->shared_hcd;
 
+       pm_runtime_get_sync(&dev->dev);
        xhci->xhc_state |= XHCI_STATE_REMOVING;
 
        usb_remove_hcd(shared_hcd);
@@ -375,8 +376,9 @@ static int xhci_plat_remove(struct platform_device *dev)
        clk_disable_unprepare(reg_clk);
        usb_put_hcd(hcd);
 
-       pm_runtime_set_suspended(&dev->dev);
        pm_runtime_disable(&dev->dev);
+       pm_runtime_put_noidle(&dev->dev);
+       pm_runtime_set_suspended(&dev->dev);
 
        return 0;
 }
index 0fda0c0..2c255d0 100644 (file)
@@ -3433,8 +3433,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
                        /* New sg entry */
                        --num_sgs;
                        sent_len -= block_len;
-                       if (num_sgs != 0) {
-                               sg = sg_next(sg);
+                       sg = sg_next(sg);
+                       if (num_sgs != 0 && sg) {
                                block_len = sg_dma_len(sg);
                                addr = (u64) sg_dma_address(sg);
                                addr += sent_len;