Use the TX FIFO size read from CAN controller register, instead of using hard coded value.
Unified · Split
| @@ -658,8 +658,7 @@ static netdev_tx_t kvaser_pciefd_start_xmit(struct sk_buff *skb, · 657 unmodified lines | ||
| 658 | 658 | /* No room for a new message, stop the queue until at least one |
| 659 | 659 | * successful transmit |
| 660 | 660 | */ |
| 661 | − if (count >= KVASER_PCIEFD_CAN_TX_MAX_COUNT || | |
| 662 | − can->can.echo_skb[can->echo_idx]) | |
| 661 | + if (count >= can->can.echo_skb_max || can->can.echo_skb[can->echo_idx]) | |
| 663 | 662 | netif_stop_queue(netdev); |
| 664 | 663 | spin_unlock_irqrestore(&can->echo_lock, irq_flags); |
| 665 | 664 | |
| @@ -802,16 +801,9 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie) · 136 unmodified lines | ||
| 802 | 801 | tx_nr_packets_max = |
| 803 | 802 | FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK, |
| 804 | 803 | ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); |
| 805 | − if (tx_nr_packets_max < KVASER_PCIEFD_CAN_TX_MAX_COUNT) { | |
| 806 | − dev_err(&pcie->pci->dev, | |
| 807 | − "Max Tx count is smaller than expected\n"); | |
| 808 | − | |
| 809 | − free_candev(netdev); | |
| 810 | − return -ENODEV; | |
| 811 | − } | |
| 812 | 804 | |
| 813 | 805 | can->can.clock.freq = pcie->freq; |
| 814 | − can->can.echo_skb_max = KVASER_PCIEFD_CAN_TX_MAX_COUNT; | |
| 806 | + can->can.echo_skb_max = min(KVASER_PCIEFD_CAN_TX_MAX_COUNT, tx_nr_packets_max - 1); | |
| 815 | 807 | can->echo_idx = 0; |
| 816 | 808 | spin_lock_init(&can->echo_lock); |
| 817 | 809 | spin_lock_init(&can->lock); |
| @@ -1311,8 +1303,7 @@ static int kvaser_pciefd_handle_ack_packet(struct kvaser_pciefd *pcie, · 493 unmodified lines | ||
| 1311 | 1303 | count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK, |
| 1312 | 1304 | ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); |
| 1313 | 1305 | |
| 1314 | − if (count < KVASER_PCIEFD_CAN_TX_MAX_COUNT && | |
| 1315 | − netif_queue_stopped(can->can.dev)) | |
| 1306 | + if (count < can->can.echo_skb_max && netif_queue_stopped(can->can.dev)) | |
| 1316 | 1307 | netif_wake_queue(can->can.dev); |
| 1317 | 1308 | |
| 1318 | 1309 | if (!one_shot_fail) { |