Revert "Bluetooth: Store advertising handle so it can be re-enabled" 86/292886/1 accepted/tizen/unified/20230517.080114
authorAnuj Jain <anuj01.jain@samsung.com>
Tue, 16 May 2023 13:55:19 +0000 (19:25 +0530)
committerAnuj Jain <anuj01.jain@samsung.com>
Tue, 16 May 2023 13:55:19 +0000 (19:25 +0530)
This reverts commit 7087c4f69487f017722df7d299ef9b7709996b79.

Patch revert is needed as it is the cause for GATT Server TCT fail.

Change-Id: I55bedbb6b0d44058c13ac06df121c5d936611c74
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c

index 44bd0b5..f9dcd5d 100644 (file)
@@ -646,7 +646,6 @@ struct hci_conn {
        __u8            init_addr_type;
        bdaddr_t        resp_addr;
        __u8            resp_addr_type;
-       __u8            adv_instance;
        __u16           handle;
        __u16           state;
        __u8            mode;
index 93792f3..0bc65c3 100644 (file)
@@ -2543,20 +2543,19 @@ static void hci_cs_disconnect(struct hci_dev *hdev, u8 status)
 
        conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
        if (conn) {
+               u8 type = conn->type;
+
                mgmt_disconnect_failed(hdev, &conn->dst, conn->type,
                                       conn->dst_type, status);
 
-               if (conn->type == LE_LINK) {
-                       hdev->cur_adv_instance = conn->adv_instance;
-                       hci_req_reenable_advertising(hdev);
-               }
-
                /* If the disconnection failed for any reason, the upper layer
                 * does not retry to disconnect in current implementation.
                 * Hence, we need to do some basic cleanup here and re-enable
                 * advertising if necessary.
                 */
                hci_conn_del(conn);
+               if (type == LE_LINK)
+                       hci_req_reenable_advertising(hdev);
        }
 
        hci_dev_unlock(hdev);
@@ -3104,6 +3103,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
        struct hci_conn_params *params;
        struct hci_conn *conn;
        bool mgmt_connected;
+       u8 type;
 
        BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
 
@@ -3158,7 +3158,10 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                }
        }
 
+       type = conn->type;
+
        hci_disconn_cfm(conn, ev->reason);
+       hci_conn_del(conn);
 
        /* The suspend notifier is waiting for all devices to disconnect so
         * clear the bit from pending tasks and inform the wait queue.
@@ -3178,12 +3181,8 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
         * or until a connection is created or until the Advertising
         * is timed out due to Directed Advertising."
         */
-       if (conn->type == LE_LINK) {
-               hdev->cur_adv_instance = conn->adv_instance;
+       if (type == LE_LINK)
                hci_req_reenable_advertising(hdev);
-       }
-
-       hci_conn_del(conn);
 
 #ifdef TIZEN_BT
        if (conn->type == ACL_LINK && !hci_conn_num(hdev, ACL_LINK)) {
@@ -5604,13 +5603,6 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
        conn->handle = handle;
        conn->state = BT_CONFIG;
 
-       /* Store current advertising instance as connection advertising instance
-        * when sotfware rotation is in use so it can be re-enabled when
-        * disconnected.
-        */
-       if (!ext_adv_capable(hdev))
-               conn->adv_instance = hdev->cur_adv_instance;
-
        conn->le_conn_interval = interval;
        conn->le_conn_latency = latency;
        conn->le_supv_timeout = supervision_timeout;
@@ -5694,13 +5686,13 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
        struct hci_evt_le_ext_adv_set_term *ev = (void *) skb->data;
        struct hci_conn *conn;
-       struct adv_info *adv;
 
        BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
 
-       adv = hci_find_adv_instance(hdev, ev->handle);
-
        if (ev->status) {
+               struct adv_info *adv;
+
+               adv = hci_find_adv_instance(hdev, ev->handle);
                if (!adv)
                        return;
 
@@ -5711,15 +5703,9 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
                return;
        }
 
-       if (adv)
-               adv->enabled = false;
-
        conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->conn_handle));
        if (conn) {
-               /* Store handle in the connection so the correct advertising
-                * instance can be re-enabled when disconnected.
-                */
-               conn->adv_instance = ev->handle;
+               struct adv_info *adv_instance;
 
                if (hdev->adv_addr_type != ADDR_LE_DEV_RANDOM ||
                    bacmp(&conn->resp_addr, BDADDR_ANY))
@@ -5730,8 +5716,9 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
                        return;
                }
 
-               if (adv)
-                       bacpy(&conn->resp_addr, &adv->random_addr);
+               adv_instance = hci_find_adv_instance(hdev, ev->handle);
+               if (adv_instance)
+                       bacpy(&conn->resp_addr, &adv_instance->random_addr);
        }
 }