From patchwork Tue Feb 16 23:33:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 384009 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 5459BC433DB for ; Tue, 16 Feb 2021 23:34:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B92E64E10 for ; Tue, 16 Feb 2021 23:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbhBPXeV (ORCPT ); Tue, 16 Feb 2021 18:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbhBPXeU (ORCPT ); Tue, 16 Feb 2021 18:34:20 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FCCEC061574 for ; Tue, 16 Feb 2021 15:33:40 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id t29so7177480pfg.11 for ; Tue, 16 Feb 2021 15:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=McBDHmfkfwbeBj/qAUK5UpWvbsYXc1zDEYxrt+U7x6s=; b=MP1MX2KvM5iRmDte6BSi5gnm8lPjuoj2qkkynbp17ijG+kE1PFqly7JgLUyqQhe5ZQ 8JWwXB/lFCvh6Cc6TWS2ewyxpx0m/8E+Ib+LiSYlhGQ4dfdHq5uz1wUYsdaEh6g5p+JN +wlSXLhP+AmE3LppfeQuvHZ3zXBmdnMkGaId+7qyaELho9Qm1e0QKLjfU/YBvhTOgBC1 gzIvbuwmkUwT7nmiHtNzM/o/VeOnWmmthubmSdDp01GCIDPszR62w0wN78yG+5IhgZT0 GiS0R/PLlxQxSboh4sl+N5w7a7wD5CdZmf8DohjfAdNqVKXbEMg6FnKITjbAYmo4U+in tG4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=McBDHmfkfwbeBj/qAUK5UpWvbsYXc1zDEYxrt+U7x6s=; b=i8S9IB+cFnbk8l0/AaS/L7eQ/udx7nSvSL6nVpPdEXWRCoeejDaw/8PJdp+wzjnT+r RWBHRr1uNC0d8n4KqQRW7fy9kFynN8ap3acAd50/LwodYKk8cP7rtoR+vUm0hEvSHkPm zas1gkbLD5bztpoRZqPrJALhr+ppGT0w6C3Z3J9MqVGukE3934SldiwcHTGQH6JquRLk zVG7lHlf/XL+XDxa5wc0kAQxzymnS/OnDYLgchduhyTTnlai+PBn/4U/QqmzEEdAy9g0 e2ktTM8OT3eTzDPUloFF2SmTBToKHMbwwSc3F2P5ZxWLbjWCr7bCm5lbyI4PfZaVrXtJ arcg== X-Gm-Message-State: AOAM530BFO5/na5Q3KRSpddiRAle4Q0J+GX3feMzOWCvNh4uKUqDaaBs m6uh7/omlxDyQc5LDZBRT5bX11EQ8LtbGA== X-Google-Smtp-Source: ABdhPJyJVu/4IHoWrndIixjJmYUzCvXnu7oLLLdxUQZf45XhXdtc9m4vQmtHcsT5WRnkPbrgE5BaLQ== X-Received: by 2002:a63:1826:: with SMTP id y38mr21258223pgl.252.1613518418917; Tue, 16 Feb 2021 15:33:38 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id h5sm99956pgv.87.2021.02.16.15.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 15:33:38 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/3] avdtp: Fix setting disconnect timer when there is no local endpoints Date: Tue, 16 Feb 2021 15:33:35 -0800 Message-Id: <20210216233337.859955-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz If there are not local endpoints left there is no point in starting the disconnect timer as without any endpoint it is not possible to configure streams anymore so the code should proceed to disconnect immediately. --- profiles/audio/avdtp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index fa72ef66a..9ddcd6464 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1226,7 +1226,13 @@ void avdtp_unref(struct avdtp *session) switch (session->state) { case AVDTP_SESSION_STATE_CONNECTED: - set_disconnect_timer(session); + /* Only set disconnect timer if there are local endpoints + * otherwise disconnect immediately. + */ + if (queue_isempty(session->lseps)) + connection_lost(session, ECONNRESET); + else + set_disconnect_timer(session); break; case AVDTP_SESSION_STATE_CONNECTING: connection_lost(session, ECONNABORTED); From patchwork Tue Feb 16 23:33:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 384008 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 73630C433E6 for ; Tue, 16 Feb 2021 23:34:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4475E64EAD for ; Tue, 16 Feb 2021 23:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbhBPXeV (ORCPT ); Tue, 16 Feb 2021 18:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbhBPXeU (ORCPT ); Tue, 16 Feb 2021 18:34:20 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825E2C06174A for ; Tue, 16 Feb 2021 15:33:40 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id b8so6360110plh.12 for ; Tue, 16 Feb 2021 15:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NV4mCh1O2tdKISHhIpj/kqto2I7ZrYdJg+KpJgpm6q8=; b=NOwdCgmhcyWap+LCGyhSvYKKjsIu/chKFvvKLk7MqS75z8qDreMtrWMqSePyAq/psO Mo6JGjfDHejq4mP5J0rZHj6/JPZko6eMOat54fXFMXatKX06T25KXq01BocfK/bHMEu7 XssKiUOEioF6JDjbxF7Im1SEbEDKgcutgQENC0G52vM9EVUTUWS8WSS7Dp0rXMVS9gtp HA1zzi1K9oPHE/vPSth/S0AjJErhid1yjasMf8PxgP4pPzBD6I1HRgOS8FpH8Kz8gLus KUxTtkSoSkpnXVP/r8FSxVFtNUeitEjr8TPeQGXgyvhnTP5mtjOUqF5Rz8SlMnChwD5x Ts1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NV4mCh1O2tdKISHhIpj/kqto2I7ZrYdJg+KpJgpm6q8=; b=ovp0b9FbPIvu3+NgRCSYUiB2uR149mACmvQqtrA5xdOc1S2ExvZtdkVivisAoT+mQ+ LrBbRfQt8xJp+avAKUXWcU3unIkZZn1D6dS7L1OAP1FQ2Wq033lYvNIOgzx6U8EdEkLE Y2V6tQqld/n6vxRqoX8j2BAkvm42rbDMhmfmc7CLnnaNcJhZDCYtm//5pVurpoL65h05 qp8J1H8WfyUQk2/iolCIfCBwWJgeeODl4Geybn0H53G2rQFxzTHRxnB1pHAP9KJXPNqT IVzFv/ZqwT1lWuhteLd65Cf0mkElmPF9bG4OME9XYCc1MCv22PvOdCjulM27Bl/rqWpQ 4w5Q== X-Gm-Message-State: AOAM530sAjmBAvi7ZtymajLWE8cHkaRk8mT2i27/xJDXb0FQOBBHUw/2 ITp+hQk7JG9e/jwkooCTe0kZCCscx8yyxw== X-Google-Smtp-Source: ABdhPJykyiN1JX04dBw44ZSS0LTC7dDQ4OdBNlyb3F4lixLQUj7UWSwZfI/9eTYFrRqDqc1u8FGV/g== X-Received: by 2002:a17:90a:f981:: with SMTP id cq1mr6193589pjb.167.1613518419792; Tue, 16 Feb 2021 15:33:39 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id h5sm99956pgv.87.2021.02.16.15.33.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 15:33:39 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/3] btio: Use G_PRIORITY_HIGH for watches Date: Tue, 16 Feb 2021 15:33:36 -0800 Message-Id: <20210216233337.859955-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210216233337.859955-1-luiz.dentz@gmail.com> References: <20210216233337.859955-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes btio watches default to G_PRIORITY_HIGH instead of G_PRIORITY_DEFAULT so it takes priority over regular traffic or timeout handling. --- btio/btio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 8230212b4..1f1c374bc 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -274,7 +274,7 @@ static void server_add(GIOChannel *io, BtIOConnect connect, server->destroy = destroy; cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL; - g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, server_cb, server, + g_io_add_watch_full(io, G_PRIORITY_HIGH, cond, server_cb, server, (GDestroyNotify) server_remove); } @@ -291,7 +291,7 @@ static void connect_add(GIOChannel *io, BtIOConnect connect, bdaddr_t dst, conn->dst = dst; cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL; - g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, connect_cb, conn, + g_io_add_watch_full(io, G_PRIORITY_HIGH, cond, connect_cb, conn, (GDestroyNotify) connect_remove); } @@ -307,7 +307,7 @@ static void accept_add(GIOChannel *io, BtIOConnect connect, gpointer user_data, accept->destroy = destroy; cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL; - g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, accept_cb, accept, + g_io_add_watch_full(io, G_PRIORITY_HIGH, cond, accept_cb, accept, (GDestroyNotify) accept_remove); } From patchwork Tue Feb 16 23:33:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 383402 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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 810A5C433E9 for ; Tue, 16 Feb 2021 23:34:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B61C64E10 for ; Tue, 16 Feb 2021 23:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbhBPXeX (ORCPT ); Tue, 16 Feb 2021 18:34:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbhBPXeV (ORCPT ); Tue, 16 Feb 2021 18:34:21 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E7CEC061756 for ; Tue, 16 Feb 2021 15:33:41 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id s16so2464055plr.9 for ; Tue, 16 Feb 2021 15:33:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rjRUuZ6S9CazXw1JtrK9M/ukL9kp/i3skiRIFM9vCfU=; b=AIT3VFj1IFDPqgAZ9uQK8XEHbfnCYptGNWBYVE5sNa8cbDfVc0mHDfUSxYBAwsVHLK b3ULuQlEBq468u7IvkxM+++Rs07c3HfdQDjIBfnZptG5U2Lg+I571JTbzNVyoT0UpzoO RNjdbEU9L+hd66O9RBRRCwE0GXEQz/AeFKm/qZ9dh5CTh6y8TbYO5YSxT7kMmztNaTSx 8L9sHC1YQaRfTsOGADt4bxGWI7T+DUdTgF0wkibjZamLvHDxIxR0qtg+9u6+4SAFbCMm AfVVyYiQA32f5VRqoOZmSynRMB4cjwUvkTbYEfQTGTGIj9v9G4kYPDah2wnhHtTzDBIN JF3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rjRUuZ6S9CazXw1JtrK9M/ukL9kp/i3skiRIFM9vCfU=; b=QMZftHYrWbkWCTx/RARLF/cTIPmsbzO6gVsPgCHQgHE2M6zgpWp8N4Q/tNZJI61ogw dKSqYm0+P1BVACzE6HD0fq+kvqYasxwHJCZshKYDsJ6qUkCW53cDZk2sH9gjuGb1ZcMe aX4xYiquTBAvDuVD6DQ7ZNB6A/pjufODIj0VgfneD4V4PS1h8ObWPgdk7BCWFvWhH/97 a8eIN19J+hrb/shsWawPEV5DM/v7dbJVo8qAfcOgJx9Up25lbmnPrwoGAlMxmdfTH1wp UB/lucus6WihwuYfPT7IkV0w8F6YWt00ApoyveiVW83yFhIWUNDwNZ3FV8hyQi/YVgHt KUgg== X-Gm-Message-State: AOAM53306bjyPRhGnpeHsiYvFdg9dsZxtCDAlmvAi96JijjApdaXc0qA 5nauuXnlCKmdP9M20oJ/iFUTM+ZG+2o1eg== X-Google-Smtp-Source: ABdhPJzLfiQH5aYw6J7H68+dD5DeEBlvJ/S5GT5hO3tHKNxoVbnjLzu+fy1CouOSHi4yXtPrBUOWEg== X-Received: by 2002:a17:90a:9288:: with SMTP id n8mr6369904pjo.91.1613518420803; Tue, 16 Feb 2021 15:33:40 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id h5sm99956pgv.87.2021.02.16.15.33.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 15:33:40 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/3] avdtp: Remove use of G_PRIORITY_LOW Date: Tue, 16 Feb 2021 15:33:37 -0800 Message-Id: <20210216233337.859955-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210216233337.859955-1-luiz.dentz@gmail.com> References: <20210216233337.859955-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz G_PRIORITY_LOW was used in order to prioritize the AVDTP media transport channel over the signalling channel but this has the side effect of delaying the dispatching of other conditions such as HUP/NVAL, so now that BtIO use G_PRIORITY_HIGH for its watches we no longer need to deprioritize session_cb. --- profiles/audio/avdtp.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 9ddcd6464..088ca58b3 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2378,19 +2378,10 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) if (session->io_id) g_source_remove(session->io_id); - /* This watch should be low priority since otherwise the - * connect callback might be dispatched before the session - * callback if the kernel wakes us up at the same time for - * them. This could happen if a headset is very quick in - * sending the Start command after connecting the stream - * transport channel. - */ - session->io_id = g_io_add_watch_full(chan, - G_PRIORITY_LOW, + session->io_id = g_io_add_watch(chan, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, - (GIOFunc) session_cb, session, - NULL); + (GIOFunc) session_cb, session); if (session->stream_setup) set_disconnect_timer(session);