shared/att: Fix not requeueing in the same channel
Luiz Augusto von Dentz
maintainerPATCH 1/5 shared/att: Fix not requeueing in the same channel
From: Luiz Augusto von Dentz <[email protected]>
If request needs to be resend due to change in the security use the chan->queue otherwise it may end up using a different channel.
--- src/shared/att.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/shared/att.c +2 -2
@@ -799,8 +799,8 @@ static bool handle_error_rsp(struct bt_att_chan *chan, uint8_t *pdu, chan->pending_req =NULL ; -/* Push operation back to request queue */ -return queue_push_head (att->req_queue, op); +/* Push operation back to channel queue */ +return queue_push_head (chan->queue, op); } static void handle_rsp(struct bt_att_chan *chan, uint8_t opcode, uint8_t *pdu,
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 2/5 shared/bap: Log error message if request cannot be sent
From: Luiz Augusto von Dentz <[email protected]>
This makes sure a error message is logged if a request cannot be sent for some reason.
--- src/shared/bap.c | 71 +++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 31 deletions(-)
src/shared/bap.c +40 -31
@@ -3397,9 +3397,13 @@ static bool bap_send(struct bt_bap *bap, struct bt_bap_req *req) };size_t i; +DBG (bap,"req %p" , req); +if (!gatt_db_attribute_get_char_data (ascs->ase_cp,NULL , &handle, -NULL ,NULL ,NULL )) +NULL ,NULL ,NULL )) { +DBG (bap,"Unable to find Control Point" );return false; + } hdr.op = req->op; hdr.num =1 +queue_length (req->group);
@@ -3416,12 +3420,41 @@ static bool bap_send(struct bt_bap *bap, struct bt_bap_req *req) ret =bt_gatt_client_write_without_response (bap->client, handle, false, iov.iov_base, iov.iov_len); -if (!ret) +if (!ret) { +DBG (bap,"Unable to Write to Control Point" );return false; + } bap->req = req; -return false; +return true; +} + +static void bap_req_complete (struct bt_bap_req *req, +const struct bt_ascs_ase_rsp *rsp) +{ +struct queue *group; + +if (!req->func) + goto done; + +if (rsp) + req->func (req->stream, rsp->code, rsp->reason, req->user_data); +else + req->func (req->stream,BT_ASCS_RSP_UNSPECIFIED ,0x00 , + req->user_data); + +done: +/* Detach from request so it can be freed separately */ + group = req->group; + req->group =NULL ; + +queue_foreach (group, (queue_foreach_func_t )bap_req_complete, + (void *)rsp); + +queue_destroy (group,NULL ); + +bap_req_free (req); }static bool bap_process_queue (void *data)
@@ -3429,14 +3462,17 @@ static bool bap_process_queue(void *data)struct bt_bap *bap = data;struct bt_bap_req *req; +DBG (bap,"" ); +if (bap->process_id) {timeout_remove (bap->process_id); bap->process_id =0 ; }while ((req =queue_pop_head (bap->reqs))) { -if (!bap_send (bap, req)) +if (bap_send (bap, req))break ; +bap_req_complete (req,NULL ); }return false;
@@ -3482,33 +3518,6 @@ static bool bap_queue_req(struct bt_bap *bap, struct bt_bap_req *req)return true; } -static void bap_req_complete (struct bt_bap_req *req, -const struct bt_ascs_ase_rsp *rsp) -{ -struct queue *group; - -if (!req->func) - goto done; - -if (rsp) - req->func (req->stream, rsp->code, rsp->reason, req->user_data); -else - req->func (req->stream,BT_ASCS_RSP_UNSPECIFIED ,0x00 , - req->user_data); - -done: -/* Detach from request so it can be freed separately */ - group = req->group; - req->group =NULL ; - -queue_foreach (group, (queue_foreach_func_t )bap_req_complete, - (void *)rsp); - -queue_destroy (group,NULL ); - -bap_req_free (req); -} -static void bap_cp_notify (struct bt_bap *bap,uint16_t value_handle,const uint8_t *value,uint16_t length,void *user_data)
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 3/5 shared/bap: Read PAC Sink/Source if respective location is found
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
If PAC Sink/Source has been found but not record has been recovered it means an error must have occured so this attempt to read the records once again.
--- src/shared/bap.c | 146 +++++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 63 deletions(-)
src/shared/bap.c +83 -63
@@ -2837,69 +2837,6 @@ static void read_sink_pac(struct bt_bap *bap, bool success, uint8_t att_ecode,bap_parse_pacs (bap,BT_BAP_SINK , bap->rdb->sinks, value, length); } -static void read_source_pac_loc (struct bt_bap *bap,bool success, -uint8_t att_ecode,const uint8_t *value, -uint16_t length,void *user_data) -{ -struct bt_pacs *pacs =bap_get_pacs (bap); - -if (!success) { -DBG (bap,"Unable to read Source PAC Location: error 0x%02x" , - att_ecode); -return ; - } - -gatt_db_attribute_write (pacs->source_loc,0 , value, length,0 ,NULL , -NULL ,NULL ); -} - -static void read_sink_pac_loc (struct bt_bap *bap,bool success, -uint8_t att_ecode,const uint8_t *value, -uint16_t length,void *user_data) -{ -struct bt_pacs *pacs =bap_get_pacs (bap); - -if (!success) { -DBG (bap,"Unable to read Sink PAC Location: error 0x%02x" , - att_ecode); -return ; - } - -gatt_db_attribute_write (pacs->sink_loc,0 , value, length,0 ,NULL , -NULL ,NULL ); -} - -static void read_pac_context (struct bt_bap *bap,bool success, -uint8_t att_ecode,const uint8_t *value, -uint16_t length,void *user_data) -{ -struct bt_pacs *pacs =bap_get_pacs (bap); - -if (!success) { -DBG (bap,"Unable to read PAC Context: error 0x%02x" , att_ecode); -return ; - } - -gatt_db_attribute_write (pacs->context,0 , value, length,0 ,NULL , -NULL ,NULL ); -} - -static void read_pac_supported_context (struct bt_bap *bap,bool success, -uint8_t att_ecode,const uint8_t *value, -uint16_t length,void *user_data) -{ -struct bt_pacs *pacs =bap_get_pacs (bap); - -if (!success) { -DBG (bap,"Unable to read PAC Supproted Context: error 0x%02x" , - att_ecode); -return ; - } - -gatt_db_attribute_write (pacs->supported_context,0 , value, length,0 , -NULL ,NULL ,NULL ); -} -static void bap_pending_destroy (void *data) {struct bt_bap_pending *pending = data;
@@ -2944,6 +2881,89 @@ static void bap_read_value(struct bt_bap *bap, uint16_t value_handle,queue_push_tail (bap->pending, pending); } +static void read_source_pac_loc (struct bt_bap *bap,bool success, +uint8_t att_ecode,const uint8_t *value, +uint16_t length,void *user_data) +{ +struct bt_pacs *pacs =bap_get_pacs (bap); + +if (!success) { +DBG (bap,"Unable to read Source PAC Location: error 0x%02x" , + att_ecode); +return ; + } + +gatt_db_attribute_write (pacs->source_loc,0 , value, length,0 ,NULL , +NULL ,NULL ); + +/* Resume reading sinks if supported but for some reason is empty */ +if (pacs->source &&queue_isempty (bap->rdb->sources)) { +uint16_t value_handle; + +if (gatt_db_attribute_get_char_data (pacs->source, +NULL , &value_handle, +NULL ,NULL ,NULL )) +bap_read_value (bap, value_handle, read_source_pac, bap); + } +} + +static void read_sink_pac_loc (struct bt_bap *bap,bool success, +uint8_t att_ecode,const uint8_t *value, +uint16_t length,void *user_data) +{ +struct bt_pacs *pacs =bap_get_pacs (bap); + +if (!success) { +DBG (bap,"Unable to read Sink PAC Location: error 0x%02x" , + att_ecode); +return ; + } + +gatt_db_attribute_write (pacs->sink_loc,0 , value, length,0 ,NULL , +NULL ,NULL ); + +/* Resume reading sinks if supported but for some reason is empty */ +if (pacs->sink &&queue_isempty (bap->rdb->sinks)) { +uint16_t value_handle; + +if (gatt_db_attribute_get_char_data (pacs->sink, +NULL , &value_handle, +NULL ,NULL ,NULL )) +bap_read_value (bap, value_handle, read_sink_pac, bap); + } +} + +static void read_pac_context (struct bt_bap *bap,bool success, +uint8_t att_ecode,const uint8_t *value, +uint16_t length,void *user_data) +{ +struct bt_pacs *pacs =bap_get_pacs (bap); + +if (!success) { +DBG (bap,"Unable to read PAC Context: error 0x%02x" , att_ecode); +return ; + } + +gatt_db_attribute_write (pacs->context,0 , value, length,0 ,NULL , +NULL ,NULL ); +} + +static void read_pac_supported_context (struct bt_bap *bap,bool success, +uint8_t att_ecode,const uint8_t *value, +uint16_t length,void *user_data) +{ +struct bt_pacs *pacs =bap_get_pacs (bap); + +if (!success) { +DBG (bap,"Unable to read PAC Supproted Context: error 0x%02x" , + att_ecode); +return ; + } + +gatt_db_attribute_write (pacs->supported_context,0 , value, length,0 , +NULL ,NULL ,NULL ); +} +static void foreach_pacs_char (struct gatt_db_attribute *attr,void *user_data) {struct bt_bap *bap = user_data;
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 4/5 shared/gatt-db: Allow passing NULL to gatt_db_attribute_write
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This makes gatt_db_attribute_write to accept NULL as a func when storing directly on the db itself.
--- src/shared/gatt-db.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
src/shared/gatt-db.c +3 -2
@@ -2095,7 +2095,7 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, {uint8_t err =0 ; -if (!attrib || !func) +if (!attrib || (!func && attrib->write_func))return false;if (attrib->write_func) {
@@ -2158,7 +2158,8 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,memcpy (&attrib->value[offset], value, len); done: -func (attrib, err, user_data); +if (func) +func (attrib, err, user_data);return true; }
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 5/5 shared/bap: Make bt_bap_pac_register to be per session
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This makes bt_bap_pac_register to be per session rather than global so the callback don't have to match the session by itself.
--- profiles/audio/bap.c | 6 ++-- src/shared/bap.c | 66 +++++++++++++++++++++++++------------------- src/shared/bap.h | 11 ++++---- 3 files changed, 45 insertions(+), 38 deletions(-)
profiles/audio/bap.c +3 -3
@@ -120,7 +120,7 @@ static void bap_data_free(struct bap_data *data)queue_destroy (data->streams,NULL );bt_bap_ready_unregister (data->bap, data->ready_id);bt_bap_state_unregister (data->bap, data->state_id); -bt_bap_pac_unregister (data->pac_id); +bt_bap_pac_unregister (data->bap, data->pac_id);bt_bap_unref (data->bap);free (data); }
@@ -1265,8 +1265,8 @@ static int bap_probe(struct btd_service *service) NULL); data->state_id =bt_bap_state_register (data->bap, bap_state, bap_connecting, data,NULL ); - data->pac_id =bt_bap_pac_register (pac_added, pac_removed, service, -NULL ); + data->pac_id =bt_bap_pac_register (data->bap, pac_added, pac_removed, + service,NULL );bt_bap_set_user_data (data->bap, service);
src/shared/bap.c +37 -29
157 lines not on this page · raw message
src/shared/bap.h +5 -6
@@ -87,12 +87,6 @@ typedef void (*bt_bap_stream_func_t)(struct bt_bap_stream *stream,typedef void (*bt_bap_func_t )(struct bt_bap *bap,void *user_data);/* Local PAC related functions */ - -unsigned int bt_bap_pac_register (bt_bap_pac_func_t added, -bt_bap_pac_func_t removed,void *user_data, -bt_bap_destroy_func_t destroy); -bool bt_bap_pac_unregister (unsigned int id); -struct bt_bap_pac_qos {uint8_t framing;uint8_t phy;
@@ -161,6 +155,11 @@ bool bt_bap_set_debug(struct bt_bap *bap, bt_bap_debug_func_t cb,bool bap_print_cc (void *data,size_t len,util_debug_func_t func,void *user_data); +unsigned int bt_bap_pac_register (struct bt_bap *bap,bt_bap_pac_func_t added, +bt_bap_pac_func_t removed,void *user_data, +bt_bap_destroy_func_t destroy); +bool bt_bap_pac_unregister (struct bt_bap *bap,unsigned int id); +unsigned int bt_bap_ready_register (struct bt_bap *bap,bt_bap_ready_func_t func,void *user_data,bt_bap_destroy_func_t destroy);
Signature · 1 line
2.37.3
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=703146
---Test result---
Test Summary:
CheckPatch FAIL 2.52 seconds GitLint PASS 1.41 seconds BuildEll PASS 27.40 seconds BluezMake PASS 1009.44 seconds MakeCheck PASS 11.49 seconds MakeDistcheck PASS 149.64 seconds CheckValgrind PASS 248.26 seconds bluezmakeextell PASS 97.45 seconds IncrementalBuild PASS 4456.90 seconds ScanBuild PASS 1048.52 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,3/5] shared/bap: Read PAC Sink/Source if respective location is found WARNING:TYPO_SPELLING: 'occured' may be misspelled - perhaps 'occurred'? #86:
means an error must have occured so this attempt to read the records
^^^^^^^
/github/workspace/src/src/13069110.patch total: 0 errors, 1 warnings, 158 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13069110.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 7 lines · On Thu, 8 Dec 2022 17:03:10 -0800 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
If request needs to be resend due to change in the security use the
chan->queueotherwise it may end up using a different channel.--- src/shared/att.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Here is the summary with links:
- [BlueZ,1/5] shared/att: Fix not requeueing in the same channel
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f8670f9aa0a0 - [BlueZ,2/5] shared/bap: Log error message if request cannot be sent https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6b5b51392312 - [BlueZ,3/5] shared/bap: Read PAC Sink/Source if respective location is found (no matching commit) - [BlueZ,4/5] shared/gatt-db: Allow passing NULL to gatt_db_attribute_write https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=be9fc9222c03
- [BlueZ,5/5] shared/bap: Make bt_bap_pac_register to be per session (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html