2014-05-03 14:18:19

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 01/13] staging: vt6656: lock changes: Remove spin locks

Remove atomic paths to usbpipe.c PIPEnsControlOut and PIPEnsControlIn

Remove from
PIPEnsControlOut
PIPEnsControlIn
BSSvSecondCallBack
FIRMWAREbDownload
vt6656_hostap_ioctl
iwctl_siwmode
iwctl_siwencode
iwctl_siwpower
iwctl_siwencodeext
KeyvInitTable
device_init_registers
device_open
device_close

Signed-off-by: Malcolm Priestley <[email protected]>
---
Note: All patches of these series must be applied.

drivers/staging/vt6656/bssdb.c | 4 ----
drivers/staging/vt6656/firmware.c | 4 +---
drivers/staging/vt6656/hostap.c | 4 ++--
drivers/staging/vt6656/iwctl.c | 15 ---------------
drivers/staging/vt6656/key.c | 3 ---
drivers/staging/vt6656/main_usb.c | 24 ++++--------------------
drivers/staging/vt6656/usbpipe.c | 6 ------
7 files changed, 7 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
index 9c78dab..b018955 100644
--- a/drivers/staging/vt6656/bssdb.c
+++ b/drivers/staging/vt6656/bssdb.c
@@ -818,8 +818,6 @@ void BSSvSecondCallBack(struct work_struct *work)
if (pDevice->Flags & fMP_DISCONNECTED)
return;

- spin_lock_irq(&pDevice->lock);
-
pDevice->uAssocCount = 0;

/* Power Saving Mode Tx Burst */
@@ -1158,8 +1156,6 @@ void BSSvSecondCallBack(struct work_struct *work)
netif_wake_queue(pDevice->dev);
}

- spin_unlock_irq(&pDevice->lock);
-
schedule_delayed_work(&pDevice->second_callback_work, HZ);
}

diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index 15c1e86..7a4a972 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -44,7 +44,7 @@ static int msglevel = MSG_LEVEL_INFO;

#define FIRMWARE_CHUNK_SIZE 0x400

-int FIRMWAREbDownload(struct vnt_private *pDevice) __must_hold(&pDevice->lock)
+int FIRMWAREbDownload(struct vnt_private *pDevice)
{
struct device *dev = &pDevice->usb->dev;
const struct firmware *fw;
@@ -55,7 +55,6 @@ int FIRMWAREbDownload(struct vnt_private *pDevice) __must_hold(&pDevice->lock)
int ii, rc;

DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n");
- spin_unlock_irq(&pDevice->lock);

rc = request_firmware(&fw, FIRMWARE_NAME, dev);
if (rc) {
@@ -92,7 +91,6 @@ free_fw:
out:
kfree(pBuffer);

- spin_lock_irq(&pDevice->lock);
return result;
}
MODULE_FIRMWARE(FIRMWARE_NAME);
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
index 67ba48b..ccf52b4 100644
--- a/drivers/staging/vt6656/hostap.c
+++ b/drivers/staging/vt6656/hostap.c
@@ -698,9 +698,9 @@ int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p)
switch (param->cmd) {
case VIAWGET_HOSTAPD_SET_ENCRYPTION:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ENCRYPTION \n");
- spin_lock_irq(&pDevice->lock);
+
ret = hostap_set_encryption(pDevice, param, p->length);
- spin_unlock_irq(&pDevice->lock);
+
break;
case VIAWGET_HOSTAPD_GET_ENCRYPTION:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_ENCRYPTION \n");
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
index cf4c06a..bfd5f37 100644
--- a/drivers/staging/vt6656/iwctl.c
+++ b/drivers/staging/vt6656/iwctl.c
@@ -441,8 +441,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"Commit the settings\n");

- spin_lock_irq(&pDevice->lock);
-
if (pDevice->bLinkPass &&
memcmp(pMgmt->abyCurrSSID,
pMgmt->abyDesireSSID,
@@ -471,8 +469,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
bScheduleCommand((void *) pDevice,
WLAN_CMD_SSID,
NULL);
-
- spin_unlock_irq(&pDevice->lock);
}
pDevice->bCommit = false;
}
@@ -1212,14 +1208,12 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);

if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- spin_lock_irq(&pDevice->lock);
KeybSetDefaultKey(pDevice,
&(pDevice->sKey),
dwKeyIndex | (1 << 31),
wrq->length, NULL,
pDevice->abyKey,
KEY_CTL_WEP);
- spin_unlock_irq(&pDevice->lock);
}
pDevice->byKeyIndex = (u8)dwKeyIndex;
pDevice->uKeyLength = wrq->length;
@@ -1242,10 +1236,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
pDevice->bEncryptionEnable = false;
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- spin_lock_irq(&pDevice->lock);
for (uu = 0; uu < MAX_KEY_TABLE; uu++)
MACvDisableKeyEntry(pDevice, uu);
- spin_unlock_irq(&pDevice->lock);
}
}
if (wrq->flags & IW_ENCODE_RESTRICTED) {
@@ -1342,12 +1334,9 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
return rc;
}

- spin_lock_irq(&pDevice->lock);
-
if (wrq->disabled) {
pDevice->ePSMode = WMAC_POWER_CAM;
PSvDisablePowerSaving(pDevice);
- spin_unlock_irq(&pDevice->lock);
return rc;
}
if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
@@ -1359,8 +1348,6 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
}

- spin_unlock_irq(&pDevice->lock);
-
switch (wrq->flags & IW_POWER_MODE) {
case IW_POWER_UNICAST_R:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R\n");
@@ -1723,9 +1710,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
KeyvInitTable(pDevice, &pDevice->sKey);
}
/*******/
- spin_lock_irq(&pDevice->lock);
ret = wpa_set_keys(pDevice, param);
- spin_unlock_irq(&pDevice->lock);

error:
kfree(buf);
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index be92c04..b173ca1 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -97,7 +97,6 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable)
int i, jj;
u8 pbyData[MAX_KEY_TABLE+1];

- spin_lock_irq(&pDevice->lock);
for (i=0;i<MAX_KEY_TABLE;i++) {
pTable->KeyTable[i].bInUse = false;
pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
@@ -122,8 +121,6 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable)
pbyData
);

- spin_unlock_irq(&pDevice->lock);
-
return;
}

diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 374d7de..e99d2a9 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -312,8 +312,6 @@ static int device_init_registers(struct vnt_private *pDevice)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n",
DEVICE_INIT_COLD, pDevice->byPacketType);

- spin_lock_irq(&pDevice->lock);
-
memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
@@ -323,20 +321,17 @@ static int device_init_registers(struct vnt_private *pDevice)
if (FIRMWAREbBrach2Sram(pDevice) == false) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
" FIRMWAREbBrach2Sram fail\n");
- spin_unlock_irq(&pDevice->lock);
return false;
}
} else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
" FIRMWAREbDownload fail\n");
- spin_unlock_irq(&pDevice->lock);
return false;
}
}

if (!BBbVT3184Init(pDevice)) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail\n");
- spin_unlock_irq(&pDevice->lock);
return false;
}

@@ -353,7 +348,6 @@ static int device_init_registers(struct vnt_private *pDevice)
sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd);
if (ntStatus != STATUS_SUCCESS) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail\n");
- spin_unlock_irq(&pDevice->lock);
return false;
}

@@ -362,7 +356,6 @@ static int device_init_registers(struct vnt_private *pDevice)
if (ntStatus != STATUS_SUCCESS) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"Cardinit request in status fail!\n");
- spin_unlock_irq(&pDevice->lock);
return false;
}

@@ -370,10 +363,8 @@ static int device_init_registers(struct vnt_private *pDevice)
ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ,
MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1,
&pDevice->byLocalID);
- if (ntStatus != STATUS_SUCCESS) {
- spin_unlock_irq(&pDevice->lock);
+ if (ntStatus != STATUS_SUCCESS)
return false;
- }

/* do MACbSoftwareReset in MACvInitialize */

@@ -604,10 +595,8 @@ static int device_init_registers(struct vnt_private *pDevice)
ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ,
MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp);

- if (ntStatus != STATUS_SUCCESS) {
- spin_unlock_irq(&pDevice->lock);
+ if (ntStatus != STATUS_SUCCESS)
return false;
- }

if ((byTmp & GPIO3_DATA) == 0) {
pDevice->bHWRadioOff = true;
@@ -634,9 +623,6 @@ static int device_init_registers(struct vnt_private *pDevice)
CARDbRadioPowerOn(pDevice);
}

-
- spin_unlock_irq(&pDevice->lock);
-
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");

return true;
@@ -1025,7 +1011,6 @@ static int device_open(struct net_device *dev)

/* if WEP key already set by iwconfig but device not yet open */
if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) {
- spin_lock_irq(&pDevice->lock);
KeybSetDefaultKey( pDevice,
&(pDevice->sKey),
pDevice->byKeyIndex | (1 << 31),
@@ -1034,7 +1019,7 @@ static int device_open(struct net_device *dev)
pDevice->abyKey,
KEY_CTL_WEP
);
- spin_unlock_irq(&pDevice->lock);
+
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
}

@@ -1081,10 +1066,9 @@ static int device_close(struct net_device *dev)
pMgmt->bShareKeyAlgorithm = false;
pDevice->bEncryptionEnable = false;
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
- spin_lock_irq(&pDevice->lock);
+
for (uu = 0; uu < MAX_KEY_TABLE; uu++)
MACvDisableKeyEntry(pDevice,uu);
- spin_unlock_irq(&pDevice->lock);

if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false) {
MACbShutdown(pDevice);
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 1a6f911..836da00 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -146,7 +146,6 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
return STATUS_FAILURE;
}

- spin_unlock_irq(&pDevice->lock);
for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {

if (pDevice->Flags & fMP_CONTROL_WRITES)
@@ -157,12 +156,10 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
if (ii >= USB_CTL_WAIT) {
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "control send request submission timeout\n");
- spin_lock_irq(&pDevice->lock);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
return STATUS_FAILURE;
}
}
- spin_lock_irq(&pDevice->lock);

return STATUS_SUCCESS;
}
@@ -208,7 +205,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
return STATUS_FAILURE;
}

- spin_unlock_irq(&pDevice->lock);
for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {

if (pDevice->Flags & fMP_CONTROL_READS)
@@ -219,12 +215,10 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
if (ii >= USB_CTL_WAIT) {
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "control rcv request submission timeout\n");
- spin_lock_irq(&pDevice->lock);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
return STATUS_FAILURE;
}
}
- spin_lock_irq(&pDevice->lock);

return ntStatus;
}
--
1.9.1



2014-05-03 14:20:03

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 10/13] staging: vt6656: lock changes device_xmit

Replace locks with the spin_lock_irqsave and spin_unlock_irqrestore

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/main_usb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 14e649a..462f95d 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -1159,8 +1159,9 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct vnt_private *pDevice = netdev_priv(dev);
struct net_device_stats *stats = &pDevice->stats;
+ unsigned long flags;

- spin_lock_irq(&pDevice->lock);
+ spin_lock_irqsave(&pDevice->lock, flags);

netif_stop_queue(dev);

@@ -1181,7 +1182,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev)
}

out:
- spin_unlock_irq(&pDevice->lock);
+ spin_unlock_irqrestore(&pDevice->lock, flags);

return NETDEV_TX_OK;
}
--
1.9.1


2014-05-03 14:19:53

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 04/13] staging: vt6656: lock changes: csMgmt_xmit.

csMgmt_xmit is nolonger atomically called but part of must be.

Reorder the function so that RFbSetPower is called first.

Add new lock spinlock for the remainder of the function.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/rxtx.c | 50 +++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 0280ed2..185b1ea 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -1386,13 +1386,32 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
u16 wTxBufSize;
u32 cbMacHdLen;
u16 wCurrentRate = RATE_1M;
+ unsigned long flags;

- pContext = s_vGetFreeContext(pDevice);
+ if (pDevice->byBBType == BB_TYPE_11A) {
+ wCurrentRate = RATE_6M;
+ byPktType = PK_TYPE_11A;
+ } else {
+ wCurrentRate = RATE_1M;
+ byPktType = PK_TYPE_11B;
+ }

- if (NULL == pContext) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n");
- return CMD_STATUS_RESOURCES;
- }
+ if (pMgmt->eScanState != WMAC_NO_SCANNING)
+ RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
+ else
+ RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
+
+ pDevice->wCurrentRate = wCurrentRate;
+
+ spin_lock_irqsave(&pDevice->lock, flags);
+
+ pContext = s_vGetFreeContext(pDevice);
+ if (!pContext) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "ManagementSend TX...NO CONTEXT!\n");
+ spin_unlock_irqrestore(&pDevice->lock, flags);
+ return CMD_STATUS_RESOURCES;
+ }

pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0];
cbFrameBodySize = pPacket->cbPayloadLen;
@@ -1400,24 +1419,6 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0];
wTxBufSize = sizeof(struct vnt_tx_fifo_head);

- if (pDevice->byBBType == BB_TYPE_11A) {
- wCurrentRate = RATE_6M;
- byPktType = PK_TYPE_11A;
- } else {
- wCurrentRate = RATE_1M;
- byPktType = PK_TYPE_11B;
- }
-
- // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
- // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
- // And cmd timer will wait data pkt TX finish before scanning so it's OK
- // to set power here.
- if (pMgmt->eScanState != WMAC_NO_SCANNING) {
- RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
- } else {
- RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
- }
- pDevice->wCurrentRate = wCurrentRate;

//Set packet type
if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000
@@ -1628,6 +1629,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
}

PIPEnsSendBulkOut(pDevice,pContext);
+
+ spin_unlock_irqrestore(&pDevice->lock, flags);
+
return CMD_STATUS_PENDING;
}

--
1.9.1


2014-05-03 14:19:56

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 06/13] staging: vt6656: lock changes: bMgrPrepareBeaconToSend add lock.

bMgrPrepareBeaconToSend is nolonger atomic

csBeacon_xmit must be locked add spin lock.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/wmgr.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c
index 0d69719..cce67cd 100644
--- a/drivers/staging/vt6656/wmgr.c
+++ b/drivers/staging/vt6656/wmgr.c
@@ -4058,6 +4058,7 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice,
struct vnt_manager *pMgmt)
{
struct vnt_tx_mgmt *pTxPacket;
+ unsigned long flags;

// pDevice->bBeaconBufReady = false;
if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){
@@ -4084,8 +4085,13 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice,
(pMgmt->abyCurrBSSID[0] == 0))
return false;

- csBeacon_xmit(pDevice, pTxPacket);
- MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
+ spin_lock_irqsave(&pDevice->lock, flags);
+
+ csBeacon_xmit(pDevice, pTxPacket);
+
+ spin_unlock_irqrestore(&pDevice->lock, flags);
+
+ MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);

return true;
}
--
1.9.1


2014-05-03 14:19:58

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 07/13] staging: vt6656: lock changes: vRunCommand nsDMA_tx_packet

vRunCommand is nolonger atomic add lock for nsDMA_tx_packet.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/wcmd.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index d51cc90..66d59d5 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -279,6 +279,7 @@ void vRunCommand(struct work_struct *work)
int ii;
u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
u8 byData;
+ unsigned long flags;

if (pDevice->Flags & fMP_DISCONNECTED)
return;
@@ -667,9 +668,13 @@ void vRunCommand(struct work_struct *work)
pDevice->bMoreData = true;
}

+ spin_lock_irqsave(&pDevice->lock, flags);
+
if (nsDMA_tx_packet(pDevice, skb) != 0)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n");

+ spin_unlock_irqrestore(&pDevice->lock, flags);
+
pMgmt->sNodeDBTable[0].wEnQueueCnt--;
}
}
@@ -690,9 +695,13 @@ void vRunCommand(struct work_struct *work)
pDevice->bMoreData = true;
}

+ spin_lock_irqsave(&pDevice->lock, flags);
+
if (nsDMA_tx_packet(pDevice, skb) != 0)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n");

+ spin_unlock_irqrestore(&pDevice->lock, flags);
+
pMgmt->sNodeDBTable[ii].wEnQueueCnt--;
// check if sta ps enable, wait next pspoll
// if sta ps disable, send all pending buffers.
--
1.9.1


2014-05-03 14:20:04

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 11/13] staging: vt6656: usbpipe.c PIPEnsControlOut use usb_control_msg

Now that this fucntion is nolonger atomic change to usb_control_msg

Return STATUS_FAILURE if ntStatus less than wLength.

Remove fMP_CONTROL_WRITES flag

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 1 -
drivers/staging/vt6656/main_usb.c | 1 -
drivers/staging/vt6656/usbpipe.c | 87 ++++-----------------------------------
3 files changed, 7 insertions(+), 82 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 622cf02..da1b70d 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -744,7 +744,6 @@ struct vnt_private {
#define fMP_POST_READS 0x00000100
#define fMP_POST_WRITES 0x00000200
#define fMP_CONTROL_READS 0x00000400
-#define fMP_CONTROL_WRITES 0x00000800

#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 462f95d..6ca5d78 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -965,7 +965,6 @@ static int device_open(struct net_device *dev)

MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
MP_SET_FLAG(pDevice, fMP_POST_READS);
MP_SET_FLAG(pDevice, fMP_POST_WRITES);

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index b707470..1ab3958 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -64,7 +64,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkInUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkOutIoCompleteWrite(struct urb *urb);
static void s_nsControlInUsbIoCompleteRead(struct urb *urb);
-static void s_nsControlInUsbIoCompleteWrite(struct urb *urb);

int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer)
@@ -74,9 +73,6 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;

- if (pDevice->Flags & fMP_CONTROL_WRITES)
- return STATUS_FAILURE;
-
if (in_interrupt()) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest);
return STATUS_FAILURE;
@@ -109,69 +105,24 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,

int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
u16 wIndex, u16 wLength, u8 *pbyBuffer)
- __releases(&pDevice->lock)
- __acquires(&pDevice->lock)
{
int ntStatus = 0;
- int ii;
-
- if (pDevice->Flags & fMP_DISCONNECTED)
- return STATUS_FAILURE;
-
- if (pDevice->Flags & fMP_CONTROL_WRITES)
- return STATUS_FAILURE;

- if (pDevice->Flags & fMP_CONTROL_READS)
- return STATUS_FAILURE;
-
- if (pDevice->pControlURB->hcpriv)
+ if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;

mutex_lock(&pDevice->usb_lock);

- MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES);
+ ntStatus = usb_control_msg(pDevice->usb,
+ usb_sndctrlpipe(pDevice->usb, 0), byRequest, 0x40, wValue,
+ wIndex, pbyBuffer, wLength, USB_CTL_WAIT);

- pDevice->sUsbCtlRequest.bRequestType = 0x40;
- pDevice->sUsbCtlRequest.bRequest = byRequest;
- pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
- pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
- pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
- pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
- pDevice->pControlURB->actual_length = 0;
- // Notice, pbyBuffer limited point to variable buffer, can't be constant.
- usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
- usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
- pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice);
+ mutex_unlock(&pDevice->usb_lock);

- ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC);
- if (ntStatus != 0) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
- "control send request submission failed: %d\n",
- ntStatus);
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
- mutex_unlock(&pDevice->usb_lock);
+ if (ntStatus < (int)wLength)
return STATUS_FAILURE;
- }
-
- for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
-
- if (pDevice->Flags & fMP_CONTROL_WRITES)
- mdelay(1);
- else
- break;
-
- if (ii >= USB_CTL_WAIT) {
- DBG_PRT(MSG_LEVEL_DEBUG,
- KERN_INFO "control send request submission timeout\n");
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
- mutex_unlock(&pDevice->usb_lock);
- return STATUS_FAILURE;
- }
- }
-
- mutex_unlock(&pDevice->usb_lock);

- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}

int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
@@ -188,9 +139,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
if (pDevice->Flags & fMP_CONTROL_READS)
return STATUS_FAILURE;

- if (pDevice->Flags & fMP_CONTROL_WRITES)
- return STATUS_FAILURE;
-
if (pDevice->pControlURB->hcpriv)
return STATUS_FAILURE;

@@ -239,27 +187,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
return ntStatus;
}

-static void s_nsControlInUsbIoCompleteWrite(struct urb *urb)
-{
- struct vnt_private *pDevice = (struct vnt_private *)urb->context;
-
- pDevice = urb->context;
- switch (urb->status) {
- case 0:
- break;
- case -EINPROGRESS:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status);
- break;
- case -ENOENT:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status);
- break;
- default:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status);
- }
-
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
-}
-
/*
* Description:
* Complete function of usb Control callback
--
1.9.1


2014-05-03 14:20:06

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 12/13] staging: vt6656: PIPEnsControlIn use usb_control_msg

Now that this function is nolonger atomic useusb_control_msg.

Return STATUS_FAILURE if ntStatus less than wLength

Remove the old struct urb and struct usb_ctrlrequest structures.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 3 --
drivers/staging/vt6656/main_usb.c | 11 -----
drivers/staging/vt6656/usbpipe.c | 94 ++++-----------------------------------
3 files changed, 9 insertions(+), 99 deletions(-)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index da1b70d..410e028 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -380,9 +380,7 @@ struct vnt_private {
u32 uCurrentDFCBIdx;

/* USB */
- struct urb *pControlURB;
struct urb *pInterruptURB;
- struct usb_ctrlrequest sUsbCtlRequest;
u32 int_interval;

/* Variables to track resources for the BULK In Pipe */
@@ -743,7 +741,6 @@ struct vnt_private {
#define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080
#define fMP_POST_READS 0x00000100
#define fMP_POST_WRITES 0x00000200
-#define fMP_CONTROL_READS 0x00000400

#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 6ca5d78..1b58cca 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -702,12 +702,6 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
INIT_WORK(&pDevice->read_work_item, RXvWorkItem);
INIT_WORK(&pDevice->rx_mng_work_item, RXvMngWorkItem);

- pDevice->pControlURB = usb_alloc_urb(0, GFP_ATOMIC);
- if (!pDevice->pControlURB) {
- DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc control urb\n");
- goto err_netdev;
- }
-
pDevice->tx_80211 = device_dma0_tx_80211;
pDevice->vnt_mgmt.pAdapter = (void *) pDevice;

@@ -964,7 +958,6 @@ static int device_open(struct net_device *dev)
}

MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
MP_SET_FLAG(pDevice, fMP_POST_READS);
MP_SET_FLAG(pDevice, fMP_POST_WRITES);

@@ -1130,10 +1123,6 @@ static void vt6656_disconnect(struct usb_interface *intf)

if (device->dev) {
unregister_netdev(device->dev);
-
- usb_kill_urb(device->pControlURB);
- usb_free_urb(device->pControlURB);
-
free_netdev(device->dev);
}
}
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 1ab3958..9946bfd 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -63,7 +63,6 @@ static int msglevel =MSG_LEVEL_INFO;
static void s_nsInterruptUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkInUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkOutIoCompleteWrite(struct urb *urb);
-static void s_nsControlInUsbIoCompleteRead(struct urb *urb);

int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer)
@@ -126,100 +125,25 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
}

int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
- u16 wIndex, u16 wLength, u8 *pbyBuffer)
- __releases(&pDevice->lock)
- __acquires(&pDevice->lock)
+ u16 wIndex, u16 wLength, u8 *pbyBuffer)
{
- int ntStatus = 0;
- int ii;
-
- if (pDevice->Flags & fMP_DISCONNECTED)
- return STATUS_FAILURE;
-
- if (pDevice->Flags & fMP_CONTROL_READS)
- return STATUS_FAILURE;
+ int ntStatus;

- if (pDevice->pControlURB->hcpriv)
+ if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;

mutex_lock(&pDevice->usb_lock);

- MP_SET_FLAG(pDevice, fMP_CONTROL_READS);
-
- pDevice->sUsbCtlRequest.bRequestType = 0xC0;
- pDevice->sUsbCtlRequest.bRequest = byRequest;
- pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
- pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
- pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
- pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
- pDevice->pControlURB->actual_length = 0;
- usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
- usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
- pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice);
-
- ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC);
- if (ntStatus != 0) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
- "control request submission failed: %d\n", ntStatus);
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
- mutex_unlock(&pDevice->usb_lock);
- return STATUS_FAILURE;
- }
-
- for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
-
- if (pDevice->Flags & fMP_CONTROL_READS)
- mdelay(1);
- else
- break;
-
- if (ii >= USB_CTL_WAIT) {
- DBG_PRT(MSG_LEVEL_DEBUG,
- KERN_INFO "control rcv request submission timeout\n");
- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
- mutex_unlock(&pDevice->usb_lock);
- return STATUS_FAILURE;
- }
- }
+ ntStatus = usb_control_msg(pDevice->usb,
+ usb_rcvctrlpipe(pDevice->usb, 0), byRequest, 0xc0, wValue,
+ wIndex, pbyBuffer, wLength, USB_CTL_WAIT);

mutex_unlock(&pDevice->usb_lock);

- return ntStatus;
-}
-
-/*
- * Description:
- * Complete function of usb Control callback
- *
- * Parameters:
- * In:
- * pDevice - Pointer to the adapter
- *
- * Out:
- * none
- *
- * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
- *
- */
-
-static void s_nsControlInUsbIoCompleteRead(struct urb *urb)
-{
- struct vnt_private *pDevice = (struct vnt_private *)urb->context;
-
- switch (urb->status) {
- case 0:
- break;
- case -EINPROGRESS:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status);
- break;
- case -ENOENT:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status);
- break;
- default:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status);
- }
+ if (ntStatus < (int)wLength)
+ return STATUS_FAILURE;

- MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+ return STATUS_SUCCESS;
}

/*
--
1.9.1


2014-05-03 14:19:51

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 03/13] staging: vt6656: lock changes: RXvMngWorkItem.

Narrow atomic locks in RXvMngWorkItem.

We must lock the DequeueRCB and RXvFreeRCB so that
they are in sync.

vMgrRxManagePacket can nolonger be atomically called.

There is no need for an overall lock.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/dpc.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 4ccaa7e..156399d 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -1363,34 +1363,43 @@ void RXvMngWorkItem(struct work_struct *work)
struct vnt_rcb *pRCB = NULL;
struct vnt_rx_mgmt *pRxPacket;
int bReAllocSkb = false;
+ unsigned long flags;

if (pDevice->Flags & fMP_DISCONNECTED)
return;

DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Mng Thread\n");

- spin_lock_irq(&pDevice->lock);
while (pDevice->NumRecvMngList!=0)
{
+ spin_lock_irqsave(&pDevice->lock, flags);
+
pRCB = pDevice->FirstRecvMngList;
pDevice->NumRecvMngList--;
DequeueRCB(pDevice->FirstRecvMngList, pDevice->LastRecvMngList);
+
+ spin_unlock_irqrestore(&pDevice->lock, flags);
+
if(!pRCB){
break;
}
pRxPacket = &(pRCB->sMngPacket);
vMgrRxManagePacket(pDevice, &pDevice->vnt_mgmt, pRxPacket);
pRCB->Ref--;
- if(pRCB->Ref == 0) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList);
- RXvFreeRCB(pRCB, bReAllocSkb);
- } else {
+ if (pRCB->Ref == 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",
+ pDevice->NumRecvFreeList, pDevice->NumRecvMngList);
+
+ spin_lock_irqsave(&pDevice->lock, flags);
+
+ RXvFreeRCB(pRCB, bReAllocSkb);
+
+ spin_unlock_irqrestore(&pDevice->lock, flags);
+ } else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rx Mng Only we have the right to free RCB\n");
}
}

pDevice->bIsRxMngWorkItemQueued = false;
- spin_unlock_irq(&pDevice->lock);
-
}

--
1.9.1


2014-05-03 14:19:54

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 05/13] staging: vt6656: lock changes: vDMA0_tx_80211

vDMA0_tx_80211 is atomically called.

RFbSetPower can not be called atomically.

If wCurrentRate is different to pDevice->wCurrentRate call
bScheduleCommand WLAN_CMD_SETPOWER.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/rxtx.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 185b1ea..ff77f20 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -1784,11 +1784,11 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb)
// 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
// And cmd timer will wait data pkt TX finish before scanning so it's OK
// to set power here.
- if (pMgmt->eScanState != WMAC_NO_SCANNING) {
- RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh);
- } else {
- RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel);
- }
+ if (wCurrentRate != pDevice->wCurrentRate) {
+ pDevice->wCurrentRate = wCurrentRate;
+
+ bScheduleCommand(pDevice, WLAN_CMD_SETPOWER, NULL);
+ }

DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl);

--
1.9.1


2014-05-15 20:28:04

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 01/13] staging: vt6656: lock changes: Remove spin locks

On Sat, May 03, 2014 at 03:17:22PM +0100, Malcolm Priestley wrote:
> Remove atomic paths to usbpipe.c PIPEnsControlOut and PIPEnsControlIn
>
> Remove from
> PIPEnsControlOut
> PIPEnsControlIn
> BSSvSecondCallBack
> FIRMWAREbDownload
> vt6656_hostap_ioctl
> iwctl_siwmode
> iwctl_siwencode
> iwctl_siwpower
> iwctl_siwencodeext
> KeyvInitTable
> device_init_registers
> device_open
> device_close
>
> Signed-off-by: Malcolm Priestley <[email protected]>
> ---
> Note: All patches of these series must be applied.

Which makes this series fail :(

Can you please resend the patches from you that I haven't applied, after
refreshing them against my tree?

thanks,

greg k-h

2014-05-03 14:19:59

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 08/13] staging: vt6656: lock changes: usbpipe.c add mutex lock

PIPEnsControlOut and PIPEnsControlIn are nolonger
atomic but they do need a usb lock.

Add new mutex lock for these functions and PIPEnsControlOutAsyn.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 1 +
drivers/staging/vt6656/main_usb.c | 2 ++
drivers/staging/vt6656/usbpipe.c | 16 ++++++++++++++++
3 files changed, 19 insertions(+)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index f36a2eb..622cf02 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -363,6 +363,7 @@ struct vnt_private {
u8 byRxMode;

spinlock_t lock;
+ struct mutex usb_lock;

u32 rx_bytes;

diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index e99d2a9..14e649a 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -695,6 +695,8 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)

device_set_options(pDevice);
spin_lock_init(&pDevice->lock);
+ mutex_init(&pDevice->usb_lock);
+
INIT_DELAYED_WORK(&pDevice->run_command_work, vRunCommand);
INIT_DELAYED_WORK(&pDevice->second_callback_work, BSSvSecondCallBack);
INIT_WORK(&pDevice->read_work_item, RXvWorkItem);
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 836da00..934d0a9 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -82,6 +82,8 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
return STATUS_FAILURE;
}

+ mutex_lock(&pDevice->usb_lock);
+
ntStatus = usb_control_msg(
pDevice->usb,
usb_sndctrlpipe(pDevice->usb , 0),
@@ -100,6 +102,8 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus);
}

+ mutex_unlock(&pDevice->usb_lock);
+
return ntStatus;
}

@@ -123,6 +127,8 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
if (pDevice->pControlURB->hcpriv)
return STATUS_FAILURE;

+ mutex_lock(&pDevice->usb_lock);
+
MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES);

pDevice->sUsbCtlRequest.bRequestType = 0x40;
@@ -143,6 +149,7 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
"control send request submission failed: %d\n",
ntStatus);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
+ mutex_unlock(&pDevice->usb_lock);
return STATUS_FAILURE;
}

@@ -157,10 +164,13 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "control send request submission timeout\n");
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
+ mutex_unlock(&pDevice->usb_lock);
return STATUS_FAILURE;
}
}

+ mutex_unlock(&pDevice->usb_lock);
+
return STATUS_SUCCESS;
}

@@ -184,6 +194,8 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
if (pDevice->pControlURB->hcpriv)
return STATUS_FAILURE;

+ mutex_lock(&pDevice->usb_lock);
+
MP_SET_FLAG(pDevice, fMP_CONTROL_READS);

pDevice->sUsbCtlRequest.bRequestType = 0xC0;
@@ -202,6 +214,7 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"control request submission failed: %d\n", ntStatus);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+ mutex_unlock(&pDevice->usb_lock);
return STATUS_FAILURE;
}

@@ -216,10 +229,13 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "control rcv request submission timeout\n");
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+ mutex_unlock(&pDevice->usb_lock);
return STATUS_FAILURE;
}
}

+ mutex_unlock(&pDevice->usb_lock);
+
return ntStatus;
}

--
1.9.1


2014-05-03 14:20:00

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 09/13] staging: vt6656: lock changes: s_nsBulkInUsbIoCompleteRead.

Use spin_lock_irqsave/spin_unlock_irqrestore

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 934d0a9..b707470 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -474,6 +474,7 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
{
struct vnt_rcb *rcb = urb->context;
struct vnt_private *priv = rcb->pDevice;
+ unsigned long flags;
int re_alloc_skb = false;

DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
@@ -493,23 +494,23 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
}

if (urb->actual_length) {
- spin_lock(&priv->lock);
+ spin_lock_irqsave(&priv->lock, flags);

if (RXbBulkInProcessData(priv, rcb, urb->actual_length) == true)
re_alloc_skb = true;

- spin_unlock(&priv->lock);
+ spin_unlock_irqrestore(&priv->lock, flags);
}

rcb->Ref--;
if (rcb->Ref == 0) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n",
priv->NumRecvFreeList);
- spin_lock(&priv->lock);
+ spin_lock_irqsave(&priv->lock, flags);

RXvFreeRCB(rcb, re_alloc_skb);

- spin_unlock(&priv->lock);
+ spin_unlock_irqrestore(&priv->lock, flags);
}

return;
--
1.9.1


2014-05-03 14:19:50

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 02/13] staging: vt6656: lock changes: vRunCommand remove locks

Removing atomic locked paths to usbpipe.c PIPEnsControlOut and PIPEnsControlIn

This function will nolonger need any locking.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/wcmd.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index de7e808..d51cc90 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -286,8 +286,6 @@ void vRunCommand(struct work_struct *work)
if (pDevice->bCmdRunning != true)
return;

- spin_lock_irq(&pDevice->lock);
-
switch (pDevice->eCommandState) {

case WLAN_CMD_SCAN_START:
@@ -365,11 +363,9 @@ void vRunCommand(struct work_struct *work)
if ((pMgmt->b11hEnable == false) ||
(pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) {
s_vProbeChannel(pDevice);
- spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, 100);
return;
} else {
- spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME);
return;
}
@@ -504,7 +500,6 @@ void vRunCommand(struct work_struct *work)
pDevice->byLinkWaitCount = 0;
pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT;
vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT);
- spin_unlock_irq(&pDevice->lock);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n");
return;
}
@@ -578,7 +573,6 @@ void vRunCommand(struct work_struct *work)
pDevice->byLinkWaitCount = 0;
pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT);
- spin_unlock_irq(&pDevice->lock);
return;
}
} else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) {
@@ -587,7 +581,6 @@ void vRunCommand(struct work_struct *work)
//mike add:wait another 2 sec if authenticated_frame delay!
pDevice->byLinkWaitCount++;
printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
- spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2);
return;
}
@@ -622,7 +615,6 @@ void vRunCommand(struct work_struct *work)
//mike add:wait another 2 sec if associated_frame delay!
pDevice->byLinkWaitCount++;
printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount);
- spin_unlock_irq(&pDevice->lock);
vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2);
return;
}
@@ -752,9 +744,9 @@ void vRunCommand(struct work_struct *work)

pDevice->byKeyIndex = 0;
pDevice->bTransmitKey = false;
- spin_unlock_irq(&pDevice->lock);
+
KeyvInitTable(pDevice, &pDevice->sKey);
- spin_lock_irq(&pDevice->lock);
+
pMgmt->byCSSPK = KEY_CTL_NONE;
pMgmt->byCSSGK = KEY_CTL_NONE;

@@ -882,7 +874,6 @@ void vRunCommand(struct work_struct *work)

s_bCommandComplete(pDevice);

- spin_unlock_irq(&pDevice->lock);
return;
}

--
1.9.1


2014-05-03 14:20:07

by Malcolm Priestley

[permalink] [raw]
Subject: [PATCH 13/13] staging: vt6656: Remove PIPEnsControlOutAsyn/CONTROLnsRequestOutAsyn

This now the sames as PIPEnsControlOut.

Replace with PIPEnsControlOut/CONTROLnsRequestOut.

Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/control.h | 3 ---
drivers/staging/vt6656/firmware.c | 2 +-
drivers/staging/vt6656/mac.c | 2 +-
drivers/staging/vt6656/usbpipe.c | 38 --------------------------------------
drivers/staging/vt6656/usbpipe.h | 2 --
5 files changed, 2 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h
index 9da9b96..4658910 100644
--- a/drivers/staging/vt6656/control.h
+++ b/drivers/staging/vt6656/control.h
@@ -36,9 +36,6 @@
#define CONTROLnsRequestOut(Device, Request, Value, Index, Length, Buffer) \
PIPEnsControlOut(Device, Request, Value, Index, Length, Buffer)

-#define CONTROLnsRequestOutAsyn(Device, Request, Value, Index, Length, Buffer) \
- PIPEnsControlOutAsyn(Device, Request, Value, Index, Length, Buffer)
-
#define CONTROLnsRequestIn(Device, Request, Value, Index, Length, Buffer) \
PIPEnsControlIn(Device, Request, Value, Index, Length, Buffer)

diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index 7a4a972..e03f1f9 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -71,7 +71,7 @@ int FIRMWAREbDownload(struct vnt_private *pDevice)
wLength = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
memcpy(pBuffer, fw->data + ii, wLength);

- NdisStatus = CONTROLnsRequestOutAsyn(pDevice,
+ NdisStatus = CONTROLnsRequestOut(pDevice,
0,
0x1200+ii,
0x0000,
diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c
index 3ce19dd..8bd3ab0 100644
--- a/drivers/staging/vt6656/mac.c
+++ b/drivers/staging/vt6656/mac.c
@@ -75,7 +75,7 @@ void MACvWriteMultiAddr(struct vnt_private *pDevice, u64 mc_filter)
*/
void MACbShutdown(struct vnt_private *pDevice)
{
- CONTROLnsRequestOutAsyn(pDevice,
+ CONTROLnsRequestOut(pDevice,
MESSAGE_TYPE_MACSHUTDOWN,
0,
0,
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 9946bfd..433edca 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -64,44 +64,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkInUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkOutIoCompleteWrite(struct urb *urb);

-int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
- u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer)
-{
- int ntStatus;
-
- if (pDevice->Flags & fMP_DISCONNECTED)
- return STATUS_FAILURE;
-
- if (in_interrupt()) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest);
- return STATUS_FAILURE;
- }
-
- mutex_lock(&pDevice->usb_lock);
-
- ntStatus = usb_control_msg(
- pDevice->usb,
- usb_sndctrlpipe(pDevice->usb , 0),
- byRequest,
- 0x40, // RequestType
- wValue,
- wIndex,
- (void *) pbyBuffer,
- wLength,
- HZ
- );
- if (ntStatus >= 0) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus);
- ntStatus = 0;
- } else {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus);
- }
-
- mutex_unlock(&pDevice->usb_lock);
-
- return ntStatus;
-}
-
int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
u16 wIndex, u16 wLength, u8 *pbyBuffer)
{
diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h
index f537703..42ad4f7 100644
--- a/drivers/staging/vt6656/usbpipe.h
+++ b/drivers/staging/vt6656/usbpipe.h
@@ -34,8 +34,6 @@

int PIPEnsControlOut(struct vnt_private *, u8 byRequest, u16 wValue,
u16 wIndex, u16 wLength, u8 *pbyBuffer);
-int PIPEnsControlOutAsyn(struct vnt_private *, u8 byRequest,
- u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer);
int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue,
u16 wIndex, u16 wLength, u8 *pbyBuffer);

--
1.9.1