Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: add a new quirk to avoid skb_reserve in u_ether.c

Some platforms (e.g. USB-DMAC on R-Car SoCs) has memory alignment
restriction. If memory alignment is not match, the usb peripheral
driver decides not to use the DMA controller. Then, the performance
is not good.

In the case of u_ether.c, since it calls skb_reserve() in rx_submit(),
it is possible to cause memory alignment mismatch.

So, this patch adds a new quirk "quirk_avoids_skb_reserve" to avoid
skb_reserve() calling in u_ether.c to improve performance.

A peripheral driver will set this flag and network gadget drivers
(e.g. f_ncm.c) will reference the flag via gadget_avoids_skb_reserve().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Yoshihiro Shimoda and committed by
Felipe Balbi
60e7396f a00c9791

+13
+13
include/linux/usb/gadget.h
··· 346 346 * or B-Peripheral wants to take host role. 347 347 * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to 348 348 * MaxPacketSize. 349 + * @quirk_avoids_skb_reserve: udc/platform wants to avoid skb_reserve() in 350 + * u_ether.c to improve performance. 349 351 * @is_selfpowered: if the gadget is self-powered. 350 352 * @deactivated: True if gadget is deactivated - in deactivated state it cannot 351 353 * be connected. ··· 400 398 unsigned quirk_altset_not_supp:1; 401 399 unsigned quirk_stall_not_supp:1; 402 400 unsigned quirk_zlp_not_supp:1; 401 + unsigned quirk_avoids_skb_reserve:1; 403 402 unsigned is_selfpowered:1; 404 403 unsigned deactivated:1; 405 404 unsigned connected:1; ··· 474 471 static inline int gadget_is_zlp_supported(struct usb_gadget *g) 475 472 { 476 473 return !g->quirk_zlp_not_supp; 474 + } 475 + 476 + /** 477 + * gadget_avoids_skb_reserve - return true iff the hardware would like to avoid 478 + * skb_reserve to improve performance. 479 + * @g: controller to check for quirk 480 + */ 481 + static inline int gadget_avoids_skb_reserve(struct usb_gadget *g) 482 + { 483 + return g->quirk_avoids_skb_reserve; 477 484 } 478 485 479 486 /**