From: Jimmy Assarsson <extja@kvaser.com>
To: linux-can@vger.kernel.org, Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
Cc: Jimmy Assarsson <jimmyassarsson@gmail.com>,
Jimmy Assarsson <extja@kvaser.com>
Subject: [PATCH v2 14/14] can: kvaser_pciefd: Use TX FIFO size read from CAN controller
Date: Mon, 29 May 2023 15:42:48 +0200 [thread overview]
Message-ID: <20230529134248.752036-15-extja@kvaser.com> (raw)
In-Reply-To: <20230529134248.752036-1-extja@kvaser.com>
Use the TX FIFO size read from CAN controller register, instead of using
hard coded value.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- Rebased on
can: kvaser_pciefd: Use FIELD_{GET,PREP} and GENMASK where appropriate
drivers/net/can/kvaser_pciefd.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c
index 0321b70a3b71..db6256f2b1b3 100644
--- a/drivers/net/can/kvaser_pciefd.c
+++ b/drivers/net/can/kvaser_pciefd.c
@@ -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
* successful transmit
*/
- if (count >= KVASER_PCIEFD_CAN_TX_MAX_COUNT ||
- can->can.echo_skb[can->echo_idx])
+ if (count >= can->can.echo_skb_max || can->can.echo_skb[can->echo_idx])
netif_stop_queue(netdev);
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 =
FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK,
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.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;
spin_lock_init(&can->echo_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,
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));
- if (count < KVASER_PCIEFD_CAN_TX_MAX_COUNT &&
- netif_queue_stopped(can->can.dev))
+ if (count < can->can.echo_skb_max && netif_queue_stopped(can->can.dev))
netif_wake_queue(can->can.dev);
if (!one_shot_fail) {
--
2.40.0
next prev parent reply other threads:[~2023-05-29 13:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 13:42 [PATCH v2 00/14] can: kvaser_pciefd: Fixes and improvments Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 01/14] can: kvaser_pciefd: Remove useless write to interrupt register Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 02/14] can: kvaser_pciefd: Remove handler for unused KVASER_PCIEFD_PACK_TYPE_EFRAME_ACK Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 03/14] can: kvaser_pciefd: Add function to set skb hwtstamps Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 04/14] can: kvaser_pciefd: Set hardware timestamp on transmitted packets Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 05/14] can: kvaser_pciefd: Define unsigned constants with type suffix 'U' Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 06/14] can: kvaser_pciefd: Remove SPI flash parameter read functionality Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 07/14] can: kvaser_pciefd: Sort includes in alphabetic order Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 08/14] can: kvaser_pciefd: Rename device ID defines Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 09/14] can: kvaser_pciefd: Change return type for kvaser_pciefd_{receive,transmit,set_tx}_irq() Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 10/14] can: kvaser_pciefd: Sort register definitions Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 11/14] can: kvaser_pciefd: Use FIELD_{GET,PREP} and GENMASK where appropriate Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 12/14] can: kvaser_pciefd: Add len8_dlc support Jimmy Assarsson
2023-05-29 13:42 ` [PATCH v2 13/14] can: kvaser_pciefd: Refactor code Jimmy Assarsson
2023-05-29 13:42 ` Jimmy Assarsson [this message]
2023-05-30 0:46 ` [PATCH v2 00/14] can: kvaser_pciefd: Fixes and improvments Vincent MAILHOL
2023-06-20 13:40 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230529134248.752036-15-extja@kvaser.com \
--to=extja@kvaser.com \
--cc=jimmyassarsson@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox