mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
can: kvaser_pciefd: Use TX FIFO size read from CAN controller
Use the TX FIFO size read from CAN controller register, instead of using hard coded value. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/all/20230529134248.752036-15-extja@kvaser.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
f4845741e4
commit
6fdcd64ec3
@@ -658,8 +658,7 @@ static netdev_tx_t kvaser_pciefd_start_xmit(struct sk_buff *skb,
|
|||||||
/* No room for a new message, stop the queue until at least one
|
/* No room for a new message, stop the queue until at least one
|
||||||
* successful transmit
|
* successful transmit
|
||||||
*/
|
*/
|
||||||
if (count >= KVASER_PCIEFD_CAN_TX_MAX_COUNT ||
|
if (count >= can->can.echo_skb_max || can->can.echo_skb[can->echo_idx])
|
||||||
can->can.echo_skb[can->echo_idx])
|
|
||||||
netif_stop_queue(netdev);
|
netif_stop_queue(netdev);
|
||||||
spin_unlock_irqrestore(&can->echo_lock, irq_flags);
|
spin_unlock_irqrestore(&can->echo_lock, irq_flags);
|
||||||
|
|
||||||
@@ -802,16 +801,9 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie)
|
|||||||
tx_nr_packets_max =
|
tx_nr_packets_max =
|
||||||
FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK,
|
FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK,
|
||||||
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));
|
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));
|
||||||
if (tx_nr_packets_max < KVASER_PCIEFD_CAN_TX_MAX_COUNT) {
|
|
||||||
dev_err(&pcie->pci->dev,
|
|
||||||
"Max Tx count is smaller than expected\n");
|
|
||||||
|
|
||||||
free_candev(netdev);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
can->can.clock.freq = pcie->freq;
|
can->can.clock.freq = pcie->freq;
|
||||||
can->can.echo_skb_max = KVASER_PCIEFD_CAN_TX_MAX_COUNT;
|
can->can.echo_skb_max = min(KVASER_PCIEFD_CAN_TX_MAX_COUNT, tx_nr_packets_max - 1);
|
||||||
can->echo_idx = 0;
|
can->echo_idx = 0;
|
||||||
spin_lock_init(&can->echo_lock);
|
spin_lock_init(&can->echo_lock);
|
||||||
spin_lock_init(&can->lock);
|
spin_lock_init(&can->lock);
|
||||||
@@ -1311,8 +1303,7 @@ static int kvaser_pciefd_handle_ack_packet(struct kvaser_pciefd *pcie,
|
|||||||
count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK,
|
count = FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK,
|
||||||
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));
|
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));
|
||||||
|
|
||||||
if (count < KVASER_PCIEFD_CAN_TX_MAX_COUNT &&
|
if (count < can->can.echo_skb_max && netif_queue_stopped(can->can.dev))
|
||||||
netif_queue_stopped(can->can.dev))
|
|
||||||
netif_wake_queue(can->can.dev);
|
netif_wake_queue(can->can.dev);
|
||||||
|
|
||||||
if (!one_shot_fail) {
|
if (!one_shot_fail) {
|
||||||
|
Reference in New Issue
Block a user