|
From: Anders J. <and...@us...> - 2001-11-22 14:02:44
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.213 1.214=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.124 1.125=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.128 1.129=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* wq_timers now use a new bt_timer_obj to prevent adding the same timer twi=
ce.
* l2cap ertx and rtx timers changed to the new one.
* One bt_timer on each tty added.
* Disable ertx when we receive a connection_complete after pending.
* bt_shutdown now disable pagescan to prevent any new connections.
The diff of the modified file(s):
--- bluetooth.c 2001/11/15 15:01:57 1.213
+++ bluetooth.c 2001/11/22 14:02:41 1.214
@@ -312,8 +312,6 @@
static tty_linebuffer tty_linebuf;
#endif /* BT_USELINEBUF */
=20
-static struct timer_list bt_timer;
-
#define BT_CON_TIMEOUT (10*HZ)
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
@@ -1881,9 +1879,10 @@
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
/* sleep if not yet connected */
if (bt_ctrl.session[line].connect_status =3D=3D -1) {
- start_wq_timer(&bt_timer, BT_CON_TIMEOUT,=20
+ start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT,=20
&bt_ctrl.connect_wq[line]);
interruptible_sleep_on(&bt_ctrl.connect_wq[line]);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
}
return bt_ctrl.session[line].connect_status;
}
@@ -1914,11 +1913,7 @@
don't appear to be working out.
--gmcnutt
*/
- /* fixme -- we probably need a lock on this timer since
- multiple processes could be trying to use it at the
- same time... or maybe use one timer per session.
- */
- start_wq_timer(&bt_timer, BT_CON_TIMEOUT,=20
+ start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT,=20
&bt_ctrl.connect_wq[line]);
=20
/* The timeout routine doesn't have a hendle to our=20
@@ -1932,6 +1927,7 @@
=20
BT_DRIVER(__FUNCTION__ ": Sleep on line %d\n", line);
interruptible_sleep_on(&bt_ctrl.connect_wq[line]);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
=20
/*=20
* If the connect_status is >=3D 0, then the lower
@@ -2052,7 +2048,7 @@
BT_DRIVER(__FUNCTION__ ": Line %d [%s]\n",
line, psmname(psm));
=20
- release_wq_timer(&bt_timer);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
wake_up_interruptible(&bt_ctrl.connect_wq[line]);
wake_up_interruptible(&bt_ctrl.any_wq);
break;
@@ -2062,7 +2058,7 @@
bt_ctrl.session[line].connect_status =3D status;
BT_DRIVER(__FUNCTION__ ": Line %d [%s]\n", line, psmname(psm));
BT_DRIVER(__FUNCTION__ ": Wake up line %d\n", line);
- release_wq_timer(&bt_timer);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
wake_up_interruptible(&bt_ctrl.connect_wq[line]);
wake_up_interruptible(&bt_ctrl.any_wq);
break;
@@ -2137,9 +2133,10 @@
=20
/* Sleep if not yet disconnected */
if (bt_ctrl.session[line].disconnect_status =3D=3D -1) {
- start_wq_timer(&bt_timer, BT_CON_TIMEOUT,=20
+ start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT,=20
&bt_ctrl.connect_wq[line]);
interruptible_sleep_on(&bt_ctrl.connect_wq[line]);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
}
=20=09=09
return bt_ctrl.session[line].disconnect_status;
@@ -2185,7 +2182,7 @@
=20
bt_ctrl.session[line].disconnect_status =3D status;
=20
- release_wq_timer(&bt_timer);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
wake_up_interruptible(&bt_ctrl.connect_wq[line]);
}
=20
@@ -2546,7 +2543,6 @@
}
}
=20
-
s32
bt_init_stack(void)
{
@@ -2698,20 +2694,21 @@
s32 i;
BT_DRIVER("Initialising bt ctrl struct\n");
=20
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
for (i =3D 0; i < BT_NBR_PORTS; i++) {
+ bt_ctrl.bt_timer[i].inuse =3D 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
bt_ctrl.connect_wq[i] =3D NULL;
- bt_reset_session(i);
- }
- bt_ctrl.any_wq =3D NULL;
#else
- for (i =3D 0; i < BT_NBR_PORTS; i++) {
init_waitqueue_head(&bt_ctrl.connect_wq[i]);
+#endif
bt_reset_session(i);
}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+ bt_ctrl.any_wq =3D NULL;
+#else
init_waitqueue_head(&bt_ctrl.any_wq);
#endif
-
bt_ctrl.nbr_upper =3D 0;
bt_ctrl.nbr_active =3D 0;
bt_ctrl.tty_last_unthrottled =3D 0;
@@ -2981,11 +2978,16 @@
struct bt_session *bt;
DSYS("Shutting down bluetooth stack\n");
=20
+ /* Disable page scan as we don't want any new connections now */
+ DSYS("Disabling page scan\n");
+
+ hci_write_scan_enable(0x00);
if (bt_stack_initiated) {
if (!bt_dfu_mode(-1)) {
/* disconnect all active connections */
for (i =3D 0; i < BT_NBR_DATAPORTS;i++) {
bt =3D &bt_ctrl.session[i];
+ release_wq_timer(&bt_ctrl.bt_timer[i]);
if ((bt->state =3D=3D BT_ACTIVE) ||=20
(bt->state =3D=3D BT_LOWERCONNECTED)) {
DSYS("Disconnecting dlci %d on line %d\n",=20
@@ -3064,32 +3066,43 @@
}
}
=20
+/* FIXME: Make a general sleepfunction a la L2ca_wait and let the this fun=
ction handle all
+ sleeping. Add a waitqueue object to the timer and let timerdata=3Dbt_ti=
mer_obj to set
+ inuse=3D0 if we timeout */
+
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
void
-start_wq_timer(struct timer_list *wq_timer,
+start_wq_timer(struct bt_timer_obj *wq_bt_timer,
u32 timeout, wait_queue_head_t *wq)
#else
void
-start_wq_timer(struct timer_list *wq_timer,
+start_wq_timer(struct bt_timer_obj *wq_bt_timer,
u32 timeout, struct wait_queue **wq)
#endif /* LINUX_VERSION_CODE */
{
- init_timer(wq_timer);
- wq_timer->function =3D wq_timeout;
- wq_timer->data =3D (unsigned long)wq;
- wq_timer->expires =3D jiffies + timeout;
- add_timer(wq_timer);
-// printk(__FUNCTION__ ": wq: 0x%x, timer: 0x%x\n", wq, wq_timer);
+ if(wq_bt_timer->inuse) {
+ D_ERR(__FUNCTION__ ": timer already used\n");
+ return;
+ }
+=09
+ wq_bt_timer->inuse =3D 1;
+ init_timer(&wq_bt_timer->timer);
+ wq_bt_timer->timer.function =3D wq_timeout;
+ wq_bt_timer->timer.data =3D (unsigned long)wq;
+ wq_bt_timer->timer.expires =3D jiffies + timeout;
+ add_timer(&wq_bt_timer->timer);
}
=20
=20
/* fixme -- only works for one function call at a time */
void
-release_wq_timer(struct timer_list *wq_timer)
+release_wq_timer(struct bt_timer_obj *wq_bt_timer)
{
- del_timer(wq_timer);
-// printk(__FUNCTION__ ": timer: 0x%x\n", wq_timer);
+ if(wq_bt_timer->inuse =3D=3D 1) {
+ del_timer(&wq_bt_timer->timer);
+ wq_bt_timer->inuse =3D 0;
}
+}
=20
void
wq_timeout(unsigned long ptr)
@@ -3100,7 +3113,6 @@
struct wait_queue **wq =3D (struct wait_queue **)ptr;
#endif /* LINUX_VERSION_CODE */
DSYS(__FUNCTION__ "\n");
-
/* wake up wait queue */
wake_up_interruptible(wq);
}
--- l2cap.c 2001/11/15 15:52:15 1.124
+++ l2cap.c 2001/11/22 14:02:41 1.125
@@ -995,6 +995,7 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
+ disable_ertx(con);
#endif
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
@@ -1274,6 +1275,7 @@
return;
}
=20=20
+=20
/* FIXME - add check with control block if this bd_addr is allowed */
=20
/* We are server and creates an l2cap connection object=20
@@ -1940,7 +1942,6 @@
}
#endif
/* do some paranoia checks */
-
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
@@ -1948,9 +1949,9 @@
=20
D_TIM(__FUNCTION__ ": current no rtx : %d\n", con->timer.rtx_no);
=20
- con->timer.rtx_inuse =3D 0;
+ con->timers.rtx.inuse =3D 0;
=20
- if (con->timer.rtx_no =3D=3D MAX_NO_RTX) {
+ if (con->timers.rtx_no =3D=3D MAX_NO_RTX) {
con->c_status =3D CSTATUS_MAX_NO_RTX;
=20
D_TIM(__FUNCTION__ ": Max number of retransmit reached\n");
@@ -1963,9 +1964,9 @@
l2ca_wakeup("rtx_timeout", con);
=20
/* reset rtx counter */
- con->timer.rtx_no =3D 0;
+ con->timers.rtx_no =3D 0;
} else {
- con->timer.rtx_no++;
+ con->timers.rtx_no++;
l2ca_timeoutind(con);=09
}
=20
@@ -1980,13 +1981,14 @@
l2cap_con *con;
D_TIM(__FUNCTION__ "\n");
con =3D (l2cap_con*)ptr;
-
/* do paranoia check */
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
}
=20
+ con->timers.ertx.inuse =3D 0;
+
con->c_status =3D CSTATUS_ERTX_TIMEOUT;
l2ca_wakeup("ertx_timeout", con);
}
@@ -2059,7 +2061,7 @@
cmd->code =3D SIG_CONREQ;
=20
/* Don't increment ID if retransmission */
- if (con->timer.rtx_no =3D=3D 0)
+ if (con->timers.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* S
ets sig_id_sent in l2cap_con */
else
@@ -2182,7 +2184,7 @@
cmd->code =3D SIG_CONFREQ;
=20
/* Don't increment ID if retransmission */
- if (con->timer.rtx_no =3D=3D 0)
+ if (con->timers.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con =
*/
else
DSYS("RTX, use same ID\n");
@@ -2241,7 +2243,7 @@
cmd->code =3D SIG_DISCREQ;
=20=20=20=20=20=20=20=20=20
/* Don't increment ID if retransmission */
- if (con->timer.rtx_no =3D=3D 0)
+ if (con->timers.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con =
*/
else
DSYS("RTX, use same ID\n");
@@ -2992,8 +2994,8 @@
{
/* multiply by 2 each rtx */
=20
- if (con->timer.rtx_no > 0)
- timeout =3D timeout*(2 << (con->timer.rtx_no - 1));
+ if (con->timers.rtx_no > 0)
+ timeout =3D timeout*(2 << (con->timers.rtx_no - 1));
=20
/* FIXME -- use flush timeout to calculate number of
retransmissions */
@@ -3001,18 +3003,18 @@
D_TIM("Starting RTX timer (%d sec)\n", timeout);
=20
/* fixme -- add timer list for multiple calls */
- if (con->timer.rtx_inuse) {
+ if (con->timers.rtx.inuse) {
D_ERR(__FUNCTION__ ": timer already used\n");
return;
}
=20
#ifdef __KERNEL__=09
- init_timer(&con->timer.rtx);
- con->timer.rtx.function =3D l2cap_rtx_timeout;
- con->timer.rtx.data =3D (unsigned long)con;
- con->timer.rtx.expires =3D jiffies + timeout*HZ;
- con->timer.rtx_inuse =3D 1;
- add_timer(&con->timer.rtx);=20=20
+ init_timer(&con->timers.rtx.timer);
+ con->timers.rtx.timer.function =3D l2cap_rtx_timeout;
+ con->timers.rtx.timer.data =3D (unsigned long)con;
+ con->timers.rtx.timer.expires =3D jiffies + timeout*HZ;
+ con->timers.rtx.inuse =3D 1;
+ add_timer(&con->timers.rtx.timer);=20=20
=20
#else /* Usermode stack */
=20
@@ -3046,11 +3048,10 @@
{
D_TIM("Disabling RTX timer\n");
#ifdef __KERNEL__
- if (con->timer.rtx_inuse) {
- del_timer(&con->timer.rtx);
- con->timer.rtx_inuse =3D 0;
- con->timer.rtx_no =3D 0;
- con->timer.rtx_action =3D RTX_ACTION_DISCONNECT;
+ if (con->timers.rtx.inuse) {
+ del_timer(&con->timers.rtx.timer);
+ con->timers.rtx.inuse =3D 0;
+ con->timers.rtx_no =3D 0;
} else
D_TIM("RTX never started\n");
#else
@@ -3065,18 +3066,18 @@
{
D_TIM("Starting ERTX timer (%d sec)\n", timeout);
=20
- if (con->timer.ertx_inuse) {
+ if (con->timers.ertx.inuse) {
D_TIM(__FUNCTION__ ": timer already used\n");
return;
}
=20
#ifdef __KERNEL__
- init_timer(&con->timer.ertx);
- con->timer.ertx.function =3D l2cap_ertx_timeout;
- con->timer.ertx.data =3D (unsigned long)con;
- con->timer.ertx.expires =3D jiffies + timeout*HZ;
- con->timer.ertx_inuse =3D 1;
- add_timer(&con->timer.ertx);
+ init_timer(&con->timers.ertx.timer);
+ con->timers.ertx.timer.function =3D l2cap_ertx_timeout;
+ con->timers.ertx.timer.data =3D (unsigned long)con;
+ con->timers.ertx.timer.expires =3D jiffies + timeout*HZ;
+ con->timers.ertx.inuse =3D 1;
+ add_timer(&con->timers.ertx.timer);
#else
/* fixme */
con->timer.ertx_inuse =3D 1;
@@ -3088,17 +3089,15 @@
{
D_TIM("Disabling ERTX timer\n");
#ifdef __KERNEL__
- if (con->timer.ertx_inuse) {
- del_timer(&con->timer.ertx);
- con->timer.ertx_inuse =3D 0;
- con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
+ if (con->timers.ertx.inuse) {
+ del_timer(&con->timers.ertx.timer);
+ con->timers.ertx.inuse =3D 0;
} else
D_TIM("ERTX never started\n");
#else /* Usermode stack */
/* FIXME */
D_ERR("disable_ertx FIXME\n");
- con->timer.ertx_inuse =3D 0;
- con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
+ con->timers.ertx.inuse =3D 0;
#endif
}
#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
--- rfcomm.c 2001/10/23 10:10:28 1.128
+++ rfcomm.c 2001/11/22 14:02:41 1.129
@@ -506,13 +506,13 @@
rfcomm_con rfcomm_con_list[BT_NBR_DATAPORTS];
=20
#ifdef __KERNEL__
-static struct timer_list rfcomm_timer;
+static struct bt_timer_obj rfcomm_timer;
#endif
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-static struct wait_queue *rfcomm_disconnect_wq =3D NULL;
+struct wait_queue *rfcomm_disconnect_wq;
#else
-static wait_queue_head_t rfcomm_disconnect_wq;
+wait_queue_head_t rfcomm_disconnect_wq;
#endif /* LINUX_VERSION_CODE */
=20
rpn_values rpn_val;
@@ -553,12 +553,6 @@
s32
rfcomm_module_init(void)
{
-#ifdef __KERNEL__
-#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
- init_waitqueue_head(&rfcomm_disconnect_wq);
-#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
-
return 0;
}
=20
@@ -607,6 +601,16 @@
rpn_val.xoff_u8 =3D 0x13;
memset(&rpn_val.pm, 0 , 2); /* Set the mask to zero */
=20=20=20=20=20=20=20=20=20
+ rfcomm_timer.inuse =3D 0;
+=20=20=20=20
+#ifdef __KERNEL__
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ init_waitqueue_head(&rfcomm_disconnect_wq);
+#else
+ rfcomm_disconnect_wq =3D NULL;
+#endif
+#endif /* __KERNEL__ */
+
#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
rfcomm_sec_man_init();
#endif
@@ -650,6 +654,9 @@
=20=20=20
DSYS("Shutting down RFCOMM\n");
=20
+ /* Make sure we don't have any outstanding timers */
+ release_wq_timer(&rfcomm_timer);
+
/* First try disconnecting */
for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
rfcomm_con *rfcomm =3D get_rfcomm_con(i);
@@ -667,7 +674,6 @@
for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
rfcomm_reset_con(i);
}
-
}
=20
/* This function creates an rfcomm connection over the control channel DCL=
I 0 */
@@ -778,6 +784,7 @@
/* FIXME -- check that we haven't already received=20
disconnect 'acknowledge' */
interruptible_sleep_on(&rfcomm_disconnect_wq);
+ release_wq_timer(&rfcomm_timer);
=20
/* Check that rfcomm session really disconnected */
/* FIXME -- add timer obj with status in rfcomm obj */
@@ -1181,7 +1188,6 @@
=20=09=09=09=09
/* this will take down l2cap aswell */
wake_up_interruptible(&rfcomm_disconnect_wq);
-=09=09=09=09
} else {
/* Data channel */
s32 tmp;
|