History

Merge tag 'linux-can-fixes-for-4.2-20150712' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says: ==================== pull-request: can 2015-07-12 this is a pull request of 8 patchs for net/master. Sergei Shtylyov contributes 5 patches for the rcar_can driver, fixing the IRQ check and several info and error messages. There are two patches by J.D. Schroeder and Roger Quadros for the c_can driver and dra7x-evm device tree, which precent a glitch in the DCAN1 pinmux. Oliver Hartkopp provides a better approach to make the CAN skbs unique, the timestamp is replaced by a counter. ====================

David S. Miller committed 11 years ago

Commit cee9f6d2 parents 76b63da d3b58c411 files · +42 −29Browse files

Unified · Split

11 files
  1. arch/arm/boot/dts/dra7-evm.dts +3 −2
  2. arch/arm/boot/dts/dra72-evm.dts +3 −2
  3. drivers/net/can/c_can/c_can.c +8 −2
  4. drivers/net/can/dev.c +2 −5
  5. drivers/net/can/rcar_can.c +10 −6
  6. drivers/net/can/slcan.c +1 −1
  7. drivers/net/can/vcan.c +0 −3
  8. include/linux/can/skb.h +2 −0
  9. net/can/af_can.c +7 −5
  10. net/can/bcm.c +2 −0
  11. net/can/raw.c +4 −3
arch/arm/boot/dts/dra7-evm.dts+3−2
@@ -686,7 +686,8 @@ · 685 unmodified lines
686 686
687&dcan1 {687&dcan1 {
688 status = "ok";688 status = "ok";
689 pinctrl-names = "default", "sleep";689 pinctrl-names = "default", "sleep", "active";
690 pinctrl-0 = <&dcan1_pins_default>;690 pinctrl-0 = <&dcan1_pins_sleep>;
691 pinctrl-1 = <&dcan1_pins_sleep>;691 pinctrl-1 = <&dcan1_pins_sleep>;
692 pinctrl-2 = <&dcan1_pins_default>;
692};693};
arch/arm/boot/dts/dra72-evm.dts+3−2
@@ -587,9 +587,10 @@ · 586 unmodified lines
587 587
588&dcan1 {588&dcan1 {
589 status = "ok";589 status = "ok";
590 pinctrl-names = "default", "sleep";590 pinctrl-names = "default", "sleep", "active";
591 pinctrl-0 = <&dcan1_pins_default>;591 pinctrl-0 = <&dcan1_pins_sleep>;
592 pinctrl-1 = <&dcan1_pins_sleep>;592 pinctrl-1 = <&dcan1_pins_sleep>;
593 pinctrl-2 = <&dcan1_pins_default>;
593};594};
594 595
595&qspi {596&qspi {
drivers/net/can/c_can/c_can.c+8−2
@@ -592,6 +592,7 @@ static int c_can_start(struct net_device *dev) · 591 unmodified lines
592{592{
593 struct c_can_priv *priv = netdev_priv(dev);593 struct c_can_priv *priv = netdev_priv(dev);
594 int err;594 int err;
595 struct pinctrl *p;
595 596
596 /* basic c_can configuration */597 /* basic c_can configuration */
597 err = c_can_chip_config(dev);598 err = c_can_chip_config(dev);
@@ -604,8 +605,13 @@ static int c_can_start(struct net_device *dev) · 6 unmodified lines
604 605
605 priv->can.state = CAN_STATE_ERROR_ACTIVE;606 priv->can.state = CAN_STATE_ERROR_ACTIVE;
606 607
607 /* activate pins */608 /* Attempt to use "active" if available else use "default" */
608 pinctrl_pm_select_default_state(dev->dev.parent);609 p = pinctrl_get_select(priv->device, "active");
610 if (!IS_ERR(p))
611 pinctrl_put(p);
612 else
613 pinctrl_pm_select_default_state(priv->device);
614
609 return 0;615 return 0;
610}616}
611 617
drivers/net/can/dev.c+2−5
@@ -440,9 +440,6 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx) · 439 unmodified lines
440 struct can_frame *cf = (struct can_frame *)skb->data;440 struct can_frame *cf = (struct can_frame *)skb->data;
441 u8 dlc = cf->can_dlc;441 u8 dlc = cf->can_dlc;
442 442
443 if (!(skb->tstamp.tv64))
444 __net_timestamp(skb);
445
446 netif_rx(priv->echo_skb[idx]);443 netif_rx(priv->echo_skb[idx]);
447 priv->echo_skb[idx] = NULL;444 priv->echo_skb[idx] = NULL;
448 445
@@ -578,7 +575,6 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) · 129 unmodified lines
578 if (unlikely(!skb))575 if (unlikely(!skb))
579 return NULL;576 return NULL;
580 577
581 __net_timestamp(skb);
582 skb->protocol = htons(ETH_P_CAN);578 skb->protocol = htons(ETH_P_CAN);
583 skb->pkt_type = PACKET_BROADCAST;579 skb->pkt_type = PACKET_BROADCAST;
584 skb->ip_summed = CHECKSUM_UNNECESSARY;580 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -589,6 +585,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) · 4 unmodified lines
589 585
590 can_skb_reserve(skb);586 can_skb_reserve(skb);
591 can_skb_prv(skb)->ifindex = dev->ifindex;587 can_skb_prv(skb)->ifindex = dev->ifindex;
588 can_skb_prv(skb)->skbcnt = 0;
592 589
593 *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));590 *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
594 memset(*cf, 0, sizeof(struct can_frame));591 memset(*cf, 0, sizeof(struct can_frame));
@@ -607,7 +604,6 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev, · 12 unmodified lines
607 if (unlikely(!skb))604 if (unlikely(!skb))
608 return NULL;605 return NULL;
609 606
610 __net_timestamp(skb);
611 skb->protocol = htons(ETH_P_CANFD);607 skb->protocol = htons(ETH_P_CANFD);
612 skb->pkt_type = PACKET_BROADCAST;608 skb->pkt_type = PACKET_BROADCAST;
613 skb->ip_summed = CHECKSUM_UNNECESSARY;609 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -618,6 +614,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev, · 4 unmodified lines
618 614
619 can_skb_reserve(skb);615 can_skb_reserve(skb);
620 can_skb_prv(skb)->ifindex = dev->ifindex;616 can_skb_prv(skb)->ifindex = dev->ifindex;
617 can_skb_prv(skb)->skbcnt = 0;
621 618
622 *cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame));619 *cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame));
623 memset(*cfd, 0, sizeof(struct canfd_frame));620 memset(*cfd, 0, sizeof(struct canfd_frame));
drivers/net/can/rcar_can.c+10−6
@@ -508,7 +508,8 @@ static int rcar_can_open(struct net_device *ndev) · 507 unmodified lines
508 508
509 err = clk_prepare_enable(priv->clk);509 err = clk_prepare_enable(priv->clk);
510 if (err) {510 if (err) {
511 netdev_err(ndev, "failed to enable periperal clock, error %d\n",511 netdev_err(ndev,
512 "failed to enable peripheral clock, error %d\n",
512 err);513 err);
513 goto out;514 goto out;
514 }515 }
@@ -526,7 +527,8 @@ static int rcar_can_open(struct net_device *ndev) · 11 unmodified lines
526 napi_enable(&priv->napi);527 napi_enable(&priv->napi);
527 err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev);528 err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev);
528 if (err) {529 if (err) {
529 netdev_err(ndev, "error requesting interrupt %x\n", ndev->irq);530 netdev_err(ndev, "request_irq(%d) failed, error %d\n",
531 ndev->irq, err);
530 goto out_close;532 goto out_close;
531 }533 }
532 can_led_event(ndev, CAN_LED_EVENT_OPEN);534 can_led_event(ndev, CAN_LED_EVENT_OPEN);
@@ -758,8 +760,9 @@ static int rcar_can_probe(struct platform_device *pdev) · 225 unmodified lines
758 }760 }
759 761
760 irq = platform_get_irq(pdev, 0);762 irq = platform_get_irq(pdev, 0);
761 if (!irq) {763 if (irq < 0) {
762 dev_err(&pdev->dev, "No IRQ resource\n");764 dev_err(&pdev->dev, "No IRQ resource\n");
765 err = irq;
763 goto fail;766 goto fail;
764 }767 }
765 768
@@ -782,7 +785,8 @@ static int rcar_can_probe(struct platform_device *pdev) · 16 unmodified lines
782 priv->clk = devm_clk_get(&pdev->dev, "clkp1");785 priv->clk = devm_clk_get(&pdev->dev, "clkp1");
783 if (IS_ERR(priv->clk)) {786 if (IS_ERR(priv->clk)) {
784 err = PTR_ERR(priv->clk);787 err = PTR_ERR(priv->clk);
785 dev_err(&pdev->dev, "cannot get peripheral clock: %d\n", err);788 dev_err(&pdev->dev, "cannot get peripheral clock, error %d\n",
789 err);
786 goto fail_clk;790 goto fail_clk;
787 }791 }
788 792
@@ -794,7 +798,7 @@ static int rcar_can_probe(struct platform_device *pdev) · 5 unmodified lines
794 priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]);798 priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]);
795 if (IS_ERR(priv->can_clk)) {799 if (IS_ERR(priv->can_clk)) {
796 err = PTR_ERR(priv->can_clk);800 err = PTR_ERR(priv->can_clk);
797 dev_err(&pdev->dev, "cannot get CAN clock: %d\n", err);801 dev_err(&pdev->dev, "cannot get CAN clock, error %d\n", err);
798 goto fail_clk;802 goto fail_clk;
799 }803 }
800 804
@@ -823,7 +827,7 @@ static int rcar_can_probe(struct platform_device *pdev) · 22 unmodified lines
823 827
824 devm_can_led_init(ndev);828 devm_can_led_init(ndev);
825 829
826 dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n",830 dev_info(&pdev->dev, "device registered (regs @ %p, IRQ%d)\n",
827 priv->regs, ndev->irq);831 priv->regs, ndev->irq);
828 832
829 return 0;833 return 0;
drivers/net/can/slcan.c+1−1
@@ -207,7 +207,6 @@ static void slc_bump(struct slcan *sl) · 206 unmodified lines
207 if (!skb)207 if (!skb)
208 return;208 return;
209 209
210 __net_timestamp(skb);
211 skb->dev = sl->dev;210 skb->dev = sl->dev;
212 skb->protocol = htons(ETH_P_CAN);211 skb->protocol = htons(ETH_P_CAN);
213 skb->pkt_type = PACKET_BROADCAST;212 skb->pkt_type = PACKET_BROADCAST;
@@ -215,6 +214,7 @@ static void slc_bump(struct slcan *sl) · 1 unmodified line
215 214
216 can_skb_reserve(skb);215 can_skb_reserve(skb);
217 can_skb_prv(skb)->ifindex = sl->dev->ifindex;216 can_skb_prv(skb)->ifindex = sl->dev->ifindex;
217 can_skb_prv(skb)->skbcnt = 0;
218 218
219 memcpy(skb_put(skb, sizeof(struct can_frame)),219 memcpy(skb_put(skb, sizeof(struct can_frame)),
220 &cf, sizeof(struct can_frame));220 &cf, sizeof(struct can_frame));
drivers/net/can/vcan.c+0−3
@@ -78,9 +78,6 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev) · 77 unmodified lines
78 skb->dev = dev;78 skb->dev = dev;
79 skb->ip_summed = CHECKSUM_UNNECESSARY;79 skb->ip_summed = CHECKSUM_UNNECESSARY;
80 80
81 if (!(skb->tstamp.tv64))
82 __net_timestamp(skb);
83
84 netif_rx_ni(skb);81 netif_rx_ni(skb);
85}82}
86 83
include/linux/can/skb.h+2−0
@@ -27,10 +27,12 @@ · 26 unmodified lines
27/**27/**
28 * struct can_skb_priv - private additional data inside CAN sk_buffs28 * struct can_skb_priv - private additional data inside CAN sk_buffs
29 * @ifindex: ifindex of the first interface the CAN frame appeared on29 * @ifindex: ifindex of the first interface the CAN frame appeared on
30 * @skbcnt: atomic counter to have an unique id together with skb pointer
30 * @cf: align to the following CAN frame at skb->data31 * @cf: align to the following CAN frame at skb->data
31 */32 */
32struct can_skb_priv {33struct can_skb_priv {
33 int ifindex;34 int ifindex;
35 int skbcnt;
34 struct can_frame cf[0];36 struct can_frame cf[0];
35};37};
36 38
net/can/af_can.c+7−5
@@ -89,6 +89,8 @@ struct timer_list can_stattimer; /* timer for statistics update */ · 88 unmodified lines
89struct s_stats can_stats; /* packet statistics */89struct s_stats can_stats; /* packet statistics */
90struct s_pstats can_pstats; /* receive list statistics */90struct s_pstats can_pstats; /* receive list statistics */
91 91
92static atomic_t skbcounter = ATOMIC_INIT(0);
93
92/*94/*
93 * af_can socket functions95 * af_can socket functions
94 */96 */
@@ -310,12 +312,8 @@ int can_send(struct sk_buff *skb, int loop) · 215 unmodified lines
310 return err;312 return err;
311 }313 }
312 314
313 if (newskb) {315 if (newskb)
314 if (!(newskb->tstamp.tv64))
315 __net_timestamp(newskb);
316
317 netif_rx_ni(newskb);316 netif_rx_ni(newskb);
318 }
319 317
320 /* update statistics */318 /* update statistics */
321 can_stats.tx_frames++;319 can_stats.tx_frames++;
@@ -683,6 +681,10 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev) · 361 unmodified lines
683 can_stats.rx_frames++;681 can_stats.rx_frames++;
684 can_stats.rx_frames_delta++;682 can_stats.rx_frames_delta++;
685 683
684 /* create non-zero unique skb identifier together with *skb */
685 while (!(can_skb_prv(skb)->skbcnt))
686 can_skb_prv(skb)->skbcnt = atomic_inc_return(&skbcounter);
687
686 rcu_read_lock();688 rcu_read_lock();
687 689
688 /* deliver the packet to sockets listening on all devices */690 /* deliver the packet to sockets listening on all devices */
net/can/bcm.c+2−0
@@ -261,6 +261,7 @@ static void bcm_can_tx(struct bcm_op *op) · 260 unmodified lines
261 261
262 can_skb_reserve(skb);262 can_skb_reserve(skb);
263 can_skb_prv(skb)->ifindex = dev->ifindex;263 can_skb_prv(skb)->ifindex = dev->ifindex;
264 can_skb_prv(skb)->skbcnt = 0;
264 265
265 memcpy(skb_put(skb, CFSIZ), cf, CFSIZ);266 memcpy(skb_put(skb, CFSIZ), cf, CFSIZ);
266 267
@@ -1217,6 +1218,7 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk) · 950 unmodified lines
1217 }1218 }
1218 1219
1219 can_skb_prv(skb)->ifindex = dev->ifindex;1220 can_skb_prv(skb)->ifindex = dev->ifindex;
1221 can_skb_prv(skb)->skbcnt = 0;
1220 skb->dev = dev;1222 skb->dev = dev;
1221 can_skb_set_owner(skb, sk);1223 can_skb_set_owner(skb, sk);
1222 err = can_send(skb, 1); /* send with loopback */1224 err = can_send(skb, 1); /* send with loopback */
net/can/raw.c+4−3
@@ -75,7 +75,7 @@ MODULE_ALIAS("can-proto-1"); · 74 unmodified lines
75 */75 */
76 76
77struct uniqframe {77struct uniqframe {
78 ktime_t tstamp;78 int skbcnt;
79 const struct sk_buff *skb;79 const struct sk_buff *skb;
80 unsigned int join_rx_count;80 unsigned int join_rx_count;
81};81};
@@ -133,7 +133,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data) · 51 unmodified lines
133 133
134 /* eliminate multiple filter matches for the same skb */134 /* eliminate multiple filter matches for the same skb */
135 if (this_cpu_ptr(ro->uniq)->skb == oskb &&135 if (this_cpu_ptr(ro->uniq)->skb == oskb &&
136 ktime_equal(this_cpu_ptr(ro->uniq)->tstamp, oskb->tstamp)) {136 this_cpu_ptr(ro->uniq)->skbcnt == can_skb_prv(oskb)->skbcnt) {
137 if (ro->join_filters) {137 if (ro->join_filters) {
138 this_cpu_inc(ro->uniq->join_rx_count);138 this_cpu_inc(ro->uniq->join_rx_count);
139 /* drop frame until all enabled filters matched */139 /* drop frame until all enabled filters matched */
@@ -144,7 +144,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data) · 4 unmodified lines
144 }144 }
145 } else {145 } else {
146 this_cpu_ptr(ro->uniq)->skb = oskb;146 this_cpu_ptr(ro->uniq)->skb = oskb;
147 this_cpu_ptr(ro->uniq)->tstamp = oskb->tstamp;147 this_cpu_ptr(ro->uniq)->skbcnt = can_skb_prv(oskb)->skbcnt;
148 this_cpu_ptr(ro->uniq)->join_rx_count = 1;148 this_cpu_ptr(ro->uniq)->join_rx_count = 1;
149 /* drop first frame to check all enabled filters? */149 /* drop first frame to check all enabled filters? */
150 if (ro->join_filters && ro->count > 1)150 if (ro->join_filters && ro->count > 1)
@@ -749,6 +749,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) · 598 unmodified lines
749 749
750 can_skb_reserve(skb);750 can_skb_reserve(skb);
751 can_skb_prv(skb)->ifindex = dev->ifindex;751 can_skb_prv(skb)->ifindex = dev->ifindex;
752 can_skb_prv(skb)->skbcnt = 0;
752 753
753 err = memcpy_from_msg(skb_put(skb, size), msg, size);754 err = memcpy_from_msg(skb_put(skb, size), msg, size);
754 if (err < 0)755 if (err < 0)