aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-05 17:52:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-05 17:52:41 -0400
commit59430c2f437767094298f30dd02ca038da0df755 (patch)
tree3c79740e3580e403df02daafba26fa6e67552c16
parente9ee3a54a164c249a0a576c403eba367a6d97be5 (diff)
parent16ebb5e0b36ceadc8186f71d68b0c4fa4b6e781b (diff)
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
-rw-r--r--drivers/net/gianfar.c1
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c120
-rw-r--r--include/net/pkt_sched.h4
-rw-r--r--net/core/sock.c2
-rw-r--r--net/sched/sch_api.c12
-rw-r--r--net/sched/sch_cbq.c25
6 files changed, 89 insertions, 75 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index e212f2c5448b..24f7ca5e17de 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -491,6 +491,7 @@ static int gfar_remove(struct of_device *ofdev)
491 491
492 dev_set_drvdata(&ofdev->dev, NULL); 492 dev_set_drvdata(&ofdev->dev, NULL);
493 493
494 unregister_netdev(dev);
494 iounmap(priv->regs); 495 iounmap(priv->regs);
495 free_netdev(priv->ndev); 496 free_netdev(priv->ndev);
496 497
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 6dcac73b4d29..f593fbbb4e52 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -2874,45 +2874,27 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv,
2874 return 0; 2874 return 0;
2875} 2875}
2876 2876
2877static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, 2877static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, dma_addr_t *src_address,
2878 u32 src_phys, u32 dest_address, u32 length) 2878 int nr, u32 dest_address, u32 len)
2879{ 2879{
2880 u32 bytes_left = length; 2880 int ret, i;
2881 u32 src_offset = 0; 2881 u32 size;
2882 u32 dest_offset = 0; 2882
2883 int status = 0;
2884 IPW_DEBUG_FW(">> \n"); 2883 IPW_DEBUG_FW(">> \n");
2885 IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n", 2884 IPW_DEBUG_FW_INFO("nr=%d dest_address=0x%x len=0x%x\n",
2886 src_phys, dest_address, length); 2885 nr, dest_address, len);
2887 while (bytes_left > CB_MAX_LENGTH) { 2886
2888 status = ipw_fw_dma_add_command_block(priv, 2887 for (i = 0; i < nr; i++) {
2889 src_phys + src_offset, 2888 size = min_t(u32, len - i * CB_MAX_LENGTH, CB_MAX_LENGTH);
2890 dest_address + 2889 ret = ipw_fw_dma_add_command_block(priv, src_address[i],
2891 dest_offset, 2890 dest_address +
2892 CB_MAX_LENGTH, 0, 0); 2891 i * CB_MAX_LENGTH, size,
2893 if (status) { 2892 0, 0);
2893 if (ret) {
2894 IPW_DEBUG_FW_INFO(": Failed\n"); 2894 IPW_DEBUG_FW_INFO(": Failed\n");
2895 return -1; 2895 return -1;
2896 } else 2896 } else
2897 IPW_DEBUG_FW_INFO(": Added new cb\n"); 2897 IPW_DEBUG_FW_INFO(": Added new cb\n");
2898
2899 src_offset += CB_MAX_LENGTH;
2900 dest_offset += CB_MAX_LENGTH;
2901 bytes_left -= CB_MAX_LENGTH;
2902 }
2903
2904 /* add the buffer tail */
2905 if (bytes_left > 0) {
2906 status =
2907 ipw_fw_dma_add_command_block(priv, src_phys + src_offset,
2908 dest_address + dest_offset,
2909 bytes_left, 0, 0);
2910 if (status) {
2911 IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n");
2912 return -1;
2913 } else
2914 IPW_DEBUG_FW_INFO
2915 (": Adding new cb - the buffer tail\n");
2916 } 2898 }
2917 2899
2918 IPW_DEBUG_FW("<< \n"); 2900 IPW_DEBUG_FW("<< \n");
@@ -3160,59 +3142,91 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
3160 3142
3161static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) 3143static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
3162{ 3144{
3163 int rc = -1; 3145 int ret = -1;
3164 int offset = 0; 3146 int offset = 0;
3165 struct fw_chunk *chunk; 3147 struct fw_chunk *chunk;
3166 dma_addr_t shared_phys; 3148 int total_nr = 0;
3167 u8 *shared_virt; 3149 int i;
3150 struct pci_pool *pool;
3151 u32 *virts[CB_NUMBER_OF_ELEMENTS_SMALL];
3152 dma_addr_t phys[CB_NUMBER_OF_ELEMENTS_SMALL];
3168 3153
3169 IPW_DEBUG_TRACE("<< : \n"); 3154 IPW_DEBUG_TRACE("<< : \n");
3170 shared_virt = pci_alloc_consistent(priv->pci_dev, len, &shared_phys);
3171 3155
3172 if (!shared_virt) 3156 pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0);
3157 if (!pool) {
3158 IPW_ERROR("pci_pool_create failed\n");
3173 return -ENOMEM; 3159 return -ENOMEM;
3174 3160 }
3175 memmove(shared_virt, data, len);
3176 3161
3177 /* Start the Dma */ 3162 /* Start the Dma */
3178 rc = ipw_fw_dma_enable(priv); 3163 ret = ipw_fw_dma_enable(priv);
3179 3164
3180 /* the DMA is already ready this would be a bug. */ 3165 /* the DMA is already ready this would be a bug. */
3181 BUG_ON(priv->sram_desc.last_cb_index > 0); 3166 BUG_ON(priv->sram_desc.last_cb_index > 0);
3182 3167
3183 do { 3168 do {
3169 u32 chunk_len;
3170 u8 *start;
3171 int size;
3172 int nr = 0;
3173
3184 chunk = (struct fw_chunk *)(data + offset); 3174 chunk = (struct fw_chunk *)(data + offset);
3185 offset += sizeof(struct fw_chunk); 3175 offset += sizeof(struct fw_chunk);
3176 chunk_len = le32_to_cpu(chunk->length);
3177 start = data + offset;
3178
3179 nr = (chunk_len + CB_MAX_LENGTH - 1) / CB_MAX_LENGTH;
3180 for (i = 0; i < nr; i++) {
3181 virts[total_nr] = pci_pool_alloc(pool, GFP_KERNEL,
3182 &phys[total_nr]);
3183 if (!virts[total_nr]) {
3184 ret = -ENOMEM;
3185 goto out;
3186 }
3187 size = min_t(u32, chunk_len - i * CB_MAX_LENGTH,
3188 CB_MAX_LENGTH);
3189 memcpy(virts[total_nr], start, size);
3190 start += size;
3191 total_nr++;
3192 /* We don't support fw chunk larger than 64*8K */
3193 BUG_ON(total_nr > CB_NUMBER_OF_ELEMENTS_SMALL);
3194 }
3195
3186 /* build DMA packet and queue up for sending */ 3196 /* build DMA packet and queue up for sending */
3187 /* dma to chunk->address, the chunk->length bytes from data + 3197 /* dma to chunk->address, the chunk->length bytes from data +
3188 * offeset*/ 3198 * offeset*/
3189 /* Dma loading */ 3199 /* Dma loading */
3190 rc = ipw_fw_dma_add_buffer(priv, shared_phys + offset, 3200 ret = ipw_fw_dma_add_buffer(priv, &phys[total_nr - nr],
3191 le32_to_cpu(chunk->address), 3201 nr, le32_to_cpu(chunk->address),
3192 le32_to_cpu(chunk->length)); 3202 chunk_len);
3193 if (rc) { 3203 if (ret) {
3194 IPW_DEBUG_INFO("dmaAddBuffer Failed\n"); 3204 IPW_DEBUG_INFO("dmaAddBuffer Failed\n");
3195 goto out; 3205 goto out;
3196 } 3206 }
3197 3207
3198 offset += le32_to_cpu(chunk->length); 3208 offset += chunk_len;
3199 } while (offset < len); 3209 } while (offset < len);
3200 3210
3201 /* Run the DMA and wait for the answer */ 3211 /* Run the DMA and wait for the answer */
3202 rc = ipw_fw_dma_kick(priv); 3212 ret = ipw_fw_dma_kick(priv);
3203 if (rc) { 3213 if (ret) {
3204 IPW_ERROR("dmaKick Failed\n"); 3214 IPW_ERROR("dmaKick Failed\n");
3205 goto out; 3215 goto out;
3206 } 3216 }
3207 3217
3208 rc = ipw_fw_dma_wait(priv); 3218 ret = ipw_fw_dma_wait(priv);
3209 if (rc) { 3219 if (ret) {
3210 IPW_ERROR("dmaWaitSync Failed\n"); 3220 IPW_ERROR("dmaWaitSync Failed\n");
3211 goto out; 3221 goto out;
3212 } 3222 }
3213 out: 3223 out:
3214 pci_free_consistent(priv->pci_dev, len, shared_virt, shared_phys); 3224 for (i = 0; i < total_nr; i++)
3215 return rc; 3225 pci_pool_free(pool, virts[i], phys[i]);
3226
3227 pci_pool_destroy(pool);
3228
3229 return ret;
3216} 3230}
3217 3231
3218/* stop nic */ 3232/* stop nic */
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 7eafb8d54470..82a3191375f5 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -61,8 +61,8 @@ psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
61} 61}
62 62
63struct qdisc_watchdog { 63struct qdisc_watchdog {
64 struct tasklet_hrtimer timer; 64 struct hrtimer timer;
65 struct Qdisc *qdisc; 65 struct Qdisc *qdisc;
66}; 66};
67 67
68extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc); 68extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
diff --git a/net/core/sock.c b/net/core/sock.c
index bbb25be7ddfe..76334228ed1c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1025,6 +1025,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
1025 sk->sk_prot = sk->sk_prot_creator = prot; 1025 sk->sk_prot = sk->sk_prot_creator = prot;
1026 sock_lock_init(sk); 1026 sock_lock_init(sk);
1027 sock_net_set(sk, get_net(net)); 1027 sock_net_set(sk, get_net(net));
1028 atomic_set(&sk->sk_wmem_alloc, 1);
1028 } 1029 }
1029 1030
1030 return sk; 1031 return sk;
@@ -1872,7 +1873,6 @@ void sock_init_data(struct socket *sock, struct sock *sk)
1872 */ 1873 */
1873 smp_wmb(); 1874 smp_wmb();
1874 atomic_set(&sk->sk_refcnt, 1); 1875 atomic_set(&sk->sk_refcnt, 1);
1875 atomic_set(&sk->sk_wmem_alloc, 1);
1876 atomic_set(&sk->sk_drops, 0); 1876 atomic_set(&sk->sk_drops, 0);
1877} 1877}
1878EXPORT_SYMBOL(sock_init_data); 1878EXPORT_SYMBOL(sock_init_data);
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 92e6f3a52c13..fdb694e9f759 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -458,7 +458,7 @@ EXPORT_SYMBOL(qdisc_warn_nonwc);
458static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) 458static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
459{ 459{
460 struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog, 460 struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog,
461 timer.timer); 461 timer);
462 462
463 wd->qdisc->flags &= ~TCQ_F_THROTTLED; 463 wd->qdisc->flags &= ~TCQ_F_THROTTLED;
464 __netif_schedule(qdisc_root(wd->qdisc)); 464 __netif_schedule(qdisc_root(wd->qdisc));
@@ -468,8 +468,8 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
468 468
469void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc) 469void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc)
470{ 470{
471 tasklet_hrtimer_init(&wd->timer, qdisc_watchdog, 471 hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
472 CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 472 wd->timer.function = qdisc_watchdog;
473 wd->qdisc = qdisc; 473 wd->qdisc = qdisc;
474} 474}
475EXPORT_SYMBOL(qdisc_watchdog_init); 475EXPORT_SYMBOL(qdisc_watchdog_init);
@@ -485,13 +485,13 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
485 wd->qdisc->flags |= TCQ_F_THROTTLED; 485 wd->qdisc->flags |= TCQ_F_THROTTLED;
486 time = ktime_set(0, 0); 486 time = ktime_set(0, 0);
487 time = ktime_add_ns(time, PSCHED_TICKS2NS(expires)); 487 time = ktime_add_ns(time, PSCHED_TICKS2NS(expires));
488 tasklet_hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS); 488 hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
489} 489}
490EXPORT_SYMBOL(qdisc_watchdog_schedule); 490EXPORT_SYMBOL(qdisc_watchdog_schedule);
491 491
492void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) 492void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
493{ 493{
494 tasklet_hrtimer_cancel(&wd->timer); 494 hrtimer_cancel(&wd->timer);
495 wd->qdisc->flags &= ~TCQ_F_THROTTLED; 495 wd->qdisc->flags &= ~TCQ_F_THROTTLED;
496} 496}
497EXPORT_SYMBOL(qdisc_watchdog_cancel); 497EXPORT_SYMBOL(qdisc_watchdog_cancel);
@@ -1456,6 +1456,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
1456 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); 1456 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags);
1457 tcm = NLMSG_DATA(nlh); 1457 tcm = NLMSG_DATA(nlh);
1458 tcm->tcm_family = AF_UNSPEC; 1458 tcm->tcm_family = AF_UNSPEC;
1459 tcm->tcm__pad1 = 0;
1460 tcm->tcm__pad2 = 0;
1459 tcm->tcm_ifindex = qdisc_dev(q)->ifindex; 1461 tcm->tcm_ifindex = qdisc_dev(q)->ifindex;
1460 tcm->tcm_parent = q->handle; 1462 tcm->tcm_parent = q->handle;
1461 tcm->tcm_handle = q->handle; 1463 tcm->tcm_handle = q->handle;
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 149b0405c5ec..d5798e17a832 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -163,7 +163,7 @@ struct cbq_sched_data
163 psched_time_t now_rt; /* Cached real time */ 163 psched_time_t now_rt; /* Cached real time */
164 unsigned pmask; 164 unsigned pmask;
165 165
166 struct tasklet_hrtimer delay_timer; 166 struct hrtimer delay_timer;
167 struct qdisc_watchdog watchdog; /* Watchdog timer, 167 struct qdisc_watchdog watchdog; /* Watchdog timer,
168 started when CBQ has 168 started when CBQ has
169 backlog, but cannot 169 backlog, but cannot
@@ -503,8 +503,6 @@ static void cbq_ovl_delay(struct cbq_class *cl)
503 cl->undertime = q->now + delay; 503 cl->undertime = q->now + delay;
504 504
505 if (delay > 0) { 505 if (delay > 0) {
506 struct hrtimer *ht;
507
508 sched += delay + cl->penalty; 506 sched += delay + cl->penalty;
509 cl->penalized = sched; 507 cl->penalized = sched;
510 cl->cpriority = TC_CBQ_MAXPRIO; 508 cl->cpriority = TC_CBQ_MAXPRIO;
@@ -512,12 +510,12 @@ static void cbq_ovl_delay(struct cbq_class *cl)
512 510
513 expires = ktime_set(0, 0); 511 expires = ktime_set(0, 0);
514 expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched)); 512 expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched));
515 ht = &q->delay_timer.timer; 513 if (hrtimer_try_to_cancel(&q->delay_timer) &&
516 if (hrtimer_try_to_cancel(ht) && 514 ktime_to_ns(ktime_sub(
517 ktime_to_ns(ktime_sub(hrtimer_get_expires(ht), 515 hrtimer_get_expires(&q->delay_timer),
518 expires)) > 0) 516 expires)) > 0)
519 hrtimer_set_expires(ht, expires); 517 hrtimer_set_expires(&q->delay_timer, expires);
520 hrtimer_restart(ht); 518 hrtimer_restart(&q->delay_timer);
521 cl->delayed = 1; 519 cl->delayed = 1;
522 cl->xstats.overactions++; 520 cl->xstats.overactions++;
523 return; 521 return;
@@ -593,7 +591,7 @@ static psched_tdiff_t cbq_undelay_prio(struct cbq_sched_data *q, int prio,
593static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) 591static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
594{ 592{
595 struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data, 593 struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data,
596 delay_timer.timer); 594 delay_timer);
597 struct Qdisc *sch = q->watchdog.qdisc; 595 struct Qdisc *sch = q->watchdog.qdisc;
598 psched_time_t now; 596 psched_time_t now;
599 psched_tdiff_t delay = 0; 597 psched_tdiff_t delay = 0;
@@ -623,7 +621,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
623 621
624 time = ktime_set(0, 0); 622 time = ktime_set(0, 0);
625 time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay)); 623 time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay));
626 tasklet_hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS); 624 hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS);
627 } 625 }
628 626
629 sch->flags &= ~TCQ_F_THROTTLED; 627 sch->flags &= ~TCQ_F_THROTTLED;
@@ -1216,7 +1214,7 @@ cbq_reset(struct Qdisc* sch)
1216 q->tx_class = NULL; 1214 q->tx_class = NULL;
1217 q->tx_borrowed = NULL; 1215 q->tx_borrowed = NULL;
1218 qdisc_watchdog_cancel(&q->watchdog); 1216 qdisc_watchdog_cancel(&q->watchdog);
1219 tasklet_hrtimer_cancel(&q->delay_timer); 1217 hrtimer_cancel(&q->delay_timer);
1220 q->toplevel = TC_CBQ_MAXLEVEL; 1218 q->toplevel = TC_CBQ_MAXLEVEL;
1221 q->now = psched_get_time(); 1219 q->now = psched_get_time();
1222 q->now_rt = q->now; 1220 q->now_rt = q->now;
@@ -1399,8 +1397,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
1399 q->link.minidle = -0x7FFFFFFF; 1397 q->link.minidle = -0x7FFFFFFF;
1400 1398
1401 qdisc_watchdog_init(&q->watchdog, sch); 1399 qdisc_watchdog_init(&q->watchdog, sch);
1402 tasklet_hrtimer_init(&q->delay_timer, cbq_undelay, 1400 hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
1403 CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
1404 q->delay_timer.function = cbq_undelay; 1401 q->delay_timer.function = cbq_undelay;
1405 q->toplevel = TC_CBQ_MAXLEVEL; 1402 q->toplevel = TC_CBQ_MAXLEVEL;
1406 q->now = psched_get_time(); 1403 q->now = psched_get_time();