![Tejun Heo](/assets/img/avatar_default.png)
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
307 lines
7.7 KiB
C
307 lines
7.7 KiB
C
//============================================================================
|
|
// Copyright (c) 1996-2002 Winbond Electronic Corporation
|
|
//
|
|
// Module Name:
|
|
// Wb35Tx.c
|
|
//
|
|
// Abstract:
|
|
// Processing the Tx message and put into down layer
|
|
//
|
|
//============================================================================
|
|
#include <linux/usb.h>
|
|
#include <linux/gfp.h>
|
|
|
|
#include "wb35tx_f.h"
|
|
#include "mds_f.h"
|
|
#include "sysdef.h"
|
|
|
|
unsigned char
|
|
Wb35Tx_get_tx_buffer(struct hw_data * pHwData, u8 **pBuffer)
|
|
{
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
|
|
*pBuffer = pWb35Tx->TxBuffer[0];
|
|
return true;
|
|
}
|
|
|
|
static void Wb35Tx(struct wbsoft_priv *adapter);
|
|
|
|
static void Wb35Tx_complete(struct urb * pUrb)
|
|
{
|
|
struct wbsoft_priv *adapter = pUrb->context;
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
struct wb35_mds *pMds = &adapter->Mds;
|
|
|
|
printk("wb35: tx complete\n");
|
|
// Variable setting
|
|
pWb35Tx->EP4vm_state = VM_COMPLETED;
|
|
pWb35Tx->EP4VM_status = pUrb->status; //Store the last result of Irp
|
|
pMds->TxOwner[ pWb35Tx->TxSendIndex ] = 0;// Set the owner. Free the owner bit always.
|
|
pWb35Tx->TxSendIndex++;
|
|
pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER;
|
|
|
|
if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
|
|
goto error;
|
|
|
|
if (pWb35Tx->tx_halt)
|
|
goto error;
|
|
|
|
// The URB is completed, check the result
|
|
if (pWb35Tx->EP4VM_status != 0) {
|
|
printk("URB submission failed\n");
|
|
pWb35Tx->EP4vm_state = VM_STOP;
|
|
goto error;
|
|
}
|
|
|
|
Mds_Tx(adapter);
|
|
Wb35Tx(adapter);
|
|
return;
|
|
|
|
error:
|
|
atomic_dec(&pWb35Tx->TxFireCounter);
|
|
pWb35Tx->EP4vm_state = VM_STOP;
|
|
}
|
|
|
|
static void Wb35Tx(struct wbsoft_priv *adapter)
|
|
{
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
u8 *pTxBufferAddress;
|
|
struct wb35_mds *pMds = &adapter->Mds;
|
|
struct urb * pUrb = (struct urb *)pWb35Tx->Tx4Urb;
|
|
int retv;
|
|
u32 SendIndex;
|
|
|
|
|
|
if (pHwData->SurpriseRemove || pHwData->HwStop)
|
|
goto cleanup;
|
|
|
|
if (pWb35Tx->tx_halt)
|
|
goto cleanup;
|
|
|
|
// Ownership checking
|
|
SendIndex = pWb35Tx->TxSendIndex;
|
|
if (!pMds->TxOwner[SendIndex]) //No more data need to be sent, return immediately
|
|
goto cleanup;
|
|
|
|
pTxBufferAddress = pWb35Tx->TxBuffer[SendIndex];
|
|
//
|
|
// Issuing URB
|
|
//
|
|
usb_fill_bulk_urb(pUrb, pHwData->WbUsb.udev,
|
|
usb_sndbulkpipe(pHwData->WbUsb.udev, 4),
|
|
pTxBufferAddress, pMds->TxBufferSize[ SendIndex ],
|
|
Wb35Tx_complete, adapter);
|
|
|
|
pWb35Tx->EP4vm_state = VM_RUNNING;
|
|
retv = usb_submit_urb(pUrb, GFP_ATOMIC);
|
|
if (retv<0) {
|
|
printk("EP4 Tx Irp sending error\n");
|
|
goto cleanup;
|
|
}
|
|
|
|
// Check if driver needs issue Irp for EP2
|
|
pWb35Tx->TxFillCount += pMds->TxCountInBuffer[SendIndex];
|
|
if (pWb35Tx->TxFillCount > 12)
|
|
Wb35Tx_EP2VM_start(adapter);
|
|
|
|
pWb35Tx->ByteTransfer += pMds->TxBufferSize[SendIndex];
|
|
return;
|
|
|
|
cleanup:
|
|
pWb35Tx->EP4vm_state = VM_STOP;
|
|
atomic_dec(&pWb35Tx->TxFireCounter);
|
|
}
|
|
|
|
void Wb35Tx_start(struct wbsoft_priv *adapter)
|
|
{
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
|
|
// Allow only one thread to run into function
|
|
if (atomic_inc_return(&pWb35Tx->TxFireCounter) == 1) {
|
|
pWb35Tx->EP4vm_state = VM_RUNNING;
|
|
Wb35Tx(adapter);
|
|
} else
|
|
atomic_dec(&pWb35Tx->TxFireCounter);
|
|
}
|
|
|
|
unsigned char Wb35Tx_initial(struct hw_data * pHwData)
|
|
{
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
|
|
pWb35Tx->Tx4Urb = usb_alloc_urb(0, GFP_ATOMIC);
|
|
if (!pWb35Tx->Tx4Urb)
|
|
return false;
|
|
|
|
pWb35Tx->Tx2Urb = usb_alloc_urb(0, GFP_ATOMIC);
|
|
if (!pWb35Tx->Tx2Urb)
|
|
{
|
|
usb_free_urb( pWb35Tx->Tx4Urb );
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//======================================================
|
|
void Wb35Tx_stop(struct hw_data * pHwData)
|
|
{
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
|
|
// Trying to canceling the Trp of EP2
|
|
if (pWb35Tx->EP2vm_state == VM_RUNNING)
|
|
usb_unlink_urb( pWb35Tx->Tx2Urb ); // Only use unlink, let Wb35Tx_destrot to free them
|
|
#ifdef _PE_TX_DUMP_
|
|
printk("EP2 Tx stop\n");
|
|
#endif
|
|
|
|
// Trying to canceling the Irp of EP4
|
|
if (pWb35Tx->EP4vm_state == VM_RUNNING)
|
|
usb_unlink_urb( pWb35Tx->Tx4Urb ); // Only use unlink, let Wb35Tx_destrot to free them
|
|
#ifdef _PE_TX_DUMP_
|
|
printk("EP4 Tx stop\n");
|
|
#endif
|
|
}
|
|
|
|
//======================================================
|
|
void Wb35Tx_destroy(struct hw_data * pHwData)
|
|
{
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
|
|
// Wait for VM stop
|
|
do {
|
|
msleep(10); // Delay for waiting function enter 940623.1.a
|
|
} while( (pWb35Tx->EP2vm_state != VM_STOP) && (pWb35Tx->EP4vm_state != VM_STOP) );
|
|
msleep(10); // Delay for waiting function enter 940623.1.b
|
|
|
|
if (pWb35Tx->Tx4Urb)
|
|
usb_free_urb( pWb35Tx->Tx4Urb );
|
|
|
|
if (pWb35Tx->Tx2Urb)
|
|
usb_free_urb( pWb35Tx->Tx2Urb );
|
|
|
|
#ifdef _PE_TX_DUMP_
|
|
printk("Wb35Tx_destroy OK\n");
|
|
#endif
|
|
}
|
|
|
|
void Wb35Tx_CurrentTime(struct wbsoft_priv *adapter, u32 TimeCount)
|
|
{
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
unsigned char Trigger = false;
|
|
|
|
if (pWb35Tx->TxTimer > TimeCount)
|
|
Trigger = true;
|
|
else if (TimeCount > (pWb35Tx->TxTimer+500))
|
|
Trigger = true;
|
|
|
|
if (Trigger) {
|
|
pWb35Tx->TxTimer = TimeCount;
|
|
Wb35Tx_EP2VM_start(adapter);
|
|
}
|
|
}
|
|
|
|
static void Wb35Tx_EP2VM(struct wbsoft_priv *adapter);
|
|
|
|
static void Wb35Tx_EP2VM_complete(struct urb * pUrb)
|
|
{
|
|
struct wbsoft_priv *adapter = pUrb->context;
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
T02_DESCRIPTOR T02, TSTATUS;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
u32 * pltmp = (u32 *)pWb35Tx->EP2_buf;
|
|
u32 i;
|
|
u16 InterruptInLength;
|
|
|
|
|
|
// Variable setting
|
|
pWb35Tx->EP2vm_state = VM_COMPLETED;
|
|
pWb35Tx->EP2VM_status = pUrb->status;
|
|
|
|
// For Linux 2.4. Interrupt will always trigger
|
|
if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
|
|
goto error;
|
|
|
|
if (pWb35Tx->tx_halt)
|
|
goto error;
|
|
|
|
//The Urb is completed, check the result
|
|
if (pWb35Tx->EP2VM_status != 0) {
|
|
printk("EP2 IoCompleteRoutine return error\n");
|
|
pWb35Tx->EP2vm_state= VM_STOP;
|
|
goto error;
|
|
}
|
|
|
|
// Update the Tx result
|
|
InterruptInLength = pUrb->actual_length;
|
|
// Modify for minimum memory access and DWORD alignment.
|
|
T02.value = cpu_to_le32(pltmp[0]) >> 8; // [31:8] -> [24:0]
|
|
InterruptInLength -= 1;// 20051221.1.c Modify the follow for more stable
|
|
InterruptInLength >>= 2; // InterruptInLength/4
|
|
for (i = 1; i <= InterruptInLength; i++) {
|
|
T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24);
|
|
|
|
TSTATUS.value = T02.value; //20061009 anson's endian
|
|
Mds_SendComplete( adapter, &TSTATUS );
|
|
T02.value = cpu_to_le32(pltmp[i]) >> 8;
|
|
}
|
|
|
|
return;
|
|
error:
|
|
atomic_dec(&pWb35Tx->TxResultCount);
|
|
pWb35Tx->EP2vm_state = VM_STOP;
|
|
}
|
|
|
|
static void Wb35Tx_EP2VM(struct wbsoft_priv *adapter)
|
|
{
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
struct urb * pUrb = (struct urb *)pWb35Tx->Tx2Urb;
|
|
u32 * pltmp = (u32 *)pWb35Tx->EP2_buf;
|
|
int retv;
|
|
|
|
if (pHwData->SurpriseRemove || pHwData->HwStop)
|
|
goto error;
|
|
|
|
if (pWb35Tx->tx_halt)
|
|
goto error;
|
|
|
|
//
|
|
// Issuing URB
|
|
//
|
|
usb_fill_int_urb( pUrb, pHwData->WbUsb.udev, usb_rcvintpipe(pHwData->WbUsb.udev,2),
|
|
pltmp, MAX_INTERRUPT_LENGTH, Wb35Tx_EP2VM_complete, adapter, 32);
|
|
|
|
pWb35Tx->EP2vm_state = VM_RUNNING;
|
|
retv = usb_submit_urb(pUrb, GFP_ATOMIC);
|
|
|
|
if (retv < 0) {
|
|
#ifdef _PE_TX_DUMP_
|
|
printk("EP2 Tx Irp sending error\n");
|
|
#endif
|
|
goto error;
|
|
}
|
|
|
|
return;
|
|
error:
|
|
pWb35Tx->EP2vm_state = VM_STOP;
|
|
atomic_dec(&pWb35Tx->TxResultCount);
|
|
}
|
|
|
|
void Wb35Tx_EP2VM_start(struct wbsoft_priv *adapter)
|
|
{
|
|
struct hw_data * pHwData = &adapter->sHwData;
|
|
struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx;
|
|
|
|
// Allow only one thread to run into function
|
|
if (atomic_inc_return(&pWb35Tx->TxResultCount) == 1) {
|
|
pWb35Tx->EP2vm_state = VM_RUNNING;
|
|
Wb35Tx_EP2VM(adapter);
|
|
}
|
|
else
|
|
atomic_dec(&pWb35Tx->TxResultCount);
|
|
}
|