Merge tag 'mfd-for-linus-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc2 / core.c
index ea0048a724cff0bdbb9b79be028996716301a562..d9269459d481ec072ee4f5f9f808e3e350d39a3a 100644 (file)
@@ -2743,6 +2743,13 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
        width = (hwcfg3 & GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK) >>
                GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT;
        hw->max_transfer_size = (1 << (width + 11)) - 1;
+       /*
+        * Clip max_transfer_size to 65535. dwc2_hc_setup_align_buf() allocates
+        * coherent buffers with this size, and if it's too large we can
+        * exhaust the coherent DMA pool.
+        */
+       if (hw->max_transfer_size > 65535)
+               hw->max_transfer_size = 65535;
        width = (hwcfg3 & GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK) >>
                GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT;
        hw->max_packet_count = (1 << (width + 4)) - 1;