Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2565410lqp; Mon, 25 Mar 2024 02:48:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDaP12Gwif52j8hIKpTiCAAJz0sU+WQuEnl7j0q3oKvzZePl1VSkDgFFtibTJ1ChFo9yf9x5R+q8ss2EvFVtkLSvNDVGxfSomuNd8w0Q== X-Google-Smtp-Source: AGHT+IFa/PoRR2SQZ+VdMkksKVBNV0bzLlu346tCgKTU7guC/2PP1du5aAURK7OJQXYKxBLWgJNQ X-Received: by 2002:a19:7716:0:b0:513:dd66:d5ed with SMTP id s22-20020a197716000000b00513dd66d5edmr3653252lfc.29.1711360123684; Mon, 25 Mar 2024 02:48:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711360123; cv=pass; d=google.com; s=arc-20160816; b=V53Q2oQBZnE3RJ89KHrdoun3HYOaVBpn36PVgT03E5WJ8+LKjOE4hzSLH/kW0LgJol SqExiTnHms1mpyW/K27XmT8yWMk9nA+LE+SmzXInWTkLqZTWqZygPw+G4EwRrNljV5SI N3Lg/9igpA+kSlhEV4V38199s3jPgEjleCGmmg+J6WB6lML32WKCkWCSw9aSeA3iseJ/ bYUorlJ9USgl0jn2cItXEWh3rsPWDZNk0pYUNrOXP6Zfy5YM2FRMTpzrHpe0wGs7gHZe eRMHkOsrXImH1fBLaEPa2V+/Vd3sH6KrD040T6W7vvvAUIoAVB3ARtrsX2mgAjG/+8lM fq4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yaJuHAMQG3nRcMDkYzxn8dyD/eE8IZARZFmlvmV62wo=; fh=xbZ8awvxoBYCxteR0XQ/p524xtWLppyNKeg39+TXSWY=; b=Po3VRn5G4HgQd1FWe7Aj3cwBOD00qM1tV7HtYNuPU3TgIfkrDLFDa6SP7ueL1c2dz+ y4tCNzLe5e92S3xcb7ed4aYJyRrVxFaoybpYM14bGGIm1eILUy9LWaH1noAk+rz1/WkO L7zg6YzHJYW1f6YwKhTr77IHOp8z5ZXbJ0eWfLhfdRiDBEW3EFS7oxv6qXBNGwdIYEDE 1yQAMPQ3r5LgSAh+tGD9WecDTB8uDQ2+r2VKzSt5zZsIOYkTyB9ZQSSWRcmL9N+tW1vQ 70Ip0VSTM9vE7xcB4u8wIRX3T95IVU93RfwVKoZVx2nJInEkZPbuRCKhE6klUnCpTw1Z NqJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vAqsYNdQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n14-20020a056402514e00b0056ba7565211si2322096edd.493.2024.03.25.02.48.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:48:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vAqsYNdQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 758901F31A67 for ; Mon, 25 Mar 2024 09:47:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9331038CE57; Mon, 25 Mar 2024 03:03:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vAqsYNdQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52414227E1F; Sun, 24 Mar 2024 23:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322124; cv=none; b=R+jH3rzbwlih142XBkR/mrcXi16lxVAYonjaU7LUAulzlYqqd6bfcDYZO9etywbyP1OMYYBEQG+nG0Hnscv/vGy3queyyiXWEn5YCDPikYhbv/VihEA5m7hg3zBHHEVgthgDmheaSR/X3sgaHPAPQ1qHI0InuV4N+/w2KAM3G84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322124; c=relaxed/simple; bh=N6bT4bWwxfuxl6esFfMfH/uw5uKXoOYPT/octj3dLsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gRR5RcAJnKCac022sWyqND63Pufux9fyjrlhbXo4qfkvgnwGj2a0zEQmW72OcY6CkACCYvbBdPLHN+qx4Lzc3DZTxZ/xDwLyGFsWFUb4C9XYvutSUwu5jIGF0gtHYERxavmjwIEqv67+UY1FkP3sr6Bl3p5OmIjAgzAPb//fZmY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vAqsYNdQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D4C7C433B2; Sun, 24 Mar 2024 23:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322123; bh=N6bT4bWwxfuxl6esFfMfH/uw5uKXoOYPT/octj3dLsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAqsYNdQL3dw+i58SwNl3XVucN2zuwsSVKHj2X+dASyhbNo/cUPEuajp1WLpbrkye Wn8H0EfEn566IMtOFh+zjIfHCymxE2ucVJKx7sZkRe8GOMh03PAlw3Cc/agRLR/6Si x2OQ41ttkWlr/WGVbyt8iFV1ANWTMOjaFvnwBV8+eZxybOwt+J1x57Qw0hHfVbokGU JUHkDfAct9uVIDcjzT2HD/5PpKWqrITUgdVtw48SW3yN0oO0YUSyevDwRqlA6ExszM dk67VIEO1MFetzIpRVA+KeB6PW3xxx11t3R5GD3sZFy6DE6AWhvhxWjYFRyC6gwFoT 8CvC7hlGPbrQA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Archie Pusaka , Ying Hsu , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.1 198/451] Bluetooth: Cancel sync command before suspend and power off Date: Sun, 24 Mar 2024 19:07:54 -0400 Message-ID: <20240324231207.1351418-199-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Archie Pusaka [ Upstream commit f419863588217f76eaf754e1dfce21ea7fcb026d ] Some of the sync commands might take a long time to complete, e.g. LE Create Connection when the peer device isn't responding might take 20 seconds before it times out. If suspend command is issued during this time, it will need to wait for completion since both commands are using the same sync lock. This patch cancel any running sync commands before attempting to suspend or adapter power off. Signed-off-by: Archie Pusaka Reviewed-by: Ying Hsu Signed-off-by: Luiz Augusto von Dentz Stable-dep-of: 2615fd9a7c25 ("Bluetooth: hci_sync: Fix overwriting request callback") Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 3 +++ net/bluetooth/mgmt.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a8932d449eb63..a7e6ce2e61c5e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2838,6 +2838,9 @@ int hci_suspend_dev(struct hci_dev *hdev) if (mgmt_powering_down(hdev)) return 0; + /* Cancel potentially blocking sync operation before suspend */ + __hci_cmd_sync_cancel(hdev, -EHOSTDOWN); + hci_req_sync_lock(hdev); ret = hci_suspend_sync(hdev); hci_req_sync_unlock(hdev); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a80bf9c42c2ef..a657dc1d4ec7a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1401,6 +1401,10 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, goto failed; } + /* Cancel potentially blocking sync operation before power off */ + if (cp->val == 0x00) + __hci_cmd_sync_cancel(hdev, -EHOSTDOWN); + err = hci_cmd_sync_queue(hdev, set_powered_sync, cmd, mgmt_set_powered_complete); -- 2.43.0