From patchwork Mon Aug 16 23:11:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 497675 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp539965jab; Mon, 16 Aug 2021 16:11:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwat3TREW+xlatt9D2ukbjwiUN1Xw0S3x0GRlDXBECVBUymV2J61aRWeasXa0cdDqIhPrY3 X-Received: by 2002:a92:3f0b:: with SMTP id m11mr273683ila.265.1629155516836; Mon, 16 Aug 2021 16:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629155516; cv=none; d=google.com; s=arc-20160816; b=JTZgxSb/ErLMy6JvvyZ5e6Op78/zqpYO+SMJLQss/4RmJ2Busayh76R/4JiiP/17XT UaykiWqcWwxjfIthsV6r0ToTMdnb26YBI7ha7E/izUrzKr6bgWyf6IvW3pdfcTUj70Vi dmWHCSfgceSTJftJfpM5vfiU3n3XJTYmeQf8i8tndZSsWebsulZJLYNEs5NR4z7rJmDv +CqnCEbbEKJyWpzJVGT8ZO4xKkX8TgPlRsqzV6/YllvBn6C6kPlP/2oVQ2Gaj4pajFDT f3HBdi9TARZ6RuLl+DoDAVV5OwLRQHrj244lR8G0HWV0WDE91uSUbYHsZw8TTE5PWqeN gNIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3wqbKr4UPEvs0QNhhWbq71AvFRB1aC289caQoG/Bnjo=; b=XRDPTGRcBgEvVYFmwXL+kYOGOCAH+Ez4dov6cuCphvZdC900YtVTlXcg8SK3lnMEKL 7zpymW8aZe+Ic9E2/DHjYw/hPS4Bfd4tf96hgJhwCUcvRC7c3sYng2aF4MoAshH4iWQI s2Eppy57pfVLx+vah5hyVlk0o28tWm6Qnmz1qB9R+PMyfFLEdN/J8uoayij9UXGwGgrp hPsVZHL9YtJJJFMqquEkd6Y2IlVgG9wAt3SpokEJtB0rkX38JKiYiG94StglBNs9IV3Y C+JrIv638Mr8Cw+IxjWVsman+cApGLlms3+DHs/p9u/N+UeGJOz1bl7eLYz4qfhksJUU FYJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jpqGEcDW; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si423223ioj.101.2021.08.16.16.11.56; Mon, 16 Aug 2021 16:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jpqGEcDW; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232731AbhHPXM1 (ORCPT + 8 others); Mon, 16 Aug 2021 19:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232618AbhHPXM0 (ORCPT ); Mon, 16 Aug 2021 19:12:26 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB877C061764 for ; Mon, 16 Aug 2021 16:11:53 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id c24so37576322lfi.11 for ; Mon, 16 Aug 2021 16:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3wqbKr4UPEvs0QNhhWbq71AvFRB1aC289caQoG/Bnjo=; b=jpqGEcDW5jGEVmSGjTSc35pfV2R+d1h01rxbmcwlxHVrH9Pi+z1P6uMdRNkH68jBLO UeQptzeDVo/CGGjmFlrrMHKlmHyKz6K+ifzdMfJVHbjOPhPEQl2gcuBbWIwkAk/NxhVt zXqVSvhEn7s9/t0Yugl27RhWgT7F0Rhq+T3boNB8BPbTGr54NL/KQBmOrsjAf2+QtOdu N34Ku5ZpbQPBTVVBryTOvP9AWrERqv0uK/gtYCWZsGQ2tqvoAjApqWiULiSwfUkFdKND HDHhSjeT9v7I/QR3wORRYsAJLTJStz9C6OaSjo1JxRQwshfEjC+/4+oPC/4h1dHm3PXF G6Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3wqbKr4UPEvs0QNhhWbq71AvFRB1aC289caQoG/Bnjo=; b=atNOBLbSUGdPyDcZ+4SVkQHGu5gU+iEIc8xTJESA+xLtpLx9iH7/YpKVSZW57CI/m8 VTxoyRjGhI3zHinaHRS3iqYc/ToH109X3ByY9ZTewbe4+HPD26t+525XhxhAYP8iL2wg K2PyWT2lN0c84F+SwVXJsqv1yh05ihl+L26Mcn8C3ZUM8XjlqCz2W5+wOqorpovK1w5r 0hF36mG+CM5JOeV/0SLtgBPUbtlo9G+znLHrrqCA2XToiIFP+HuOlBY5kAAjaR9qQlqS puF4PrFn2gc6RS3FT8PlfPMMd0snzBWNDMjiyk6j87sgDypODBVgi7tITul7yViEesyF dfmA== X-Gm-Message-State: AOAM531Hv0nDkXx8/4PGREC6ot1R4p/jM4tbJLG2GbtC7qAFYz1oIyig LFTonmDjxP7IIR1xbMAUV6eTqg== X-Received: by 2002:a19:6b02:: with SMTP id d2mr149660lfa.522.1629155512033; Mon, 16 Aug 2021 16:11:52 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id e6sm22846lfr.257.2021.08.16.16.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 16:11:51 -0700 (PDT) From: Dmitry Baryshkov To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: "David S. Miller" , Jakub Kicinski , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Kai-Heng Feng Subject: [PATCH] Revert "Bluetooth: Shutdown controller after workqueues are flushed or cancelled" Date: Tue, 17 Aug 2021 02:11:50 +0300 Message-Id: <20210816231150.1478727-1-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This reverts commit 0ea9fd001a14ebc294f112b0361a4e601551d508. It moved calling shutdown callback after flushing the queues. In doing so it disabled calling the shutdown hook completely: shutdown condition tests for HCI_UP in hdev->flags, which gets cleared now before checking this condition (see test_and_clear_bit(HCI_UP, ...) call). Thus shutdown hook was never called. This would not be a problem itself and could fixed with just removing the HCI_UP condition (since if we are this point, we already know that the HCI device was up before calling hci_dev_do_close(). However the fact that shutdown hook was not called hid the fact that it is not proper to call shutdown hook so late in the sequence. The hook would usually call __hci_cmd_sync()/__hci_cmd_sync_ev(), which would timeout without running queues. Thus I think it is more proper at this moment to revert the commit and look for a better solution. Fixes: 0ea9fd001a14 ("Bluetooth: Shutdown controller after workqueues are flushed or cancelled") Cc: Kai-Heng Feng Signed-off-by: Dmitry Baryshkov --- net/bluetooth/hci_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.30.2 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e1a545c8a69f..677d880068a4 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1721,6 +1721,14 @@ int hci_dev_do_close(struct hci_dev *hdev) BT_DBG("%s %p", hdev->name, hdev); + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && + !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && + test_bit(HCI_UP, &hdev->flags)) { + /* Execute vendor specific shutdown routine */ + if (hdev->shutdown) + hdev->shutdown(hdev); + } + cancel_delayed_work(&hdev->power_off); cancel_delayed_work(&hdev->ncmd_timer); @@ -1798,14 +1806,6 @@ int hci_dev_do_close(struct hci_dev *hdev) clear_bit(HCI_INIT, &hdev->flags); } - if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && - !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && - test_bit(HCI_UP, &hdev->flags)) { - /* Execute vendor specific shutdown routine */ - if (hdev->shutdown) - hdev->shutdown(hdev); - } - /* flush cmd work */ flush_work(&hdev->cmd_work);