Search Linux Wireless

Re: [RFC 11/12] mt76usb: allocate urb and sg as linear data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Alloc sg table at the end of urb structure. This will increase
> cache usage.
> 

I am curious, have you observed any performance improvement doing so?

> Signed-off-by: Stanislaw Gruszka <sgruszka@xxxxxxxxxx>
> ---
>  drivers/net/wireless/mediatek/mt76/usb.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> index 0b9f0b5fd37d..dd487f65f44e 100644
> --- a/drivers/net/wireless/mediatek/mt76/usb.c
> +++ b/drivers/net/wireless/mediatek/mt76/usb.c
> @@ -336,19 +336,19 @@ static bool mt76u_check_sg(struct mt76_dev *dev)
>  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 *)((u8 *)e->urb + sizeof(struct urb));

You can avoid u8 cast doing:
(struct scatterlist *)(e->urb + 1)

Regards,
Lorenzo

>  
>  	return 0;
>  }
> -- 
> 1.9.3
> 

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux