Commit b8ca02f1 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek

kernel/wr_pstats: trivial: checkpatch style fixes

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent b41e8354
......@@ -53,7 +53,7 @@ struct cntrs_dev {
/* circular bufer for passing Port's IRQ mask between irq handler and
* the tasklet */
uint32_t port_irqs[PSTATS_IRQBUFSZ];
uint64_t overflows[PSTATS_IRQBUFSZ][PSTATS_NPORTS];
uint64_t overflows[PSTATS_IRQBUFSZ][PSTATS_NPORTS];
volatile int irqs_head;
int irqs_tail;
};
......@@ -107,7 +107,7 @@ static uint64_t pstats_irq_cntrs(int port)
val = (port<<PSTATS_CR_PORT_SHIFT | PSTATS_CR_RD_IRQ);
pstats_writel(val, pstats_dev, CR);
//read lower half of cntrs overflow mask
/* read lower half of cntrs overflow mask */
mask = (((uint64_t)pstats_readl(pstats_dev, L2_CNT_VAL)) << 32);
mask &= 0xFFFFFFFF00000000LL;
mask |= (uint64_t) pstats_readl(pstats_dev, L1_CNT_VAL);
......@@ -131,39 +131,48 @@ static void pstats_tlet_fn(unsigned long arg)
device->irqs_tail += PSTATS_IRQBUFSZ;
}
while(device->irqs_tail != device->irqs_head) {
//printk(KERN_WARNING "tlet head=%d, tail=%d\n", device->irqs_head, device->irqs_tail);
irqs = device->port_irqs[device->irqs_tail];
/* level 1 of IRQs is device->port_irqs where each bit set to 1 says
* there is at least one overflowed counter on the port correcponding
* to the bit */
//printk("irqs %5x\n", irqs);
for (port = 0; port < pstats_nports; ++port) {
if (!(irqs>>port & 0x01))
continue; /*there is no irq from this port*/
/* Level 2 of IRQs is reading additional IRQ flags register for
* each port that has bit in device->port_irqs set to 1. This
* register is a set of IRQ flags per-counter for a given port.
* That means, when i-th bit in cntrs_ov is set, i-th counter
* for this port has to be incremented by 1<<PSTATS_MSB_SHIFT */
spin_lock(&device->port_mutex[port]);
cntrs_ov = &(device->overflows[device->irqs_tail][port]);
//if(port==0)
// printk(KERN_WARNING "cntrs_ov: %08x %08x\n", (uint32_t)((*cntrs_ov)>>32 & 0xffffffff),
// (uint32_t)((*cntrs_ov) & 0x00ffffffffLL));
for (cntr = 0; cntr < PSTATS_CNT_PP; ++cntr) {
/*decode counters overflow flags to increment coutners*/
if ((*cntrs_ov)>>cntr & 0x01) {
ptr = cntr_idx(device->cntrs, port, cntr);
*ptr += 1<<PSTATS_MSB_SHIFT;
}
}
spin_unlock(&device->port_mutex[port]);
}
device->irqs_tail = (device->irqs_tail+1) % PSTATS_IRQBUFSZ;
}
while (device->irqs_tail != device->irqs_head) {
if (0)
printk(KERN_WARNING "tlet head=%d, tail=%d\n",
device->irqs_head, device->irqs_tail);
irqs = device->port_irqs[device->irqs_tail];
/* level 1 of IRQs is device->port_irqs where each bit
* set to 1 says there is at least one overflowed
* counter on the port correcponding to the bit
*/
if (0)
printk(KERN_WARNING "irqs %5x\n", irqs);
for (port = 0; port < pstats_nports; ++port) {
if (!(irqs>>port & 0x01))
continue; /* there is no irq from this port*/
/* Level 2 of IRQs is reading additional IRQ
* flags register for each port that has bit
* in device->port_irqs set to 1. This
* register is a set of IRQ flags per-counter
* for a given port. That means, when i-th
* bit in cntrs_ov is set, i-th counter for
* this port has to be incremented by
* 1<<PSTATS_MSB_SHIFT
*/
spin_lock(&device->port_mutex[port]);
cntrs_ov = &(device->overflows[device->irqs_tail][port]);
//if(port==0)
// printk(KERN_WARNING "cntrs_ov: %08x %08x\n", (uint32_t)((*cntrs_ov)>>32 & 0xffffffff),
// (uint32_t)((*cntrs_ov) & 0x00ffffffffLL));
for (cntr = 0; cntr < PSTATS_CNT_PP; ++cntr) {
/*decode counters overflow flags to increment coutners*/
if ((*cntrs_ov)>>cntr & 0x01) {
ptr = cntr_idx(device->cntrs, port, cntr);
*ptr += 1<<PSTATS_MSB_SHIFT;
}
}
spin_unlock(&device->port_mutex[port]);
}
device->irqs_tail = (device->irqs_tail+1) % PSTATS_IRQBUFSZ;
}
}
DECLARE_TASKLET(proc_ports, pstats_tlet_fn, (unsigned long)&pstats_dev);
......@@ -177,10 +186,10 @@ static irqreturn_t pstats_irq_handler(int irq, void *devid)
pstats_irq_disable(PSTATS_ALL_MSK);
pstats_irq_clear(irqs);
device->port_irqs[device->irqs_head] = irqs;
/* dump all overflow information so that we don't lose any if tasklet is
* delayed */
for(i=0; i<pstats_nports; ++i)
device->overflows[device->irqs_head][i] = pstats_irq_cntrs(i);
/* dump all overflow information so that we don't lose any if
* tasklet is delayed */
for (i = 0; i < pstats_nports; ++i)
device->overflows[device->irqs_head][i] = pstats_irq_cntrs(i);
device->irqs_head = (device->irqs_head + 1) % PSTATS_IRQBUFSZ;
//device->port_irqs[device->irqs_head++ % PSTATS_IRQBUFSZ] = irqs;
......@@ -233,19 +242,18 @@ static int pstats_handler(ctl_table *ctl, int write, void *buffer,
{
int ret;
int port;
unsigned int data;
unsigned int data;
port = (int)ctl->extra1;
if( port < pstats_nports && !write ) {
pstats_rd_cntrs(port);
}
else if( !write ) {
/* read stuff for info file */
data = pstats_readl(pstats_dev, INFO);
pstats_info[PINFO_VER] = PSTATS_INFO_VER_R(data);
pstats_info[PINFO_CNTPW] = PSTATS_INFO_CPW_R(data);
pstats_info[PINFO_CNTPP] = PSTATS_INFO_CPP_R(data);
}
if (port < pstats_nports && !write) {
pstats_rd_cntrs(port);
} else if (!write) {
/* read stuff for info file */
data = pstats_readl(pstats_dev, INFO);
pstats_info[PINFO_VER] = PSTATS_INFO_VER_R(data);
pstats_info[PINFO_CNTPW] = PSTATS_INFO_CPW_R(data);
pstats_info[PINFO_CNTPP] = PSTATS_INFO_CPP_R(data);
}
ret = proc_dointvec(ctl, 0, buffer, lenp, ppos);
......@@ -297,13 +305,13 @@ static int __init pstats_init(void)
pstats_ctl_table[i].proc_handler = pstats_handler;
pstats_ctl_table[i].extra1 = (void *)i;
}
/* the last one with info about pstats */
pstats_ctl_table[i].procname = "info";
pstats_ctl_table[i].data = pstats_info;
pstats_ctl_table[i].maxlen = PINFO_SIZE * sizeof(int);
pstats_ctl_table[i].mode = 0444;
pstats_ctl_table[i].proc_handler = pstats_handler;
pstats_ctl_table[i].extra1 = (void *)i;
/* the last one with info about pstats */
pstats_ctl_table[i].procname = "info";
pstats_ctl_table[i].data = pstats_info;
pstats_ctl_table[i].maxlen = PINFO_SIZE * sizeof(int);
pstats_ctl_table[i].mode = 0444;
pstats_ctl_table[i].proc_handler = pstats_handler;
pstats_ctl_table[i].extra1 = (void *)i;
pstats_header = register_sysctl_table(proc_table);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment