linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: "Alexis Lothoré" <alexis.lothore@bootlin.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Eric Dumazet <edumazet@google.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	Marek Vasut <marex@denx.de>, Rob Herring <robh@kernel.org>,
	Ajay Singh <ajay.kathat@microchip.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Kalle Valo <kvalo@kernel.org>,
	devicetree@vger.kernel.org, Conor Dooley <conor+dt@kernel.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-bluetooth@vger.kernel.org,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH 09/12] wifi: wilc1000: disable firmware power save if bluetooth is in use
Date: Sun, 16 Feb 2025 16:07:29 +0000	[thread overview]
Message-ID: <20250216160729.GG1615191@kernel.org> (raw)
In-Reply-To: <20250212-wilc3000_bt-v1-9-9609b784874e@bootlin.com>

On Wed, Feb 12, 2025 at 04:46:28PM +0100, Alexis Lothoré wrote:
> If the wlan interface exposed by wilc driver has power save enabled
> (either explicitly with iw dev wlan set power_save on, or because
> kernel is built with CONFIG_CFG80211_DEFAULT_PS), it will send a power
> management command to the wlan firmware when corresponding interface is
> brought up. The bluetooth part, if used, is supposed to work
> independently from the WLAN CPU. Unfortunately, this power save
> management, if applied by the WLAN side, disrupts bluetooth operations
> (the bluetooth CPU does not answer any command anymore on the UART
> interface)
> 
> Make sure that the bluetooth part can work independently by disabling
> power save in wlan firmware when bluetooth is in use.
> 
> Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
> ---
>  drivers/net/wireless/microchip/wilc1000/bt.c       | 29 +++++++++++++++++++---
>  drivers/net/wireless/microchip/wilc1000/cfg80211.c |  5 +++-
>  drivers/net/wireless/microchip/wilc1000/netdev.h   |  3 +++
>  3 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/bt.c b/drivers/net/wireless/microchip/wilc1000/bt.c
> index b0f68a5479a5bd6f70e2390a35512037dc6c332b..f0eb5fb506eddf0f6f4f3f0b182eaa650c1c7a87 100644
> --- a/drivers/net/wireless/microchip/wilc1000/bt.c
> +++ b/drivers/net/wireless/microchip/wilc1000/bt.c
> @@ -7,6 +7,7 @@
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <net/wilc.h>
> +#include "cfg80211.h"
>  #include "netdev.h"
>  #include "wlan_if.h"
>  #include "wlan.h"
> @@ -261,22 +262,36 @@ static int wilc_bt_start(struct wilc *wilc)
>  int wilc_bt_init(void *wilc_wl_priv)
>  {
>  	struct wilc *wilc = (struct wilc *)wilc_wl_priv;
> +	struct wilc_vif *vif;
>  	int ret;
>  
> +	wilc->bt_enabled = true;
> +
>  	if (!wilc->hif_func->hif_is_init(wilc)) {
>  		dev_info(wilc->dev, "Initializing bus before starting BT");
>  		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
>  		ret = wilc->hif_func->hif_init(wilc, false);
>  		release_bus(wilc, WILC_BUS_RELEASE_ONLY);
> -		if (ret)
> +		if (ret) {
> +			wilc->bt_enabled = false;
>  			return ret;
> +		}
>  	}
>  
> +	/* Power save feature managed by WLAN firmware may disrupt
> +	 * operations from the bluetooth CPU, so disable it while bluetooth
> +	 * is in use (if enabled, it will be enabled back when bluetooth is
> +	 * not used anymore)
> +	 */
> +	vif = wilc_get_wl_to_vif(wilc);
> +	if (wilc->power_save_mode && wilc_set_power_mgmt(vif, false))
> +		goto hif_deinit;

Hi Alexis,

Jumping to hif_deinit will result in the function returning ret.
But ret may not not be initialised until a few lines below.

Flagged by Smatch.

> +
>  	mutex_lock(&wilc->radio_fw_start);
>  	ret = wilc_bt_power_up(wilc);
>  	if (ret) {
>  		dev_err(wilc->dev, "Error powering up bluetooth chip\n");
> -		goto hif_deinit;
> +		goto reenable_power_save;
>  	}
>  	ret = wilc_bt_firmware_download(wilc);
>  	if (ret) {
> @@ -293,10 +308,14 @@ int wilc_bt_init(void *wilc_wl_priv)
>  
>  power_down:
>  	wilc_bt_power_down(wilc);
> -hif_deinit:
> +reenable_power_save:
> +	if (wilc->power_save_mode_request)
> +		wilc_set_power_mgmt(vif, true);
>  	mutex_unlock(&wilc->radio_fw_start);
> +hif_deinit:
>  	if (!wilc->initialized)
>  		wilc->hif_func->hif_deinit(wilc);
> +	wilc->bt_enabled = false;
>  	return ret;
>  }
>  EXPORT_SYMBOL(wilc_bt_init);

...


  reply	other threads:[~2025-02-16 16:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 15:46 [PATCH 00/12] bluetooth: hci_wilc: add new bluetooth driver Alexis Lothoré
2025-02-12 15:46 ` [PATCH 01/12] dt-bindings: bluetooth: describe wilc 3000 bluetooth chip Alexis Lothoré
2025-02-13  9:25   ` Krzysztof Kozlowski
2025-02-13 15:25     ` Alexis Lothoré
2025-02-14  7:47       ` Krzysztof Kozlowski
2025-02-12 15:46 ` [PATCH 02/12] wifi: wilc1000: add a read-modify-write API for registers accesses Alexis Lothoré
2025-02-12 15:46 ` [PATCH 03/12] wifi: wilc1000: add lock to prevent concurrent firmware startup Alexis Lothoré
2025-02-12 15:46 ` [PATCH 04/12] wifi: wilc1000: allow to use acquire/release bus in other parts of driver Alexis Lothoré
2025-02-12 15:46 ` [PATCH 05/12] wifi: wilc1000: do not depend on power save flag to wake up chip Alexis Lothoré
2025-02-12 15:46 ` [PATCH 06/12] wifi: wilc1000: remove timeout parameter from set_power_mgmt Alexis Lothoré
2025-02-12 15:46 ` [PATCH 07/12] wifi: wilc1000: reorganize makefile objs into sorted list Alexis Lothoré
2025-02-12 15:46 ` [PATCH 08/12] wifi: wilc1000: add basic functions to allow bluetooth bringup Alexis Lothoré
2025-02-12 15:46 ` [PATCH 09/12] wifi: wilc1000: disable firmware power save if bluetooth is in use Alexis Lothoré
2025-02-16 16:07   ` Simon Horman [this message]
2025-02-12 15:46 ` [PATCH 10/12] bluetooth: hci_wilc: add wilc hci driver Alexis Lothoré
2025-02-12 16:14   ` Luiz Augusto von Dentz
2025-02-12 17:01     ` Alexis Lothoré
2025-02-13  9:24   ` Krzysztof Kozlowski
2025-02-13 15:30     ` Alexis Lothoré
2025-02-12 15:46 ` [PATCH 11/12] ARM: dts: at91-sama5d27_wlsom1: update bluetooth chip description Alexis Lothoré
2025-02-12 15:46 ` [PATCH 12/12] MAINTAINERS: add entry for new wilc3000 bluetooth driver Alexis Lothoré
2025-02-12 22:08 ` [PATCH 00/12] bluetooth: hci_wilc: add new " Rob Herring (Arm)

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=20250216160729.GG1615191@kernel.org \
    --to=horms@kernel.org \
    --cc=ajay.kathat@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=marex@denx.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).