MLK-19787 can: flexcan: fix CAN can't receive remote request frame
The flexcan driver allocates canfd-skb no matter whether use CAN FD mode or not, it's unreasonable due to it will affect the parse of the remote request frame. To fix the issue, allocating can-skb with "alloc_can_skb()" in normal mode and canfd-skb with "alloc_canfd_skb()" in fd mode. Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>pull/10/head
parent
09db42b6df
commit
7fca8c6ebe
|
@ -1737,12 +1737,14 @@ static int flexcan_probe(struct platform_device *pdev)
|
||||||
priv->pdata = dev_get_platdata(&pdev->dev);
|
priv->pdata = dev_get_platdata(&pdev->dev);
|
||||||
priv->devtype_data = devtype_data;
|
priv->devtype_data = devtype_data;
|
||||||
priv->reg_xceiver = reg_xceiver;
|
priv->reg_xceiver = reg_xceiver;
|
||||||
|
priv->offload.is_canfd = false;
|
||||||
|
|
||||||
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
|
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
|
||||||
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_TIMESTAMP_SUPPORT_FD) {
|
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_TIMESTAMP_SUPPORT_FD) {
|
||||||
if (!(of_find_property(np, "disable-fd-mode", NULL))) {
|
if (!(of_find_property(np, "disable-fd-mode", NULL))) {
|
||||||
priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD;
|
priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD;
|
||||||
priv->can.bittiming_const = &flexcan_fd_bittiming_const;
|
priv->can.bittiming_const = &flexcan_fd_bittiming_const;
|
||||||
|
priv->offload.is_canfd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->tx_mb_reserved_idx = FLEXCAN_TX_MB_RESERVED_OFF_TIMESTAMP_FD;
|
priv->tx_mb_reserved_idx = FLEXCAN_TX_MB_RESERVED_OFF_TIMESTAMP_FD;
|
||||||
|
|
|
@ -125,8 +125,12 @@ static struct sk_buff *can_rx_offload_offload_one(struct can_rx_offload *offload
|
||||||
|
|
||||||
/* If queue is full or skb not available, read to discard mailbox */
|
/* If queue is full or skb not available, read to discard mailbox */
|
||||||
if (likely(skb_queue_len(&offload->skb_queue) <=
|
if (likely(skb_queue_len(&offload->skb_queue) <=
|
||||||
offload->skb_queue_len_max))
|
offload->skb_queue_len_max)) {
|
||||||
skb = alloc_canfd_skb(offload->dev, &cf);
|
if (offload->is_canfd)
|
||||||
|
skb = alloc_canfd_skb(offload->dev, &cf);
|
||||||
|
else
|
||||||
|
skb = alloc_can_skb(offload->dev, (struct can_frame **)&cf);
|
||||||
|
}
|
||||||
|
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
struct canfd_frame cf_overflow;
|
struct canfd_frame cf_overflow;
|
||||||
|
|
|
@ -35,6 +35,8 @@ struct can_rx_offload {
|
||||||
struct napi_struct napi;
|
struct napi_struct napi;
|
||||||
|
|
||||||
bool inc;
|
bool inc;
|
||||||
|
|
||||||
|
bool is_canfd;
|
||||||
};
|
};
|
||||||
|
|
||||||
int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload);
|
int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload);
|
||||||
|
|
Loading…
Reference in New Issue