Commit 59430c2f authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6:
  tc: Fix unitialized kernel memory leak
  pkt_sched: Revert tasklet_hrtimer changes.
  net: sk_free() should be allowed right after sk_alloc()
  gianfar: gfar_remove needs to call unregister_netdev()
  ipw2200: firmware DMA loading rework
parents e9ee3a54 16ebb5e0
...@@ -491,6 +491,7 @@ static int gfar_remove(struct of_device *ofdev) ...@@ -491,6 +491,7 @@ static int gfar_remove(struct of_device *ofdev)
dev_set_drvdata(&ofdev->dev, NULL); dev_set_drvdata(&ofdev->dev, NULL);
unregister_netdev(dev);
iounmap(priv->regs); iounmap(priv->regs);
free_netdev(priv->ndev); free_netdev(priv->ndev);
......
...@@ -2874,45 +2874,27 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, ...@@ -2874,45 +2874,27 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
return 0; return 0;
} }
static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, dma_addr_t *src_address,
u32 src_phys, u32 dest_address, u32 length) int nr, u32 dest_address, u32 len)
{ {
u32 bytes_left = length; int ret, i;
u32 src_offset = 0; u32 size;
u32 dest_offset = 0;
int status = 0;
IPW_DEBUG_FW(">> \n"); IPW_DEBUG_FW(">> \n");
IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n", IPW_DEBUG_FW_INFO("nr=%d dest_address=0x%x len=0x%x\n",
src_phys, dest_address, length); nr, dest_address, len);
while (bytes_left > CB_MAX_LENGTH) {
status = ipw_fw_dma_add_command_block(priv, for (i = 0; i < nr; i++) {
src_phys + src_offset, size = min_t(u32, len - i * CB_MAX_LENGTH, CB_MAX_LENGTH);
dest_address + ret = ipw_fw_dma_add_command_block(priv, src_address[i],
dest_offset, dest_address +
CB_MAX_LENGTH, 0, 0); i * CB_MAX_LENGTH, size,
if (status) { 0, 0);
if (ret) {
IPW_DEBUG_FW_INFO(": Failed\n"); IPW_DEBUG_FW_INFO(": Failed\n");
return -1; return -1;
} else } else
IPW_DEBUG_FW_INFO(": Added new cb\n"); IPW_DEBUG_FW_INFO(": Added new cb\n");
src_offset += CB_MAX_LENGTH;
dest_offset += CB_MAX_LENGTH;
bytes_left -= CB_MAX_LENGTH;
}
/* add the buffer tail */
if (bytes_left > 0) {
status =
ipw_fw_dma_add_command_block(priv, src_phys + src_offset,
dest_address + dest_offset,
bytes_left, 0, 0);
if (status) {
IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n");
return -1;
} else
IPW_DEBUG_FW_INFO
(": Adding new cb - the buffer tail\n");
} }
IPW_DEBUG_FW("<< \n"); IPW_DEBUG_FW("<< \n");
...@@ -3160,59 +3142,91 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len) ...@@ -3160,59 +3142,91 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
{ {
int rc = -1; int ret = -1;
int offset = 0; int offset = 0;
struct fw_chunk *chunk; struct fw_chunk *chunk;
dma_addr_t shared_phys; int total_nr = 0;
u8 *shared_virt; int i;
struct pci_pool *pool;
u32 *virts[CB_NUMBER_OF_ELEMENTS_SMALL];
dma_addr_t phys[CB_NUMBER_OF_ELEMENTS_SMALL];
IPW_DEBUG_TRACE("<< : \n"); IPW_DEBUG_TRACE("<< : \n");
shared_virt = pci_alloc_consistent(priv->pci_dev, len, &shared_phys);
if (!shared_virt) pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0);
if (!pool) {
IPW_ERROR("pci_pool_create failed\n");
return -ENOMEM; return -ENOMEM;
}
memmove(shared_virt, data, len);
/* Start the Dma */ /* Start the Dma */
rc = ipw_fw_dma_enable(priv); ret = ipw_fw_dma_enable(priv);
/* the DMA is already ready this would be a bug. */ /* the DMA is already ready this would be a bug. */
BUG_ON(priv->sram_desc.last_cb_index > 0); BUG_ON(priv->sram_desc.last_cb_index > 0);
do { do {
u32 chunk_len;
u8 *start;
int size;
int nr = 0;
chunk = (struct fw_chunk *)(data + offset); chunk = (struct fw_chunk *)(data + offset);
offset += sizeof(struct fw_chunk); offset += sizeof(struct fw_chunk);
chunk_len = le32_to_cpu(chunk->length);
start = data + offset;
nr = (chunk_len + CB_MAX_LENGTH - 1) / CB_MAX_LENGTH;
for (i = 0; i < nr; i++) {
virts[total_nr] = pci_pool_alloc(pool, GFP_KERNEL,
&phys[total_nr]);
if (!virts[total_nr]) {
ret = -ENOMEM;
goto out;
}
size = min_t(u32, chunk_len - i * CB_MAX_LENGTH,
CB_MAX_LENGTH);
memcpy(virts[total_nr], start, size);
start += size;
total_nr++;
/* We don't support fw chunk larger than 64*8K */
BUG_ON(total_nr > CB_NUMBER_OF_ELEMENTS_SMALL);
}
/* build DMA packet and queue up for sending */ /* build DMA packet and queue up for sending */
/* dma to chunk->address, the chunk->length bytes from data + /* dma to chunk->address, the chunk->length bytes from data +
* offeset*/ * offeset*/
/* Dma loading */ /* Dma loading */
rc = ipw_fw_dma_add_buffer(priv, shared_phys + offset, ret = ipw_fw_dma_add_buffer(priv, &phys[total_nr - nr],
le32_to_cpu(chunk->address), nr, le32_to_cpu(chunk->address),
le32_to_cpu(chunk->length)); chunk_len);
if (rc) { if (ret) {
IPW_DEBUG_INFO("dmaAddBuffer Failed\n"); IPW_DEBUG_INFO("dmaAddBuffer Failed\n");
goto out; goto out;
} }
offset += le32_to_cpu(chunk->length); offset += chunk_len;
} while (offset < len); } while (offset < len);
/* Run the DMA and wait for the answer */ /* Run the DMA and wait for the answer */
rc = ipw_fw_dma_kick(priv); ret = ipw_fw_dma_kick(priv);
if (rc) { if (ret) {
IPW_ERROR("dmaKick Failed\n"); IPW_ERROR("dmaKick Failed\n");
goto out; goto out;
} }
rc = ipw_fw_dma_wait(priv); ret = ipw_fw_dma_wait(priv);
if (rc) { if (ret) {
IPW_ERROR("dmaWaitSync Failed\n"); IPW_ERROR("dmaWaitSync Failed\n");
goto out; goto out;
} }
out: out:
pci_free_consistent(priv->pci_dev, len, shared_virt, shared_phys); for (i = 0; i < total_nr; i++)
return rc; pci_pool_free(pool, virts[i], phys[i]);
pci_pool_destroy(pool);
return ret;
} }
/* stop nic */ /* stop nic */
......
...@@ -61,8 +61,8 @@ psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound) ...@@ -61,8 +61,8 @@ psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
} }
struct qdisc_watchdog { struct qdisc_watchdog {
struct tasklet_hrtimer timer; struct hrtimer timer;
struct Qdisc *qdisc; struct Qdisc *qdisc;
}; };
extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc); extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
......
...@@ -1025,6 +1025,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, ...@@ -1025,6 +1025,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
sk->sk_prot = sk->sk_prot_creator = prot; sk->sk_prot = sk->sk_prot_creator = prot;
sock_lock_init(sk); sock_lock_init(sk);
sock_net_set(sk, get_net(net)); sock_net_set(sk, get_net(net));
atomic_set(&sk->sk_wmem_alloc, 1);
} }
return sk; return sk;
...@@ -1872,7 +1873,6 @@ void sock_init_data(struct socket *sock, struct sock *sk) ...@@ -1872,7 +1873,6 @@ void sock_init_data(struct socket *sock, struct sock *sk)
*/ */
smp_wmb(); smp_wmb();
atomic_set(&sk->sk_refcnt, 1); atomic_set(&sk->sk_refcnt, 1);
atomic_set(&sk->sk_wmem_alloc, 1);
atomic_set(&sk->sk_drops, 0); atomic_set(&sk->sk_drops, 0);
} }
EXPORT_SYMBOL(sock_init_data); EXPORT_SYMBOL(sock_init_data);
......
...@@ -458,7 +458,7 @@ EXPORT_SYMBOL(qdisc_warn_nonwc); ...@@ -458,7 +458,7 @@ EXPORT_SYMBOL(qdisc_warn_nonwc);
static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
{ {
struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog, struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog,
timer.timer); timer);
wd->qdisc->flags &= ~TCQ_F_THROTTLED; wd->qdisc->flags &= ~TCQ_F_THROTTLED;
__netif_schedule(qdisc_root(wd->qdisc)); __netif_schedule(qdisc_root(wd->qdisc));
...@@ -468,8 +468,8 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) ...@@ -468,8 +468,8 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc) void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc)
{ {
tasklet_hrtimer_init(&wd->timer, qdisc_watchdog, hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
CLOCK_MONOTONIC, HRTIMER_MODE_ABS); wd->timer.function = qdisc_watchdog;
wd->qdisc = qdisc; wd->qdisc = qdisc;
} }
EXPORT_SYMBOL(qdisc_watchdog_init); EXPORT_SYMBOL(qdisc_watchdog_init);
...@@ -485,13 +485,13 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) ...@@ -485,13 +485,13 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
wd->qdisc->flags |= TCQ_F_THROTTLED; wd->qdisc->flags |= TCQ_F_THROTTLED;
time = ktime_set(0, 0); time = ktime_set(0, 0);
time = ktime_add_ns(time, PSCHED_TICKS2NS(expires)); time = ktime_add_ns(time, PSCHED_TICKS2NS(expires));
tasklet_hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS); hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
} }
EXPORT_SYMBOL(qdisc_watchdog_schedule); EXPORT_SYMBOL(qdisc_watchdog_schedule);
void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
{ {
tasklet_hrtimer_cancel(&wd->timer); hrtimer_cancel(&wd->timer);
wd->qdisc->flags &= ~TCQ_F_THROTTLED; wd->qdisc->flags &= ~TCQ_F_THROTTLED;
} }
EXPORT_SYMBOL(qdisc_watchdog_cancel); EXPORT_SYMBOL(qdisc_watchdog_cancel);
...@@ -1456,6 +1456,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q, ...@@ -1456,6 +1456,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);
tcm = NLMSG_DATA(nlh); tcm = NLMSG_DATA(nlh);
tcm->tcm_family = AF_UNSPEC; tcm->tcm_family = AF_UNSPEC;
tcm->tcm__pad1 = 0;
tcm->tcm__pad2 = 0;
tcm->tcm_ifindex = qdisc_dev(q)->ifindex; tcm->tcm_ifindex = qdisc_dev(q)->ifindex;
tcm->tcm_parent = q->handle; tcm->tcm_parent = q->handle;
tcm->tcm_handle = q->handle; tcm->tcm_handle = q->handle;
......
...@@ -163,7 +163,7 @@ struct cbq_sched_data ...@@ -163,7 +163,7 @@ struct cbq_sched_data
psched_time_t now_rt; /* Cached real time */ psched_time_t now_rt; /* Cached real time */
unsigned pmask; unsigned pmask;
struct tasklet_hrtimer delay_timer; struct hrtimer delay_timer;
struct qdisc_watchdog watchdog; /* Watchdog timer, struct qdisc_watchdog watchdog; /* Watchdog timer,
started when CBQ has started when CBQ has
backlog, but cannot backlog, but cannot
...@@ -503,8 +503,6 @@ static void cbq_ovl_delay(struct cbq_class *cl) ...@@ -503,8 +503,6 @@ static void cbq_ovl_delay(struct cbq_class *cl)
cl->undertime = q->now + delay; cl->undertime = q->now + delay;
if (delay > 0) { if (delay > 0) {
struct hrtimer *ht;
sched += delay + cl->penalty; sched += delay + cl->penalty;
cl->penalized = sched; cl->penalized = sched;
cl->cpriority = TC_CBQ_MAXPRIO; cl->cpriority = TC_CBQ_MAXPRIO;
...@@ -512,12 +510,12 @@ static void cbq_ovl_delay(struct cbq_class *cl) ...@@ -512,12 +510,12 @@ static void cbq_ovl_delay(struct cbq_class *cl)
expires = ktime_set(0, 0); expires = ktime_set(0, 0);
expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched)); expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched));
ht = &q->delay_timer.timer; if (hrtimer_try_to_cancel(&q->delay_timer) &&
if (hrtimer_try_to_cancel(ht) && ktime_to_ns(ktime_sub(
ktime_to_ns(ktime_sub(hrtimer_get_expires(ht), hrtimer_get_expires(&q->delay_timer),
expires)) > 0) expires)) > 0)
hrtimer_set_expires(ht, expires); hrtimer_set_expires(&q->delay_timer, expires);
hrtimer_restart(ht); hrtimer_restart(&q->delay_timer);
cl->delayed = 1; cl->delayed = 1;
cl->xstats.overactions++; cl->xstats.overactions++;
return; return;
...@@ -593,7 +591,7 @@ static psched_tdiff_t cbq_undelay_prio(struct cbq_sched_data *q, int prio, ...@@ -593,7 +591,7 @@ static psched_tdiff_t cbq_undelay_prio(struct cbq_sched_data *q, int prio,
static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
{ {
struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data, struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data,
delay_timer.timer); delay_timer);
struct Qdisc *sch = q->watchdog.qdisc; struct Qdisc *sch = q->watchdog.qdisc;
psched_time_t now; psched_time_t now;
psched_tdiff_t delay = 0; psched_tdiff_t delay = 0;
...@@ -623,7 +621,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) ...@@ -623,7 +621,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
time = ktime_set(0, 0); time = ktime_set(0, 0);
time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay)); time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay));
tasklet_hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS); hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS);
} }
sch->flags &= ~TCQ_F_THROTTLED; sch->flags &= ~TCQ_F_THROTTLED;
...@@ -1216,7 +1214,7 @@ cbq_reset(struct Qdisc* sch) ...@@ -1216,7 +1214,7 @@ cbq_reset(struct Qdisc* sch)
q->tx_class = NULL; q->tx_class = NULL;
q->tx_borrowed = NULL; q->tx_borrowed = NULL;
qdisc_watchdog_cancel(&q->watchdog); qdisc_watchdog_cancel(&q->watchdog);
tasklet_hrtimer_cancel(&q->delay_timer); hrtimer_cancel(&q->delay_timer);
q->toplevel = TC_CBQ_MAXLEVEL; q->toplevel = TC_CBQ_MAXLEVEL;
q->now = psched_get_time(); q->now = psched_get_time();
q->now_rt = q->now; q->now_rt = q->now;
...@@ -1399,8 +1397,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt) ...@@ -1399,8 +1397,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
q->link.minidle = -0x7FFFFFFF; q->link.minidle = -0x7FFFFFFF;
qdisc_watchdog_init(&q->watchdog, sch); qdisc_watchdog_init(&q->watchdog, sch);
tasklet_hrtimer_init(&q->delay_timer, cbq_undelay, hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
q->delay_timer.function = cbq_undelay; q->delay_timer.function = cbq_undelay;
q->toplevel = TC_CBQ_MAXLEVEL; q->toplevel = TC_CBQ_MAXLEVEL;
q->now = psched_get_time(); q->now = psched_get_time();
......
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