All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: Hillf Danton <hdanton@sina.com>
Cc: Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Bluez <linux-bluetooth@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] Bluetooth: Shutdown controller after workqueues are flushed or cancelled
Date: Thu, 5 Aug 2021 15:19:28 +0800	[thread overview]
Message-ID: <CAAd53p6BXj_Yxq+8GvDW4eNvbXisz2WK9uf5rcLrCwkMiSB4-g@mail.gmail.com> (raw)
In-Reply-To: <20210805063536.2698-1-hdanton@sina.com>

[snipped]

> >How? Most of the time the BT controller can't be brought up again
> >after shutdown(), and we need to stop other activities before that.
> >What other reasoning is expected?
>
> See below.
> >
> >Kai-Heng
> >
> >>
> >> >time it's just "Bluetooth: hci0: HCI reset during shutdown failed" in
> >> >dmesg.
>
> In drivers/bluetooth/btusb.c, there are three cases of
>
>         bt_dev_err(hdev, "HCI reset during shutdown failed");
>
> and in btusb_shutdown_intel_new() it has nothing to do with kfree_skb()
> because of IS_ERR(skb).

No, kfree_skb() doesn't gets called in this case. But when that
happens the BT controller won't work anymore.

>
> Feel free to specify why an skb error links to the race you are trying to fix.

The race here is that the btusb_shutdown_intel_new() is trying to
reset the controller while other works like scanning or discovering
are still underway.
So the patch is to ensure that shutdown() callback is invoked after
other works are cancelled.

I think I understand what you are trying to ask, you want to know
where the double kfree_skb() race happens.
I didn't really investigate that because quiesce the other activities
then call shutdown() is the right thing to do and I haven't seen the
kernel splat since.

Kai-Heng

>
> >> >
> >> >Kai-Heng
> >>
> >>
> >> +++ x/net/bluetooth/hci_request.c
> >> @@ -257,8 +257,10 @@ int __hci_req_sync(struct hci_dev *hdev,
> >>                 break;
> >>         }
> >>
> >> -       kfree_skb(hdev->req_skb);
> >> -       hdev->req_skb = NULL;
> >> +       if (!err) {
> >> +               kfree_skb(hdev->req_skb);
> >> +               hdev->req_skb = NULL;
> >> +       }
> >>         hdev->req_status = hdev->req_result = 0;
> >>
> >>         bt_dev_dbg(hdev, "end: err %d", err);

  parent reply	other threads:[~2021-08-05  7:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  7:14 [PATCH v2] Bluetooth: Shutdown controller after workqueues are flushed or cancelled Kai-Heng Feng
2021-05-14  8:12 ` [v2] " bluez.test.bot
2021-05-14 18:15 ` [PATCH v2] " Marcel Holtmann
2021-07-28 13:50   ` Mattijs Korpershoek
2021-07-28 15:25     ` Kai-Heng Feng
2021-07-30 11:40       ` Mattijs Korpershoek
2021-08-03  6:42         ` Kai-Heng Feng
2021-08-03  8:21           ` Mattijs Korpershoek
2021-08-04 14:42             ` Kai-Heng Feng
2021-08-05  6:55               ` Mattijs Korpershoek
2021-08-05 15:50                 ` Kai-Heng Feng
2021-08-06  8:51                   ` Mattijs Korpershoek
2021-08-06 15:36                     ` Kai-Heng Feng
2021-08-09  9:19                       ` Mattijs Korpershoek
     [not found] ` <20210802030538.2023-1-hdanton@sina.com>
2021-08-03  6:45   ` Kai-Heng Feng
     [not found]     ` <20210803074722.2383-1-hdanton@sina.com>
2021-08-04 14:35       ` Kai-Heng Feng
     [not found]         ` <20210805030024.2603-1-hdanton@sina.com>
2021-08-05  3:44           ` Kai-Heng Feng
     [not found]             ` <20210805063536.2698-1-hdanton@sina.com>
2021-08-05  7:19               ` Kai-Heng Feng [this message]
2021-08-05  6:12     ` Hsin-Yi Wang
     [not found]       ` <20210805070114.2803-1-hdanton@sina.com>
2021-08-05  7:04         ` Hsin-Yi Wang

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=CAAd53p6BXj_Yxq+8GvDW4eNvbXisz2WK9uf5rcLrCwkMiSB4-g@mail.gmail.com \
    --to=kai.heng.feng@canonical.com \
    --cc=hdanton@sina.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=mkorpershoek@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.