Commit 96a607b6 authored by Felix Fietkau's avatar Felix Fietkau

mt76: move mcu timeout handling to .mcu_parse_response

Preparation for further cleanup
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent f320d812
...@@ -17,8 +17,18 @@ static int ...@@ -17,8 +17,18 @@ static int
mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd, mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq) struct sk_buff *skb, int seq)
{ {
struct mt7603_mcu_rxd *rxd = (struct mt7603_mcu_rxd *)skb->data; struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
struct mt7603_mcu_rxd *rxd;
if (!skb) {
dev_err(mdev->dev,
"MCU message %d (seq %d) timed out\n",
cmd, seq);
dev->mcu_hang = MT7603_WATCHDOG_TIMEOUT;
return -ETIMEDOUT;
}
rxd = (struct mt7603_mcu_rxd *)skb->data;
if (seq != rxd->seq) if (seq != rxd->seq)
return -EAGAIN; return -EAGAIN;
...@@ -85,15 +95,6 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, ...@@ -85,15 +95,6 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
while (wait_resp) { while (wait_resp) {
skb = mt76_mcu_get_response(&dev->mt76, expires); skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) {
dev_err(mdev->dev,
"MCU message %d (seq %d) timed out\n",
cmd, seq);
dev->mcu_hang = MT7603_WATCHDOG_TIMEOUT;
ret = -ETIMEDOUT;
break;
}
ret = mt7603_mcu_parse_response(mdev, cmd, skb, seq); ret = mt7603_mcu_parse_response(mdev, cmd, skb, seq);
dev_kfree_skb(skb); dev_kfree_skb(skb);
if (ret != -EAGAIN) if (ret != -EAGAIN)
......
...@@ -182,9 +182,16 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb, ...@@ -182,9 +182,16 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb,
int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd, int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq) struct sk_buff *skb, int seq)
{ {
struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data; struct mt7615_mcu_rxd *rxd;
int ret = 0; int ret = 0;
if (!skb) {
dev_err(mdev->dev, "Message %ld (seq %d) timeout\n",
cmd & MCU_CMD_MASK, seq);
return -ETIMEDOUT;
}
rxd = (struct mt7615_mcu_rxd *)skb->data;
if (seq != rxd->seq) if (seq != rxd->seq)
return -EAGAIN; return -EAGAIN;
...@@ -238,12 +245,6 @@ int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq) ...@@ -238,12 +245,6 @@ int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq)
while (true) { while (true) {
skb = mt76_mcu_get_response(&dev->mt76, expires); skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) {
dev_err(dev->mt76.dev, "Message %ld (seq %d) timeout\n",
cmd & MCU_CMD_MASK, seq);
return -ETIMEDOUT;
}
ret = mt7615_mcu_parse_response(&dev->mt76, cmd, skb, seq); ret = mt7615_mcu_parse_response(&dev->mt76, cmd, skb, seq);
dev_kfree_skb(skb); dev_kfree_skb(skb);
if (ret != -EAGAIN) if (ret != -EAGAIN)
......
...@@ -13,8 +13,18 @@ ...@@ -13,8 +13,18 @@
int mt76x02_mcu_parse_response(struct mt76_dev *mdev, int cmd, int mt76x02_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq) struct sk_buff *skb, int seq)
{ {
u32 *rxfce = (u32 *)skb->cb; struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
u32 *rxfce;
if (!skb) {
dev_err(mdev->dev,
"MCU message %d (seq %d) timed out\n", cmd,
seq);
dev->mcu_timeout = 1;
return -ETIMEDOUT;
}
rxfce = (u32 *)skb->cb;
if (seq != FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, *rxfce)) if (seq != FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, *rxfce))
return -EAGAIN; return -EAGAIN;
...@@ -57,15 +67,6 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, ...@@ -57,15 +67,6 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
while (wait_resp) { while (wait_resp) {
skb = mt76_mcu_get_response(&dev->mt76, expires); skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) {
dev_err(mdev->dev,
"MCU message %d (seq %d) timed out\n", cmd,
seq);
ret = -ETIMEDOUT;
dev->mcu_timeout = 1;
break;
}
ret = mt76x02_mcu_parse_response(mdev, cmd, skb, seq); ret = mt76x02_mcu_parse_response(mdev, cmd, skb, seq);
dev_kfree_skb(skb); dev_kfree_skb(skb);
if (ret != -EAGAIN) if (ret != -EAGAIN)
......
...@@ -313,9 +313,16 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd, ...@@ -313,9 +313,16 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq) struct sk_buff *skb, int seq)
{ {
struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data; struct mt7915_mcu_rxd *rxd;
int ret = 0; int ret = 0;
if (!skb) {
dev_err(mdev->dev, "Message %d (seq %d) timeout\n",
cmd, seq);
return -ETIMEDOUT;
}
rxd = (struct mt7915_mcu_rxd *)skb->data;
if (seq != rxd->seq) if (seq != rxd->seq)
return -EAGAIN; return -EAGAIN;
...@@ -347,12 +354,6 @@ mt7915_mcu_wait_response(struct mt7915_dev *dev, int cmd, int seq) ...@@ -347,12 +354,6 @@ mt7915_mcu_wait_response(struct mt7915_dev *dev, int cmd, int seq)
while (true) { while (true) {
skb = mt76_mcu_get_response(&dev->mt76, expires); skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) {
dev_err(dev->mt76.dev, "Message %d (seq %d) timeout\n",
cmd, seq);
return -ETIMEDOUT;
}
ret = mt7915_mcu_parse_response(&dev->mt76, cmd, skb, seq); ret = mt7915_mcu_parse_response(&dev->mt76, cmd, skb, seq);
dev_kfree_skb(skb); dev_kfree_skb(skb);
if (ret != -EAGAIN) if (ret != -EAGAIN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment