308-rt2x00-do-not-align-payload-on-modern-H-W.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From: Stanislaw Gruszka <sgruszka@redhat.com>
  2. Date: Sun, 2 Nov 2014 13:38:47 +0100
  3. Subject: [PATCH] rt2x00: do not align payload on modern H/W
  4. RT2800 and newer hardware require padding between header and payload if
  5. header length is not multiple of 4.
  6. For historical reasons we also align payload to to 4 bytes boundary, but
  7. such alignment is not needed on modern H/W.
  8. Patch improve performance on embedded CPUs and _possibly_ fixes
  9. skb_under_panic problems reported from time to time:
  10. https://bugzilla.kernel.org/show_bug.cgi?id=84911
  11. https://bugzilla.kernel.org/show_bug.cgi?id=72471
  12. http://marc.info/?l=linux-wireless&m=139108549530402&w=2
  13. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1087591
  14. But we can not explain or otherwise confirm the patch fixes this panic
  15. issue for sure.
  16. Originally-From: Helmut Schaa <helmut.schaa@googlemail.com>
  17. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
  18. ---
  19. --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
  20. +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
  21. @@ -158,55 +158,29 @@ void rt2x00queue_align_frame(struct sk_b
  22. skb_trim(skb, frame_length);
  23. }
  24. -void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length)
  25. +/*
  26. + * H/W needs L2 padding between the header and the paylod if header size
  27. + * is not 4 bytes aligned.
  28. + */
  29. +void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int hdr_len)
  30. {
  31. - unsigned int payload_length = skb->len - header_length;
  32. - unsigned int header_align = ALIGN_SIZE(skb, 0);
  33. - unsigned int payload_align = ALIGN_SIZE(skb, header_length);
  34. - unsigned int l2pad = payload_length ? L2PAD_SIZE(header_length) : 0;
  35. + unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
  36. - /*
  37. - * Adjust the header alignment if the payload needs to be moved more
  38. - * than the header.
  39. - */
  40. - if (payload_align > header_align)
  41. - header_align += 4;
  42. -
  43. - /* There is nothing to do if no alignment is needed */
  44. - if (!header_align)
  45. + if (!l2pad)
  46. return;
  47. - /* Reserve the amount of space needed in front of the frame */
  48. - skb_push(skb, header_align);
  49. -
  50. - /*
  51. - * Move the header.
  52. - */
  53. - memmove(skb->data, skb->data + header_align, header_length);
  54. -
  55. - /* Move the payload, if present and if required */
  56. - if (payload_length && payload_align)
  57. - memmove(skb->data + header_length + l2pad,
  58. - skb->data + header_length + l2pad + payload_align,
  59. - payload_length);
  60. -
  61. - /* Trim the skb to the correct size */
  62. - skb_trim(skb, header_length + l2pad + payload_length);
  63. + skb_push(skb, l2pad);
  64. + memmove(skb->data, skb->data + l2pad, hdr_len);
  65. }
  66. -void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length)
  67. +void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int hdr_len)
  68. {
  69. - /*
  70. - * L2 padding is only present if the skb contains more than just the
  71. - * IEEE 802.11 header.
  72. - */
  73. - unsigned int l2pad = (skb->len > header_length) ?
  74. - L2PAD_SIZE(header_length) : 0;
  75. + unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
  76. if (!l2pad)
  77. return;
  78. - memmove(skb->data + l2pad, skb->data, header_length);
  79. + memmove(skb->data + l2pad, skb->data, hdr_len);
  80. skb_pull(skb, l2pad);
  81. }