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 | /* No room for a new message, stop the queue until at least one | 658 | /* No room for a new message, stop the queue until at least one |
| 659 | * successful transmit | 659 | * successful transmit |
| 660 | */ | 660 | */ |
| 661 | if (count >= KVASER_PCIEFD_CAN_TX_MAX_COUNT || | 661 | if (count >= can->can.echo_skb_max || can->can.echo_skb[can->echo_idx]) |
| 662 | can->can.echo_skb[can->echo_idx]) | ||
| 663 | netif_stop_queue(netdev); | 662 | netif_stop_queue(netdev); |
| 664 | spin_unlock_irqrestore(&can->echo_lock, irq_flags); | 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 | tx_nr_packets_max = | 801 | tx_nr_packets_max = |
| 803 | FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK, | 802 | FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK, |
| 804 | ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); | 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 | can->can.clock.freq = pcie->freq; | 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 | can->echo_idx = 0; | 807 | can->echo_idx = 0; |
| 816 | spin_lock_init(&can->echo_lock); | 808 | spin_lock_init(&can->echo_lock); |
| 817 | spin_lock_init(&can->lock); | 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 | count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK, | 1303 | count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK, |
| 1312 | ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); | 1304 | ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG)); |
| 1313 | 1305 | ||
| 1314 | if (count < KVASER_PCIEFD_CAN_TX_MAX_COUNT && | 1306 | if (count < can->can.echo_skb_max && netif_queue_stopped(can->can.dev)) |
| 1315 | netif_queue_stopped(can->can.dev)) | ||
| 1316 | netif_wake_queue(can->can.dev); | 1307 | netif_wake_queue(can->can.dev); |
| 1317 | 1308 | ||
| 1318 | if (!one_shot_fail) { | 1309 | if (!one_shot_fail) { |