Hi Guennadi, On Sat, Apr 07, 2007 at 03:59:26AM +0300, Samuel Ortiz wrote: > IMHO, irnet_flow_indication() should be called asynchronously by > irttp_run_tx_queue(), through some bottom-half mechanism. That would fix your > locking issues, and that would reduce the time we spend in the IrDA code with > this lock taken. > > I will try to come up with some patches for you later this weekend. The patch below schedules irnet_flow_indication() asynchronously. Could you please give it a try (it builds, but I couldn't test it...) ? : diff --git a/include/net/irda/irttp.h b/include/net/irda/irttp.h index a899e58..941f0f1 100644 --- a/include/net/irda/irttp.h +++ b/include/net/irda/irttp.h @@ -128,6 +128,7 @@ struct tsap_cb { struct net_device_stats stats; struct timer_list todo_timer; + struct work_struct irnet_flow_work; /* irttp asynchronous flow restart */ __u32 max_seg_size; /* Max data that fit into an IrLAP frame */ __u8 max_header_size; diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 7069e4a..a0d0f26 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c @@ -367,6 +367,29 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, /*************************** CLIENT CALLS ***************************/ /************************** LMP CALLBACKS **************************/ /* Everything is happily mixed up. Waiting for next clean up - Jean II */ +static void irttp_flow_restart(struct work_struct *work) +{ + struct tsap_cb * self = + container_of(work, struct tsap_cb, irnet_flow_work); + + if (self == NULL) + return; + + /* Check if we can accept more frames from client. */ + if ((self->tx_sdu_busy) && + (skb_queue_len(&self->tx_queue) < TTP_TX_LOW_THRESHOLD) && + (!self->close_pend)) { + if (self->notify.flow_indication) + self->notify.flow_indication(self->notify.instance, + self, FLOW_START); + + /* self->tx_sdu_busy is the state of the client. + * We don't really have a race here, but it's always safer + * to update our state after the client - Jean II */ + self->tx_sdu_busy = FALSE; + } +} + /* * Function irttp_open_tsap (stsap, notify) @@ -402,6 +425,8 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) self->todo_timer.data = (unsigned long) self; self->todo_timer.function = &irttp_todo_expired; + INIT_WORK(&self->irnet_flow_work, irttp_flow_restart); + /* Initialize callbacks for IrLMP to use */ irda_notify_init(&ttp_notify); ttp_notify.connect_confirm = irttp_connect_confirm; @@ -761,25 +786,10 @@ static void irttp_run_tx_queue(struct tsap_cb *self) self->stats.tx_packets++; } - /* Check if we can accept more frames from client. - * We don't want to wait until the todo timer to do that, and we - * can't use tasklets (grr...), so we are obliged to give control - * to client. That's ok, this test will be true not too often - * (max once per LAP window) and we are called from places - * where we can spend a bit of time doing stuff. - Jean II */ if ((self->tx_sdu_busy) && (skb_queue_len(&self->tx_queue) < TTP_TX_LOW_THRESHOLD) && (!self->close_pend)) - { - if (self->notify.flow_indication) - self->notify.flow_indication(self->notify.instance, - self, FLOW_START); - - /* self->tx_sdu_busy is the state of the client. - * We don't really have a race here, but it's always safer - * to update our state after the client - Jean II */ - self->tx_sdu_busy = FALSE; - } + schedule_work(&self->irnet_flow_work); /* Reset lock */ self->tx_queue_lock = 0; - To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html