Alloc sg table at the end of urb structure. This will increase
cache usage.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
static int
mt76u_urb_alloc(struct mt76_dev *dev, struct mt76_queue_entry *e)
{
- struct urb *urb;
+ unsigned int size = sizeof(struct urb);
+
+ if (dev->usb.sg_en)
+ size += MT_SG_MAX_SIZE * sizeof(struct scatterlist);
- urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!urb)
+ e->urb = kzalloc(size, GFP_KERNEL);
+ if (!e->urb)
return -ENOMEM;
- e->urb = urb;
- if (dev->usb.sg_en) {
- urb->sg = devm_kcalloc(dev->dev, MT_SG_MAX_SIZE,
- sizeof(*urb->sg), GFP_KERNEL);
- if (!urb->sg)
- return -ENOMEM;
- }
+ usb_init_urb(e->urb);
+
+ if (dev->usb.sg_en)
+ e->urb->sg = (struct scatterlist *)(e->urb + 1);
return 0;
}