mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
can: rockchip_canfd: prepare to use full TX-FIFO depth
So far the TX-FIFO is only used with a depth of 1, although the hardware offers a depth of 2. The workaround for the chips that are affected by erratum 6, i.e. EFF frames may be send as standard frames, is to re-send the EFF frame. This means the driver cannot queue the next frame for sending, as long ad the EFF frame has not been successfully send out. Introduce rkcanfd_get_effective_tx_free() that returns "0" space in the TX-FIFO if an EFF frame is pending and the actual free space in the TX-FIFO otherwise. Then replace rkcanfd_get_tx_free() with rkcanfd_get_effective_tx_free() everywhere. Tested-by: Alibek Omarov <a1ba.omarov@gmail.com> Acked-by: Heiko Stuebner <heiko@sntech.de> Link: https://patch.msgid.link/20240904-rockchip-canfd-v5-16-8ae22bcb27cc@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
669904d146
commit
ae002cc32e
@ -124,7 +124,7 @@ static int rkcanfd_rxstx_filter(struct rkcanfd_priv *priv,
|
|||||||
|
|
||||||
WRITE_ONCE(priv->tx_tail, priv->tx_tail + 1);
|
WRITE_ONCE(priv->tx_tail, priv->tx_tail + 1);
|
||||||
netif_subqueue_completed_wake(priv->ndev, 0, 1, frame_len,
|
netif_subqueue_completed_wake(priv->ndev, 0, 1, frame_len,
|
||||||
rkcanfd_get_tx_free(priv),
|
rkcanfd_get_effective_tx_free(priv),
|
||||||
RKCANFD_TX_START_THRESHOLD);
|
RKCANFD_TX_START_THRESHOLD);
|
||||||
|
|
||||||
*tx_done = true;
|
*tx_done = true;
|
||||||
|
@ -8,6 +8,40 @@
|
|||||||
|
|
||||||
#include "rockchip_canfd.h"
|
#include "rockchip_canfd.h"
|
||||||
|
|
||||||
|
static bool rkcanfd_tx_tail_is_eff(const struct rkcanfd_priv *priv)
|
||||||
|
{
|
||||||
|
const struct canfd_frame *cfd;
|
||||||
|
const struct sk_buff *skb;
|
||||||
|
unsigned int tx_tail;
|
||||||
|
|
||||||
|
if (!rkcanfd_get_tx_pending(priv))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tx_tail = rkcanfd_get_tx_tail(priv);
|
||||||
|
skb = priv->can.echo_skb[tx_tail];
|
||||||
|
if (!skb) {
|
||||||
|
netdev_err(priv->ndev,
|
||||||
|
"%s: echo_skb[%u]=NULL tx_head=0x%08x tx_tail=0x%08x\n",
|
||||||
|
__func__, tx_tail,
|
||||||
|
priv->tx_head, priv->tx_tail);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfd = (struct canfd_frame *)skb->data;
|
||||||
|
|
||||||
|
return cfd->can_id & CAN_EFF_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int rkcanfd_get_effective_tx_free(const struct rkcanfd_priv *priv)
|
||||||
|
{
|
||||||
|
if (priv->devtype_data.quirks & RKCANFD_QUIRK_RK3568_ERRATUM_6 &&
|
||||||
|
rkcanfd_tx_tail_is_eff(priv))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return rkcanfd_get_tx_free(priv);
|
||||||
|
}
|
||||||
|
|
||||||
static void rkcanfd_start_xmit_write_cmd(const struct rkcanfd_priv *priv,
|
static void rkcanfd_start_xmit_write_cmd(const struct rkcanfd_priv *priv,
|
||||||
const u32 reg_cmd)
|
const u32 reg_cmd)
|
||||||
{
|
{
|
||||||
@ -42,7 +76,7 @@ int rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
|||||||
return NETDEV_TX_OK;
|
return NETDEV_TX_OK;
|
||||||
|
|
||||||
if (!netif_subqueue_maybe_stop(priv->ndev, 0,
|
if (!netif_subqueue_maybe_stop(priv->ndev, 0,
|
||||||
rkcanfd_get_tx_free(priv),
|
rkcanfd_get_effective_tx_free(priv),
|
||||||
RKCANFD_TX_STOP_THRESHOLD,
|
RKCANFD_TX_STOP_THRESHOLD,
|
||||||
RKCANFD_TX_START_THRESHOLD)) {
|
RKCANFD_TX_START_THRESHOLD)) {
|
||||||
if (net_ratelimit())
|
if (net_ratelimit())
|
||||||
@ -99,7 +133,7 @@ int rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
|||||||
rkcanfd_start_xmit_write_cmd(priv, reg_cmd);
|
rkcanfd_start_xmit_write_cmd(priv, reg_cmd);
|
||||||
|
|
||||||
netif_subqueue_maybe_stop(priv->ndev, 0,
|
netif_subqueue_maybe_stop(priv->ndev, 0,
|
||||||
rkcanfd_get_tx_free(priv),
|
rkcanfd_get_effective_tx_free(priv),
|
||||||
RKCANFD_TX_STOP_THRESHOLD,
|
RKCANFD_TX_STOP_THRESHOLD,
|
||||||
RKCANFD_TX_START_THRESHOLD);
|
RKCANFD_TX_START_THRESHOLD);
|
||||||
|
|
||||||
|
@ -533,6 +533,7 @@ int rkcanfd_handle_rx_int(struct rkcanfd_priv *priv);
|
|||||||
|
|
||||||
void rkcanfd_timestamp_init(struct rkcanfd_priv *priv);
|
void rkcanfd_timestamp_init(struct rkcanfd_priv *priv);
|
||||||
|
|
||||||
|
unsigned int rkcanfd_get_effective_tx_free(const struct rkcanfd_priv *priv);
|
||||||
void rkcanfd_xmit_retry(struct rkcanfd_priv *priv);
|
void rkcanfd_xmit_retry(struct rkcanfd_priv *priv);
|
||||||
int rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev);
|
int rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev);
|
||||||
void rkcanfd_handle_tx_done_one(struct rkcanfd_priv *priv, const u32 ts,
|
void rkcanfd_handle_tx_done_one(struct rkcanfd_priv *priv, const u32 ts,
|
||||||
|
Loading…
Reference in New Issue
Block a user