mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vasyl Vavrychuk <vvavrychuk@gmail.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-bluetooth@vger.kernel.org
Cc: Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
Subject: [RFC PATCH] Bluetooth: core: Allow bind HCI socket user channel when HCI is UP.
Date: Tue, 12 Apr 2022 15:09:45 +0300	[thread overview]
Message-ID: <20220412120945.28862-1-vasyl.vavrychuk@opensynergy.com> (raw)

This is needed for user-space to ensure that HCI init scheduled from
hci_register_dev is completed.

Function hci_register_dev queues power_on workqueue which will run
hci_power_on > hci_dev_do_open. Function hci_dev_do_open sets HCI_INIT
for some time.

It is not allowed to bind to HCI socket user channel when HCI_INIT is
set. As result, bind might fail when user-space program is run early
enough during boot.

Now, user-space program can first issue HCIDEVUP ioctl to ensure HCI
init scheduled at hci_register_dev was completed.

Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
---
 net/bluetooth/hci_sock.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 33b3c0ffc339..c98de809f856 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1194,9 +1194,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
 
 		if (test_bit(HCI_INIT, &hdev->flags) ||
 		    hci_dev_test_flag(hdev, HCI_SETUP) ||
-		    hci_dev_test_flag(hdev, HCI_CONFIG) ||
-		    (!hci_dev_test_flag(hdev, HCI_AUTO_OFF) &&
-		     test_bit(HCI_UP, &hdev->flags))) {
+		    hci_dev_test_flag(hdev, HCI_CONFIG)) {
 			err = -EBUSY;
 			hci_dev_put(hdev);
 			goto done;
-- 
2.30.2


             reply	other threads:[~2022-04-12 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 12:09 Vasyl Vavrychuk [this message]
2022-04-22  9:20 ` Marcel Holtmann
2022-04-26  9:24   ` Vasyl Vavrychuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220412120945.28862-1-vasyl.vavrychuk@opensynergy.com \
    --to=vvavrychuk@gmail.com \
    --cc=davem@davemloft.net \
    --cc=johan.hedberg@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vasyl.vavrychuk@opensynergy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®