From patchwork Thu Nov 5 06:40:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 317916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 841CAC00A89 for ; Thu, 5 Nov 2020 06:40:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F72920936 for ; Thu, 5 Nov 2020 06:40:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GSZRtBDW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725320AbgKEGkr (ORCPT ); Thu, 5 Nov 2020 01:40:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgKEGkq (ORCPT ); Thu, 5 Nov 2020 01:40:46 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B25A9C0613CF for ; Wed, 4 Nov 2020 22:40:46 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id e23so357088qkm.20 for ; Wed, 04 Nov 2020 22:40:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=cHsyr7+Xnk8MKrJWSSQ723ouixQm4NmMA4sk4MHmrho=; b=GSZRtBDW14qaToV1YmetfSClAs4smDFliKdolHW16bZyuukhCbqJxdF0cvqJc7zxO7 anjZPn8eIVFahDDTjFhPAfzpVYA89b/PE+H8hcuPmEqlYWHMkuupS5NPzTpdsPIpty1N Wh575HPdTvPwpXKO1BUSOb7jiIpt2uXFPr8zebXZqjj5ehWxUc+BizKvfhWg1Hz4Giuy Tm8RcGpApsbyAOYcoTr64LZMeRgFPSv7IayW01jm0Ts2HKQbo5VixpUbreVrXgs/mkGH TeGUQnoTQo3mQe2HpEj8byo6tMNZRL9evWw420faNPNXyy5YzvYagmCGeA4R9/1Q/+/Z Bi2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=cHsyr7+Xnk8MKrJWSSQ723ouixQm4NmMA4sk4MHmrho=; b=P+dWZ1fvzqAD4276WN08sR2kW+R4F0teM9ZBhCZtuo9WkeJCWt4VQZfsBHXZjT/sQz 6syrJPlAjS1gfnq5XOvCHeUFCmvDWKrAB6D4AMa7wFRdOvprCOHJqY7lwatZmVKEJn8k WDh4DLzXI0RfecIMRWB28r17z/uOTBdoDkLkvWzxfGWayeBYWlbms1QP/F0detdh86HB rnd5RLz8HC4LbY7Ww8J8Gj4RwEs+FGlKA8REzrB6D2rY9hoFDT6GuUyDl6oHGtPpKev8 FdoFAG288XAd0D9pQJX7zx5CTHEkUzK2YEY30l6ofjiYitRgQ6EVJtDfJOIeuQFtIZXk 55VA== X-Gm-Message-State: AOAM532xmsZj8tZgU1Hwgq86HvaYdJMebPEBSbXyk6rzJ4elDEt9FyND cgA74ZHmQNh/Icm4UCiaDFJm+RgI39XpVe+NIIIHwXGb2+wOml9coPlHWfwwBwYqkvTApnpRlJc PZaNKtuU34j3126SaNnMOluKOP652CpSkB3Q2+5AST61HxCVdx6gMKCNyIcwB9cPvPv/KcZeut2 4V X-Google-Smtp-Source: ABdhPJxH3WC6Ab8N3IEb1KxMrppmG99SpIzzwODoG7VUFrmcluACHHZYGbTdkfHs7j1HuZl2cXqd0c2JUoOw Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:ad4:46ca:: with SMTP id g10mr1087040qvw.2.1604558445699; Wed, 04 Nov 2020 22:40:45 -0800 (PST) Date: Thu, 5 Nov 2020 14:40:32 +0800 Message-Id: <20201105144005.Bluez.v3.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v3 1/3] service: add adapter powered check before connecting From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka When policy_connect() is called, there might be a case where the power is just turned off, hence the adapter is down. Add a check in btd_service_connect to detect such condition. --- Changes in v3: * Update the commit message to reflect changes in v2. Changes in v2: * Add adapter status check in btd_service_connect() instead of using btd_device_connect_services() src/service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/service.c b/src/service.c index d810fc3b05..21a52762e6 100644 --- a/src/service.c +++ b/src/service.c @@ -229,6 +229,9 @@ int btd_service_connect(struct btd_service *service) if (!profile->connect) return -ENOTSUP; + if (!btd_adapter_get_powered(device_get_adapter(service->device))) + return -ENETDOWN; + switch (service->state) { case BTD_SERVICE_STATE_UNAVAILABLE: return -EINVAL; From patchwork Thu Nov 5 06:40:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 319434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B3F0C00A89 for ; Thu, 5 Nov 2020 06:40:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37DF02071A for ; Thu, 5 Nov 2020 06:40:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZtgOVjdm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725861AbgKEGkw (ORCPT ); Thu, 5 Nov 2020 01:40:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgKEGkw (ORCPT ); Thu, 5 Nov 2020 01:40:52 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33BC2C0613CF for ; Wed, 4 Nov 2020 22:40:52 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id t12so605190pgv.0 for ; Wed, 04 Nov 2020 22:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=AiMlLJgHixAXDnCP8ZY72ZbeqLVurDL36FqDlebGM/8=; b=ZtgOVjdmQI26kRDYKIW5vRBGW7JwgkwfgDLSjII5ASh2mQoV67Md74IOQdrQuJIKPD THobIf2oZ7HQfn4GoHEgNym7e11H3B1WpD4F7hu5NcMqtX7uWvMPp41f07trq+6VAGhF G8AiMpOd1F4Tc4lBJFHanq71z5Aa/SOKF0xV32jM2wJhLyv+Wr7vJWQ7BlTAcMHwqnli inPJVlXq17pnXug1FctdquHXnQinkFKmMWos0A/51AYjpSa84K3j3iwuiYmkVwlTC8/n 79r6ExuygRCTNUGzdu/fnnC4lwq7FJF9T01mEUAB2wiQrmcN7uJeH4utVJKN8fArm0tj Dy8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AiMlLJgHixAXDnCP8ZY72ZbeqLVurDL36FqDlebGM/8=; b=VR1wdaIm1a2u2mydLkUJVkdbG6sxaK2p8R/XpbSNwI4O0uJyDHihu8pfOa0XwtBmzG jK/51Au8o1kAwCnQibMKIW356QVhFqW4EXl1V6QnNTHzlQvfcZzNsk9QDRGbrYIjYbBc BtOgMo6E5XXluQGpnJiRWQJ9SFpg83pYTIb7G0Emt8Y/kXL6oLzSC+zABxXGT26sckpf Y5lSAsox279ScGviWj5yZt9wWhyqB4LOkD22Pr9WBWyCnR9FcWSskTwVOI1bQUJao/pv KjrkViT2KbLjU9PPn5UliQsiJyfsDtqKHNjMRRaswTpizR1Y6BAGYI/5cf5A8DmYtrx3 Ovgg== X-Gm-Message-State: AOAM531BLu1As+hNBFCNTzQLIEFFbrer04g4nQhvXiEfiJBnDoHSXyNS Zqc1SbrBek6mpToPUYT4u9D8u7yrh6HRZMOVIcv8MgHloFecP2+l7ZYKtEKAgk7/j3DD/vk787z qMCVG6JQT+Q66hibMPa7Xbg9EenGUXEr0wdFpS1j5yjigTeNFI6vCj//Krh8ufwVoGhk7ey4iRZ 50 X-Google-Smtp-Source: ABdhPJzQOKLk4bdAPbeoNNYbZWRLSk+HTZFwyFoj/A/GF/3Pbbmwl3NpBh5W0jRJBY1+UeQWeQJtSdKbmXDZ Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a17:902:7c14:b029:d4:d894:7eed with SMTP id x20-20020a1709027c14b02900d4d8947eedmr625745pll.81.1604558451568; Wed, 04 Nov 2020 22:40:51 -0800 (PST) Date: Thu, 5 Nov 2020 14:40:33 +0800 In-Reply-To: <20201105144005.Bluez.v3.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> Message-Id: <20201105144005.Bluez.v3.2.I4c872b9b8fdee53a335db41acbb6e59fe9692cc5@changeid> Mime-Version: 1.0 References: <20201105144005.Bluez.v3.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v3 2/3] audio: unref session when failed to setup From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka There is a possibility to miss unref-ing when source/sink fails at setup. Reviewed-by: Sonny Sasaka --- (no changes since v1) profiles/audio/sink.c | 5 ++++- profiles/audio/source.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c index 134d157bc6..d672670e25 100644 --- a/profiles/audio/sink.c +++ b/profiles/audio/sink.c @@ -258,8 +258,11 @@ gboolean sink_setup_stream(struct btd_service *service, struct avdtp *session) sink->connect_id = a2dp_discover(sink->session, discovery_complete, sink); - if (sink->connect_id == 0) + if (sink->connect_id == 0) { + avdtp_unref(sink->session); + sink->session = NULL; return FALSE; + } return TRUE; } diff --git a/profiles/audio/source.c b/profiles/audio/source.c index fca85d4cb3..c706c928a7 100644 --- a/profiles/audio/source.c +++ b/profiles/audio/source.c @@ -259,8 +259,11 @@ gboolean source_setup_stream(struct btd_service *service, source->connect_id = a2dp_discover(source->session, discovery_complete, source); - if (source->connect_id == 0) + if (source->connect_id == 0) { + avdtp_unref(source->session); + source->session = NULL; return FALSE; + } return TRUE; } From patchwork Thu Nov 5 06:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 317915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69871C00A89 for ; Thu, 5 Nov 2020 06:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0057420936 for ; Thu, 5 Nov 2020 06:41:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VzK40psF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726152AbgKEGlB (ORCPT ); Thu, 5 Nov 2020 01:41:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725294AbgKEGlB (ORCPT ); Thu, 5 Nov 2020 01:41:01 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB317C0613CF for ; Wed, 4 Nov 2020 22:41:00 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id y11so510094ybm.22 for ; Wed, 04 Nov 2020 22:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=3uB46e4wAC56usX3WUKxk/x85EKQRpS+HGXlr+AFs78=; b=VzK40psFTw4avCkuhImx9RcW9zF5NGk/KKytrYCbLQrjrzOWa4Sj7UdKPsp+0Pyk3H H+QQ1pO57GHs5ZTc9KY7wT7NJhEBXEGI1oFfwZkOPN3p8nyGGdi4Onz2CvXaEhjXvG2o i1iVdfG4zLuwYBtBDtwcxLBUtH8jtXKtW8j6PUnHaTAPDBQv7nB9KT/CYBUSybCytWdS 5R1rMSNVZKV1IDWfag4D7nY8gt99IdiLcu7cuqfl4YbmQxoTdOq0BqsHDUAxw8GlI/p8 AKHxXgoKEnAS0lRAGDQl1Ks8aC/Hk5zHOQGXHf/qiBQRHHjIv3VUtPWjeCUB2j6H2OIa dThA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3uB46e4wAC56usX3WUKxk/x85EKQRpS+HGXlr+AFs78=; b=sultUFF06lIJKiNagboGG4M54Bj2+qXT3piSSEoSUQee9j0TykBUJbJL8L/Lm1sKXc 9pbktB9XbJeP+eP+Oq1KxB7erU0tyd/rlOBgKUN6qmGw3nu2mETrBIK9POtN2uBeO+8O W8oyoaE7/jyLa3YKQ66HwLSUTJpxxG1sP2Z3RBKZr/AehZCBP6woFvi5ctsogkk5Mooq vSGFa8gmnOh1V83sKwX0EtwvK2yxfSYGdrIlgugkY7OT1djy7vtKxGY71KPyh6DoQoUI FENIJy7H8C2e6bsJTx0LuJJ7INglyp9QkLdPFSxCofW+d+o0u8Ho/eMB4ULpzeX65hI6 m7MQ== X-Gm-Message-State: AOAM5308SC8E3ze+u2WeRgou2P+9MrpvqH2Z+8sT6HcFenCnOGT73NcG J2s18Ynx26ScxXHIjwL0cbQ3y9jRUfvi9Lzyncv+zwlMnV/JX1qpsTlP0wIMkg1v6I5gVdGzdup YGlw2zUKd5a3yL4Os7kE5UmegRXxS8/AcfDmKL1qD1fycTTwVojwczTyNl+yPsRXNeR0RAhVfbV nS X-Google-Smtp-Source: ABdhPJxZufL0FLCa1nP94j0R0ReBVMs1StU4nvuPshLa7IpMwPPeAjel2pxxN/1ipfCuCSQdF9VTXUUWYCXh Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a25:7444:: with SMTP id p65mr1547915ybc.57.1604558460074; Wed, 04 Nov 2020 22:41:00 -0800 (PST) Date: Thu, 5 Nov 2020 14:40:34 +0800 In-Reply-To: <20201105144005.Bluez.v3.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> Message-Id: <20201105144005.Bluez.v3.3.Ib69ea31cb69840b941b725a1d889473c5e6cac97@changeid> Mime-Version: 1.0 References: <20201105144005.Bluez.v3.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v3 3/3] audio/avdtp: Report failure in disconnected state From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka A2DP are relying on the disconnected state callback to do cleanup. If failure occurs when AVDTP are already in the disconnected state, we didn't make any transition state, therefore A2DP would miss this event. This patch allows the transition to disconnected state, even though we are previously already in the disconnected state. Reviewed-by: Sonny Sasaka --- (no changes since v1) profiles/audio/avdtp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 4c39088b8f..16fa20bba7 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2612,6 +2612,11 @@ static int send_req(struct avdtp *session, gboolean priority, if (session->state == AVDTP_SESSION_STATE_DISCONNECTED) { session->io = l2cap_connect(session); if (!session->io) { + /* Report disconnection anyways, as the other layers + * are using this state for cleanup. + */ + avdtp_set_state(session, + AVDTP_SESSION_STATE_DISCONNECTED); err = -EIO; goto failed; }