From patchwork Thu Apr 2 12:55:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11470683 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 426DB15AB for ; Thu, 2 Apr 2020 12:55:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18CED207FF for ; Thu, 2 Apr 2020 12:55:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="hM597ZbW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388407AbgDBMzW (ORCPT ); Thu, 2 Apr 2020 08:55:22 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:10111 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388245AbgDBMzW (ORCPT ); Thu, 2 Apr 2020 08:55:22 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 48tNMW3Fznz9j; Thu, 2 Apr 2020 14:55:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1585832120; bh=5jAf1VoZWn9lMFIQz+fgkF64ICr0x3eCyKsy0w4hzhs=; h=Date:From:Subject:To:Cc:From; b=hM597ZbWrUkB5NfDrSE4QYZZRFZyrkL9NvMxmEAHsl8k1depplbDCoG/NQayKrES6 AyOFKWPPDOi+qIltEkSZpfMLjGEnNrfCvulMKrFi9UYhvaxnl1A0om0gMYHiDaKx8h xDPQGOjLQsvOQWqh7h4ArqWBY4F6T9vq+pJBuROa0pghShtM5X/yo1Z3w56SfqXo24 QyNMeqkRUe92S0g1CAIQhMeTr+Iaf8mZko56mYb2O1x2r/yXeudqFe1X+n7dNLY/4s +NOwcNBnMut9wu0ZA0nbc39lMsY/hHpi/Tei5EYZ8jfo6iiegvSqBjm9TXtvwGxth+ zmKgwMQUX4cIQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Thu, 02 Apr 2020 14:55:18 +0200 Message-Id: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT MIME-Version: 1.0 To: Marcel Holtmann , Johan Hedberg , Guillaume La Roque , Kevin Hilman , Frederic Danis Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The IRQ polarity is be configured in bcm_setup_sleep(). Make the configured value match what is in the DeviceTree. Cc: stable@vger.kernel.org Fixes: f25a96c8eb46 ("Bluetooth: hci_bcm: enable IRQ capability from devicetree") Signed-off-by: Michał Mirosław --- drivers/bluetooth/hci_bcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index b236cb11c0dc..36b7f0d00c4b 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -1153,7 +1153,8 @@ static int bcm_of_probe(struct bcm_device *bdev) device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params", bdev->pcm_int_params, 5); bdev->irq = of_irq_get_byname(bdev->dev->of_node, "host-wakeup"); - + bdev->irq_active_low = irq_get_trigger_type(bdev->irq) + & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW); return 0; } From patchwork Thu Apr 2 12:55:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11470679 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76E0B1668 for ; Thu, 2 Apr 2020 12:55:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 543FA20787 for ; Thu, 2 Apr 2020 12:55:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="ohDWv12O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388449AbgDBMzX (ORCPT ); Thu, 2 Apr 2020 08:55:23 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:36702 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388332AbgDBMzW (ORCPT ); Thu, 2 Apr 2020 08:55:22 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 48tNMX2ZGMzHd; Thu, 2 Apr 2020 14:55:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1585832120; bh=aHNL2/KGosIZfGJPSq9g/S4QzmyubMu5Xs648XxruJc=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=ohDWv12OW4HTE/v/HtsqOo6NnyHs6wGqLl67g90OAPnO3DtNMJaQV4A/tqfF9NEK1 FiIbJo2Nl6lgWEaaTnO6+8U/gsGO5j4AWjFNSNfIRd29i1xPfGHGde+7lruqTPkJx3 hmpPnGu8+vxYm1rGken0Db2EEeDRTq1F83A464OR1Ik5m8T3XApsGi6O9dzxNrVcUn ll2ldbozsXqtNk6GvRx9Rim3E1EO1LzyoOnIZVr2088l0EyJIlodVOloRYuqbe/qKn L6PSjhOs8sT0jySDjXLD41Ja8srlhgJpjXqsfDvoqEBNrogsapwKExXHd+wz3Ugppo mOH8UuKKVSlpQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Thu, 02 Apr 2020 14:55:20 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ MIME-Version: 1.0 To: Marcel Holtmann , Johan Hedberg , Frederic Danis , Guillaume La Roque , Kevin Hilman Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When BT module can't be initialized, but it has an IRQ, unloading the driver WARNs when trying to free not-yet-requested IRQ. Fix it by noting whether the IRQ was requested. WARNING: CPU: 2 PID: 214 at kernel/irq/devres.c:144 devm_free_irq+0x49/0x4ca [...] WARNING: CPU: 2 PID: 214 at kernel/irq/manage.c:1746 __free_irq+0x8b/0x27c Trying to free already-free IRQ 264 Modules linked in: hci_uart(-) btbcm bluetooth ecdh_generic ecc libaes CPU: 2 PID: 214 Comm: rmmod Tainted: G W 5.6.1mq-00044-ga5f9ea098318-dirty #928 [...] [] (devm_free_irq) from [] (bcm_close+0x97/0x118 [hci_uart]) [] (bcm_close [hci_uart]) from [] (hci_uart_unregister_device+0x33/0x3c [hci_uart]) [] (hci_uart_unregister_device [hci_uart]) from [] (serdev_drv_remove+0x13/0x20) [] (serdev_drv_remove) from [] (device_release_driver_internal+0x97/0x118) [] (device_release_driver_internal) from [] (driver_detach+0x2f/0x58) [] (driver_detach) from [] (bus_remove_driver+0x41/0x94) [] (bus_remove_driver) from [] (bcm_deinit+0x1b/0x740 [hci_uart]) [] (bcm_deinit [hci_uart]) from [] (hci_uart_exit+0x13/0x30 [hci_uart]) [] (hci_uart_exit [hci_uart]) from [] (sys_delete_module+0x109/0x1d0) [] (sys_delete_module) from [] (ret_fast_syscall+0x1/0x5a) [...] Cc: stable@vger.kernel.org Fixes: 6cc4396c8829 ("Bluetooth: hci_bcm: Add wake-up capability") Signed-off-by: Michał Mirosław --- drivers/bluetooth/hci_bcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index 36b7f0d00c4b..19e4587f366c 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -118,6 +118,7 @@ struct bcm_device { u32 oper_speed; int irq; bool irq_active_low; + bool irq_acquired; #ifdef CONFIG_PM struct hci_uart *hu; @@ -333,6 +334,8 @@ static int bcm_request_irq(struct bcm_data *bcm) goto unlock; } + bdev->irq_acquired = true; + device_init_wakeup(bdev->dev, true); pm_runtime_set_autosuspend_delay(bdev->dev, @@ -514,7 +517,7 @@ static int bcm_close(struct hci_uart *hu) } if (bdev) { - if (IS_ENABLED(CONFIG_PM) && bdev->irq > 0) { + if (IS_ENABLED(CONFIG_PM) && bdev->irq_acquired) { devm_free_irq(bdev->dev, bdev->irq, bdev); device_init_wakeup(bdev->dev, false); pm_runtime_disable(bdev->dev);