Search Linux Wireless

Re: [PATCH v4 3/4] mt76: speed up usb bulk copy

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

 



On 11/19/19 1:15 PM, Lorenzo Bianconi wrote:
>> Use larger batches for usb copy to speed this operation up. Otherwise it
>> would be too slow for copying new beacons or broadcast frames over usb.
>> Assure, that always a multiple of 4 Bytes is copied, as outlined in
>> 850e8f6fbd "mt76: round up length on mt76_wr_copy" from Felix Fietkau.
>>
>> Signed-off-by: Markus Theil <markus.theil@xxxxxxxxxxxxx>
>> ---
>>  drivers/net/wireless/mediatek/mt76/mt76.h |  2 +-
>>  drivers/net/wireless/mediatek/mt76/usb.c  | 24 +++++++++++++++++------
>>  2 files changed, 19 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
>> index 8aec7ccf2d79..7a6f5d097a3d 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
>> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
>> @@ -383,7 +383,7 @@ enum mt76u_out_ep {
>>  struct mt76_usb {
>>  	struct mutex usb_ctrl_mtx;
>>  	union {
>> -		u8 data[32];
>> +		u8 data[128];
>>  		__le32 reg_val;
>>  	};
>>  
>> diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
>> index 20c6fe510e9d..f1f67b0f8265 100644
>> --- a/drivers/net/wireless/mediatek/mt76/usb.c
>> +++ b/drivers/net/wireless/mediatek/mt76/usb.c
>> @@ -149,18 +149,30 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset,
>>  		       const void *data, int len)
>>  {
>>  	struct mt76_usb *usb = &dev->usb;
>> -	const u32 *val = data;
>> -	int i, ret;
>> +	const u8 *val = data;
>> +	int ret;
>> +	int current_batch_size;
>> +	int i = 0;
>> +
>> +	/* Assure that always a multiple of 4 bytes are copied,
>> +	 * otherwise beacons can be corrupted.
>> +	 * See: "mt76: round up length on mt76_wr_copy"
>> +	 * Commit 850e8f6fbd5d0003b0
>> +	 */
>> +	len = DIV_ROUND_UP(len, 4) * 4;
>>  
>>  	mutex_lock(&usb->usb_ctrl_mtx);
>> -	for (i = 0; i < DIV_ROUND_UP(len, 4); i++) {
>> -		put_unaligned(val[i], (u32 *)usb->data);
>> +	while (i < len) {
>> +		current_batch_size = min((int)sizeof(usb->data), len - i);
> What about using min_t() here?
Sorry, read it too late for v5. I'll wait a bit for other comments and
include it in a next version.
>> +		memcpy(usb->data, val + i, current_batch_size);
>>  		ret = __mt76u_vendor_request(dev, MT_VEND_MULTI_WRITE,
>>  					     USB_DIR_OUT | USB_TYPE_VENDOR,
>> -					     0, offset + i * 4, usb->data,
>> -					     sizeof(u32));
>> +					     0, offset + i, usb->data,
>> +					     current_batch_size);
>>  		if (ret < 0)
>>  			break;
>> +
>> +		i += current_batch_size;
>>  	}
>>  	mutex_unlock(&usb->usb_ctrl_mtx);
>>  }
>> -- 
>> 2.24.0
>>
-- 
Markus Theil

Technische Universität Ilmenau, Fachgebiet Telematik/Rechnernetze
Postfach 100565
98684 Ilmenau, Germany

Phone: +49 3677 69-4582
Email: markus[dot]theil[at]tu-ilmenau[dot]de
Web: http://www.tu-ilmenau.de/telematik




[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