Resubmission of Fixes in rfcomm tty
Subsystems (2)
PATCH 1/1 Resubmission of Fixes in rfcomm tty
Marcel,
Since you said you completely forgot about the patch, here is a resubmission of my kernel patch for RFCOMM tty support from a while back.
rfcomm-tty-keep-socket-data:
If the TTY socket receives data before TTY is created, or the TTY is not opened (e.g. on devfs) then the data is discarded. This makes it impossible to support some protocols which send data right away, e.g. DUN and HFP
This one should be applied first.
rfcomm-tty-echo-overflow:
The serial core sends us lots of 1 byte requests when dealing with canonical ttys (e.g. ones that echo). This attempts to fix this issue by tweaking how the wfree is handled and also tries to be intelligent in the handling these 1 byte requests by appending them to the pending packet if there is room.
-Denis
net/bluetooth/rfcomm/core.c +5 -1
@@ -457,11 +457,10 @@BT_DBG ("dlc %p mtu %d len %d" , d, d->mtu, len);if (len > d->mtu)return -EINVAL ; -rfcomm_make_uih (skb, d->addr);skb_queue_tail (&d->tx_queue, skb);if (!test_bit (RFCOMM_TX_THROTTLED , &d->flags))rfcomm_schedule (RFCOMM_SCHED_TX );return len;
@@ -1021,10 +1020,11 @@put_unaligned (htobs (__len16 (len)), (__le16 *) &hdr->len); }else { hdr = (void *)skb_push (skb,3 ); hdr->len =__len8 (len); } + hdr->addr = addr; hdr->ctrl =__ctrl (RFCOMM_UIH ,0 ); crc =skb_put (skb,1 ); *crc =__fcs ((void *) hdr);
@@ -1673,19 +1673,23 @@ }if (test_bit (RFCOMM_TX_THROTTLED , &d->flags))return skb_queue_len (&d->tx_queue); +/* Need to lock this in case the tty driver might be messing with the tx queue */ +rfcomm_dlc_lock (d);while (d->tx_credits && (skb =skb_dequeue (&d->tx_queue))) { +rfcomm_make_uih (skb, d->addr); err =rfcomm_send_frame (d->session, skb->data, skb->len);if (err <0 ) {skb_queue_head (&d->tx_queue, skb);break ; }kfree_skb (skb); d->tx_credits--; } +rfcomm_dlc_unlock (d);if (d->cfc && !d->tx_credits) {/* We're out of TX credits. * Set TX_THROTTLED flag to avoid unnesary wakeups by dlc_send. */ set_bit (RFCOMM_TX_THROTTLED , &d->flags);
net/bluetooth/rfcomm/tty.c +57 -1
144 lines not on this page · raw message
net/bluetooth/rfcomm/tty.c +19 -6
@@ -292,18 +311,17 @@ }/* ---- Send buffer ---- */ static inline unsigned int rfcomm_room (struct rfcomm_dlc *dlc) { -/* We can't let it be zero, because we don't get a callback -when tx_credits becomes nonzero, hence we'd never wake up */ -return dlc->mtu * (dlc->tx_credits?:1 ); +return RFCOMM_MAX_CREDITS *RFCOMM_DEFAULT_MTU *10 ; }static void rfcomm_wfree (struct sk_buff *skb) {struct rfcomm_dev *dev = (void *) skb->sk; +atomic_sub (skb->truesize, &dev->wmem_alloc);if (test_bit (RFCOMM_TTY_ATTACHED , &dev->flags))tasklet_schedule (&dev->wakeup_task);rfcomm_dev_put (dev); }
@@ -690,14 +745,30 @@struct sk_buff *skb;int err =0 , sent =0 , size;BT_DBG ("tty %p count %d" , tty, count); +/* We get lots of 1 byte requests in canonical mode */ +/* So we just put them on the tail of our tx queue */ +/* if possible */ + +rfcomm_dlc_lock (dlc); + skb =skb_peek_tail (&dlc->tx_queue); +if (skb) { + size =min_t (uint, count, dlc->mtu - skb->len); +memcpy (skb_put (skb, size), buf + sent, size); + + sent += size; + count -= size; + } +rfcomm_dlc_unlock (dlc); + skb =0 ; +while (count) { size =min_t (uint, count, dlc->mtu); - skb =rfcomm_wmalloc (dev, size +RFCOMM_SKB_RESERVE ,GFP_ATOMIC ); + skb =rfcomm_wmalloc (dev, dlc->mtu +RFCOMM_SKB_RESERVE ,GFP_ATOMIC );if (!skb)break ;skb_reserve (skb,RFCOMM_SKB_HEAD_RESERVE );
@@ -964,12 +1035,10 @@BT_DBG ("tty %p dev %p" , tty, dev);if (!dev || !dev->dlc)return ; -skb_queue_purge (&dev->dlc->tx_queue); -if (test_bit (TTY_DO_WRITE_WAKEUP , &tty->flags) && tty->ldisc.write_wakeup) tty->ldisc.write_wakeup (tty); }static void rfcomm_tty_send_xchar (struct tty_struct *tty,char ch)
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel