linux/include/linux/usb
Sebastian Andrzej Siewior df24955beb usb: core: buffer: smallest buffer should start at ARCH_DMA_MINALIGN
commit 5efd2ea8c9 upstream.

the following error pops up during "testusb -a -t 10"
| musb-hdrc musb-hdrc.1.auto: dma_pool_free buffer-128,	f134e000/be842000 (bad dma)
hcd_buffer_create() creates a few buffers, the smallest has 32 bytes of
size. ARCH_KMALLOC_MINALIGN is set to 64 bytes. This combo results in
hcd_buffer_alloc() returning memory which is 32 bytes aligned and it
might by identified by buffer_offset() as another buffer. This means the
buffer which is on a 32 byte boundary will not get freed, instead it
tries to free another buffer with the error message.

This patch fixes the issue by creating the smallest DMA buffer with the
size of ARCH_KMALLOC_MINALIGN (or 32 in case ARCH_KMALLOC_MINALIGN is
smaller). This might be 32, 64 or even 128 bytes. The next three pools
will have the size 128, 512 and 2048.
In case the smallest pool is 128 bytes then we have only three pools
instead of four (and zero the first entry in the array).
The last pool size is always 2048 bytes which is the assumed PAGE_SIZE /
2 of 4096. I doubt it makes sense to continue using PAGE_SIZE / 2 where
we would end up with 8KiB buffer in case we have 16KiB pages.
Instead I think it makes sense to have a common size(s) and extend them
if there is need to.
There is a BUILD_BUG_ON() now in case someone has a minalign of more than
128 bytes.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2015-03-06 14:43:30 -08:00
..
association.h USB: wusb: annotate association types withe proper endianness 2009-01-07 09:59:51 -08:00
atmel_usba_udc.h USB: include/usb/*.h checkpatch cleanup 2010-05-20 13:21:47 -07:00
audio-v2.h ALSA: snd-usb: handle raw data format of UAC2 devices 2013-03-18 08:47:13 +01:00
audio.h UAPI: (Scripted) Disintegrate include/linux/usb 2012-10-09 09:49:07 +01:00
c67x00.h USB: add Cypress c67x00 OTG controller core driver 2008-05-02 10:25:56 -07:00
cdc-wdm.h USB: cdc-wdm: implement IOCTL_WDM_MAX_COMMAND 2013-03-25 13:32:20 -07:00
cdc_ncm.h net: cdc_ncm: fix control message ordering 2014-03-18 15:32:32 -04:00
ch9.h usb: common: introduce usb_state_string() 2013-03-18 11:17:11 +02:00
chipidea.h usb: chipidea: add freescale imx28 special write register method 2014-01-13 15:55:19 -08:00
composite.h usb: gadget: configfs: allow setting function instance's name 2013-12-12 13:43:35 -06:00
ehci_def.h USB: EHCI: Tegra: Fix wrong register definition 2012-09-18 17:40:56 +01:00
ehci_pdriver.h ehci-platform: add pre_setup() method to platform data 2013-06-11 16:10:45 +09:00
ezusb.h USB: ezusb: unexport some functions that aren't being used 2012-10-24 14:19:16 -07:00
functionfs.h usb: gadget: FunctionFS: Remove compatibility layer 2013-12-12 13:43:40 -06:00
g_hid.h USB: gadget: add HID gadget driver 2010-05-20 13:21:35 -07:00
gadget.h usb: gadget: add "maxpacket_limit" field to struct usb_ep 2013-12-17 13:17:41 -06:00
gadget_configfs.h usb: gadget: the start of the configfs interface 2013-04-03 14:43:32 +03:00
gpio_vbus.h USB: gpio_vbus: wakeup support on GPIO VBUS interrupts 2012-05-17 11:20:34 -07:00
hcd.h usb: core: buffer: smallest buffer should start at ARCH_DMA_MINALIGN 2015-03-06 14:43:30 -08:00
input.h USB: Standardize inclusion protection and add where missing. 2008-04-24 21:16:42 -07:00
iowarrior.h USB: Standardize inclusion protection and add where missing. 2008-04-24 21:16:42 -07:00
irda.h usb: irda: cleanup on ir-usb module 2008-07-21 15:16:27 -07:00
isp116x.h USB: Standardize inclusion protection and add where missing. 2008-04-24 21:16:42 -07:00
isp1301.h USB: Add driver for NXP ISP1301 USB transceiver 2012-05-01 13:33:02 -04:00
isp1362.h USB: NXP ISP1362 USB host driver 2009-09-23 06:46:30 -07:00
isp1760.h USB: isp1760: allow platform devices to customize devflags 2009-09-23 06:46:29 -07:00
m66592.h usb: gadget: m66592-udc: add function for external controller 2011-07-09 01:08:39 +03:00
msm_hsusb.h usb: phy: msm: Move mach dependent code to platform data 2014-01-09 00:06:48 -08:00
msm_hsusb_hw.h USB: OTG: msm: Add PHY suspend support for MSM8960 2011-05-06 18:27:49 -07:00
musb-omap.h usb: musb: twl: use mailbox API to send VBUS or ID events 2012-06-25 14:07:39 +03:00
musb-ux500.h usb: phy: ab8500-usb: update irq handling code 2013-03-18 14:41:33 +02:00
musb.h usb: musb: dsps: add support for suspend and resume 2013-11-26 10:58:16 -06:00
net2280.h USB: include/usb/*.h checkpatch cleanup 2010-05-20 13:21:47 -07:00
of.h usb: of: fix build breakage caused by recent patches 2013-07-30 09:09:15 +03:00
ohci_pdriver.h USB: ohci: allow platform driver to specify the number of ports 2012-10-22 11:23:59 -07:00
omap_control_usb.h usb: phy: omap: Add omap-control Support for AM437x 2013-12-19 09:27:42 -06:00
omap_usb.h usb: phy: add a new driver for usb3 phy 2013-01-25 13:02:50 +02:00
otg-fsm.h usb: phy: move OTG FSM header 2013-11-26 10:58:18 -06:00
otg.h usb: add devicetree helpers for determining dr_mode and phy_type 2013-06-17 13:47:09 -07:00
phy.h usb: phy: protect against NULL phy pointers 2013-07-29 13:56:45 +03:00
phy_companion.h usb: phy: add a new driver for omap usb2 phy 2012-09-06 20:14:53 +03:00
quirks.h USB: core: add device-qualifier quirk 2014-11-14 09:00:05 -08:00
r8a66597.h usb: gadget: r8a66597-udc: add support for SUDMAC 2011-10-13 20:38:39 +03:00
renesas_usbhs.h usb: renesas_usbhs: fixup sparse errors for common.c 2013-04-02 11:42:48 +03:00
rndis_host.h usb/net: rndis: break out <linux/rndis.h> defines 2012-05-12 15:02:22 -04:00
samsung_usb_phy.h ARM: EXYNOS: Update & move usb-phy types to generic include layer 2013-01-23 13:39:07 +02:00
serial.h USB: serial: export usb_serial_generic_write_start 2013-10-11 17:00:26 -07:00
sl811.h USB: Standardize inclusion protection and add where missing. 2008-04-24 21:16:42 -07:00
storage.h usb/storage: remove Filler member from struct bulk_cs_wrap 2012-02-28 11:11:22 -08:00
tegra_usb_phy.h usb: phy: tegra: Program new PHY parameters 2013-08-12 13:29:52 -05:00
tilegx.h usb: add host support for the tilegx architecture 2012-07-18 16:40:29 -04:00
uas.h uas: task mgmt & error handling 2012-06-25 11:51:01 -07:00
ulpi.h usb: ulpi: Define a *otg_ulpi_create no-op 2013-03-20 17:30:40 +02:00
usb_phy_gen_xceiv.h usb: patches for v3.13 2013-10-24 16:18:40 +01:00
usbnet.h usbnet: include wait queue head in device structure 2014-03-27 14:59:10 -04:00
wusb-wa.h usb: wusbcore: preserve endianness of cached descriptors 2013-10-19 05:19:21 -07:00
wusb.h usb: wusbcore: fix deadlock in wusbhc_gtk_rekey 2013-12-02 15:21:04 -08:00