Commit 38b3fef1730319e2730af3fc9f73698e3a9aeb4a

Authored by Andrei Emeltchenko
Committed by Gustavo Padovan
1 parent b82c29d81d

Bluetooth: Improve debugging messages for hci_conn

Improve debugging of hci_conn objects by: adding print to hci_conn
refcounting, adding object spcifier when missing, change conn to hcon
since conn is heavily used for l2cap_conn objects and this is misleading.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Showing 2 changed files with 28 additions and 22 deletions Side-by-side Diff

include/net/bluetooth/hci_core.h
... ... @@ -587,12 +587,18 @@
587 587  
588 588 static inline void hci_conn_hold(struct hci_conn *conn)
589 589 {
  590 + BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt),
  591 + atomic_read(&conn->refcnt) + 1);
  592 +
590 593 atomic_inc(&conn->refcnt);
591 594 cancel_delayed_work(&conn->disc_work);
592 595 }
593 596  
594 597 static inline void hci_conn_put(struct hci_conn *conn)
595 598 {
  599 + BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt),
  600 + atomic_read(&conn->refcnt) - 1);
  601 +
596 602 if (atomic_dec_and_test(&conn->refcnt)) {
597 603 unsigned long timeo;
598 604 if (conn->type == ACL_LINK || conn->type == LE_LINK) {
net/bluetooth/hci_conn.c
... ... @@ -107,7 +107,7 @@
107 107 {
108 108 struct hci_cp_create_conn_cancel cp;
109 109  
110   - BT_DBG("%p", conn);
  110 + BT_DBG("hcon %p", conn);
111 111  
112 112 if (conn->hdev->hci_ver < BLUETOOTH_VER_1_2)
113 113 return;
... ... @@ -120,7 +120,7 @@
120 120 {
121 121 struct hci_cp_disconnect cp;
122 122  
123   - BT_DBG("%p", conn);
  123 + BT_DBG("hcon %p", conn);
124 124  
125 125 conn->state = BT_DISCONN;
126 126  
... ... @@ -134,7 +134,7 @@
134 134 struct hci_dev *hdev = conn->hdev;
135 135 struct hci_cp_add_sco cp;
136 136  
137   - BT_DBG("%p", conn);
  137 + BT_DBG("hcon %p", conn);
138 138  
139 139 conn->state = BT_CONNECT;
140 140 conn->out = true;
... ... @@ -152,7 +152,7 @@
152 152 struct hci_dev *hdev = conn->hdev;
153 153 struct hci_cp_setup_sync_conn cp;
154 154  
155   - BT_DBG("%p", conn);
  155 + BT_DBG("hcon %p", conn);
156 156  
157 157 conn->state = BT_CONNECT;
158 158 conn->out = true;
... ... @@ -196,7 +196,7 @@
196 196 struct hci_dev *hdev = conn->hdev;
197 197 struct hci_cp_le_start_enc cp;
198 198  
199   - BT_DBG("%p", conn);
  199 + BT_DBG("hcon %p", conn);
200 200  
201 201 memset(&cp, 0, sizeof(cp));
202 202  
203 203  
... ... @@ -213,11 +213,11 @@
213 213 {
214 214 struct hci_conn *sco = conn->link;
215 215  
216   - BT_DBG("%p", conn);
217   -
218 216 if (!sco)
219 217 return;
220 218  
  219 + BT_DBG("hcon %p", conn);
  220 +
221 221 if (!status) {
222 222 if (lmp_esco_capable(conn->hdev))
223 223 hci_setup_sync(sco, conn->handle);
... ... @@ -235,7 +235,7 @@
235 235 disc_work.work);
236 236 __u8 reason;
237 237  
238   - BT_DBG("conn %p state %s", conn, state_to_string(conn->state));
  238 + BT_DBG("hcon %p state %s", conn, state_to_string(conn->state));
239 239  
240 240 if (atomic_read(&conn->refcnt))
241 241 return;
... ... @@ -266,7 +266,7 @@
266 266 {
267 267 struct hci_dev *hdev = conn->hdev;
268 268  
269   - BT_DBG("conn %p mode %d", conn, conn->mode);
  269 + BT_DBG("hcon %p mode %d", conn, conn->mode);
270 270  
271 271 if (test_bit(HCI_RAW, &hdev->flags))
272 272 return;
... ... @@ -301,7 +301,7 @@
301 301 {
302 302 struct hci_conn *conn = (void *) arg;
303 303  
304   - BT_DBG("conn %p mode %d", conn, conn->mode);
  304 + BT_DBG("hcon %p mode %d", conn, conn->mode);
305 305  
306 306 hci_conn_enter_sniff_mode(conn);
307 307 }
... ... @@ -382,7 +382,7 @@
382 382 {
383 383 struct hci_dev *hdev = conn->hdev;
384 384  
385   - BT_DBG("%s conn %p handle %d", hdev->name, conn, conn->handle);
  385 + BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
386 386  
387 387 del_timer(&conn->idle_timer);
388 388  
... ... @@ -557,7 +557,7 @@
557 557 /* Check link security requirement */
558 558 int hci_conn_check_link_mode(struct hci_conn *conn)
559 559 {
560   - BT_DBG("conn %p", conn);
  560 + BT_DBG("hcon %p", conn);
561 561  
562 562 if (hci_conn_ssp_enabled(conn) && !(conn->link_mode & HCI_LM_ENCRYPT))
563 563 return 0;
... ... @@ -568,7 +568,7 @@
568 568 /* Authenticate remote device */
569 569 static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
570 570 {
571   - BT_DBG("conn %p", conn);
  571 + BT_DBG("hcon %p", conn);
572 572  
573 573 if (conn->pending_sec_level > sec_level)
574 574 sec_level = conn->pending_sec_level;
... ... @@ -602,7 +602,7 @@
602 602 /* Encrypt the the link */
603 603 static void hci_conn_encrypt(struct hci_conn *conn)
604 604 {
605   - BT_DBG("conn %p", conn);
  605 + BT_DBG("hcon %p", conn);
606 606  
607 607 if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) {
608 608 struct hci_cp_set_conn_encrypt cp;
... ... @@ -616,7 +616,7 @@
616 616 /* Enable security */
617 617 int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
618 618 {
619   - BT_DBG("conn %p", conn);
  619 + BT_DBG("hcon %p", conn);
620 620  
621 621 /* For sdp we don't need the link key. */
622 622 if (sec_level == BT_SECURITY_SDP)
... ... @@ -669,7 +669,7 @@
669 669 /* Check secure link requirement */
670 670 int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level)
671 671 {
672   - BT_DBG("conn %p", conn);
  672 + BT_DBG("hcon %p", conn);
673 673  
674 674 if (sec_level != BT_SECURITY_HIGH)
675 675 return 1; /* Accept if non-secure is required */
... ... @@ -684,7 +684,7 @@
684 684 /* Change link key */
685 685 int hci_conn_change_link_key(struct hci_conn *conn)
686 686 {
687   - BT_DBG("conn %p", conn);
  687 + BT_DBG("hcon %p", conn);
688 688  
689 689 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
690 690 struct hci_cp_change_conn_link_key cp;
... ... @@ -699,7 +699,7 @@
699 699 /* Switch role */
700 700 int hci_conn_switch_role(struct hci_conn *conn, __u8 role)
701 701 {
702   - BT_DBG("conn %p", conn);
  702 + BT_DBG("hcon %p", conn);
703 703  
704 704 if (!role && conn->link_mode & HCI_LM_MASTER)
705 705 return 1;
... ... @@ -720,7 +720,7 @@
720 720 {
721 721 struct hci_dev *hdev = conn->hdev;
722 722  
723   - BT_DBG("conn %p mode %d", conn, conn->mode);
  723 + BT_DBG("hcon %p mode %d", conn, conn->mode);
724 724  
725 725 if (test_bit(HCI_RAW, &hdev->flags))
726 726 return;
... ... @@ -894,7 +894,7 @@
894 894 struct hci_dev *hdev = conn->hdev;
895 895 struct hci_chan *chan;
896 896  
897   - BT_DBG("%s conn %p", hdev->name, conn);
  897 + BT_DBG("%s hcon %p", hdev->name, conn);
898 898  
899 899 chan = kzalloc(sizeof(struct hci_chan), GFP_KERNEL);
900 900 if (!chan)
... ... @@ -913,7 +913,7 @@
913 913 struct hci_conn *conn = chan->conn;
914 914 struct hci_dev *hdev = conn->hdev;
915 915  
916   - BT_DBG("%s conn %p chan %p", hdev->name, conn, chan);
  916 + BT_DBG("%s hcon %p chan %p", hdev->name, conn, chan);
917 917  
918 918 list_del_rcu(&chan->list);
919 919  
... ... @@ -929,7 +929,7 @@
929 929 {
930 930 struct hci_chan *chan, *n;
931 931  
932   - BT_DBG("conn %p", conn);
  932 + BT_DBG("hcon %p", conn);
933 933  
934 934 list_for_each_entry_safe(chan, n, &conn->chan_list, list)
935 935 hci_chan_del(chan);