Skip to content

Commit cee9f6d

Browse files
committed
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. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 76b63da + d3b58c4 commit cee9f6d

File tree

11 files changed

+42
-29
lines changed

11 files changed

+42
-29
lines changed

arch/arm/boot/dts/dra7-evm.dts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,8 @@
686686

687687
&dcan1 {
688688
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>;
691691
pinctrl-1 = <&dcan1_pins_sleep>;
692+
pinctrl-2 = <&dcan1_pins_default>;
692693
};

arch/arm/boot/dts/dra72-evm.dts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,10 @@
587587

588588
&dcan1 {
589589
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>;
592592
pinctrl-1 = <&dcan1_pins_sleep>;
593+
pinctrl-2 = <&dcan1_pins_default>;
593594
};
594595

595596
&qspi {

drivers/net/can/c_can/c_can.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ static int c_can_start(struct net_device *dev)
592592
{
593593
struct c_can_priv *priv = netdev_priv(dev);
594594
int err;
595+
struct pinctrl *p;
595596

596597
/* basic c_can configuration */
597598
err = c_can_chip_config(dev);
@@ -604,8 +605,13 @@ static int c_can_start(struct net_device *dev)
604605

605606
priv->can.state = CAN_STATE_ERROR_ACTIVE;
606607

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+
609615
return 0;
610616
}
611617

drivers/net/can/dev.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,6 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
440440
struct can_frame *cf = (struct can_frame *)skb->data;
441441
u8 dlc = cf->can_dlc;
442442

443-
if (!(skb->tstamp.tv64))
444-
__net_timestamp(skb);
445-
446443
netif_rx(priv->echo_skb[idx]);
447444
priv->echo_skb[idx] = NULL;
448445

@@ -578,7 +575,6 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
578575
if (unlikely(!skb))
579576
return NULL;
580577

581-
__net_timestamp(skb);
582578
skb->protocol = htons(ETH_P_CAN);
583579
skb->pkt_type = PACKET_BROADCAST;
584580
skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -589,6 +585,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
589585

590586
can_skb_reserve(skb);
591587
can_skb_prv(skb)->ifindex = dev->ifindex;
588+
can_skb_prv(skb)->skbcnt = 0;
592589

593590
*cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
594591
memset(*cf, 0, sizeof(struct can_frame));
@@ -607,7 +604,6 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
607604
if (unlikely(!skb))
608605
return NULL;
609606

610-
__net_timestamp(skb);
611607
skb->protocol = htons(ETH_P_CANFD);
612608
skb->pkt_type = PACKET_BROADCAST;
613609
skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -618,6 +614,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
618614

619615
can_skb_reserve(skb);
620616
can_skb_prv(skb)->ifindex = dev->ifindex;
617+
can_skb_prv(skb)->skbcnt = 0;
621618

622619
*cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame));
623620
memset(*cfd, 0, sizeof(struct canfd_frame));

drivers/net/can/rcar_can.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ static int rcar_can_open(struct net_device *ndev)
508508

509509
err = clk_prepare_enable(priv->clk);
510510
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",
512513
err);
513514
goto out;
514515
}
@@ -526,7 +527,8 @@ static int rcar_can_open(struct net_device *ndev)
526527
napi_enable(&priv->napi);
527528
err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev);
528529
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);
530532
goto out_close;
531533
}
532534
can_led_event(ndev, CAN_LED_EVENT_OPEN);
@@ -758,8 +760,9 @@ static int rcar_can_probe(struct platform_device *pdev)
758760
}
759761

760762
irq = platform_get_irq(pdev, 0);
761-
if (!irq) {
763+
if (irq < 0) {
762764
dev_err(&pdev->dev, "No IRQ resource\n");
765+
err = irq;
763766
goto fail;
764767
}
765768

@@ -782,7 +785,8 @@ static int rcar_can_probe(struct platform_device *pdev)
782785
priv->clk = devm_clk_get(&pdev->dev, "clkp1");
783786
if (IS_ERR(priv->clk)) {
784787
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);
786790
goto fail_clk;
787791
}
788792

@@ -794,7 +798,7 @@ static int rcar_can_probe(struct platform_device *pdev)
794798
priv->can_clk = devm_clk_get(&pdev->dev, clock_names[clock_select]);
795799
if (IS_ERR(priv->can_clk)) {
796800
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);
798802
goto fail_clk;
799803
}
800804

@@ -823,7 +827,7 @@ static int rcar_can_probe(struct platform_device *pdev)
823827

824828
devm_can_led_init(ndev);
825829

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",
827831
priv->regs, ndev->irq);
828832

829833
return 0;

drivers/net/can/slcan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ static void slc_bump(struct slcan *sl)
207207
if (!skb)
208208
return;
209209

210-
__net_timestamp(skb);
211210
skb->dev = sl->dev;
212211
skb->protocol = htons(ETH_P_CAN);
213212
skb->pkt_type = PACKET_BROADCAST;
214213
skb->ip_summed = CHECKSUM_UNNECESSARY;
215214

216215
can_skb_reserve(skb);
217216
can_skb_prv(skb)->ifindex = sl->dev->ifindex;
217+
can_skb_prv(skb)->skbcnt = 0;
218218

219219
memcpy(skb_put(skb, sizeof(struct can_frame)),
220220
&cf, sizeof(struct can_frame));

drivers/net/can/vcan.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
7878
skb->dev = dev;
7979
skb->ip_summed = CHECKSUM_UNNECESSARY;
8080

81-
if (!(skb->tstamp.tv64))
82-
__net_timestamp(skb);
83-
8481
netif_rx_ni(skb);
8582
}
8683

include/linux/can/skb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
/**
2828
* struct can_skb_priv - private additional data inside CAN sk_buffs
2929
* @ifindex: ifindex of the first interface the CAN frame appeared on
30+
* @skbcnt: atomic counter to have an unique id together with skb pointer
3031
* @cf: align to the following CAN frame at skb->data
3132
*/
3233
struct can_skb_priv {
3334
int ifindex;
35+
int skbcnt;
3436
struct can_frame cf[0];
3537
};
3638

net/can/af_can.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ struct timer_list can_stattimer; /* timer for statistics update */
8989
struct s_stats can_stats; /* packet statistics */
9090
struct s_pstats can_pstats; /* receive list statistics */
9191

92+
static atomic_t skbcounter = ATOMIC_INIT(0);
93+
9294
/*
9395
* af_can socket functions
9496
*/
@@ -310,12 +312,8 @@ int can_send(struct sk_buff *skb, int loop)
310312
return err;
311313
}
312314

313-
if (newskb) {
314-
if (!(newskb->tstamp.tv64))
315-
__net_timestamp(newskb);
316-
315+
if (newskb)
317316
netif_rx_ni(newskb);
318-
}
319317

320318
/* update statistics */
321319
can_stats.tx_frames++;
@@ -683,6 +681,10 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev)
683681
can_stats.rx_frames++;
684682
can_stats.rx_frames_delta++;
685683

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+
686688
rcu_read_lock();
687689

688690
/* deliver the packet to sockets listening on all devices */

net/can/bcm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ static void bcm_can_tx(struct bcm_op *op)
261261

262262
can_skb_reserve(skb);
263263
can_skb_prv(skb)->ifindex = dev->ifindex;
264+
can_skb_prv(skb)->skbcnt = 0;
264265

265266
memcpy(skb_put(skb, CFSIZ), cf, CFSIZ);
266267

@@ -1217,6 +1218,7 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
12171218
}
12181219

12191220
can_skb_prv(skb)->ifindex = dev->ifindex;
1221+
can_skb_prv(skb)->skbcnt = 0;
12201222
skb->dev = dev;
12211223
can_skb_set_owner(skb, sk);
12221224
err = can_send(skb, 1); /* send with loopback */

net/can/raw.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ MODULE_ALIAS("can-proto-1");
7575
*/
7676

7777
struct uniqframe {
78-
ktime_t tstamp;
78+
int skbcnt;
7979
const struct sk_buff *skb;
8080
unsigned int join_rx_count;
8181
};
@@ -133,7 +133,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
133133

134134
/* eliminate multiple filter matches for the same skb */
135135
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) {
137137
if (ro->join_filters) {
138138
this_cpu_inc(ro->uniq->join_rx_count);
139139
/* drop frame until all enabled filters matched */
@@ -144,7 +144,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
144144
}
145145
} else {
146146
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;
148148
this_cpu_ptr(ro->uniq)->join_rx_count = 1;
149149
/* drop first frame to check all enabled filters? */
150150
if (ro->join_filters && ro->count > 1)
@@ -749,6 +749,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
749749

750750
can_skb_reserve(skb);
751751
can_skb_prv(skb)->ifindex = dev->ifindex;
752+
can_skb_prv(skb)->skbcnt = 0;
752753

753754
err = memcpy_from_msg(skb_put(skb, size), msg, size);
754755
if (err < 0)

0 commit comments

Comments
 (0)