Skip to contentSkip to conversation

mac802154: cleanup concurrent check

PATCH In review Alexander Aring 3 participants 9 messages Mar 26, 2015 – Mar 27, 2015

Subsystems (3)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/3 mac802154: cleanup concurrent check

This patch cleanups the checking of different mac phy depended values by handling depended mac settings per hw support flag in one condition.

---
 net/mac802154/iface.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
net/mac802154/iface.c +6 -14
index 9b8e264..3f6a3fe 100644
@@ -174,24 +174,16 @@ ieee802154_check_mac_settings(struct ieee802154_local *local,
 	}
 
 	if (local->hw.flags & IEEE802154_HW_AFILT) {
-		if (wpan_dev->pan_id != nwpan_dev->pan_id)
-			return -EBUSY;
-
-		if (wpan_dev->short_addr != nwpan_dev->short_addr)
-			return -EBUSY;
-
-		if (wpan_dev->extended_addr != nwpan_dev->extended_addr)
+		if (wpan_dev->pan_id != nwpan_dev->pan_id ||
+		    wpan_dev->short_addr != nwpan_dev->short_addr ||
+		    wpan_dev->extended_addr != nwpan_dev->extended_addr)
 			return -EBUSY;
 	}
 
 	if (local->hw.flags & IEEE802154_HW_CSMA_PARAMS) {
-		if (wpan_dev->min_be != nwpan_dev->min_be)
-			return -EBUSY;
-
-		if (wpan_dev->max_be != nwpan_dev->max_be)
-			return -EBUSY;
-
-		if (wpan_dev->csma_retries != nwpan_dev->csma_retries)
+		if (wpan_dev->min_be != nwpan_dev->min_be ||
+		    wpan_dev->max_be != nwpan_dev->max_be ||
+		    wpan_dev->csma_retries != nwpan_dev->csma_retries)
 			return -EBUSY;
 	}
 
Signature · 1 line
2.3.4
author maintainer
#1 lore raw

PATCH 2/3 at86rf230: remove unnecessary spinlock

This spinlock isn't necessary because if we are in TX_ON/TX_ARET_ON state the transceiver can't be interrupted e.g. by receiving a frame when a SHR was detected. In this time the transceiver doesn't leave the TX_ON/TX_ARET_ON state until the tx complete irq change the state into RX_AACK_ON again. This means a receiving interrupt in state TX_ON/TX_ARET_ON can't happen and is_tx is protected by transceiver.

---
 drivers/net/ieee802154/at86rf230.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/net/ieee802154/at86rf230.c +0 -9
index cc5efa1..1278dd5 100644
@@ -25,7 +25,6 @@
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
-#include <linux/spinlock.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/at86rf230.h>
 #include <linux/regmap.h>
@@ -96,8 +95,6 @@ struct at86rf230_local {
 	unsigned long cal_timeout;
 	s8 max_frame_retries;
 	bool is_tx;
-	/* spinlock for is_tx protection */
-	spinlock_t lock;
 	u8 tx_retry;
 	struct sk_buff *tx_skb;
 	struct at86rf230_state_change tx;
@@ -878,10 +875,8 @@ at86rf230_rx_trac_check(void *context)
 static void
 at86rf230_irq_trx_end(struct at86rf230_local *lp)
 {
-	spin_lock(&lp->lock);
 	if (lp->is_tx) {
 		lp->is_tx = 0;
-		spin_unlock(&lp->lock);
 
 		if (lp->tx_aret)
 			at86rf230_async_state_change(lp, &lp->irq,
@@ -894,7 +889,6 @@ at86rf230_irq_trx_end(struct at86rf230_local *lp)
 						     at86rf230_tx_complete,
 						     true);
 	} else {
-		spin_unlock(&lp->lock);
 		at86rf230_async_read_reg(lp, RG_TRX_STATE, &lp->irq,
 					 at86rf230_rx_trac_check, true);
 	}
@@ -964,9 +958,7 @@ at86rf230_write_frame(void *context)
 	u8 *buf = ctx->buf;
 	int rc;
 
-	spin_lock(&lp->lock);
 	lp->is_tx = 1;
-	spin_unlock(&lp->lock);
 
 	buf[0] = CMD_FB | CMD_WRITE;
 	buf[1] = skb->len + 2;
@@ -1698,7 +1690,6 @@ static int at86rf230_probe(struct spi_device *spi)
 	if (rc < 0)
 		goto free_dev;
 
-	spin_lock_init(&lp->lock);
 	init_completion(&lp->state_complete);
 
 	spi_set_drvdata(spi, lp);
Signature · 1 line
2.3.4
#2 lore raw

Re: [PATCH bluetooth-next 2/3] at86rf230: remove unnecessary spinlock

Hi Alex,

Quoted 11 lines

This spinlock isn't necessary because if we are in TX_ON/TX_ARET_ON state the transceiver can't be interrupted e.g. by receiving a frame when a SHR was detected. In this time the transceiver doesn't leave the TX_ON/TX_ARET_ON state until the tx complete irq change the state into RX_AACK_ON again. This means a receiving interrupt in state TX_ON/TX_ARET_ON can't happen and is_tx is protected by transceiver.

---
drivers/net/ieee802154/at86rf230.c | 9 ---------

1 file changed, 9 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

author maintainer
#3 lore raw

PATCH 3/3 at86rf230: fix is_tx while error handling

In reply to Alexander Aring

This patch fix the error handling when is_tx is true. The error handling tries to get the transceiver into RX_AACK_ON mode then we need to be sure that is_tx is false.

---
 drivers/net/ieee802154/at86rf230.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ieee802154/at86rf230.c +1 -0
index 1278dd5..5ad46f7 100644
@@ -457,6 +457,7 @@ at86rf230_async_error_recover(void *context)
 	struct at86rf230_state_change *ctx = context;
 	struct at86rf230_local *lp = ctx->lp;
 
+	lp->is_tx = 0;
 	at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON, NULL, false);
 	ieee802154_wake_queue(lp->hw);
 }
Signature · 1 line
2.3.4
#4 lore raw

Re: [PATCH bluetooth-next 3/3] at86rf230: fix is_tx while error handling

Quoted 3 lines · Alexander Aring

This patch fix the error handling when is_tx is true. The error handling tries to get the transceiver into RX_AACK_ON mode then we need to be sure that is_tx is false.

Generally speaking, first fix errors, then clean up and improve code.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
author maintainer
#5 lore raw

Re: [PATCH bluetooth-next 3/3] at86rf230: fix is_tx while error handling

Quoted 7 lines · Marc Kleine-Budde
Quoted 3 lines · Alexander Aring

This patch fix the error handling when is_tx is true. The error handling tries to get the transceiver into RX_AACK_ON mode then we need to be sure that is_tx is false.

Generally speaking, first fix errors, then clean up and improve code.

should I resend again with a new sequence of this patch series?

I know it's some mixed things which I detect while hacking the nl802154 crypto foo. But I will remember Marc's words before sending next series. :-)

btw:
I think if an spi_async error occurs then something goes really wrong and a rescue by doing a TRX_OFF -> RX_AACK_ON doesn't help also anymore.

We need then something like rf_kill framework.

- Alex

#6 lore raw

Re: [PATCH bluetooth-next 3/3] at86rf230: fix is_tx while error handling

Hi Alex,

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

This patch fix the error handling when is_tx is true. The error handling tries to get the transceiver into RX_AACK_ON mode then we need to be sure that is_tx is false.

Quoted 8 lines
Quoted 2 lines

Generally speaking, first fix errors, then clean up and improve code.

should I resend again with a new sequence of this patch series?

I know it's some mixed things which I detect while hacking the nl802154 crypto foo. But I will remember Marc's words before sending next series. :-)

I am fine either way. I can apply the patches as you sent them.

Regards

Marcel

#7 lore raw

Re: [PATCH bluetooth-next 3/3] at86rf230: fix is_tx while error handling

In reply to Alexander Aring

Hi Alex,

Quoted 8 lines

This patch fix the error handling when is_tx is true. The error handling tries to get the transceiver into RX_AACK_ON mode then we need to be sure that is_tx is false.

---
drivers/net/ieee802154/at86rf230.c | 1 +

1 file changed, 1 insertion(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#8 lore raw
In reply to Alexander Aring

Hi Alex,

Quoted 7 lines

This patch cleanups the checking of different mac phy depended values by handling depended mac settings per hw support flag in one condition.

---
net/mac802154/iface.c | 20 ++++++--------------

1 file changed, 6 insertions(+), 14 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel