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. ====================
Unified · Split
| @@ -686,7 +686,8 @@ · 685 unmodified lines | ||
| 686 | 686 | |
| 687 | 687 | &dcan1 { |
| 688 | 688 | status = "ok"; |
| 689 | − pinctrl-names = "default", "sleep"; | |
| 690 | − pinctrl-0 = <&dcan1_pins_default>; | |
| 689 | + pinctrl-names = "default", "sleep", "active"; | |
| 690 | + pinctrl-0 = <&dcan1_pins_sleep>; | |
| 691 | 691 | pinctrl-1 = <&dcan1_pins_sleep>; |
| 692 | + pinctrl-2 = <&dcan1_pins_default>; | |
| 692 | 693 | }; |
| @@ -587,9 +587,10 @@ · 586 unmodified lines | ||
| 587 | 587 | |
| 588 | 588 | &dcan1 { |
| 589 | 589 | status = "ok"; |
| 590 | − pinctrl-names = "default", "sleep"; | |
| 591 | − pinctrl-0 = <&dcan1_pins_default>; | |
| 590 | + pinctrl-names = "default", "sleep", "active"; | |
| 591 | + pinctrl-0 = <&dcan1_pins_sleep>; | |
| 592 | 592 | pinctrl-1 = <&dcan1_pins_sleep>; |
| 593 | + pinctrl-2 = <&dcan1_pins_default>; | |
| 593 | 594 | }; |
| 594 | 595 | |
| 595 | 596 | &qspi { |
| @@ -592,6 +592,7 @@ static int c_can_start(struct net_device *dev) · 591 unmodified lines | ||
| 592 | 592 | { |
| 593 | 593 | struct c_can_priv *priv = netdev_priv(dev); |
| 594 | 594 | int err; |
| 595 | + struct pinctrl *p; | |
| 595 | 596 | |
| 596 | 597 | /* basic c_can configuration */ |
| 597 | 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 | 606 | priv->can.state = CAN_STATE_ERROR_ACTIVE; |
| 606 | 607 | |
| 607 | − /* activate pins */ | |
| 608 | − pinctrl_pm_select_default_state(dev->dev.parent); | |
| 608 | + /* Attempt to use "active" if available else use "default" */ | |
| 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 | 615 | return 0; |
| 610 | 616 | } |
| 611 | 617 | |
| @@ -440,9 +440,6 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx) · 439 unmodified lines | ||
| 440 | 440 | struct can_frame *cf = (struct can_frame *)skb->data; |
| 441 | 441 | u8 dlc = cf->can_dlc; |
| 442 | 442 | |
| 443 | − if (!(skb->tstamp.tv64)) | |
| 444 | − __net_timestamp(skb); | |
| 445 | − | |
| 446 | 443 | netif_rx(priv->echo_skb[idx]); |
| 447 | 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 | 575 | if (unlikely(!skb)) |
| 579 | 576 | return NULL; |
| 580 | 577 | |
| 581 | − __net_timestamp(skb); | |
| 582 | 578 | skb->protocol = htons(ETH_P_CAN); |
| 583 | 579 | skb->pkt_type = PACKET_BROADCAST; |
| 584 | 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 | 586 | can_skb_reserve(skb); |
| 591 | 587 | can_skb_prv(skb)->ifindex = dev->ifindex; |
| 588 | + can_skb_prv(skb)->skbcnt = 0; | |
| 592 | 589 | |
| 593 | 590 | *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); |
| 594 | 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 | 604 | if (unlikely(!skb)) |
| 608 | 605 | return NULL; |
| 609 | 606 | |
| 610 | − __net_timestamp(skb); | |
| 611 | 607 | skb->protocol = htons(ETH_P_CANFD); |
| 612 | 608 | skb->pkt_type = PACKET_BROADCAST; |
| 613 | 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 | 615 | can_skb_reserve(skb); |
| 620 | 616 | can_skb_prv(skb)->ifindex = dev->ifindex; |
| 617 | + can_skb_prv(skb)->skbcnt = 0; | |
| 621 | 618 | |
| 622 | 619 | *cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame)); |
| 623 | 620 | memset(*cfd, 0, sizeof(struct canfd_frame)); |
| @@ -508,7 +508,8 @@ static int rcar_can_open(struct net_device *ndev) · 507 unmodified lines | ||
| 508 | 508 | |
| 509 | 509 | err = clk_prepare_enable(priv->clk); |
| 510 | 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 | 513 | err); |
| 513 | 514 | goto out; |
| 514 | 515 | } |
| @@ -526,7 +527,8 @@ static int rcar_can_open(struct net_device *ndev) · 11 unmodified lines | ||
| 526 | 527 | napi_enable(&priv->napi); |
| 527 | 528 | err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev); |
| 528 | 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 | 532 | goto out_close; |
| 531 | 533 | } |
| 532 | 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 | 762 | irq = platform_get_irq(pdev, 0); |
| 761 | − if (!irq) { | |
| 763 | + if (irq < 0) { | |
| 762 | 764 | dev_err(&pdev->dev, "No IRQ resource\n"); |
| 765 | + err = irq; | |
| 763 | 766 | goto fail; |
| 764 | 767 | } |
| 765 | 768 | |
| @@ -782,7 +785,8 @@ static int rcar_can_probe(struct platform_device *pdev) · 16 unmodified lines | ||
| 782 | 785 | priv->clk = devm_clk_get(&pdev->dev, "clkp1"); |
| 783 | 786 | if (IS_ERR(priv->clk)) { |
| 784 | 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 | 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 | 798 | priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]); |
| 795 | 799 | if (IS_ERR(priv->can_clk)) { |
| 796 | 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 | 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 | 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 | 831 | priv->regs, ndev->irq); |
| 828 | 832 | |
| 829 | 833 | return 0; |
| @@ -207,7 +207,6 @@ static void slc_bump(struct slcan *sl) · 206 unmodified lines | ||
| 207 | 207 | if (!skb) |
| 208 | 208 | return; |
| 209 | 209 | |
| 210 | − __net_timestamp(skb); | |
| 211 | 210 | skb->dev = sl->dev; |
| 212 | 211 | skb->protocol = htons(ETH_P_CAN); |
| 213 | 212 | skb->pkt_type = PACKET_BROADCAST; |
| @@ -215,6 +214,7 @@ static void slc_bump(struct slcan *sl) · 1 unmodified line | ||
| 215 | 214 | |
| 216 | 215 | can_skb_reserve(skb); |
| 217 | 216 | can_skb_prv(skb)->ifindex = sl->dev->ifindex; |
| 217 | + can_skb_prv(skb)->skbcnt = 0; | |
| 218 | 218 | |
| 219 | 219 | memcpy(skb_put(skb, sizeof(struct can_frame)), |
| 220 | 220 | &cf, sizeof(struct can_frame)); |
| @@ -78,9 +78,6 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev) · 77 unmodified lines | ||
| 78 | 78 | skb->dev = dev; |
| 79 | 79 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 80 | 80 | |
| 81 | − if (!(skb->tstamp.tv64)) | |
| 82 | − __net_timestamp(skb); | |
| 83 | − | |
| 84 | 81 | netif_rx_ni(skb); |
| 85 | 82 | } |
| 86 | 83 | |
| @@ -27,10 +27,12 @@ · 26 unmodified lines | ||
| 27 | 27 | /** |
| 28 | 28 | * struct can_skb_priv - private additional data inside CAN sk_buffs |
| 29 | 29 | * @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 | 31 | * @cf: align to the following CAN frame at skb->data |
| 31 | 32 | */ |
| 32 | 33 | struct can_skb_priv { |
| 33 | 34 | int ifindex; |
| 35 | + int skbcnt; | |
| 34 | 36 | struct can_frame cf[0]; |
| 35 | 37 | }; |
| 36 | 38 | |
| @@ -89,6 +89,8 @@ struct timer_list can_stattimer; /* timer for statistics update */ · 88 unmodified lines | ||
| 89 | 89 | struct s_stats can_stats; /* packet statistics */ |
| 90 | 90 | struct s_pstats can_pstats; /* receive list statistics */ |
| 91 | 91 | |
| 92 | +static atomic_t skbcounter = ATOMIC_INIT(0); | |
| 93 | + | |
| 92 | 94 | /* |
| 93 | 95 | * af_can socket functions |
| 94 | 96 | */ |
| @@ -310,12 +312,8 @@ int can_send(struct sk_buff *skb, int loop) · 215 unmodified lines | ||
| 310 | 312 | return err; |
| 311 | 313 | } |
| 312 | 314 | |
| 313 | − if (newskb) { | |
| 314 | − if (!(newskb->tstamp.tv64)) | |
| 315 | − __net_timestamp(newskb); | |
| 316 | − | |
| 315 | + if (newskb) | |
| 317 | 316 | netif_rx_ni(newskb); |
| 318 | − } | |
| 319 | 317 | |
| 320 | 318 | /* update statistics */ |
| 321 | 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 | 681 | can_stats.rx_frames++; |
| 684 | 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 | 688 | rcu_read_lock(); |
| 687 | 689 | |
| 688 | 690 | /* deliver the packet to sockets listening on all devices */ |
| @@ -261,6 +261,7 @@ static void bcm_can_tx(struct bcm_op *op) · 260 unmodified lines | ||
| 261 | 261 | |
| 262 | 262 | can_skb_reserve(skb); |
| 263 | 263 | can_skb_prv(skb)->ifindex = dev->ifindex; |
| 264 | + can_skb_prv(skb)->skbcnt = 0; | |
| 264 | 265 | |
| 265 | 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 | 1220 | can_skb_prv(skb)->ifindex = dev->ifindex; |
| 1221 | + can_skb_prv(skb)->skbcnt = 0; | |
| 1220 | 1222 | skb->dev = dev; |
| 1221 | 1223 | can_skb_set_owner(skb, sk); |
| 1222 | 1224 | err = can_send(skb, 1); /* send with loopback */ |
| @@ -75,7 +75,7 @@ MODULE_ALIAS("can-proto-1"); · 74 unmodified lines | ||
| 75 | 75 | */ |
| 76 | 76 | |
| 77 | 77 | struct uniqframe { |
| 78 | − ktime_t tstamp; | |
| 78 | + int skbcnt; | |
| 79 | 79 | const struct sk_buff *skb; |
| 80 | 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 | 134 | /* eliminate multiple filter matches for the same skb */ |
| 135 | 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 | 137 | if (ro->join_filters) { |
| 138 | 138 | this_cpu_inc(ro->uniq->join_rx_count); |
| 139 | 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 | 145 | } else { |
| 146 | 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 | 148 | this_cpu_ptr(ro->uniq)->join_rx_count = 1; |
| 149 | 149 | /* drop first frame to check all enabled filters? */ |
| 150 | 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 | 750 | can_skb_reserve(skb); |
| 751 | 751 | can_skb_prv(skb)->ifindex = dev->ifindex; |
| 752 | + can_skb_prv(skb)->skbcnt = 0; | |
| 752 | 753 | |
| 753 | 754 | err = memcpy_from_msg(skb_put(skb, size), msg, size); |
| 754 | 755 | if (err < 0) |